Skip to content

Instantly share code, notes, and snippets.

View tombh's full-sized avatar

Thomas Buckley-Houston tombh

View GitHub Profile
@tombh
tombh / gist:b45e86788620435adc5a
Last active November 9, 2021 13:49
Use .env file to filter sensitive data from VCR cassettes
# 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"
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)
class ErrorHandler
def foo
potential_error
rescue StandardError
puts 'An error was handled'
end
end
RSpec.describe do
let(:instance) { ErrorHandler.new }
#! env ruby
loop do
begin
ping = `ping -n -c 1 -W 3 google.in 2>&1`
rescue
puts "Failed ping"
sleep 1
next

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.

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:

{
"nodes": [
{
"name": "Testing",
"contact": "info@hotosm.org",
"locations": [
{
"type": "s3",
"bucket_name": "oam-uploader"
}
Japanese, Hokkaido, Jingisukan
Japanese, Hokkaido, Rui-be
Japanese, Hokkaido, Hokkaido
Japanese, Tohoku region, Wanko soba
Japanese, Tohoku region, Morioka
Japanese, Tohoku region, Kiritanpo
Japanese, Tohoku region, Gy
Japanese, Chubu and Kanto regions, Inago no tsukudani
Japanese, Chubu and Kanto regions, Monjayaki
Japanese, Chubu and Kanto regions, Sushi