Skip to content

Instantly share code, notes, and snippets.

View gist:799085
.shiney_button // Gross but clear class name
:background red
:border 1px solid black
:color white
.post input[type=submit]
@extend .shiney_button
.user input[type=submit]
@extend .shiney_button
View gist:787131
" Unformatting
nmap <silent><leader>u :s/\v(\S+)@<=\s+/ /g<CR>
vmap <silent><leader>u J :s/\v(\S+)@<=\s+/ /g<CR>
View gist:761375
def search_options
options = {
:engagement_end_date_gte => Time.zone.now.to_date,
:hotel_state_id_is => @state_id
}
options[:hotel_city_id_is] = @city_id if @city_id.present?
options
end
View gist:761362
def search_options
{}.tap {|o|
o[ :engagement_end_date_gte ] = Time.zone.now.to_date
o[ :hotel_state_id_is ] = @state_id
o[ :hotel_city_id_is ] = @city_id if @city_id.present?
}
end
View time_helpers.rb
def today_is date
now = Time.zone.parse date
today = now.to_date
Time.zone.stub!( :now ).and_return( now )
Time.stub!( :now ).and_return(now)
Date.stub!( :today ).and_return( today )
end
@andyferra
andyferra / qr-code-bookmarklet.js
Created Nov 5, 2010
Just a little bookmarklet that will open a new window with a QR code for the current page's URL
View qr-code-bookmarklet.js
javascript:(function(){ window.open( 'http://chart.apis.google.com/chart?cht=qr&chs=512x512&chl=' + document.location.href,'qrcodepopup','width=700,height=700') })();
View custom_matcher_example.rb
def rhyme_with(expected)
simple_matcher do |given, matcher|
matcher.description = "rhyme with #{expected.inspect}"
matcher.failure_message = "expected #{given.inspect} to rhyme with #{expected.inspect}"
matcher.negative_failure_message = "expected #{given.inspect} not to rhyme with #{expected.inspect}"
given.rhymes_with? expected
end
end
View callback-fu.html
<html>
<head>
<script type="text/javascript">
function SayChain(previous) {
var current = this;
this.previous = previous;
this.then = function(text) {
View test.rb
# spec/tags.rb
Tag.define :foo do
# ...
end
Tag.define /logged_in_as_(.*)/ do |role_name|
end
View test.rb
class Foo
override_method :method_name, :hash => 'skdjsfghkjwehgvkjervgjwehgvkjhgwejv', :with => :my_method
override_method :method_name, :hash => 'skdjsfghkjwehgvkjervgjwehgvkjhgwejv' do
end
override_method :method_name, :hash => ['skdjsfghkjwehgvkjervgjwehgvkjhgwejv', '2345678956785678d7sfs7fdsfds'] do
end