Skip to content

Instantly share code, notes, and snippets.

zetter / cache_recipies.rb
Created December 27, 2020 13:57
Script for caching external links from a jekyll site.
View cache_recipies.rb
require "jekyll"
require "ostruct"
require "faraday"
def data_for_file(path)
content =
if content =~ Jekyll::Document::YAML_FRONT_MATTER_REGEXP
content = $POSTMATCH
data = SafeYAML.load(Regexp.last_match(1))
return data
zetter /
Created September 20, 2020 16:43
Cookbook example
layout title from link quote type
Cheese and marmite flapjacks
Sarah Cook (Olive)
A great way to pack in the oats without adding tons of sugar – these savoury flapjacks combine cheese and Marmite together for an umami flavour explosion.

I was looking for a savoury recipe to use up some oats. Once I was out of marmite and used white miso paste instead.

zetter / tracepoint_log_process.rb
Created March 6, 2019 12:15
Code to process a log that I created using TracePoint
View tracepoint_log_process.rb
require 'json'
require 'csv'
class Line
attr_reader :thread_no, :line_no, :path, :klass, :method_id, :event, :code, :line
def initialize(row)
@thread_no, @line_no, @path, @klass, @method_id, @event, @code = row
zetter / output.tsv
Last active August 17, 2018 18:37
Find words in Omegawiki that are the reverse of the same word in another language
View output.tsv
word_1 word_2 word_1_language word_2_language
ramer remar French Castilian
afaka akafa French Castilian
NATO OTAN English French
nier rein Afrikaans French
NATO OTAN German French
NATO OTAN Italian French
erum mure Ainu (Latin) Interlingua
NATO OTAN English Castilian
agua auga Castilian Mirandese
zetter / wait_for_pending_requests.rb
Created March 22, 2018 13:54
Re-writing method without timeout
View wait_for_pending_requests.rb
def wait_for_pending_requests
start =
while pending_requests?
if ( - start) > 60
raise "Requests did not finish in 60 seconds"
zetter / subtyping.txt
Created October 9, 2017 08:39
View subtyping.txt
There was a programmer from Skegness,
Who had a language that was a bit of a mess,
They implemented subtyping, and no longer was there griping,
All while keeping safety, preservation and progress
zetter /
Created December 6, 2014 20:48
Deploying my personal site using s3cmd
jekyll build
s3cmd sync -r --acl-public public/ s3://
zetter / enrolment_cuke_spec.rb
Last active June 28, 2020 02:28
Enrolment cucumber-like rspec feature spec
View enrolment_cuke_spec.rb
feature 'Enrolment' do
scenario 'Enrolling in a course' do
def given_there_is_a_course
@course = FactoryGirl.create(:course)
zetter / enrolment_spec.rb
Last active August 29, 2015 14:03
Enrolment rspec feature spec
View enrolment_spec.rb
feature 'Enrolment' do
scenario 'Enrolling in a course' do
course = FactoryGirl.create(:course)
learner = FactoryGirl.create(:learner)
login_as learner
visit course_path(course)
expect(page).to have_content('Thanks for joining!')
zetter / enrolling.feature
Last active August 29, 2015 14:03
Enrolling in a course Cucumber feature
View enrolling.feature
Feature: Enrolment
Scenario: Enrolling in a course
Given there is a course
And I am logged in as a learner
When I enrol on a course
Then the course should appear in 'my courses'