Skip to content

Instantly share code, notes, and snippets.

View oisin's full-sized avatar
💭
Thing.

Oisín Hurley oisin

💭
Thing.
View GitHub Profile
@oisin
oisin / gist:952572
Created May 2, 2011 23:36
API version checking using Sinatra's before filter
require 'sinatra'
# Set the version of the API being run here
#
MAJOR_VERSION = 1
MINOR_VERSION = 0
helpers do
def version_compatible?(nums)
return MAJOR_VERSION == nums[0].to_i && MINOR_VERSION >= nums[1].to_i
@oisin
oisin / snarf-notes.rb
Created May 12, 2011 08:25
Grab notes from a Slideshare presentation and turn them into an HTML document
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# Replace stupid 'smart' quotes in text, replace '\n' with real
# newlines, change selected diacritical marks
#
def cleaned(str)
str.gsub(/\\n/,"\n").gsub(/\‘|\’/, "'").gsub(/\”|\“/, '"').gsub(/í/, 'i')
end
@oisin
oisin / gist:987247
Created May 23, 2011 18:34 — forked from leereilly/gist:987094
API version checking using Sinatra's before filter; supports nested resources
require 'sinatra'
# Set the version of the API being run here
#
MAJOR_VERSION = 1
MINOR_VERSION = 0
VERSION_REGEX = %r{/api/v(\d)\.(\d)}
helpers do
def version_compatible?(nums)
@oisin
oisin / .gitconfig
Created October 5, 2011 15:48
Sample git config with aliases and log formatting
[user]
name = Your Name Here
email = Your Name Here
[diff]
[color]
ui = auto
[alias]
st = status
ci = commit
co = checkout
@oisin
oisin / attach_snapshot_volumes.sh
Created January 20, 2012 15:34
Scripts to create/attach/snapshot multiple EBS volumes
(i=0; for vol in $(awk '{print $2}' vol_snaps.txt); do i=$((i+1)); ec2-attach-volume $vol -i i-aa3bc4c8 -d /dev/sdv${i}; done)
@oisin
oisin / Rakefile
Created September 18, 2012 06:29
CircleCI coverage retrieval - Rake task to email coverage figures and CircleCI config to trigger post-build
require 'pony'
require 'zip/zip'
desc "Email the coverage to someone who gives a damn"
task :email_coverage do
archive = "test-coverage.zip"
Zip::ZipFile.open(archive, 'w') do |zipfile|
Dir["coverage/**/**"].reject{ |f| f == archive}.each do |file|
zipfile.add(file.sub('coverage/',''),file)
@oisin
oisin / gist:4444722
Last active December 10, 2015 13:59 — forked from bdougherty/gist:125113
get_git_branch() {
git branch | awk '/^\*/ { print $2 }'
}
get_git_dirty() {
git diff --quiet || echo '*'
}
get_git_prompt() {
git branch &> /dev/null || return 1
@oisin
oisin / gist:4529781
Created January 14, 2013 12:37
Resize a bunch of tiff files to 865x585 and convert them to pngs. Used to convert screenshots to a good size for 1024x768 presentation slides.
#!/bin/bash
files=`find . -name '*.tiff'`
for f in $files
do
dir=`dirname $f`
target=`basename -s .tiff $f`
convert $f -resize 865x585 ${dir}/${target}_865x585.png
echo ${dir}/${target}_865x585.png
done
@oisin
oisin / gist:5329873
Last active December 15, 2015 21:59
Programming languages timeline.
1982 Tandy Basic
1982 z80 Assembler
1983 MS Color Basic
1983 6809 Assembler
1985 Pascal
1985 DCL
1985 68000 Assembler
1986 C
1986 Modula 2
1986 Ada
@oisin
oisin / gist:5329909
Created April 7, 2013 10:21
THE KVIKKALKUL PROGRAMMING LANGUAGE
THE KVIKKALKUL PROGRAMMING LANGUAGE
Note: this message contains top secret information of the Swedish Navy.
Possession of this information in Sweden can (and will in most cases)
lead to Capital Punishment. DO NOT DISTRIBUTE THIS INFORMATION
TO SWEDEN!!!
INTRODUCTION
When I worked for the Swedish Navy in 1957 as a programmer, my task was to