Skip to content

Instantly share code, notes, and snippets.

View gautamkrishnar's full-sized avatar

Gautam krishna R gautamkrishnar

View GitHub Profile
@gautamkrishnar
gautamkrishnar / backup.sh
Created June 21, 2015 14:31
Backup your website directory (Linux Shell Script) in a folder with foldername as current time in the backup folder
View backup.sh
d="$(date -d -now)"
mkdir backup/"$d"
cp -r /var/www/html/* backup/"$d"
@gautamkrishnar
gautamkrishnar / mail.php
Created August 9, 2015 05:29
Sending an e-mail using PHP
View mail.php
< ?php
// the message
$msg = "First line of textnSecond line of text";
// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);
// send email
mail("someone@example.com","My subject",$msg);
? >
@gautamkrishnar
gautamkrishnar / backup-hdd.sh
Created December 6, 2015 07:29
Backup your hdd to an image with following simple command:
View backup-hdd.sh
dd bs=4096 conv=noerror,sync if=/dev/sdc1 | gzip -c > img.gz
@gautamkrishnar
gautamkrishnar / upload.php
Created December 20, 2015 09:54
file extension fiter for file upload
View upload.php
//upload code
$filename=$_FILE['name']['filename_in_html']; //you can change this with your filename
$allowed='png,jpg'; //which file types are allowed seperated by comma
$extension_allowed= explode(',', $allowed);
$file_extension= pathinfo($filename, PATHINFO_EXTENSION);
if(array_search($file_extension, $extension_allowed))
{
echo "$extension_allowed allowed for uploading file";
}
@gautamkrishnar
gautamkrishnar / add-all-empty-directory-git.sh
Last active June 28, 2019 15:01
Add all empty directories to github
View add-all-empty-directory-git.sh
#This shell script will find all empty directories and sub-directories in a project folder and creates a .gitkeep file, so that the empty directory
#can be added to the git index.
find * -type d -empty -exec touch {}/.gitkeep \;
@gautamkrishnar
gautamkrishnar / get_sources.sh
Created June 18, 2016 15:00
(linux from scratch) LFS 7.9 Get all required sources bash script
View get_sources.sh
wget http://download.savannah.gnu.org/releases/acl/acl-2.2.52.src.tar.gz
wget http://download.savannah.gnu.org/releases/attr/attr-2.4.47.src.tar.gz
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.xz
wget http://ftp.gnu.org/gnu/automake/automake-1.15.tar.xz
wget http://ftp.gnu.org/gnu/bash/bash-4.3.30.tar.gz
wget http://alpha.gnu.org/gnu/bc/bc-1.06.95.tar.bz2
wget http://ftp.gnu.org/gnu/binutils/binutils-2.26.tar.bz2
wget http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.xz
wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
wget http://sourceforge.net/projects/check/files/check/0.10.0/check-0.10.0.tar.gz
View sri.go
package sri
import (
"crypto/sha256"
"encoding/base64"
"fmt"
"io/ioutil"
)
func Generate256(file string) (string, error) {
@gautamkrishnar
gautamkrishnar / english-words.py
Created December 27, 2016 08:54
Script to generate a coma seporated file(.csv) from a given input file with normal english words and unicode characters...
View english-words.py
from nltk.corpus import wordnet #Using Natural language toolkit (http://www.nltk.org/)
import codecs
def check(str):
if not wordnet.synsets(str):
return 1
else:
return 0
a=0
if __name__ == '__main__':
@gautamkrishnar
gautamkrishnar / multiprocessing.py
Created July 12, 2017 11:04
simple program to do python multiprocessing
View multiprocessing.py
import multiprocessing as mp
process_list = []
def pr1(test,test1):
"""
@:param: test,test1 (Integer)
process 1
"""
print("Pr 1 prining... '"+str(test)+"','"+str(test1)+"' recieved...")
@gautamkrishnar
gautamkrishnar / lib.py
Created July 13, 2017 06:40
A simple python thread based random number generator
View lib.py
import threading
x=0 #to get a random number
killswitch = False # To kill thread after use
def threaded_return(que):
"""
Returning data from thread safely (Returns current value of x)
:param que:
:return:
"""
global x