This file contains hidden or 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 'rack' | |
| class Object | |
| def webapp | |
| class << self | |
| define_method :call do |env| | |
| func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
| [200, {}, send(func, *attrs)] | |
| end |
This file contains hidden or 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
| #config/initializers/carrierwave.rb | |
| CarrierWave.configure do |config| | |
| if Rails.env.production? or Rails.env.development? | |
| config.storage :cloud_files | |
| config.cloud_files_username = "your_username" | |
| config.cloud_files_api_key = "your_key" | |
| config.cloud_files_container = "test" | |
| config.cloud_files_cdn_host = "c0012345.cdnn.cloudfiles.rackspacecloud.com" | |
| def store_dir |
This file contains hidden or 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
| =begin | |
| Need to install gems heroku, newrelic_rpm | |
| $ gem install heroku newrelic_rpm | |
| Set your apps setting | |
| app_name : heroku's app_name of auto scaling | |
| license_key : NewRelic api key. You can get heroku's NewRelic admin console. "App setting" and "Agent configuration" | |
| execute with cron every minutes | |
| $ ruby ./adjust_dynos_with_newrelic.rb |
This file contains hidden or 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
| ctrl-z | |
| bg | |
| touch /tmp/stdout | |
| touch /tmp/stderr | |
| gdb -p $! | |
| # In GDB | |
| p dup2(open("/tmp/stdout", 1), 1) | |
| p dup2(open("/tmp/stderr", 1), 2) |
This file contains hidden or 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
| # app/presenters/api/v1/other_resource_presenter.rb | |
| class Api::V1::OtherResourcePresenter | |
| attr_reader :other_resource | |
| def initialize( other_resource ) | |
| @other_resource = other_resource | |
| end | |
| def as_json( include_root = false ) |
This file contains hidden or 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
| # Use feature, background, and scenario blocks to write acceptance tests in test/unit | |
| # which are really just integration tests. include capybara or webrat or something and voila. | |
| # test/acceptance_helper.rb | |
| require 'test_helper' | |
| module ActionDispatch | |
| class AcceptanceTest < ActionDispatch::IntegrationTest | |
| class << self | |
| alias :background :setup |
This file contains hidden or 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
| curl https://gist.github.com/raw/999435/fc2718ac3f488ab2341b65dc2ae5c123f8859bff/fast-require-ruby-19.2-p180 > /tmp/require-performance-fix-1.9.2.patch | |
| rvm install 1.9.2-p180 --patch /tmp/require-performance-fix-1.9.2.patch |
This file contains hidden or 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
| --- a/load.c 2010-10-23 05:36:38.000000000 -0400 | |
| +++ b/patchload.c 2011-06-05 08:58:00.000000000 -0400 | |
| @@ -40,14 +40,6 @@ | |
| VALUE ary; | |
| long i; | |
| - for (i = 0; i < RARRAY_LEN(load_path); ++i) { | |
| - VALUE str = rb_check_string_type(RARRAY_PTR(load_path)[i]); | |
| - if (NIL_P(str) || !rb_is_absolute_path(RSTRING_PTR(str))) | |
| - goto relative_path_found; |
This file contains hidden or 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
| # autoload concerns | |
| module YourApp | |
| class Application < Rails::Application | |
| config.autoload_paths += %W( | |
| #{config.root}/app/controllers/concerns | |
| #{config.root}/app/models/concerns | |
| ) | |
| end | |
| end |
This file contains hidden or 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 "http://rubygems.org" | |
| group :development do | |
| gem 'rake' | |
| gem 'guard' | |
| gem 'coffee-script' | |
| gem 'rb-fsevent' | |
| gem 'rb-inotify' | |
| gem 'compass', '0.11.5' | |
| gem 'sass', '3.1.5' | |
| gem 'guard-compass' |