Skip to content

Instantly share code, notes, and snippets.

View jellybob's full-sized avatar

Jon Wood jellybob

View GitHub Profile
@jellybob
jellybob / stats.rake
Created November 5, 2011 14:05
Include fast specs in your code stats.
task :stats => :statsetup
task :statsetup do
fast_spec_dir = "fast_spec" # Change this if you keep them elsewhere.
require 'rails/code_statistics'
::STATS_DIRECTORIES << %W(Fast\ specs #{fast_spec_dir}) if File.exist?(fast_spec_dir)
::CodeStatistics::TEST_TYPES << "Fast specs" if File.exist?(fast_spec_dir)
end
@jellybob
jellybob / db.rake
Created January 31, 2012 17:24
Preparing multiple MySQL databases with Rails 2.3
namespace :db do
namespace :test do
task :prepare => :environment do
abcs = ActiveRecord::Base.configurations
[ "", "_data_warehouse" ].each do |db|
# Dump the development database
config = abcs["development#{db}"]
cmd = "mysqldump -u#{config["username"]} -p#{config["password"]} #{config["database"]} --no-data > #{RAILS_ROOT}/db/development#{db}_structure.sql"
`#{cmd}`
@jellybob
jellybob / firewalls.md
Created June 22, 2012 09:08
Why do we need firewalls?

Why do we need firewalls?

There are a few things which are typically referred to as "firewalls", with different purposes. All of them however control access to a network by restricting which ports and IP addresses can be connected to.

## Software Firewalls

This is the thing built into Windows and other operating systems that pops up boxes saying "Do you want to allow [thing x] to connect to the Internet?". They're designed to prevent malicious software that has been installed on your machine sending your data to other places, or bulk mailing people. They can also be used to restrict connections coming in to your computer.

## Hardware Firewalls

letmein
@jellybob
jellybob / download_harrington.rb
Created September 29, 2012 21:38
Download Honor Harrington books for Kindle conversion.
# Go to http://www.baen.com/series_list.asp?letter=H and find the book ID for the one you
# want, and replace the book variable with it. Run this program, and add the resulting
# index.html to Calibre, which can then convert it to a .mobi. Finally, email the .mobi
# to your Kindle and enjoy.
require 'capybara'
require 'capybara/dsl'
require 'capybara/webkit'
require 'fileutils'
book = "0743435710"
(ns media-mogul.frontend.callbacks)
(defmulti renderer (fn [ state container graphics ] (:view state) ))
(defmethod renderer :default
[ state container graphics ]
(doto graphics
(.drawString "Using default renderer", 30, 30)))
(defmulti updater (fn [ state container delta ] (:view state) ))
(defmethod updater :default
(def state
ref { :view-ns 'media-mogul.frontend.main-menu })
(defn- callback
[ name & args ]
; Rummages around in the specified namespace, extracts any public methods
; and then finds the one with the same name as the callback being requested.
;
; Then evals it for good measure.
(let [ callback-fn @(name (ns-publics (the-ns (:view-ns @state)))) ]
defmulti foo (fn [ identifier, message ] identifier)
(defmethod foo :hello [ message ]
(println "Hello " message))
@jellybob
jellybob / gist:5858953
Last active December 18, 2015 23:08
I may be a little annoyed with Yodel now.
Good day to you sirs and madams,
I've been asked via Twitter by Danny on your customer support team to make a formal complaint. Presumably contacting you via Twitter wasn't considered formal enough. I shall endeavour to make sure we've been introduced and bow correctly next time.
On Saturday the 15th of June a large parcel was delivered to my address, 20 Middle Hill, despite the label on said parcel saying 20 Egham Hill. Well, I say it was delivered. Others might say it was unceremoniously dumped outside the front door in the rain.
At 1:20pm on that day I rang your customer support phone line, but everyone goes home at 1pm on a Saturday. In exasperation I had a quick moan about it on Twitter. They're used to me moaning about your service since almost every delivery results in the driver not finding my house for several attempts, or just plain not turning up.
On Monday Danny sent me a message, suggesting that if I got in touch he could arrange for the parcel to be picked up. Success! A customer service tri
<meta name="auth0_client_key" content="<%= Application.get_env(:traverse, :auth0)[:client_key] %>">
<meta name="auth0_endpoint" content="<%= Application.get_env(:traverse, :auth0)[:endpoint] %>">