Skip to content

Instantly share code, notes, and snippets.

Avatar

Idris Mokhtarzada idris

View GitHub Profile
@idris
idris / github.sh
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.
View github.sh
#!/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 Jun 10, 2012
Allow CORS with python simple http server
View cors_server.py
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