Skip to content

Instantly share code, notes, and snippets.

View doolin's full-sized avatar

Dave Doolin doolin

View GitHub Profile
@amatsuda
amatsuda / Xresult
Created August 17, 2011 09:59
An RSpec matcher for asserting AR query
% rspec spec/models/user_spec.rb
.F.F.
Failures:
1) User
Failure/Error: it { should query :where => {:name => 'bar'} }
expected [:where] to query {:where=>{:name=>"bar"}}
# ./spec/models/user_spec.rb:6
@scribu
scribu / cpt-redirect.php
Created July 27, 2011 22:49
CPT Redirect
<?php
define( 'MY_CPT', 'actor' );
/**
* Redirects /cary-grant/ to /actor/cary-grant/ or whatever the correct URL is
*/
function redirect_old_cpt_urls() {
if ( !is_404() )
return;
@kurisu
kurisu / automatic_fixture_generation.rb
Created May 12, 2011 19:25
Automatic DOM Fixture Generation in Jasmine
<<-README
Put this here /spec/javascripts/support/jasmine_extensions
The observed and output folders are set up for Rails, but there's no reason
you couldn't change them to work with any DOM-generating back-end.
Also, we found it helpful to clean the html we wrote to these fixtures by
remove script tags and changing the body to a div, so it fit nicely into the
jasmine_content div.
@DavidYKay
DavidYKay / gist:912765
Created April 10, 2011 21:52
"Can Code Be Like Literature" - Jeremy Ashkenas
Jeremy
Absolutely brilliant
both technically
and oratorically
He wrote CoffeeScript
1st place 5k
21 min, 3 seconds
<7min mile
Big picture
@wbailey
wbailey / databases.rake
Created February 11, 2011 08:58
ActiveRecord migrations outside of Rails
require 'yaml'
require 'logger'
require 'active_record'
namespace :db do
def create_database config
options = {:charset => 'utf8', :collation => 'utf8_unicode_ci'}
create_db = lambda do |config|
ActiveRecord::Base.establish_connection config.merge('database' => nil)
def parse(name)
case name
when /^\[(.+)\](.+)\[(.+)\]$/
[ $1 + $2 + $3, $1 + $2, $2 + $3, $2 ]
when /^\[(.+)\](.+)$/
[ $1 + $2, $2 ]
when /^(.+)\[(.+)\]$/
[ $1, $1 + $2 ]
else
[ name ]
@EmmanuelOga
EmmanuelOga / r191.txt
Created December 26, 2009 22:42
curb, typhoeus, net:http, em-http quick benchmark
ruby 1.9.1p243 (2009-07-16 revision 24175) [x86_64-linux]
curb (0.6.2.1)
em-http-request (0.2.5)
eventmachine (0.12.10)
typhoeus (0.1.13)
user system total real Memory (Kb)
4kb std
0.000000 0.000000 3.010000 ( 22.408594) 24,484