Instantly share code, notes, and snippets.

View gist:2507892
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes", "#{@scope[:shallow_prefix]}", "#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :projects # => config/routes/projects.rb
namespace :admin do
View gist:4024626
/Users/pro/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `keys' for nil:NilClass (NoMethodError)
from /Users/pro/.rvm/gems/ruby-1.9.3-p194/bundler/gems/librato-rails-7fdb0ec65cb2/lib/librato/rails.rb:57:in `check_config'
from /Users/pro/.rvm/gems/ruby-1.9.3-p194/bundler/gems/librato-rails-7fdb0ec65cb2/lib/librato/rails.rb:111:in `setup'
from /Users/pro/.rvm/gems/ruby-1.9.3-p194/bundler/gems/librato-rails-7fdb0ec65cb2/lib/librato/rails/railtie.rb:11:in `block in <class:Railtie>'
from /Users/pro/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/pro/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `run'
from /Users/pro/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/pro/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `each'
from /Users/pro/.r
View gist:3898499
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PROMOTE VARIABLE TO RSPEC LET
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! PromoteToLet()
:normal! dd
" :exec '?^\s*it\>'
:normal! P
:.s/\(\w\+\) = \(.*\)$/let(:\1) { \2 }/
:normal ==
endfunction
View gist:3117600
19:13:56 sidekiq.1 | Thread TID-ousccjq2c
19:13:56 sidekiq.1 | /Users/pro/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/monitor.rb:185:in `mon_enter'
19:13:56 sidekiq.1 | /Users/pro/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/monitor.rb:209:in `mon_synchronize'
19:13:56 sidekiq.1 | /Users/pro/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:290:in `checkin'
19:13:56 sidekiq.1 | /Users/pro/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:176:in `release_connection'
19:13:56 sidekiq.1 | /Users/pro/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:386:in `block in clear_active_connections!'
19:13:56 sidekiq.1 | /Users/pro/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:386:in `each_value'
19:13:56 sidekiq.1 | /Users/pro/.rvm/gems/ruby-1.9.3-p12
View deploy.rb
load 'deploy/assets'
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :web, :except => { :no_release => true } do
%x{bundle exec rake assets:precompile}
%x{rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{host}:#{shared_path}}
%x{bundle exec rake assets:clean}
end
View hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
View clean-merged-branches
#!/bin/sh
#/ Usage: clean-merged-branches [-f]
#/ Delete merged branches from the origin remote.
#/
#/ Options:
#/ -f Really delete the branches. Without this branches are shown
#/ but nothing is deleted.
set -e
# show usage maybe
View gist:1341179
namespace :resque do
task :setup => :environment do
Resque.before_fork { ActiveRecord::Base.connection.disconnect! }
Resque.after_fork { ActiveRecord::Base.establish_connection }
end
end
View gist:1050827
ArgumentError: wrong number of arguments (3 for 2)
from /Users/pro/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.7/lib/active_record/connection_adapters/mysql2_adapter.rb:634:in `select'
from /Users/pro/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/database_statements.rb:9:in `select_all'
from /Users/pro/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
from /Users/pro/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc4/lib/active_record/base.rb:473:in `find_by_sql'
from /Users/pro/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc4/lib/active_record/relation.rb:109:in `to_a'
from /Users/pro/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc4/lib/active_record/relation/finder_methods.rb:155:in `all'
from /Users/pro/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc4/lib/active_record/base.rb:444:in `all'
from (irb):1
from /Users/pro/.rvm/gems/ruby-1.9.2-p180/
View linechart.html
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html;charset=UTF-8' http-equiv='content-type' />
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type='text/javascript'>
google.load('visualization', '1', {'packages':['linechart']});
</script>
<title>AGGRHHHH</title>
</head>
<body onload='drawVisualization()'>