Skip to content

Instantly share code, notes, and snippets.

@jayrambhia
jayrambhia / xkcd_viewer.py
Created March 11, 2012 21:51
xkcd viewer (offline version)
"""
See this gist: https://gist.github.com/1984424
Download both of these gists. save it in same folder. The down_xkcd.py will download all the xkcd comics from net. And view comics using xkcd_viewer.py
"""
import pygtk
import gtk
from PIL import Image
import os
from random import randint
@jayrambhia
jayrambhia / down_ted_vids.py
Created March 11, 2012 07:56
A python script to download all the TED videos
import urllib2
import urllib
#import re
from BeautifulSoup import BeautifulSoup
"""
Download this file in html version
https://docs.google.com/spreadsheet/ccc?key=0AsKzpC8gYBmTcGpHbFlILThBSzhmZkRhNm8yYllsWGc&hl=en#gid=0"
"""
url = "The URL of above file" # url = "file:///home/jay/Downloads/index.html"
@jayrambhia
jayrambhia / down_xkcd.py
Created March 6, 2012 06:54
A python script to download/update xkcd comic strip
import urllib2
import os
from BeautifulSoup import BeautifulSoup
BASE_URL = "http://xkcd.com"
proxy = {"http":"http://user:pass@proxy:port/",
"https":"https://user:pass@proxy:port/"}
Proxy = urllib2.ProxyHandler(proxy)
opener = urllib2.build_opener(Proxy)
@jayrambhia
jayrambhia / searchfiles.py
Created March 5, 2012 15:22
A script to search files in the given directory. Search file by name, name and type, type, etc
import os
import mimetypes
def main():
target_file = raw_input('Enter the name of the file(Separate with comma): ')
target_type = raw_input('Enter the type of the file(Separate with spaces): ').split()
target_dir = raw_input('Enter directory (Press Enter for current directory)(Separate with comma): ')
flag = 0
if target_file:
target_file = target_file.split(',')
@jayrambhia
jayrambhia / stickynote.py
Created February 13, 2012 20:38
A simple sticky note application using pygtk!
import pygtk
pygtk.require('2.0')
import gtk
import os
class TextBox:
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_size_request(200,250)
self.window.connect("destroy", self.close_application)
@jayrambhia
jayrambhia / MakeDirectories.py
Created February 10, 2012 10:44
Create directories (eg. home/user/direc1/direc2/direc3/direc4) even if direc1, direc2, direc3 doesn't exist. It will create all the directories. Just give absolute path.
import os
def makeDir(path):
if os.path.isdir(path):
return
dir1, dir2 = os.path.split(path)
makeDir(dir1)
os.mkdir(path)
return
@jayrambhia
jayrambhia / bookmark.py
Created February 1, 2012 22:49
A python script to back up all the bookmarks(firefox compatible). It returns a dictionary with url as key and (title, tag, add_date, modified_date) tuple as the value. It also stores it in gdbm. Another script is provided to read all the bookmarks.
'''
Author: Jay Rambhia
email : [email protected]
A new script supporting both Mozilla Firefox and Google Chrome bookmarks:
https://github.com/jayrambhia/Bookmark-Manager
'''
import os
import json
import pickle
import gdbm
@jayrambhia
jayrambhia / playBanshee.py
Created February 1, 2012 20:48
A python script to play banshee media player(can use only terminal commands).
'''
Author : Jay Rambhia
email : [email protected]
twitter: @jayrambhia
'''
import os
import time
import threading
import sys
from multiprocessing import Process
@jayrambhia
jayrambhia / bookmark-json.py
Created January 28, 2012 06:52
Fetch Bookmark details from temp files of browsers using json
"""
Created on Fri Jan 27 21:48:58 2012
@author: jay
"""
import json
import os
import gdbm
import time
@jayrambhia
jayrambhia / bookmark-html.py
Created January 27, 2012 19:11
Extract bookmarks (from html file) from the browser
"""
@author: jay
"""
from BeautifulSoup import BeautifulSoup
import gdbm
import pickle
import time
def main():