Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:
注:(r3 代表 Rails 3,r4 代表 Rails 4)
# routes.rbI. Create a Middleman project with middleman-ember-template
$ middleman init hello --template=ember
II. Install ember.js package
$ bower install ember
| class Price | |
| include Comparable | |
| attr_reader :amount | |
| def initialize(amount) | |
| @amount = amount | |
| end | |
| def <=>(obj) |
| # using accessors: | |
| attr_volatile :table, :size_control | |
| def check_for_resize | |
| while (current_table = table) && MAX_CAP > (table_size = current_table.size) && RESIZING != (size_ctrl = size_control) && size_ctrl < @counter.sum | |
| try_in_resize_lock(current_table, size_ctrl) do | |
| self.table = rebuild(current_table) | |
| (table_size << 1) - (table_size >> 1) # 75% load factor | |
| end |
| module DelayedJob | |
| module Matchers | |
| def enqueue_delayed_job(handler) | |
| DelayedJobMatcher.new handler | |
| end | |
| class DelayedJobMatcher | |
| def initialize(handler) | |
| @handler = handler | |
| @attributes = {} |
| #!/usr/bin/env ruby | |
| require 'em-http-request' | |
| require 'fiber' | |
| require "ruby-debug" | |
| class AsynUploader | |
| @successes = [] | |
| @failures = [] |
| require 'goliath' | |
| require 'em-synchrony/em-http' | |
| class UploadProxy < Goliath::API | |
| def on_headers(env, headers) | |
| env.logger.info 'received headers: ' + headers.inspect | |
| env['async-headers'] = headers | |
| end |
| require 'rack/utils' | |
| require 'rack/session/abstract/id' | |
| require 'remcached' | |
| require 'em-synchrony/em-remcached' | |
| module Slurper | |
| module Rack | |
| class Session < ::Rack::Session::Abstract::ID | |
| include Goliath::Rack::AsyncMiddleware |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)