Skip to content

Instantly share code, notes, and snippets.

@amkong
amkong / Calculator
Created May 3, 2014 22:38
Calculator
def add(*numbers)
numbers.inject(0) { |sum, number| sum + number }
end
def subtract(*numbers)
sum = numbers.shift
numbers.inject(sum) { |sum, number| sum - number }
end
@amkong
amkong / Array_length
Created May 3, 2014 22:39
Array_length
def length_finder(input_array)
input_array.collect {|array| array.length}
end
@amkong
amkong / Fizz_Buzz
Created May 3, 2014 22:40
Fizz Buzz
for num in 1..100
if num % 3 == 0
puts "Fizz"
elsif num % 5 == 0
puts "Buzz"
else
puts num
end
end
@amkong
amkong / non_duplicated_array
Created May 3, 2014 22:40
Non Duplicated Array
def non_duplicated_values(values)
values.find_all {|num| values.count(num) == 1}
end
states.each do |states, states_info|
cities_list = states_info[:cities]
if cities_list.include?(user_input)
puts states
end
end
@amkong
amkong / gist:3f23facf9f26a4e6a4d7
Created May 8, 2014 20:26
Qualified Method_of_methods
def experience_check(candidates, years_of_experience)
candidates.select {|candidate| candidate[:years_of_experience] >= years_of_experience}
end
def min_github_points_check(candidates, min_github_points)
candidates.select {|candidate| candidate[:github_points] >= min_github_points}
end
def language_check(candidates)
candidates.select {|candidate| candidate[:languages].include?('Ruby') || candidate[:languages].include?('Python')}

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt