image
Redirect all traffic to HTTPS

use on your .htaccess file

2022-02-16 14:08:46 by Omar
Original Link Author Link
                                    RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
                                

Linux Other

TAGS : htaccess,ssl,redirect
image
Get PID of a program on Linux

2022-02-19 14:49:01 by Omar
Original Link Author Link
                                    - one way
pidof vim

- other way
pregp -u root vim

- to kill the program
pkill [pid]


                                

Linux

TAGS : PID, get PID, kill
image
Verifying if previous command was successful

2022-02-22 13:48:54 by Omar
Original Link Author Link
                                    if [ $? -ne 0 ]; then
	echo "The command was not successful.";
	#do the needful / exit
fi;
                                

Linux

TAGS : script,command,successful
image
Checking if process is running

2022-02-22 13:50:33 by Omar
Original Link Author Link
                                    # Define shell function
check_process() {
	echo "Checking if process $1 exists..."
	[ "$1" = "" ]  && return 0
	PROCESS_NUM=$(ps -ef | grep "$1" | grep -v "grep" | wc -l)
	if [ $PROCESS_NUM -ge 1 ];
	then
	        return 1
	else
	        return 0
	fi
}
                                

Linux

TAGS : process,running
image
Downloading youtube playlist using youtube-dl

2022-02-24 02:35:06 by Omar
Original Link Author Link
                                    pip install -upgrade youtube-dl

youtube-dl -i --yes-playlist --playlist-start 1 --write-thumbnail --write-auto-sub --sub-format srt --format mp4 -o "%(playlist_index)s-%(title)s.%(ext)s" 
                                

Linux

TAGS : download,youtube
image
Rename and resize images

2022-02-24 02:42:15 by Omar
Original Link Author Link
                                    #!/bin/sh
counter=1
root=mypict
resolution=400x300
for i in `ls -1 $1/*.jpg`; do
        echo "Now working on $i"
        convert -resize $resolution $i ${root}_${counter}.jpg
        counter=`expr $counter + 1`
done
                                

Linux

TAGS : resize,rename,images,folder