:ex .
:Ex
def count_to limit, index = 1, nums = [] | |
if nums.empty? | |
nums = [1,2] | |
end | |
if index == limit | |
return (nums) | |
else | |
next_digit = nums[-2] + nums[-1] | |
if next_digit <= limit | |
nums << next_digit |
def gcd *args | |
divisors = args.map do |arg| | |
(1..arg).select { |n| arg % n == 0} # find all divisors | |
end | |
divisors.inject(:&).max # find intersection of all arrays, grab max value | |
end | |
p gcd( 12, 24, 36 ) |
# CLI Exercises | |
1. Create a new directory in your home directory named flowers. | |
2. Create four directories in flowers/: petunia, violet, marigold, and seeds. | |
3. Create four files in violet/ | |
- marigold-seeds.txt | |
- marigold-food.txt | |
- violet-seeds.txt | |
- petunia-bulbs.txt | |
4. Copy the marigold related files to the marigold directory |
Start | |
===== | |
1. Install Git | |
http://git-scm.com/download/mac | |
(But consider using Homebrew) | |
2. Make a GitHub account | |
https://github.com/ | |
3. Open Terminal |
Start | |
===== | |
1. Install Git | |
http://git-scm.com/download/mac | |
(But consider using Homebrew) | |
2. Make a GitHub account | |
https://github.com/ | |
3. Open Terminal |
$ xcode-select --install
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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”.
Solve this problem without using any loops.
upstream app { | |
# Path to Unicorn SOCK file, as defined previously | |
server unix:/tmp/unicorn.superheros.sock fail_timeout=0; | |
} | |
server{ | |
listen 80; | |
server_name qed.im; | |
root /var/www/superheros; | |
try_files $uri/index.html $uri @app; |