This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'methodfinder' | |
# _why's MethodFinder addition tweaked and revised. | |
# <http://redhanded.hobix.com/inspect/stickItInYourIrbrcMethodfinder.html> | |
class MethodFinder | |
def self.with_redirected_streams | |
redirect_streams | |
yield | |
ensure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Capybara | |
def Capybara.auto_save_and_open_page=(val) | |
@auto_save_and_open_page = !!val | |
end | |
def Capybara.auto_save_and_open_page? | |
@auto_save_and_open_page ||= false | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define('backbone', ['lib-underscore', 'lib-backbone'], function () { | |
Backbone.mixin = function (view, mixin, custom) { | |
if (custom) { | |
if (custom.events && mixin.events) { | |
mixin = _.clone(mixin) | |
_.defaults(custom.events, mixin.events) | |
} | |
_.extend(mixin, custom) | |
} | |
var source = view.prototype || view |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# By Steve Leung | |
# steve@leungs.me | |
class ActiveRecord::Relation | |
# temporarily hack for allowing combining scopes with OR | |
# doesn't add the join tables so need to use .includes manually | |
# ie. Jobship.includes(:job).or(Jobship.accepted, Jobship.declined).count | |
def or(*scopes) | |
clauses = *scopes.map do |relation| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compresses all .js and .css files under the assets path. | |
namespace :deploy do | |
# It is important that we execute this after :normalize_assets because | |
# ngx_http_gzip_static_module recommends that compressed and uncompressed | |
# variants have the same mtime. Note that gzip(1) sets the mtime of the | |
# compressed file after the original one automatically. | |
after :normalize_assets, :gzip_assets do | |
on release_roles(fetch(:assets_roles)) do | |
assets_path = release_path.join('public', fetch(:assets_prefix)) | |
within assets_path do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "octokit" # gem install octokit | |
1.upto(5) do |page| | |
Octokit.repositories("railscasts", page: page, per_page: 100).each do |repo| | |
system "git clone git://github.com/railscasts/#{repo.name}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'rake' | |
gem 'lotus-router' | |
gem 'lotus-controller' | |
gem 'lotus-view' | |
group :test do | |
gem 'rspec' | |
gem 'capybara' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install specific version of Homebrew formula | |
# usage example: | |
# $ brew-install ssh-copy-id 6.0p1 | |
function brew-install { | |
local formula version formula_hash | |
formula=$1 | |
version=$2 | |
cd `brew --prefix` | |
git_last_commit_id=`git rev-parse --short HEAD` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :stage, 'production' | |
set :shared_children, shared_children << 'tmp/sockets' | |
puma_sock = "unix://#{shared_path}/sockets/puma.sock" | |
puma_control = "unix://#{shared_path}/sockets/pumactl.sock" | |
puma_state = "#{shared_path}/sockets/puma.state" | |
puma_log = "#{shared_path}/log/puma-#{stage}.log" | |
namespace :deploy do | |
desc "Start the application" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calculating ------------------------------------- | |
type-safe users 273.000 i/100ms | |
ar user models 257.000 i/100ms | |
------------------------------------------------- | |
type-safe users 2.813k (± 1.7%) i/s - 14.196k | |
ar user models 2.574k (±10.7%) i/s - 12.850k | |
Comparison: | |
type-safe users: 2812.7 i/s | |
ar user models: 2574.2 i/s - 1.09x slower |
OlderNewer