Skip to content

Instantly share code, notes, and snippets.

View abhiomkar's full-sized avatar

Abhinay Omkar abhiomkar

View GitHub Profile
#!/usr/bin/python
# Title: Update Employee records in a plain text file
FILE_NAME = 'employee.txt'
DELIMIT = ';'
def prompt_values():
_values = {}
_values['ename'] = raw_input("Employee Name: ")
_values['esal'] = float(raw_input("Employee Sal: "))
@abhiomkar
abhiomkar / pythemall.py
Created June 20, 2010 07:21
Snippet to spit out direct links from the given URL for the mentioned types (like '.mp3', '.zip' etc)
#!/usr/bin/python
# Title: pythemall - Python clone of Downloadthemall
# Description: snippet to download direct URLs from a given page
__author__ = 'Abhinay Omkar'
from BeautifulSoup import BeautifulSoup
from urllib import urlopen
from urlparse import urlparse
from getopt import getopt
@abhiomkar
abhiomkar / gen-jquery.css().py
Created June 22, 2010 22:00
to use in jquery
# input:
#
# margin: 0px;
# padding: 0px;
# top: 0px;
#
# output:
# margin: "0px",
# padding: "0px",
# top: "0px",
// ==UserScript==
// @name blank2self
// @namespace http://abhiomkar.in
// @description blank2self
// @include http://*
// @include https://*
// @version 0.1
// ==/UserScript==
aTags = document.getElementsByTagName("a"); for(i=0; i< aTags.length; i++) { aTags[i].target = "_self"; }
@abhiomkar
abhiomkar / top2blank.js
Created June 30, 2010 13:29
Make external links to load in the new window (or tab). Doesn't work if the href is the javascript function.
// ==UserScript==
// @name top2blank
// @description Set External links' target value to _blank
// @namespace http://abhiomkar.in
// @include http://*
// @include https://*
// ==/UserScript==
aTags = document.getElementsByTagName("a");
@abhiomkar
abhiomkar / console.log.js
Created July 21, 2010 13:37
User-defined console.log() function for debug messages in JavaScript. Useful if Firebug is not installed in your browser.
// Author: Abhinay Omkar
if(!window.console){
var console = {
log: function(msg){
throw new Error(msg);
}
}
}
@abhiomkar
abhiomkar / window.history.urlchange.js
Created July 21, 2010 19:22
Copy and paste this code to url, see what it does!
var dashes = ""; var num = 20; while(--num) dashes += "-"; setInterval(function() { window.history.pushState("", "", dashes.slice(0, num % 20) + "foo" + dashes.slice(num % 20)); num++;}, 500)
#include <stdio.h>
int main(){
printf("Hello World!\n");
}
@abhiomkar
abhiomkar / setdsm.sh
Created March 6, 2011 10:46
setdsm sets the DJANGO_SETTINGS_MODULE to the settings.py in the current directory and add the current directory and it’s parent to PYTHONPATH. Source: http://www.juiceanalytics.com/writing/django_settings_module/
function setdsm() {
# add the current directory and the parent directory to PYTHONPATH
# sets DJANGO_SETTINGS_MODULE
export PYTHONPATH=$PYTHONPATH:$PWD/..
export PYTHONPATH=$PYTHONPATH:$PWD
if [ -z "$1" ]; then
x=${PWD/\/[^\/]*\/}
export DJANGO_SETTINGS_MODULE=$x.settings
else
export DJANGO_SETTINGS_MODULE=$1
@abhiomkar
abhiomkar / stop-cherokee-osx.sh
Created March 15, 2011 21:12
Command to Stop / Start Cherokee Web Server on Mac OS X
# Stop Cherokee Web Server
sudo launchctl unload -w /Library/LaunchDaemons/org.cherokee.webserver.plist
# Start Cherokee Web Server
sudo launchctl load -w /Library/LaunchDaemons/org.cherokee.webserver.plist