Skip to content

Instantly share code, notes, and snippets.

View schneems's full-sized avatar

Richard Schneeman schneems

View GitHub Profile
[2011-12-17 13:32:49] ERROR NoMethodError: undefined method `debug_rjs=' for ActionView::Base:Class
/Users/schneems/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-7bde2e2578ea/actionpack/lib/action_view/railtie.rb:34:in `block (3 levels) in <class:Railtie>'
/Users/schneems/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-7bde2e2578ea/actionpack/lib/action_view/railtie.rb:33:in `each'
/Users/schneems/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-7bde2e2578ea/actionpack/lib/action_view/railtie.rb:33:in `block (2 levels) in <class:Railtie>'
/Users/schneems/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-7bde2e2578ea/activesupport/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/Users/schneems/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-7bde2e2578ea/activesupport/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/Users/schneems/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-7bde2e2578ea/activesupport/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
/Users/schneems/.rvm/gems/r
@schneems
schneems / Gemfile
Last active September 28, 2015 23:18
Bootstrap A Fork of Rails
source 'http://rubygems.org'
gem 'rails', :git => '/Users/schneems/documents/projects/rails'
gem 'journey', :git => 'git://github.com/rails/journey.git'
gem 'arel', :git => 'git://github.com/rails/arel.git'
gem 'sqlite3'
@schneems
schneems / gist:1515221
Created December 23, 2011 20:01
delayed log
# DelayedLog Goals: decouple logging and sending logs, keep controllers Dry
# Example
# =======
## Define how LogWrapper writes to logs
# DelayedLog.on_send do |options|
#
# end
## Build a log to send
_____
< yay >
-----
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
# Cut will do the trick
# to grab caracters 2 to 3 we can use
# `cut -c 2-3
echo 'hello' | cut -c 2-3
'el'
cat my-file-name.txt | cut -c 100000-101000
# output
@schneems
schneems / user_helper.rb
Created January 16, 2012 13:51
Devise Stub logged in user
include Devise::TestHelpers
# gives us the login_as(@user) method when request object is not present
include Warden::Test::Helpers
Warden.test_mode!
# Will run the given code as the user passed in
def as_user(user=nil, &block)
current_user = user || Factory.create(:user)
if request.present?
@schneems
schneems / gist:1621039
Created January 16, 2012 14:11
Devise stubbing in action
let(:user) { Factory.create(:user) }
# To use the methods you can call
# methods directly on them like this:
scenario 'works while logged in' do
as_user(user).visit teach_path
# ...
# Or you can pass the code you wish
@schneems
schneems / gist:1649893
Created January 20, 2012 22:11
pagination uris
{
'previous': '/users?page=1',
'next': '/users?page=3',
'users': [ {...} ]
}
@schneems
schneems / gist:1705468
Created January 30, 2012 17:09
Receive GZIP params in Rails
def handle_gzip_params
# When the server receives a request with content-type "gzip/json" this will be called which will unzip it,
# and then parse it as json
# The use case is so clients such as Android or Iphone can zip their long request such as Inviters#addressbook emails
# Then the server can unpack the request and parse the parameters as normal.
if request.content_type == "gzip/json"
data = ActiveSupport::JSON.decode(ActiveSupport::Gzip.decompress(request.raw_post))
data = {:_json => data} unless data.is_a?(Hash)
params ||= {}

Calculating Reverse Polish Notation

Write an implementation that returns the correct results given an array in parsed RPN

[9]                         #=> 9
[9,1,'+']                   #=> 10
[9,1,'+',5,'+']             #=> 15
[3, 5, '+', 7, 6, '+', '/'] #=&gt; 0.6153846153846154