This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add in base 7 routes | |
get '/notes' do | |
@notes = Note.all | |
erb :'notes/_index' | |
end | |
get '/notes/new' do | |
@note = Note.new | |
erb :'notes/_new' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
require 'awesome_print' | |
require 'colorize' | |
class House | |
attr_reader :name, :description, :pictures, :rooms, :address | |
def initialize(args = {}) | |
@name = args[:name] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
// Die model | |
var Die = function(id) { | |
this.value = Math.floor((Math.random()*6)+1); | |
this.id = id; | |
} | |
Die.prototype.roll = function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var controller = new Controller; | |
$('#roller button.add').on('click', function() { | |
controller.add(); | |
}); | |
$('#roller button.roll').on('click', function() { | |
controller.roll(); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var controller = new Controller; | |
$('#roller button.add').on('click', function() { | |
controller.add(); | |
}); | |
$('#roller button.roll').on('click', function() { | |
controller.roll(); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jshint strict: false */ | |
/*global $:false, undef: true */ | |
/*jshint unused: false, undef:false */ | |
$(document).ready(function(){ | |
//Model | |
var Die = function (id) { | |
this.side = 0; | |
this.id = id; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Github | |
class Client | |
include HTTParty | |
base_uri "https://api.github.com" | |
def initialize(username, password) | |
@user_auth = { :username => username, :password => password } | |
@token_auth = "token 8205ba1597bdb27b197018ea35117d1ef45e588f" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -------------------------------------------------------- | |
# variable scope: understanding where a variable "lives" | |
# -------------------------------------------------------- | |
# | |
# in Ruby there are: | |
# - 4 kinds of variable scope: | |
# | |
# - global ($db, $connection, $file) | |
# - class (@@total, @@poolsize) | |
# - instance (@age, @name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hospital | |
attr_accessor :name, :address, :employees, :patients | |
def initialize(args) | |
@name = args[:name] | |
@address = args[:address] | |
@employees = args[:employees] || [] | |
@patients = args[:patients] || [] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To understand recursion, you first need to understand recursion. | |
# Now, on a serious note, | |
# a recursive function is one that calls itself. | |
# For a recursive algorithm to terminate you need a base case | |
# (e.g. a condition where the function does not call itself recursively) | |
# and you also need to make sure that you get closer to that base case in each recursive call. | |
# Let's look at a very simple example first: |