- Fat Model, Skinny Controller
- Object-Oriented Design Patterns
- Single Responsibility Principle
http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/
int dataPin = 2; | |
int clockPin = 3; | |
int csPin = 4; | |
byte chars[] = { | |
B00011000, | |
B00111100, | |
B01100110, | |
B11000011, |
http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/
module HashExtensions | |
def symbolize_keys | |
inject({}) do |acc, (k,v)| | |
key = String === k ? k.to_sym : k | |
value = Hash === v ? v.symbolize_keys : v | |
acc[key] = value | |
acc | |
end | |
end | |
end |
//Useful if you have a slow CI server... | |
When /^I wait until all Ajax requests are complete$/ do | |
wait_until do | |
page.evaluate_script('$.active') == 0 | |
end | |
end |
To set up search history backward in inputrc add these settings: | |
This will add you ctrl + up and ctrl + down to complete command partial. But if you change your mind and want to jump different command you can simply do it by using up and down without the ctrl. | |
/etc/inputrc: | |
"\e[1;5A": history-search-backward | |
"\e[1;5B": history-search-forward | |
http://www.linuxquestions.org/questions/linux-desktop-74/how-to-search-command-history-beginning-with-what-you-type-789471/ | |
http://forums.opensuse.org/archives-software/337292-trivial-bash-question.html |
#!/bin/bash | |
# | |
# app Rails application served through an Unicorn instance | |
# | |
# Author Romain Champourlier @ softr.li | |
# | |
# chkconfig: - 87 13 | |
# | |
# description: This a web application developed in Ruby On Rails | |
# which is served through an Unicorn instance. |
en: | |
errors: | |
messages: | |
wrong_content_type: "is the wrong content type" |
### app access token | |
graph = Koala::Facebook::OAuth.new APP_ID, APP_SECRET | |
graph.get_app_access_token # => APP_TOKEN | |
### create test users with permissions | |
test_users = Koala::Facebook::TestUsers.new app_id: APP_ID, secret: APP_SECRET | |
user = test_users.create true, 'email,user_birthday,user_posts', name: 'Bob' | |
# => | |
# { "id" => USER_ID, | |
# "access_token" => USER_ACCESS_TOKEN, |
NOTE: I've created a gem based on this: https://github.com/natritmeyer/yarjuf | |
--------- | |
rspec my_spec.rb -r ./junit.rb -f JUnit -o results.xml |
after_fork do |server, worker| | |
# Override the default logger to use a separate log for each Unicorn worker. | |
# https://github.com/rails/rails/blob/3-2-stable/railties/lib/rails/application/bootstrap.rb#L23-L49 | |
Rails.logger = ActiveRecord::Base.logger = ActionController::Base.logger = begin | |
path = Rails.configuration.paths["log"].first | |
f = File.open(path.sub(".log", "-#{worker.nr}.log"), "a") | |
f.binmode | |
f.sync = true | |
logger = ActiveSupport::TaggedLogging.new(ActiveSupport::BufferedLogger.new(f)) |