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
#from http://github.com/dchelimsky/railsconf2010-app/blob/latest/features/step_definitions/swimlane_steps.rb | |
When /^I move "([^"]*)" to the "([^"]*)" swimlane$/ do |card_title, swimlane_name| | |
visit cards_path | |
#sweet hotness add @javascript tag to the feature | |
if(@javascript) | |
card_widget = page.driver.find(card_widget(card_title)).first | |
swimlane_widget = page.driver.find(swimlane_widget(swimlane_name)).first | |
card_widget.drag_to(swimlane_widget) | |
else |
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
; sums the number between 1 and 999 that are multiples of 3 or 5 | |
(reduce + (filter #(= 0 (* (rem % 3) (rem % 5))) (take 999 (iterate inc 1)))) |
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
(1..999).map{|n| n if n%3==0 or n%5==0}.compact.reduce(:+) |
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
public class untitled | |
{public static void main (String[] args){ | |
int total = 0; | |
for(int i=1; i<1000; i++){ | |
if(i%3==0 || i%5==0){ | |
total += i; | |
} | |
} | |
System.out.println(total); | |
} |
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
(1..999).map{|n| n if [3,5].any?{|argument| n%argument==0}}.compact.reduce(:+) |
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
; define a lazy loaded fib. sequence | |
(def fibs | |
(lazy-cat [0 1] (map + fibs (rest fibs)))) | |
;add all the even numbers where the last element is less than 4M | |
(reduce + | |
(filter even? | |
(take-while #(< % 4000000) fibs))) |
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
#parallel assignment FTW | |
sum,a,b = 0,0,1 | |
sum += (b * (1-b%2)) while (a,b = b, a+b).last < 4_000_000 | |
puts sum |
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
puts "hello world" |
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
## IRB | |
jruby-1.5.0 > import 'java.util.Random' | |
=> Java::JavaUtil::Random | |
jruby-1.5.0 > Java::JavaUtil::Random.new | |
=> #<Java::JavaUtil::Random:0x57c501f7> | |
jruby-1.5.0 > Java::JavaUtil::Random.new(45) | |
=> #<Java::JavaUtil::Random:0x2ffecaeb> | |
jruby-1.5.0 > j =Java::JavaUtil::Random.new | |
=> #<Java::JavaUtil::Random:0x4e62974e> |
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
# app.rb | |
require 'rubygems' | |
require 'bundler/setup' | |
Bundler.setup | |
require 'sinatra' | |
require 'net/ssh' | |
host = "myurl" | |
user = "me" | |
keys = ["my.key"] |