Skip to content

Instantly share code, notes, and snippets.

View supaspoida's full-sized avatar

Lar Van Der Jagt supaspoida

View GitHub Profile
@supaspoida
supaspoida / donors_choose_spec.rb
Created February 14, 2012 20:46
How I'd express the donors choose spec
describe DonorsChoose do
describe "requesting data" do
let(:test_title) { "A test project" }
def mock_request(args)
request = double(:fetch => %Q/{"proposals": [{"title": "#{test_title}"}]}/)
DonorsChoose::Request.should_receive(:new).with(args).and_return(request)
end
context "via lat & lng" do
@supaspoida
supaspoida / vimtips.md
Created December 15, 2011 00:31
Vim Tips

Vim has a special register for the system pasteboard.

Access it via: "*

Paste: "*p

Copy line: "*Y

require 'ostruct'
module ApplicationHelper
def pluralize(*args, &blk)
result = super
if block_given?
count, *text = result.split
yield OpenStruct.new(text: text.join(' '), count: count)
nil
else
@supaspoida
supaspoida / candidate_spec.rb
Created October 11, 2011 13:41 — forked from knwang/candidate_spec.rb
Proofing_oven: Candidate Spec with search
require 'spec_helper'
describe Candidate do
subject { Fabricate(:candidate, first_name: "Joe", last_name: "Doe") }
describe "#full_name" do
its(:full_name) { should == "Joe Doe" }
end
describe "#search" do
RSpec::Matchers.define :have_country do |expected|
match do |actual|
# usage:
# field_labeled('Select your address').should have_option("Home Address")
RSpec::Matchers.define :have_option do |expected|
def options_for(select_field)
select_field.all('option').map &:text
end
match do |select_field|
@supaspoida
supaspoida / gist:1270387
Created October 7, 2011 14:29
guard cucumber fails on second run
Run Cucumber features features/admin_deletes_an_event.feature features/admin_deletes_an_event.feature:7
ERROR: Guard::Cucumber failed to achieve its <run_on_change>, exception was:
Errno::ENOENT: No such file or directory - features/admin_deletes_an_event.feature:7
/Users/dev/.Guardfile:92:in `read'
/Users/dev/.Guardfile:92:in `block in cucumber_command'
/Users/dev/.Guardfile:91:in `each'
/Users/dev/.Guardfile:91:in `any?'
/Users/dev/.Guardfile:91:in `cucumber_command'
/Users/dev/.rvm/gems/ruby-1.9.2-p136@hr_2011/gems/guard-cucumber-0.7.2/lib/guard/cucumber/runner.rb:24:in `run'
/Users/dev/.rvm/gems/ruby-1.9.2-p136@hr_2011/gems/guard-cucumber-0.7.2/lib/guard/cucumber.rb:85:in `run_on_change'
@supaspoida
supaspoida / nav.html.haml
Created October 6, 2011 17:33
Navigation "DSL"
%ul{class: navigation.current_selector}
- navigation.items.each do |item|
%li{class: item.selector}= link_to item.text, item

Welcome to Drift!

Drift is an always-already versioned, cloud-backed text editor. You can use it to take notes, and save them in the GitHub cloud.

Your gists are always saved locally, and any changes you make will get pushed to GitHub's servers.

To name a gist, touch its name in the toolbar.

You can use the share button at the top-right to copy a link to one of your gists, or view it on the web in Safari.

@supaspoida
supaspoida / .vimrc.local
Created September 3, 2011 21:07
Convert hashes to 1.9.2 style with vim
# Run :NotRocket to convert current buffer.
# Thanks to @tpope for the vim regex fu
command! -bar -range=% NotRocket :<line1>,<line2>s/:\(\w\+\)\s*=>/\1:/ge
@supaspoida
supaspoida / regext.txt
Created August 23, 2011 20:57 — forked from jt/regext.txt
Regular expression notes
- any character you use it will literally match it except special characters
^ $ ? . / \ [ ] { } ( ) + * - all the special characters that will need escaping if you don't want them to be special
// - regexp ruby class
Common Patterns (I authored)
/[\w+\.~-]+@[\w~-]+.[\w\.]+/ - match emails, conforms to RFC 3986 section 3.3
/\+?(\d)?[-|\.|\s]?\(?(\d{3})\)?[-|\.|\s]?(\d{3})[-|\.|\s]?(\d{4})/ - match phone numbers, https://gist.github.com/1009331
Strategies