Skip to content

Instantly share code, notes, and snippets.

Thursday, 14 March 2013
Today and tomorrow we'll build a very simple restaurant review app.
This app will:
- show a list of restaurants it knows about
- show an individual page for a restaurant with reviews
- allow adding reviews
- allow creating new restaurants
@makersacademy
makersacademy / guard.rb
Created March 6, 2013 10:53
guard clauses
def sell_alcohol
raise "call police" if client.wanted_criminal? # stops the execution
return if under_18? # guard clause
return if drunk?
return if broke?
sell_wine!
end
@makersacademy
makersacademy / blocks.rb
Created March 6, 2013 10:11
Blocks examples
#!/usr/bin/env ruby
def each(array)
array.length.times do |i|
yield array[i]
end
end
def select(array)
result = []
@makersacademy
makersacademy / rvm
Last active December 14, 2015 11:59
How to install rvm 1.9.3 on a Mac without it failing
rvm get head
rvm install 2.0.0 --autolibs=4 --with-gcc=gcc
@makersacademy
makersacademy / boris_bikes.rb
Created March 1, 2013 17:15
Ideas for an exericise
# Bicycles, docking stations, vans, central system to control the vans, people
# people would ride bikes
# vans would move them around
# a central station would control the vans
# repair facility would take the broken bikes and fix them
# repaired bikes would be delivered to stations
# report on the most/least used stations
# bikes would be taken out of service after 1000 rides
@makersacademy
makersacademy / Preferences.sublime-settings
Created March 1, 2013 10:15 — forked from leoallen85/Preferences.sublime-settings
Recommended Sublime User settings, you can access your own settings by going Sublime Text 2 > Preferences > Settings - User or pressing ⌘ + , Then add these to your preferences
{
// This means every time you move away from your current tab it saves, no more cmd + s!
"save_on_focus_lost": true,
// Let's get rid of all those trailing white spaces!
"trim_trailing_white_space_on_save": true,
// A good idea to view all white space to make sure you're not using tabs
"draw_white_space": "all",
set autoeval
set autolist
set autoreload
class HTML
def initialize(str)
@str = str
end
# instance method (note it makes use of an instance variable)
def render
puts "<div>#{@str}</div>"
end
class Base
def public_method
puts 'public method called'
end
# This works as we are calling the private method
# from within the object
def call_private_method
private_method
require 'debugger'
class Hello
def hi_there
debugger
puts "wohoo"
end
end
testing = Hello.new