Skip to content

Instantly share code, notes, and snippets.

@olly
olly / bundler-rspec-inline.rb
Created October 23, 2023 12:29 — forked from odlp/bundler-rspec-inline.rb
Inline Bundler and autorun RSpec
require "bundler/inline"
gemfile do
gem "rspec"
end
require "rspec/autorun"
RSpec.describe "inline Bundler and autorun RSpec" do
it "is convenient for self-contained examples & bug repros" do
@olly
olly / test.rb
Last active October 28, 2022 10:06
module WhatAmIMissing
module Cat
module Bill
def thing
[1,2,3]
end
end
end
class John
@olly
olly / actual.txt
Last active January 13, 2020 18:53
ActionView subclass regression
$ ruby test.rb 6.0.0
<h1>Sample</h1>
===
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
olly / README.md
Last active March 6, 2018 17:38
`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.

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
extern crate chrono;
#[macro_use]
extern crate serde_json;
extern crate uuid;
use chrono::TimeZone;
#!/usr/bin/env ruby
#
# usage: rails-merge-db-schema <current-file> <base-file> <other-file> <marker-size>
#
# install:
#
# $ git config --global merge.railsschema.name "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
olly / set_test.rb
Created April 5, 2017 13:41
Ruby Set#include? strangeness
require 'minitest/autorun'
require 'set'
class Foo
def initialize(s)
@s = s
end
def ==(other)
@s == other

Keybase proof

I hereby claim:

  • I am olly on github.
  • I am ollylegg (https://keybase.io/ollylegg) on keybase.
  • I have a public key ASCz5Gv6Xa5KiEHzGYm3agmh25E853LgPFwieUp2iq4Hqgo

To claim this, I am signing this object:

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.

Authorizatio

@olly
olly / cheats.md
Created March 9, 2015 09:59
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 move current line to the top