Skip to content

Instantly share code, notes, and snippets.

@coldclimate
coldclimate / gist:5926209
Created July 4, 2013 09:20
What is in branch A that is not in Branch B made pretty
git log --pretty=oneline --abbrev-commit --decorate B..A
@coldclimate
coldclimate / gist:5926630
Last active December 19, 2015 08:38
Find the commit on Master that was HEAD when branch FEATURE was branched (I'm not 100% on this wizardry) (found in http://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git)
diff -u <(git rev-list --first-parent FEATURE) \
<(git rev-list --first-parent master) | \
sed -ne 's/^ //p' | head -1
@coldclimate
coldclimate / gist:5968918
Created July 10, 2013 18:38
Cheese scale. 1 (rubbish) to 10 (perfect)
1 Cheez Whiz
2 Dairylea
3 French Brie
4 Edam
5 Mild Cheddar
6 Smoked Applewood
7 Summerset Brie
8 Mature Cheddar
9 St James
10 Stilton
@coldclimate
coldclimate / gist:5974697
Created July 11, 2013 11:35
When developing scripts which are going to be run by cloud-init
The scripts you pass through as a compiled user-script are split up and expanded into /var/lib/cloud/instance/scripts so you can go and run them again and debug
// Don't forget this line or signal handling won't work:
declare(ticks = 1);
// This global flag is used to trigger a configuration file reload.
$load_config = true;
// The SIGHUP handler doesn't do any actual work; it just sets the flag.
function handle_hup($signal) {
global $load_config;
$load_config = true;
@coldclimate
coldclimate / gist:6163245
Created August 6, 2013 09:53
Find all errors, log out the time the happened, then hillbilly histogram them
grep -n "Connection refused" error.log-20130806 | awk '{print $2}' > errortimes.log
sort errortimes.log | uniq -c
@coldclimate
coldclimate / gist:7170213
Created October 26, 2013 14:45
Convert a list into a set in redis
redis-cli lrange 2013_10_26 0 2000 | xargs redis-cli sadd s2013_10_26
@coldclimate
coldclimate / gist:8831241
Created February 5, 2014 19:28
How I got hubot running and talking to hipchat on Ubuntu 13
sudo apt-get update
sudo apt-get install nodejs npm
sudo apt-get install build-essential libssl-dev git-core redis-server libexpat1-dev
npm install -g coffee-script
sudo npm install -g coffee-script
sudo npm install -g hubot coffee-script
sudo mkdir myrobot
sudo chown ubuntu:ubuntu myrobot
hubot --create myrobot
cd myrobot/
{
"BrowserGUID" : "aa558a9bdba8b2558260e168bd79f3ff",
"ContactId" : "961f9d23c127472507b8441b25e1025f",
"Duration" : 0,
"GoalNo" : 2,
"GoalTitle" : "Form submission",
"GoalType" : "form",
"PageTypeId" : 3,
"ProcessedPPA" : [
"ProcessActions_FieldToCompany_Post_input_2",
@coldclimate
coldclimate / gist:9994931
Created April 5, 2014 17:22
Grab your last.fm all time stats and see what you've contributed to the world listening stats.
import lastfm
api_key = 'REPLACEME'
api = lastfm.Api(api_key)
user = api.get_user('REPLACEME')
tracks = user.top_tracks
for track in tracks:
gcount = api.get_track(artist=track.artist.name,track=track.name).stats.playcount
print "%s %s %s of %s (%f )" % (track.artist.name,track.name, track.stats.playcount, gcount, track.stats.playcount/gcount)