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
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 }
View gist:40cde96a4e67b3d754bf
task calculate_per_location_costs: :environment do
year = ENV['YEAR'].to_i
month = ENV['MONTH'].to_i
# Method 1: By server usage
# Get all servers that were created in the given month
servers_by_location = Server.with_deleted
.where('extract(year from created_at) = ?', year)
.where('extract(month from created_at) = ?', month)
.group_by(&:location)
@tombh
tombh / gist:b45e86788620435adc5a
Last active Aug 29, 2015
Use .env file to filter sensitive data from VCR cassettes
View gist:b45e86788620435adc5a
# Assuming that you're using .env to store your sensitive app credentials, then you can
# use VCR's `filter_sensitive_data` method to convert occurrences of those credentials
# to `<%= ENV['#{key}'] %>` in your recorded VCR cassettes.
require 'vcr'
# Use the .env file to compile the list of sensitive data that should not be recorded in
# cassettes
def sensitive_strings
contents = File.read "#{Rails.root}/.env"
@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 gist:9466ba47bed9555328d4
chocolates = ['maltesers', 'minstrels', 'green & blacks', 'montezuma']
we_ate = chocolates[0..1]
# Outputs: ['maltesers', 'minstrels']
View gist:317b8168a65d97a88f83
<?php
$chocolates = ['maltesers', 'minstrels', 'green & blacks', 'montezuma'];
$we_ate = array_slice($chocolates, 0, 2);
// Outputs: ['maltesers', 'minstrels']
?>
You can’t perform that action at this time.