Skip to content

Instantly share code, notes, and snippets.

olly / actual.txt
Last active Jan 13, 2020
ActionView subclass regression
View actual.txt
$ ruby test.rb 6.0.0
Traceback (most recent call last):
21: from test.rb:30:in `<main>'
20: from /usr/local/var/rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/actionview-6.0.0/lib/action_view/helpers/rendering_helper.rb:30:in `render'
19: from /usr/local/var/rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/actionview-6.0.0/lib/action_view/base.rb:304:in `in_rendering_context'
18: from /usr/local/var/rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/actionview-6.0.0/lib/action_view/helpers/rendering_helper.rb:34:in `block in render'
olly /
Last active Mar 6, 2018
`data-anonymization` `SelectFromDatabase` patch

Prevents SQL error caused by primary_key not being set

Previously the SelectFromDatabase strategy connects to the database, and extracts the values, when it's initalized. However, at this stage,the table isn't fully configured and so when it creates the source table, it doesn't set a primary key.

By changing it to lazily fetch, and cache, the values; we ensure that the source table will be correctly configured.

extern crate chrono;
extern crate serde_json;
extern crate uuid;
use chrono::TimeZone;
View rails-merge-db-schema
#!/usr/bin/env ruby
# usage: rails-merge-db-schema <current-file> <base-file> <other-file> <marker-size>
# install:
# $ git config --global "newer Rails schema version"
# $ git config --global merge.railsschema.driver "rails-merge-db-schema %A %O %B %L"
exit 1 if ARGV.size != 4
olly / set_test.rb
Created Apr 5, 2017
Ruby Set#include? strangeness
View set_test.rb
require 'minitest/autorun'
require 'set'
class Foo
def initialize(s)
@s = s
def ==(other)
@s == other

Keybase proof

I hereby claim:

  • I am olly on github.
  • I am ollylegg ( on keybase.
  • I have a public key ASCz5Gv6Xa5KiEHzGYm3agmh25E853LgPFwieUp2iq4Hqgo

To claim this, I am signing this object:

View SSL Client Auth

Client SSL Authentication

The use case I had when I implemented client SSL authentication was to secure a web interface for a centralised log service that I was running. I wanted it to have it available, securely, on the public internet. I implemented it using nginx's ssl module.

I only had this available for 4-5 developers. I think I'd only attempt to use this for anyone who is comfortable with SSH keys or if it was an API client. I think the technical bar is a little too high for anything else.

I wrote some scripts, which I've pushed to a public GitHub repository: olly/heracles. The README is a mix of actual commands that work, and thoughts for how things could be configured. The idea was for it to generate CAs, server certificates and client certificates, and store them in a git repository for easy backup. There in a fairly rough state, but what's there works and I had tested on a real setup.


olly /
Created Mar 9, 2015
a personal vim cheatsheet

vim cheatsheet

Copy & Paste

"ayw yank word into the "a" register
"Ayw yank word and append into the "a" register

Moving through a document

z<return> move current line to the top

View application.html.erb
<!DOCTYPE html>
<%= stylesheet_link_tag 'application' %>
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tags %>
View gist:963de94953d83c8094a3
class User
has_many :friendships
has_many :friends, through: :friendships
class Friendship
belongs_to :friend, class: User
belongs_to :friendee, class: User
You can’t perform that action at this time.