Skip to content

Instantly share code, notes, and snippets.

View idris's full-sized avatar

Idris Mokhtarzada idris

View GitHub Profile
@idris
idris / github.sh
Created November 13, 2012 04:03
command-line utility that opens a browser to the given file/directory/commit in GitHub. Now has blame command which opens github blame page.
#!/bin/bash
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
else
echo $branch
fi
@enjalot
enjalot / cors_server.py
Created June 10, 2012 06:19
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