Skip to content

Instantly share code, notes, and snippets.

zumbalogy

Block or report user

Report or block zumbalogy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View markvchaney.rb
stems = ARGF.read
.split
.each_cons(2)
.group_by(&:first)
def next_word(ary)
ary.sample[1]
end
e = Enumerator.new do |e|
View gist:f8e17feaf719e52f0bcb
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)',
@zumbalogy
zumbalogy / ruby uniq
Created Aug 3, 2014
uniq in ruby is funny stuff
View ruby uniq
[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]
View gist:8338016
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
View gist:8213846
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
@zumbalogy
zumbalogy / gist:7806202
Last active Dec 30, 2015
No input validation, but yes to multi-stops
View gist:7806202
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"
You can’t perform that action at this time.