Skip to content

Instantly share code, notes, and snippets.

Avatar

Gautam krishna R gautamkrishnar

View GitHub Profile
@gautamkrishnar
gautamkrishnar / backup.sh
Created Jun 21, 2015
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 / mainpage.xaml
Created Jun 21, 2015
Windows phone XAML Namespace Declarations
View mainpage.xaml
<Page
x:Class="HelloWorldWP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:HelloWorldWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
@gautamkrishnar
gautamkrishnar / back.js
Created Jul 17, 2015
Adding this script to the back button of your site's subpages can make your site load more faster on clicking the back button on your subpages
View back.js
function backme(){
if(history.back.toString)
{history.back();}
else
{window.location("http://www.yoursite.com/");}
}
@gautamkrishnar
gautamkrishnar / mail.php
Created Aug 9, 2015
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 Dec 6, 2015
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 Dec 20, 2015
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 Jun 28, 2019
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 Jun 18, 2016
(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 Dec 27, 2016
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__':