As configured in my dotfiles.
start new:
tmux
start new with session name:
| # If your workers are inactive for a long period of time, they'll lose | |
| # their MySQL connection. | |
| # | |
| # This hack ensures we re-connect whenever a connection is | |
| # lost. Because, really. why not? | |
| # | |
| # Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar) | |
| # | |
| # From: | |
| # http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/ |
| #To install ruby-debug on Ubuntu ruby-1.9.3 you need to download from http://rubyforge.org/frs/?group_id=8883 | |
| linecache19-0.5.13.gem | |
| ruby_core_source-0.1.5.gem | |
| ruby-debug19-0.11.6.gem | |
| ruby-debug-base19-0.11.26.gem | |
| #Then in your console | |
| export RVM_SRC=/your/path/to/ruby-1.9.3 |
| require 'test_helper' | |
| shared_examples_for 'An Adapter' do | |
| describe '#read' do | |
| before do | |
| @adapter.write(@key = 'whiskey', @value = "Jameson's") | |
| end | |
| it 'reads a given key' do | |
| @adapter.read(@key).must_equal(@value) |
As configured in my dotfiles.
start new:
tmux
start new with session name:
For a while, I have felt that the following is the correct way to improve the mass assignment problem without increasing the burden on new users. Now that the problem with the Rails default has been brought up again, it's a good time to revisit it.
When creating a form with form_for, include a signed token including all of the fields that were created at form creation time. Only these fields are allowed.
To allow new known fields to be added via JS, we could add:
| require 'rubygems' | |
| require "bundler/setup" | |
| require 'eventmachine' | |
| require 'sinatra' | |
| require 'redis' | |
| require 'json' | |
| QUEUESET = 'QUEUESET' # queue index | |
| UUID_SUFFIX = ':UUID' # queue unique id | |
| QUEUE_SUFFIX = ':queue' # suffix to identify each queue's LIST |
| rails_root = File.expand_path('../../', __FILE__) | |
| $LOAD_PATH.unshift(rails_root) unless $LOAD_PATH.include?(rails_root) | |
| require 'bundler/setup' | |
| require 'active_record' | |
| require 'rspec/rails/extensions/active_record/base' | |
| require 'spec/support/require_helper' | |
| require 'spec/support/helpers' | |
| require 'ostruct' | |
| Bundler.require :models |
| # A queue that you can pass to IO.select. | |
| # | |
| # NOT THREAD SAFE: Only one thread should write; only one thread should read. | |
| # | |
| # Purpose: | |
| # Allow easy integration of data-producing threads into event loops. The | |
| # queue will be readable from select's perspective as long as there are | |
| # objects in the queue. | |
| # | |
| # Implementation: |
| # The following should prevent an ArgumentError "invalid %-encoding (...%)" exception from being raised for malformed URLs. | |
| # To use this code simply drop this in your rails app initializers. | |
| # See: https://github.com/rack/rack/issues/337 | |
| # Taken from: http://stackoverflow.com/a/11162317/1075006 | |
| module URI | |
| major, minor, patch = RUBY_VERSION.split('.').map { |v| v.to_i } |