Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View quad's full-sized avatar

Scott Robinson quad

View GitHub Profile
@quad
quad / plaque-spec.rb
Created August 20, 2011 08:12
A spec for plaque
require 'json'
require 'socket'
require 'timeout'
TIMEOUT = 2
RSpec::Matchers.define :respond_with do |regexp|
match do |io|
begin
Timeout::timeout(TIMEOUT) { @message = io.readline }
@quad
quad / whereami.rb
Created October 5, 2011 16:21
Inspired by _why c1-5
#!/usr/bin/env ruby
class String
def shuffle
chars.to_a.shuffle.join
end
end
me = File.basename __FILE__
where_am_i = File.dirname __FILE__
@quad
quad / find-fucked-specs.sh
Created November 1, 2011 03:12
YO DAWG I HERD U LIKE ORDER-DEPENDENT TESTS?
#!/bin/sh
#
# YO DAWG I HERD U LIKE ORDER-DEPENDENT TESTS?
#
# SO I PUT ORDER-DEPENDENT EXAMPLES N UR ORDER-DEPENDENT SPECS
# SO U CAN B NON-DETERMINISTIC WHILE UR NON-DETERMINISTIC
#
# http://memegenerator.net/instance/11059517
function die () {
@quad
quad / runtext.sh
Last active September 11, 2018 11:49
Things: My Consumer Lifestyle, Enumerated
#!/bin/sh
# The most important line in any shell program.
#
# Sometimes, though, I wish it worked in the [shebang][].
set -e
file="$1"
@quad
quad / buildlight.rb
Created March 21, 2012 02:59
blinky configuration
#!/usr/bin/env ruby
require 'rubygems'
require 'blinky'
l = Blinky.new.light
module Blinky
module GoCiServer
def get_server_locations
@quad
quad / example-spec.rb
Created April 20, 2012 08:52
RSpec vs. Cucumber
Describe "Logging In" do
Context "Successful Login" do
before do
User.create(:username => "Scott", :password => "Tiger")
visit :login_page
on_page_with(:login_form) do |login_form|
login_form.login("Scott", "Tiger")
end
end
@quad
quad / aussie-models.py
Created May 2, 2012 12:09
Blonde, brunette, redhead...
#
# The hair colors of Australian fashion models
#
import json
import re
import urllib.request
API = 'http://en.wikipedia.org/w/api.php?%s'
@quad
quad / tie.js
Created May 27, 2012 21:45
Retarded simple event-binding "DSL"
/*
Retarded simple event-binding "DSL"
Best with:
* jQuery (or Zepto)
* event_emitter
https://github.com/ajaxorg/ace/blob/master/lib/ace/lib/event_emitter.js
Usage:
tie($(window), "hashchange")
@quad
quad / lockit.sh
Created June 29, 2012 09:32
Achtung: a not very nice hotdog
#!/bin/sh
#
# We have a few repeat customers here at the TWU 27 hotdog shack.
#
# They've decided it's FUN to visit our stand.
#
# So, we've cooked up something a little special for our valued customers.
set -e
@quad
quad / pecha.rb
Created August 10, 2012 05:51
Discrimination made easy!
NUM_POOLS = 5
Grad = Struct.new :name, :gender, :region
def norm_name first, last
"#{first.strip} #{last.strip}"
end
def norm_gender gender
{'M' => 'Male', 'F' => 'Female'}[gender] || gender