Skip to content

Instantly share code, notes, and snippets.

@jkeyes
jkeyes / gist:1028958
Created June 16, 2011 09:40
Find unbound ports on localhost
import random
import socket
# range of ports where available ports can be found
PORT_RANGE = [33000,60000]
def find_unbound_port():
"""
Returns an unbound port number on 127.0.0.1.
"""
@jkeyes
jkeyes / newtab
Created October 21, 2010 11:54
Opens a new tab in Terminal.app for the current working directory
#!/bin/sh -
if [ $# -ne 1 ]; then
PATHDIR=`pwd`
else
PATHDIR=$1
fi
/usr/bin/osascript > /dev/null <<-EOF
activate application "Terminal"
context = {
'database': {
'port': 9990,
'users': ['number2', 'dr_evil']
},
'admins': ['number2@virtucon.com', 'dr_evil@virtucon.com'],
'domain.name': 'virtucon.com'
}
# Most comprehensive solution by http://stackoverflow.com/users/95810/alex-martelli
def get_revision(path=None):
"""
Return the revision identifier of the last commit in a git or svn source pool.
"""
if path is None:
path = "."
import os, re, subprocess
revision = None
os.chdir(path)