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
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
< ?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:
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
//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 / 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 / multiprocessing.py
Created July 12, 2017 11:04
simple program to do python multiprocessing
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
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
@gautamkrishnar
gautamkrishnar / pinger.py
Created July 30, 2017 11:22
A python script to increase the views of your pastebin profile. See the results: https://pastebin.com/u/gautamkrishnar
import requests
import threading
import os
import random
pastebinurl = "https://pastebin.com/u/gautamkrishnar"
def loaduseragents():
"""
Loads the list of user agents from user_agents.txt
:return:
"""
@gautamkrishnar
gautamkrishnar / keybase.md
Last active October 29, 2017 10:29
keybase.md

Keybase proof

I hereby claim:

  • I am gautamkrishnar on github.
  • I am gkrish (https://keybase.io/gkrish) on keybase.
  • I have a public key ASA7kdEWVJClHLW8EkVu1aRXGE9Ldn6JuZOrPHEAbpS7CQo

To claim this, I am signing this object:

@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 \;