Skip to content

Instantly share code, notes, and snippets.

View madhurjain's full-sized avatar

Madhur Jain madhurjain

  • San Jose
View GitHub Profile
@madhurjain
madhurjain / tweets.php
Created January 13, 2012 15:43
Grab tweets using PHP
<?php
// Specify the Twitter Screen Name and Number of tweets to be retrieved
$timeline_url = "http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=twitter&count=5";
$xml_feed = simplexml_load_file($timeline_url);
function relative_time($time_value){
$values = explode(" ",$time_value);
$time_value = $values[1]." ".$values[2].", ".$values[5]." ".$values[3];
$parsed_date = strtotime($time_value);
@madhurjain
madhurjain / rmbackup.sh
Created May 7, 2012 04:40
Remove linux backup files
find ./ -name '*~' | xargs rm
@madhurjain
madhurjain / .bashrc
Last active October 4, 2015 11:27
Enable full-color support in terminal
if [ -n "$DISPLAY" -a "$TERM" == "xterm" ]; then
export TERM=xterm-256color
fi
@madhurjain
madhurjain / Windows WiFi HotSpot
Created December 30, 2012 16:40
Create a WiFi HotSpot to share your Internet connection using this tiny batch script. Put each line in a separate .bat file
Create and Start Hotspot
netsh wlan set hostednetwork mode=allow ssid=MyHotspot key=MyPassword
Start Hotspot
netsh wlan start hostednetwork
Stop Hotspot
netsh wlan stop hostednetwork
@madhurjain
madhurjain / file_rename.sh
Last active December 11, 2015 15:18
Shell script to rename/move a file after it is downloaded
#!/bin/bash
echo "1. Rename file1.zip -> file2.zip"
echo "2. Move file1.tar.gz -> file2.tar.gz"
echo "3. Exit"
echo "Please enter your choice: "
read option
#The base folder path
basePath="/home/mad"
@madhurjain
madhurjain / process.py
Created June 27, 2013 06:49
CSV file processing in python
import csv, re, traceback
# Read category file to dict
categoryFile = open('categories.csv', 'rb')
try:
categoryDict = csv.DictReader(categoryFile);
cDesc = []
mainCat = []
secondCat = []
thirdCat = []
@madhurjain
madhurjain / AhoCorasick.pas
Last active December 9, 2020 14:35
AhoCorasick Implementation in Delphi / Pascal
unit AhoCorasick;
interface
uses Classes, Generics.Collections;
type
ptrNode = ^TNode;
TNode = record
id: Cardinal; // Node Id for debugging
@madhurjain
madhurjain / Building Boost with VS 2017.md
Last active May 29, 2018 07:47
Building Boost Library using Visual Studio 2017
  1. Download and Extract Boost
  2. Run bootstrap.bat
  3. Open generated project-config.jam and add path to MSVC 2017 like below
import option ; 
 
using msvc : 14.0 : "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x86\cl.exe"; 
 
option.set keep-going : false ; 
@madhurjain
madhurjain / windows_set_testsigning_on.bat
Created April 11, 2017 19:14
Set TESTSIGNING on for Windows Drivers Testing
bcdedit.exe -set loadoptions DISABLE_INTEGRITY_CHECKS
bcdedit.exe -set TESTSIGNING ON
@madhurjain
madhurjain / handy_commands.md
Last active April 12, 2017 19:33
Handy Commands

Handy Commands

Generate Energy Report on Windows

  • Run elevated cmd prompt and type powercfg -energy