This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Require fields. | |
it_should_require :wish, :author, :title, :body, :signature | |
# Validate string lengths | |
it_should_validate_strings :body => 1024, :title => 255, :signature => 25 | |
# Strings can be absent. Default length is 255, like Rails. | |
it_should_validate_strings :story => 10000, | |
:blurb => {:optional => true}, | |
:tagline => {:optional => true} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "February 29" do | |
freeze_time | |
before(:each) do | |
@birthday = new_birthday(:month => 2, :day => 29, :year => 1984) | |
end | |
it "knows it's a jerk" do | |
@birthday.should be_feb_29 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AssetsHelper | |
def background_images(images) | |
content_for :head do | |
content_tag(:style, :type => 'text/css') do | |
images.map{|selector, path| css_background_image(selector, path)}. | |
join("\n") | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Copy | |
def self.for(wish) | |
Copy.const_get(@wish.class.name.demodulize).new(@wish) | |
end | |
# These methods are used by all Copy packages | |
class CopyPackage | |
def initialize(wish) | |
@wish = wish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fixnum | |
def of | |
result = [] | |
self.times {|i| result << yield(i)} | |
result | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateTotalSelected(form) { | |
var totalSelected = getTotalSelected(form); | |
var elem = getElementsByClassName(form, 'current_selected', 'span')[0]; | |
elem.setTextValue(totalSelected) | |
} | |
function getTotalSelected(form) { | |
var serializedForm = form.serialize(); | |
var ids = serializedForm.ids; | |
if (!ids) { | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export FILE=file/to/test.rb | |
export MOD=$(stat -c %Y $FILE | cut -d ' ' -f1) | |
while sleep .1 | |
do | |
NEWMOD=$(stat -c %Y $FILE | cut -d ' ' -f1) | |
if [ $NEWMOD -gt $MOD ] | |
then | |
echo Changed $MOD $NEWMOD | |
export MOD=$NEWMOD | |
ruby $FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
query = $*.shift | |
if $*.empty? && $stdin.tty? | |
puts "You haven't given grep anything" | |
else | |
cmd = %(grep "#{query}" #{$*.join(' ')}) | |
puts `#{cmd}` | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApiFormats | |
API_FORMATS = %w[json xml].map(&:to_sym).freeze | |
def self.included(base) | |
base.send :private, :api_formats | |
end | |
def api_formats(format, data=nil, options={}) | |
API_FORMATS.each do |encoding| | |
format.send(encoding) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map <Leader>y :echo system('echo -n '.shellescape(@").' \| npaste')<CR> |
OlderNewer