When we define an error class in a module, we do one of the following.
module App
class Error < StandardError; end
class ServerError < Error; end
class ClientError < Error; end
endWhen we define an error class in a module, we do one of the following.
module App
class Error < StandardError; end
class ServerError < Error; end
class ClientError < Error; end
end| class << self | |
| def recent | |
| where(...) | |
| end | |
| end | |
| module Scopes | |
| def recent | |
| where(...) | |
| end |
| class Person < ActiveRecord::Base | |
| def self.recent | |
| where('added_at > ? AND deleted = ?', ...).where('address IS NULL').order('last_name, first_name') | |
| end | |
| end |
| > GeoIP::DB.country '64.15.156.242' | |
| => #<struct GeoIP::City | |
| request="64.15.156.242", | |
| ip="64.15.156.242", | |
| country_code2="CA", | |
| country_code3="CAN", | |
| country_name="Canada", | |
| continent_code="NA", | |
| region_name="QC", | |
| city_name="Montreal", |
| http { | |
| set $limitreq_zone 1; | |
| limit_req_zone $limitreq_zone zone=one:10m rate=100r/s; | |
| ... | |
| server { | |
| ... | |
| location /foo/ { | |
| limit_req zone=one; |
Turning gist into a blogging platform? Cool idea.
If you're interested, go to gist.io.
| controller :users do | |
| [ :login, :signup, :thankyou, :forgot, :goodbye ].each do |name| | |
| match name, action: name, as: name | |
| end | |
| [ :confirm, :reset_password ].each do |name| | |
| match "#{name}/:id", action: name, as: name | |
| end | |
| post 'logout', action: :logout, as: :logout | |
| end | |
| resources :users |
| ======================================================================== | |
| BYTE UNIX Benchmarks (Version 5.1.2) | |
| System: uptimer-staging: GNU/Linux | |
| OS: GNU/Linux -- 2.6.32-5-686 -- #1 SMP Mon Mar 26 05:20:33 UTC 2012 | |
| Machine: i686 (unknown) | |
| Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8") | |
| CPU 0: Intel(R) Xeon(R) CPU E5645 (4800.2 bogomips) | |
| Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSCALL/SYSRET | |
| CPU 1: Intel(R) Xeon(R) CPU E5645 (4800.2 bogomips) |
| %li | |
| = link_to some_url do | |
| %strong= blog.title | |
| %i= unread_count |
| /* keyframes for animation; simple 0 to 360 */ | |
| @-webkit-keyframes spin { | |
| from { -webkit-transform: rotate(0deg); } | |
| to { -webkit-transform: rotate(360deg); } | |
| } | |
| @-moz-keyframes spin { | |
| from { -moz-transform: rotate(0deg); } | |
| to { -moz-transform: rotate(360deg); } | |
| } |