Skip to content

Instantly share code, notes, and snippets.

@sranso
sranso / gist:7520217
Last active December 28, 2015 15:09
Iteration: for a blog post
#javascript
for (var i=0; i<3, i++)
{
console.log("hello");
};
#ruby
3.times do |i|
puts "hello" unless i == 3
end
@sranso
sranso / gist:7540569
Created November 19, 2013 04:59
.each iterator example
["two", "headed", "boy", 1945].each do |value|
puts value
end
@sranso
sranso / gist:7546968
Created November 19, 2013 15:22
.each vs .collect
[1, 2, 3, 4].each { |x| x*2 }
#=> [1, 2, 3, 4]
[1, 2, 3, 4].each { |x| print x*2 }
#=> 2468 => [1, 2, 3, 4]
[1, 2, 3, 4].collect { |x| x*2 }
#=> [2, 4, 6, 8]
[1, 2, 3, 4].each { |x| x*2 }
@sranso
sranso / world class v1
Created December 6, 2013 00:15
Game of
class World
attr_reader :world_array_y, :world_array_x
def initialize
create_world
@world_array_y
@world_array_x
end
def create_world
class World
attr_reader :board
def initialize
create_world
end
def create_world
@board = []
30.times do |y|
@sranso
sranso / expected
Last active December 30, 2015 10:39
o . . . . . . . . . . . . o
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
o . . . . . . . . . . . . o
songs_i_love = {
"Afterlife" => "Arcade Fire",
"Mirrors" => "Justin Timberlake",
"Skinny Love" => "Bon Iver",
"Five Seconds" => "Twin Shadow"
}
songs_i_love["Five Seconds"] #=> "Twin Shadows"
songs_i_love.[]( "Five Seconds" )

Student Sinata App: Part Zero

Objective

Get comfortable writing routes and creating ERB views in a very simple Sinatra App.

Tutorial

Part 1: Bootstrap the app