Skip to content

Instantly share code, notes, and snippets.

zetter / cache_recipies.rb
Created Dec 27, 2020
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
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 / enrolment_cuke_spec.rb
Last active Jun 28, 2020
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 / tracepoint_log_process.rb
Created Mar 6, 2019
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 Aug 17, 2018
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 Mar 22, 2018
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 / parse_icons_from_icomoon.rb
Created Dec 9, 2013
Parse the icon file from icomoon and print out a ruby hash of character names to characters.
View parse_icons_from_icomoon.rb
# Usage:
# run the file with the dev.svg from icomoon (not the plain svg)
# ruby parse_icons_from_icomoon.rb /path/to/
require 'nokogiri'
file = ARGV[0]
svg =
document = Nokogiri::XML(svg)
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 / Slow queries
Created Feb 8, 2011
Find the slowest queries lines in a rails development log
View Slow queries
slow = []
File.readlines(file).each do |line|
if line =~ /Load\ \(([\d\.]*)ms\)/
time = $1.to_f
if time >= 500.0
slow << [time, line]
zetter / phantomjs
Last active Jan 3, 2016
Filter out userSpaceScaleFactor warning on phantomjs on Mavericks
View phantomjs
/usr/local/bin/phantomjs_original $@ 2> >(grep -v userSpaceScaleFactor 1>&2)