Skip to content

Instantly share code, notes, and snippets.

@stevenwilkin
stevenwilkin / Gemfile
Created April 22, 2015 16:13
Smoke test output document generator
source 'https://rubygems.org'
ruby '2.2.2'
gem 'mechanize'
@stevenwilkin
stevenwilkin / config.ru
Last active August 29, 2015 14:17
Rack redirector
app = lambda do |env|
[301, {'Location' => 'https://www.pensionwise.gov.uk/'}, []]
end
run app
Date: Tue, 30 Sep 2014 16:49:43 +0000
From: Louis Goff-Beardsley <[email protected]>
To: London Ruby Users Group <[email protected]>
Subject: [LRUG] [JOBS] Contracts Galore
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Hi LRUG,
Just a quick note, the yearly "Just got back from holiday, oh God we need more development done" contracts rush has come and we've been inundated with requests for upper-Mid level & Senior Ruby and/or Javascript contractors.
@stevenwilkin
stevenwilkin / delete_gemsets.sh
Created October 2, 2014 13:26
Delete all gemsets for all rubies managed by RVM
#!/bin/bash -l
for RUBY in `rvm list strings`
do
rvm use $RUBY
for GEMSET in `rvm gemset list | grep -E '^ ' | grep -v '*'`
do
rvm --force gemset delete $GEMSET
done
done
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@stevenwilkin
stevenwilkin / fizz_buzz.go
Created December 25, 2013 00:35
FizzBuzz in Go
package main
func main() {
for i:= 1; i <= 100; i++ {
if (i % 3 == 0) && (i % 5 == 0) {
println("FizzBuzz")
} else if i % 3 == 0 {
println("Fizz")
} else if i % 5 == 0 {
println("Buzz")
@stevenwilkin
stevenwilkin / gist:6727189
Created September 27, 2013 11:24
Calculating memcached miss-rate
HITS=`echo "stats" | nc 127.0.0.1 11211 | grep get_hits | awk '{print $3}' | sed 's/[^0-9]//'`
MISSES=`echo "stats" | nc 127.0.0.1 11211 | grep get_misses | awk '{print $3}' | sed 's/[^0-9]//'`
echo "($MISSES * 100) / ($HITS + $MISSES)" | bc
# MAC manipulators
alias random_mac='sudo ifconfig en0 ether `openssl rand -hex 6 | sed "s/\(..\)/\1:/g; s/.$//"`'
alias restore_mac='sudo ifconfig en0 ether YOUR_ORIGINAL_MAC_ADDRESS_GOES_HERE'
require 'net/http'
require 'rack'
# todo
# - detect ssl
# - keepalive?
module Rack
class Forwarder
def initialize(host, port=80)
@stevenwilkin
stevenwilkin / p01-matraka-explained.js
Created August 15, 2012 14:15 — forked from tlack/p01-matraka-explained.js
p01's Matraka javascript demo decoded
// Matraka's source code decoded and beautified
// by @tlack
//
// Matraka is a 1005 byte Javascript "demo" by p01. It includes an 'evolving animation'
// and great dirty synth music. View here:
//
// http://www.p01.org/releases/MATRAKA/matraka.png.html
//
// I fondly recall the demo scene of my youth, puzzling over the work of Future
// Creators and those guys. I was puzzled by this worked so I had to figure it