Skip to content

Instantly share code, notes, and snippets.

View SahilC's full-sized avatar

Sahil Chelaramani SahilC

View GitHub Profile
@SahilC
SahilC / Backup.php
Created November 28, 2012 22:26
Php Mysql Database backup and restore
<?php
$dump_path = ""; //input location for the backup to be saved
$host = ""; //db host e.g.- localhost
$user = ""; //user e.g.-root
$pass = ""; //password
$command=$dump_path.'mysqldump -h '.$host.' -u '.$user.' bank > bank.sql';
system($command);
?>
@SahilC
SahilC / clock.asm
Created December 19, 2012 10:31
A simple assembly code for the 8086 microprocessor to display a digital clock in real time.
.model small
.stack 1024
.data
.code
start:
mov ax,@data
mov ds,ax
extrn writesint:proc
mov ah,2ch
int 21h
@SahilC
SahilC / Solution
Last active December 15, 2015 05:49
vacationlabs registration link solution
def f(n):
for i in xrange(1,n):
if i%3==0 and i%5==0:
print 'Whazaa'
elif i%3==0:
print 'Hip'
elif i%5==0:
print 'Hop'
else:
print i
@SahilC
SahilC / rem.py
Created April 17, 2013 12:46
Find mod of two numbers without mod
def f(nr,dr):
return (nr-dr*(nr/dr))
@SahilC
SahilC / Manga.py
Created June 7, 2013 21:00
A simple python script to download Manga from MangaReader.
from urllib import request
print("Input Url to Manga on MangaReader")
x=input()
u=request.urlopen(x)
line=str(u.read(),encoding='utf8')
no=line.index("document['pu']")
no2=line.find(";",no)
print(no2-no)
url=line[no+17:no2]
url2=line[no+18:no2-12]
@SahilC
SahilC / Primes.py
Created September 10, 2013 13:22
Strangely awesome way to find prime numbers
def prime(n):
for i in range(3,n):
if 2**(i-1)%i==1:
print i
@SahilC
SahilC / gist:af0206645e069fded7db
Created August 22, 2014 12:27
Find all IPs connected to a network, assuming that your IP range is 192.168.1.x
#!/bin/bash
for ip in 192.168.1.{1..254}; do
ping -c 1 -W 1 $ip | grep "64 bytes" &
done
@SahilC
SahilC / quotes.sh
Created December 9, 2014 10:24
A bash script to give you a random quote everytime you open your terminal. Add the following lines to your bashrc.
# font color : green
color='\e[0;32m'
# font color : white
NC='\e[0m'
getquote(){
num_online_quotes=9999
rand_online=$[ ( $RANDOM % $num_online_quotes ) + 1 ]
quote=$(wget -q -O - "http://www.quotationspage.com/quote/$rand_online.html" |
@SahilC
SahilC / Define.sh
Created December 9, 2014 13:44
Use this script to find meanings of words from bash shell. For convenience, make this script executable and add alias to file with the command `alias define='path-to-define.sh-file'`
#!/bin/bash
wget -q -O - "http://www.macmillandictionary.com/dictionary/british/$1" | grep -P -o "<span class=\"DEFINITION\">(.*?)</span>" | grep -Po '(?<=href=")[^"]*' | grep -Po '=.*?$' | cut -d = -f 2 | awk '{printf "%s ",$1}'
@SahilC
SahilC / specialScript.py
Last active March 30, 2016 14:15
:) :) :)
import matplotlib.pyplot as mpplt
import matplotlib.gridspec as gridspec
import numpy
figure = mpplt.figure(figsize=(11, 10))
gs = gridspec.GridSpec(3, 12)
plt = figure.add_subplot(gs[0, :])
plt.hlines(3, -10, 10, color='red')
plt.hlines(-3, -10, 10, color='red')