Skip to content

Instantly share code, notes, and snippets.

View geocodinglife's full-sized avatar
👨‍💻
Keep Coding

Ricardo Alarcon geocodinglife

👨‍💻
Keep Coding
  • remote
View GitHub Profile
@geocodinglife
geocodinglife / math.rb
Last active October 27, 2015 19:08
simple math
g = -> (f, x) { f.call(x, 3) }
h = -> (x, y) { x + y }
g.call(h, 5)
>>8
#same as this
geo = -> (zombi, gasparin) { zombi.call(gasparin, 3) }
jose = -> (gasparin, frankenstein) { gasparin + frankenstein }
geo.call(jose, 5)
>> 8

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

puts 'hello world'
class Employee
attr_accessor :name, :salary
def initialize(name, salary)
@name = name
@salary = salary.to_i
end
def start_salary
class Car
attr_accessor :speed, :acceleration, :braking, :velocity
def initialize(velocity = 0)
@velocity = velocity
end
def accelerate(acceleration)
acceleration == 0 ? @velocity + 1 : @velocity + acceleration
end
<h1>How remote true works</h1>
<%= form_tag remote: true do %>
<%= text_field_tag "name" %>
<%= submit_tag "sumit you name" %>
<% end %>
<div style="border: 1px red solid" id="names">
<%= @names %>
class Person
attr_reader :name
def initialize(name)
self.name = name
end
def name=(name)
if name == nil or name.size == 0
raise ArgumentError.new('Must have a name.')
end
.tiny-stone{
width: 45px;
height: 45px;
position: relative;
margin: auto;
background: image-url('green-ubatuba.jpg');
background-size: cover;
}
class RoomsController < ApplicationController
def index
@rooms = Room.all
end
def show
@room = Room.find(params[:id])
end
def new
#pending to comberted to more objec oriented.......