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
stems = ARGF.read | |
.split | |
.each_cons(2) | |
.group_by(&:first) | |
def next_word(ary) | |
ary.sample[1] | |
end | |
e = Enumerator.new do |e| |
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
IOS_DEVICES = { | |
'iPhone1,1' => 'iPhone 1G', | |
'iPhone1,2' => 'iPhone 3G', | |
'iPhone2,1' => 'iPhone 3GS', | |
'iPhone3,1' => 'iPhone 4', | |
'iPhone3,3' => 'iPhone 4 (Verizon)', | |
'iPhone4,1' => 'iPhone 4S', | |
'iPhone5,1' => 'iPhone 5 (GSM)', | |
'iPhone5,2' => 'iPhone 5 (GSM+CDMA)', | |
'iPhone5,3' => 'iPhone 5C (GSM)', |
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,2,3].permutation {|v| p v if v.first.odd?} | |
[1, 2, 3] | |
[1, 3, 2] | |
[3, 1, 2] | |
[3, 2, 1] | |
# => [1, 2, 3] | |
[1,1,2,2,3,3].uniq | |
# => [1, 2, 3] |
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
STARTING UP WITH RAILS Tunr App | |
$ rails new tunr_app -d postgresql -T | |
* update database.yml —> change default username to my username | |
* remove default index page —> $ rm public/index.html | |
$ rake db:create |
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 './names' | |
total = 0 | |
@names.sort.each_with_index do |name, index| | |
name_score = 0 | |
a = name.upcase | |
a.each_byte do |byte| | |
name_score += (byte-64) | |
end | |
total += (name_score * index+1) | |
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
n = %w( Times_Square 34th 28th 23th Union_Square 8th ) | |
l = %w( 8th 6th Union_Square 3rd 1st ) | |
six = %w( Grand_Central 33rd 28th 23rd Union_Square Astor_Place ) | |
q = %w( Times_Square Herald_Square Union_Square Canal_St ) | |
puts "What train on? [n, l, six, q]" | |
on_train = gets.chomp | |
case on_train | |
when "n" |