Skip to content

Instantly share code, notes, and snippets.

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
@jshawl
jshawl / gcd.rb
Last active August 29, 2015 14:10
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 )

Ex-mode uses

Explore Files in current directory

:ex .

Explore Files in directory relevant to open file

:Ex

@jshawl
jshawl / cli
Created November 17, 2014 20:33
# 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
@jshawl
jshawl / Git notes
Last active August 29, 2015 14:09 — forked from richardcornish/git.md
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
@jshawl
jshawl / git-notes
Last active August 29, 2015 14:09 — forked from richardcornish/git.md
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

Installfest!

Sublime Text

Download

XCode CLI tools

$ xcode-select --install
@jshawl
jshawl / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

FizzBuzz!

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”.

Bonus!

Solve this problem without using any loops.

Double Bonus!

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;