Skip to content

Instantly share code, notes, and snippets.

View andyferra's full-sized avatar

Andy Ferra andyferra

View GitHub Profile
.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
" Unformatting
nmap <silent><leader>u :s/\v(\S+)@<=\s+/ /g<CR>
vmap <silent><leader>u J :s/\v(\S+)@<=\s+/ /g<CR>
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
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
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 November 5, 2010 10:20
Just a little bookmarklet that will open a new window with a QR code for the current page's URL
javascript:(function(){ window.open( 'http://chart.apis.google.com/chart?cht=qr&chs=512x512&chl=' + document.location.href,'qrcodepopup','width=700,height=700') })();
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
<html>
<head>
<script type="text/javascript">
function SayChain(previous) {
var current = this;
this.previous = previous;
this.then = function(text) {
# spec/tags.rb
Tag.define :foo do
# ...
end
Tag.define /logged_in_as_(.*)/ do |role_name|
end
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