Skip to content

Instantly share code, notes, and snippets.

View jamiembrown's full-sized avatar

Jamie Brown jamiembrown

View GitHub Profile
@jamiembrown
jamiembrown / gist:8601748
Created January 24, 2014 17:15
Bash function to emulate Linux watch on Mac OS
function watch {
while :; do clear; $@; sleep 2; done
}
@jamiembrown
jamiembrown / gist:8601776
Created January 24, 2014 17:16
Bash function to emulate Linux pkill on Mac OS
function pkill {
osascript -e 'tell application "'$1'" to quit saving no'
}
@jamiembrown
jamiembrown / gist:8601786
Created January 24, 2014 17:17
Bash function to mount a volume on Mac OS
function macmount {
osascript -e 'mount volume "'$1'"'
}
@jamiembrown
jamiembrown / gist:8601844
Created January 24, 2014 17:19
Bash function to get a value from a remote JSON file
function getjson {
curl --silent $1 | python -c 'import sys, json; print json.load(sys.stdin)[sys.argv[1]]' $2
}
@jamiembrown
jamiembrown / .vimrc
Created January 24, 2014 17:21
A perfect .vimrc file
syntax on
color desert
" Search customisation
set showmatch
set incsearch
set hlsearch
set ignorecase
set smartcase
@jamiembrown
jamiembrown / gist:8602117
Created January 24, 2014 17:33
Check if a process is running, kill it or start it
# Check if a process is running or not
def is_proc_running(proc_name):
command = 'ps aux | grep -v grep | grep -v /bin/sh | grep ' + proc_name
output = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True).communicate()[0]
if len(output)==0:
return False
else:
return True
@jamiembrown
jamiembrown / lat_long_square.php
Created April 10, 2014 12:54
Create a square around a latitude and longitude based on a distance in meters in PHP
$distance = 30000;
$radius_of_earth = 6335000;
$longitude_offset = ($distance / $radius_of_earth) * (180 / pi()) / cos(($latitude * pi())/180);
$latitude_offset = ($distance / $radius_of_earth) * (180 / pi());
$max_longitude = $longitude + $longitude_offset;
$min_longitude = $longitude - $longitude_offset;
$max_latitude = $latitude + $latitude_offset;
$min_latitude = $latitude - $latitude_offset;
@jamiembrown
jamiembrown / facebook-search
Created July 11, 2014 13:14
Get access token and search Facebook graph search using Python