Skip to content

Instantly share code, notes, and snippets.

@dreamr
dreamr / gist:9711694
Created March 22, 2014 18:09
The rules and principles I try to follow
* Keep methods rediculously short
* Methods should do 1 thing
* Be idempotent when at all possible
* Leave objects open to extension, but closed to modification
* Don't modify objects unless constrained by memory operations
* Wrap Network and Disk and Database calls with encapsulation
* Dont mock what you dont own
* Write real unit tests, test inside the boundaries
* Write common path itegration tests, test the boundaries themselves
@dreamr
dreamr / vistalegre_scam.md
Created April 14, 2014 19:58
Do NOT rent from VisteLegre in Puerto Vallarta!

TERRIBLE EXPERIENCE!

I moved back to Vallarta in spring of 2014. The first apartment these guys rented to my finance and I turned out to be a crazy lady who accused us of having cats we do not have and kicking us out at 2am the first night we arrived.

After dragging all our belongings down over 100 steps and into a taxi and to a hotel, it was a night of hell.

The next day they moved us to a new apartment. We bought a washer machine and a very nice hammock. The building was shared by other short term vistalegre rental customers. In 3 months we had three gay old men (1 at a time) beneath us in the lower apartment.

Their smoke was constantly in my apartment, there was no separate meter on the gas so I shelled out all the gas money after it repeatedly ran out. Vistalegre did little to reimburse me for the other tenants half.

@dreamr
dreamr / 1-with-lambdas.rb
Last active August 29, 2015 14:00
Laziness - or code as data!
shout =->(name) { "HELLO #{name.upcase}!" }
def greet(name, greeter)
greeter.call(name)
end
puts greet("Robert", shout) #=> HELLO ROBERT!
class User < ActiveRecord::Base
def display_name
full_name || email_designator || "I haz no name nor email!"
end
def email_designator
return nil if email.blank?
@email_designator = email.split("@")[0]
end
# Run
rails rails_app_name -m http://github.com/dreamr/dream_template/raw/master/base.rb
# Then
cd rails_app_name
rake db:create && rake db:migrate
rake gems:install
rake gems:unpack
# To start up autospec
## Bid controller
actions: create
views: new, form (partial including the form)
## Pictures controller
actions: index, new, create, edit, update, destroy
views: same ^^
We couldn’t find that file to show.
@dreamr
dreamr / person.rb
Created January 5, 2010 09:26 — forked from Mikr0Tik/person.rb
class Person < ActiveRecord::Base
before_save :before_save_foo, :before_save_bar
before_create :before_create_claat
before_validation :before_validation_bar
after_save :after_save_clean_skip_callbacks
attr_accessor :skip_callbacks
SKIPPABLE_CALLBACKS = [:before_save_foo, :before_save_bar]
SKIPPABLE_CALLBACKS.each do |cb|
Hello. My name is Johnathan and I am from Craig, Colorado. Look it up on google maps and rate it in your head of total suckiness.
I want to get out of here very very badly, and I now have some work lined up in Los Angeles, studying under one of the top 100 rails coders in the world. I have a friend out there that has a room for me to stay in while I get on my feet. Everything is all set EXCEPT;
I need a bus ticket out of this hell hole. That is it. I have enough money to scrape by on once my ticket is paid for.
SO!!! I am asking for YOUR help. My Ruby and Rails community. Some of you make very good money, some of you understand the value of a dream. Give $5 or $10 bucks and call it a beer. It's one of the things that makes our community so great.
ActionController::Routing::Routes.draw do |map|
map.with_options :controller => 'static' do |static|
static.home '/', :action => 'home'
static.home '/home', :action => 'home'
static.dogma '/practices', :action => 'practices'
static.projects '/projects', :action => 'projects'
static.access_denied '/access-denied', :action => 'denied'
end