Skip to content

Instantly share code, notes, and snippets.

View hwatkins's full-sized avatar

Hugh Watkins hwatkins

View GitHub Profile
@hwatkins
hwatkins / rspec_rails_cheetsheet.rb
Created October 15, 2012 22:38 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@hwatkins
hwatkins / gist:3491399
Created August 27, 2012 19:10 — forked from seyhunak/gist:3479066
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% this module models a typical manager/worker pattern, where manager may spawn a large number of workers
%% required behaviour:
%%
%% 1) manager must log unexpected worker exits
%%
%% - manager must trap exits in init function -> 'process_flag(trap_exit, true)'
%% - workers must be spawned with spawn_link
%% - worker exit messages are handled by manager handle_info handler [where they can be logged etc]
-module(stopwatch).
-behaviour(gen_server).
%% Server API
-export([start_link/0, stop/0]).
%% Client API
-export([start_timer/0, stop_timer/0, read_timer/0]).
%% gen_server callbacks
#!/usr/bin/racc
# -*- encoding: utf-8 -*- Lapis Racc Parser Class
# Andy Brown <neorab@gmail.com> [April, 12, 2010]
/* This is a BNF style parser generator grammar for the
* Lapis Language to be used by racc. Racc is a tool
* much like Yacc or Bison implemented for Ruby.
*
* Racc will parse this file and create a lapis.tab.rb
* file that contains a Parser class with a do_parse
#!/usr/bin/env ruby
#
# Discover the contribution status of a user for all their watched repos: owner, collaborator, or watcher
# Returns JSON { "repo" => { ... }, "owner" => is project owner?, "collaborator" => has collaborator access? }
#
# Returns either Array of JSON above; or streams each JSON result as discovered (--stream flag)
#
# Usage:
#
# Save to file github_user_collaborations.rb
$:.unshift('~/rufus/rufus-tokyo/lib')
require 'benchmark'
require 'rubygems'
require 'faker'
require 'date'
#
# the data
#
%%% File : recomendations.erl
%%% Author : Russell Brown <russell@pango.lan>
%%% Description : The first chapter of Programming Collective Inteligence, but in elrang, like.
%%% Created : 15 Jun 2009 by Russell Brown <russell@pango.lan>
-module(recomendations).
-compile(export_all).
%%
module Main where
import Network.Socket
import System.Environment
import Control.Concurrent
import Control.Monad
-- Port number to listen on
listenPort :: PortNumber
listenPort = 3000