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
In the language of your choice write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". |
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 Permit < ActiveRecord::Base | |
# ... snip* | |
# Assume "def model" exists elsewhere in the class. | |
def to_ability | |
modes = [:create, :read, :update, :destroy].select do |mode| | |
self.send(:"can_#{mode}?") | |
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
Removing app/controllers/activities_meta_data_controller.rb | |
Removing app/controllers/aspects_controller.rb | |
Removing app/controllers/impacts_controller.rb | |
Removing app/controllers/legislation_values_controller.rb | |
Removing app/models/activities_meta_data_store.rb | |
Removing app/models/activities_meta_datum.rb | |
Removing app/models/activities_meta_datum_methods/key_value_store.rb | |
Removing app/models/activity_observer.rb | |
Removing app/models/aspect.rb | |
Removing app/models/facility_register_observer.rb |
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
rails-script () { | |
rfpath=$(find-rakefile .) | |
target=$1; shift | |
if [ -f $rfpath/script/rails ]; then | |
$rfpath/script/rails $target $argv | |
else | |
$rfpath/script/$target $argv | |
fi | |
} |
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
@posts = (params[:title] ? Post.where("UPPER(posts.title) LIKE UPPER(%?%)", parmas[:title]) : Post).paginate(:page => 1, :order => "created_at DESC", :per_page => 20) |
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
%p.intro | |
== Hello #{h(@user.email)}, | |
%br/ | |
%br/ | |
== We've just launched MakeYourGirlfriendHappy.com! You had signed up on our mailing list and we took the liberty of creating your account for you so you don't have to enter your information twice. Click #{link_to('here',"http://makeyourgirlfriendhappy.com/profile/password/edit?reset_password_token=#{@user.reset_password_token}")} to create your password. | |
%br/ | |
%br/ | |
== Regards, | |
%br/ | |
%br/ |
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
ruby-1.9.2-p0 > string = "ABC" | |
=> "ABC" | |
ruby-1.9.2-p0 > def string.thing | |
ruby-1.9.2-p0 > puts 'abc' | |
ruby-1.9.2-p0 > end | |
=> nil | |
ruby-1.9.2-p0 > string.thing | |
abc | |
=> nil | |
ruby-1.9.2-p0 > "abc".thing |
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
Ryans-iPhone:~ root# sudo gem install rails | |
dyld: lazy symbol binding failed: Symbol not found: __OSSwapInt16 | |
Referenced from: /usr/lib/ruby/1.9.1/arm-darwin9/socket.bundle | |
Expected in: flat namespace | |
dyld: Symbol not found: __OSSwapInt16 | |
Referenced from: /usr/lib/ruby/1.9.1/arm-darwin9/socket.bundle | |
Expected in: flat namespace | |
Trace/BPT trap |
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
candidates = [:burke, :kevin, :lisa, :mark, :afolabi, :brent, :tiffany, :cary, :peer, :brock, :john, :keith, :brad, :ryan] | |
# Let's let everyone make their own choice :P | |
occurrences = candidates.inject({}) {|h,candidate| h[candidate] = candidates.sample(3); h} | |
# Now tally them up | |
counts = occurrences.values.flatten.inject({}) {|h,person| h[person] ||= 0; h[person] += 1; h} | |
sorted = counts.sort {|a,b| b.last <=> a.last } |
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
def thing | |
"ASDF" | |
end | |
puts thing #=> ASDF | |
if false | |
thing = "JKL:" | |
end |