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
@tombh
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: https://github.com/pwnall/zerg_support/blob/faaa5dd140c95588a1db2a25f6c9d9cacb4f9b0a/lib/zerg_support/open_ssh.rb
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.
View oin-buckets-testing.json
{
"nodes": [
{
"name": "Testing",
"contact": "info@hotosm.org",
"locations": [
{
"type": "s3",
"bucket_name": "oam-uploader"
}
View keybase.md

Keybase proof

I hereby claim:

  • I am tombh on github.
  • I am tombh (https://keybase.io/tombh) on keybase.
  • I have a public key whose fingerprint is 3317 BFD3 B392 2F6C 0DAE BE40 62CC 4ABB D9C0 B437

To claim this, I am signing this object:

View oam-roadmap.md

These are some opiniated ideas for improvements to OAM/OIN. They are first of all straw men: merely ideas to stimulate conversation. My guiding principles here are the general software engineering best practices I've come to appreciate over the years. Therefore there is little here in terms of new features and little that an end-user would explicitly notice. They concern the health of the code: reduction of regression bugs, ease and confidence of refactoring, reduction of the learning curve for newcomers and contributors, scalability and browser performance.

These are of course good things in any circumstances. Though I have also borne in mind HOT's plans to promote and expand OAM beyond its current audience and vision.

Github Improvements

Contribution policies

  • Always rebase, rather than merge, by default on github. This makes the Git logs more readable.
  • PRs must include new/amended test cases.
  • master as the default branch, with staging and production reflecting increasing stability.
View bsnl_radar.rb
#! env ruby
loop do
begin
ping = `ping -n -c 1 -W 3 google.in 2>&1`
rescue
puts "Failed ping"
sleep 1
next
View rspec_raise_error_spec.rb
class ErrorHandler
def foo
potential_error
rescue StandardError
puts 'An error was handled'
end
end
RSpec.describe do
let(:instance) { ErrorHandler.new }
@tombh
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)
else
return nil
end
end
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 http://stackoverflow.com/questions/2948328/access-attributes-methods-comments-programmatically-in-ruby
class Module
@tombh
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)
# GRRRRRRRRRRRRRRRRRRRRR!
require 'net/http'
# A utility for signing an url using OAuth in a way that's convenient for debugging
View config.ru
# config.ru for Rackup + Wordpress, based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/
# added hackery to work around wordpress issues - Patrick Anderson (patrick@trinity-ai.com)
# 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
You can’t perform that action at this time.