Skip to content

Instantly share code, notes, and snippets.

Thomas Buckley-Houston tombh

Block or report user

Report or block tombh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
# for Rackup + Wordpress, based on
# added hackery to work around wordpress issues - Patrick Anderson (
# clearly this could be cleaner, but it does work
# And more hackery by @twombh to work in Linux environment
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
# patch Php from rack-legacy to substitute the original request so
tombh / boss_search.rb
Created Aug 16, 2012 — forked from erikeldridge/example.rb
A utility for signing an url using OAuth in a way that's convenient for debugging
View boss_search.rb
# This whole thing is horrible.
# Firstly Yahoo's website, docs and UI are terrible.
# Second, OAuth!? For a simple search API, WTF!?
# Thirdly, this code is bodged together, undocumented and didn't work with queries that needed URI escaping (but does now)
require 'net/http'
# A utility for signing an url using OAuth in a way that's convenient for debugging
View vagrant-snapshot.rb
# Place this file in the same directory as `Vagrantfile'
# then simply require "vagrant-snapshot.rb" at the top of Vagrantfile.
require 'optparse'
Vagrant.commands.register(:snap) { Snap::Commands }
# Provide rake-like desc() 'inflected' documentation
# See
class Module
tombh / quiet_fetch.rb
Created Jun 18, 2013
When you're accessing deep keys within a hash you don't want to have to write stuff like `if foo && foo["bar"] && foo["bar"]["baz"] && foo["bar"]["baz"]["bang"]`. So here's an idea to have a method on the Hash class that uses a sort of XML type query, eg; hash.quiet_fetch('a/b/c')
View quiet_fetch.rb
class Hash
def quiet_fetch query
current = self
query.split('/').each do |key|
if current.fetch(key, false)
current = current.fetch(key)
return nil
tombh / gist:5519b4a0d17d78a9fef7
Created Jun 4, 2014
Docker-api rspec errors after bumping API_VERSION to 0.11
View gist:5519b4a0d17d78a9fef7
1) Docker::Container#changes returns the changes as an array
Failure/Error: ]
expected: [{"Path"=>"/dev", "Kind"=>0}, {"Path"=>"/dev/kmsg", "Kind"=>0}, {"Path"=>"/root", "Kind"=>2}]
got: [{"Kind"=>2, "Path"=>"/root"}] (using ==)
@@ -1,4 +1,2 @@
-[{"Path"=>"/dev", "Kind"=>0},
- {"Path"=>"/dev/kmsg", "Kind"=>0},
- {"Path"=>"/root", "Kind"=>2}]
+[{"Kind"=>2, "Path"=>"/root"}]
tombh / gist:ffa163e8c05beb3c8317
Created Jun 12, 2014
Rspec exception getting caught by async method
View gist:ffa163e8c05beb3c8317
require 'celluloid'
# It wasn't until I commented out this line that I realised what was actually going on below
# Celluloid.logger = nil
class Foo
include Celluloid
def do
View gist:60c8a4e463d22a06d326
desc 'Add, remove and list config for an app'
command :config do |c|
c.desc 'Delete config by keys'
c.command :rm do |sc|
sc.action do |global_options, options, args|
@api.request :delete, "/app/#{Git.first_sha}/config", {
keys: args.to_json
View gist:317b8168a65d97a88f83
$chocolates = ['maltesers', 'minstrels', 'green & blacks', 'montezuma'];
$we_ate = array_slice($chocolates, 0, 2);
// Outputs: ['maltesers', 'minstrels']
View gist:9466ba47bed9555328d4
chocolates = ['maltesers', 'minstrels', 'green & blacks', 'montezuma']
we_ate = chocolates[0..1]
# Outputs: ['maltesers', 'minstrels']
tombh / gist:f66de84fd3a63e670ad9
Created Jan 3, 2015
Convert OpenSSH public key to OpenSSL public key using ruby
View gist:f66de84fd3a63e670ad9
require 'base64'
require 'openssl'
# Parse SSH keys to be used by OpenSSL lib
# Taken from Zerg Support project.
# See:
module OpenSSHKeyConverter
# The components in a openssh .pub / known_host RSA public key.
RSA_COMPONENTS = ['ssh-rsa', :e, :n]
# The components in a openssh .pub / known_host DSA public key.
You can’t perform that action at this time.