Skip to content

Instantly share code, notes, and snippets.

View abhiomkar's full-sized avatar

Abhinay Omkar abhiomkar

View GitHub Profile
@abhiomkar
abhiomkar / awk-wc.sh
Created January 11, 2010 21:09
WC USING AWK - WITHOUT USING WC
#!/bin/bash
# Author : Abhinay Omkar (c) 2007
# Description : wc using awk. without using wc.
# License : GPLv2
# This is free software. You may redistribute copies of it under the terms of
# the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
# There is NO WARRANTY, to the extent permitted by law.
#
# Copyright (C) 2007 Free Software Foundation, Inc.
@abhiomkar
abhiomkar / Python: Guess Number Game
Created January 16, 2010 11:12
Python Game: Guess Number Game
#!/usr/bin/python
#Author: Abhinay Omkar
#Title: Guess Number Game
import random
class GuessNumber:
def startGame(self):
print 'Guess a number!'
t=0
@abhiomkar
abhiomkar / HelloWorld.py
Created January 30, 2010 13:15
Use'less' Python Snippets
print "hello world!"
# Copy files of Source1, Source2 and Source 3 Directories to Destination Folder
find Source1 Source2 Source3 -type f -exec cp '{}' Destination/ \;
@abhiomkar
abhiomkar / pyedit.sh
Created March 26, 2010 12:04 — forked from defunkt/vipy.sh
Simple shell script that locates a Python module and opens it in your default editor.
#!/bin/bash
# forked from gist:320305 by mmalone
if [ $# -ne 1 ]; then
echo "Usage: pyedit <python module>"
exit 1
fi
MODULE_LOCATION=`python -c "import $1; print $1.__file__.rstrip('c')"`
@abhiomkar
abhiomkar / InstallFlickrBird.sh
Created March 30, 2010 19:24
...to embed in my blog
mkdir MyFlickrBackup
cd MyFlickrBackup
#Download FlickrBird Script
wget http://github.com/abhiomkar/FlickrBird/raw/master/flickrbird.py
#Give execute permissions to run it
chmod +x flickrbird.py
#Yah! run it...
./flickrbird.py
# Author: Abhinay Omkar
# Youtube Downloader
import sys
from urllib import urlopen, unquote
from urlparse import parse_qs, urlparse
youtube_watchurl = sys.argv[1]
url_query = urlparse(youtube_watchurl).query
video_id = parse_qs(url_query)['v'][0]
url_data = urlopen('http://www.youtube.com/get_video_info?&video_id=' + video_id).read()
@abhiomkar
abhiomkar / youtube-downloadr-oneliner.py
Created May 12, 2010 13:50
One-liner to download youtube video in Python
# Author: Abhinay Omkar
# Title: One-liner to download youtube video in Python
from urllib import urlopen, unquote; from urlparse import parse_qs, urlparse; youtube_watchurl="http://www.youtube.com/watch?v=NeSuirvA6UE&playnext_from=TL&videos=MS3Hq4oBj08"; video_id = parse_qs(urlparse(youtube_watchurl).query)['v'][0]; open(video_id+'.mp4', 'wb').write(urlopen("http://www.youtube.com/get_video?video_id=%s&t=%s&fmt=18"%(video_id, parse_qs(unquote(urlopen('http://www.youtube.com/get_video_info?&video_id=' + video_id).read().decode('utf-8')))['token'][0])).read())
@abhiomkar
abhiomkar / BY GOOGLE PACMAN ON THE 21ST OF MAY 2010.js
Created May 21, 2010 22:02
BY GOOGLE PACMAN ON THE 21ST OF MAY 2010
google.pacman ||
function () {
var a = true,
e = false,
g = {},
i = [1, 4, 2, 8],
l = {
0: {
axis: 0,
increment: 0
#!/usr/bin/python
# Author: Abhinay Omkar
# Title: Program to convert CSV Formatted data to HTML tables (without using any APIs)
def write2file(str, filename):
"""Write the content of 'str' to file - 'filename'"""
f = open(filename, 'w')
f.write(str)
f.close()