Skip to content

Instantly share code, notes, and snippets.

View gautamkrishnar's full-sized avatar

Gautam krishna R gautamkrishnar

View GitHub Profile
@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...
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 / add-all-empty-directory-git.sh
Last active June 28, 2019 15:01
Add all empty directories to github
#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 / upload.php
Created December 20, 2015 09:54
file extension fiter for file upload
//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 / backup-hdd.sh
Created December 6, 2015 07:29
Backup your hdd to an image with following simple command:
dd bs=4096 conv=noerror,sync if=/dev/sdc1 | gzip -c > img.gz
@gautamkrishnar
gautamkrishnar / mail.php
Created August 9, 2015 05:29
Sending an e-mail using 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.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
d="$(date -d -now)"
mkdir backup/"$d"
cp -r /var/www/html/* backup/"$d"