Disable User Account Control (UAC) in Windows 10

Open Regedit and browse to this registry location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\SystemHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System In the right panel, set the value of the DWORD entry “EnableLUA” to 0: If you do not have this DWORD entry, then create it. Then reboot the computer.

Get the Output of a Program in a Variable in Bash

Do you need to get the output of a program in a variable in Bash? There are two simple ways to achieve that: var=`./run.sh params`var=`./run.sh params` Or alternatively you can use $(), i.e: var=$(./run.sh params)var=$(./run.sh params) Remember to not put spaces before or after the = operator. If you need to capture also error messages […]

Capture Multiple Line Output Into a Bash Variable

Lets say you have a bash script “run.sh” that outputs multiple lines, i.e: line1 line2 line3line1 line2 line3 You capture the script output in a bash variable like this: OUTPUT=$(/root/run.sh)OUTPUT=$(/root/run.sh) Now pay attention on how you echo the output: Echo Variable Without Double-Quotes If you echo the variable without the double-quotes: echo $OUTPUTecho $OUTPUT It […]

How to Extract Domain from URL in Bash

Using awk you can extract a domain name from an URL: echo http://example.com/index.php | awk -F[/:] ‘{print $4}’echo http://example.com/index.php | awk -F[/:] ‘{print $4}’ The output is: example.comexample.com

Disable Driver Signature Enforcement on Windows 7 64-bit

If you need to load unsigned kernel-mode drivers on Windows 7 64-bit you need to disable the Disable Driver Signature Enforcement, that is used to deny loading of unsigned drivers. To disable Disable Driver Signature Enforcement do this: 1) Restart the PC and press F8 2) On the Advanced Boot Options select: Disable Driver Signature […]

Get Local File Permissions from Command-Line on Linux

Using stat command you can get local file permissions: stat -c "%a %n" /path/to/file/or/folderstat -c "%a %n" /path/to/file/or/folder Here is an example output: $ stat -c "%a %n" ./Documents/Testing.html 664 ./Documents/Testing.html$ stat -c "%a %n" ./Documents/Testing.html 664 ./Documents/Testing.html Details about the stat parameters: %a Access rights in octal %n File name%a Access rights in octal […]

Automatically Renew Let’s Encrypt Certificates (Nginx)

Here I made a simple bash script that automatically renew all Let’s Encrypt certificates and reload Nginx only once, if at least one certificate was renewed successfully: #!/bin/sh   # ===DESCRIPTION # This script is used to renew Let’s Encrypt certificates via certbot # And reload Nginx web server only once if at least one […]

Run Shell Command And Capture Output in Python

To run a shell command and capture the output in Python, use: import subprocess   batcmd="ls"   result = subprocess.check_output(batcmd, shell=True)import subprocess batcmd="ls" result = subprocess.check_output(batcmd, shell=True) With “shell=True” you will get the same behavior as os.system(). To capture the strerr use: result = subprocess.check_output([batcmd], stderr=subprocess.STDOUT)result = subprocess.check_output([batcmd], stderr=subprocess.STDOUT)

Python Iterate over a List in Chunks

Here is a function that iterates a list in chunks: # (in python 2 use xrange() instead of range() to avoid allocating a list) def chunker(seq, size): return (seq[pos:pos + size] for pos in range(0, len(seq), size))# (in python 2 use xrange() instead of range() to avoid allocating a list) def chunker(seq, size): return (seq[pos:pos […]

Run Processes in Parallel in Python

Today I found a nice example to run processes in parallel in python: import os from multiprocessing import Pool     processes = (‘process1.py’, ‘process2.py’, ‘process3.py’)     def run_process(process): os.system(‘python {}’.format(process))     pool = Pool(processes=3) pool.map(run_process, processes)import os from multiprocessing import Pool processes = (‘process1.py’, ‘process2.py’, ‘process3.py’) def run_process(process): os.system(‘python {}’.format(process)) pool = […]