Skip to content

Instantly share code, notes, and snippets.


Idris Mokhtarzada idris

View GitHub Profile
idris /
Created Nov 13, 2012
command-line utility that opens a browser to the given file/directory/commit in GitHub. Now has blame command which opens github blame page.
function parse_git_branch {
local branch=`cd $DIR;git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ "$branch" == "" ]; then
exit 1
echo $branch
enjalot /
Created Jun 10, 2012
Allow CORS with python simple http server
import SimpleHTTPServer
class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def send_head(self):
"""Common code for GET and HEAD commands.
This sends the response code and MIME headers.
Return value is either a file object (which has to be copied
to the outputfile by the caller unless the command was HEAD,
and must be closed by the caller under all circumstances), or