Skip to content

Instantly share code, notes, and snippets.

View rdavila's full-sized avatar

Rubén Dávila Santos rdavila

View GitHub Profile
@rdavila
rdavila / log.txt
Created October 8, 2011 19:08
City.select([:id, :name]).where(:state_id => 4).as_json
[2011-10-08 14:06:42] ERROR NoMethodError: undefined method `bytesize' for #<Array:0x007fcd02461cf8>
/Users/rubendavila/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.3.4/lib/rack/utils.rb:257:in `bytesize'
/Users/rubendavila/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/rack/content_length.rb:28:in `block in call'
/Users/rubendavila/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/query_cache.rb:45:in `each'
/Users/rubendavila/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/query_cache.rb:45:in `each'
/Users/rubendavila/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:458:in `each'
/Users/rubendavila/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.3.4/lib/rack/body_proxy.rb:23:in `method_missing'
/Users/rubendavila/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/rack/content_length.rb:26:in `call'
/Users/rubendavila/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/rack/debugger.rb:21:in `ca
class RegistrationsController < Devise::RegistrationsController
before_filter :check_presence_of_plan_id_and_campaign_id, :only => [ :new, :create ]
protected
def check_presence_of_plan_id_and_campaign_id
redirect_to plans_url if cookies[:plan_id].blank? || cookies[:campaign_id].blank?
end
end
@rdavila
rdavila / log
Created September 30, 2011 22:12
postgres install log
==> Downloading http://ftp9.us.postgresql.org/pub/mirrors/postgresql/source/v9.0.4/postgresql-9.0.4.tar.bz2
File already downloaded in /Users/rdavila/Library/Caches/Homebrew
/usr/bin/tar xf /Users/rdavila/Library/Caches/Homebrew/postgresql-9.0.4.tar.bz2
Warning: Detected a framework Python that does not have 64-bit support in:
/Library/Frameworks/Python.framework/Versions/Current/Python
e configure script seems to prefer this version of Python over any others,
you may experience linker problems as described in:
http://osdir.com/ml/pgsql-general/2009-09/msg00160.html
/opt/ree/bin/ruby -S bundle exec rspec --backtrace --color ./spec/parallel_spec.rb
.....Parallel execution interrupted, exiting ...
...........................
Finished in 20.53 seconds
32 examples, 0 failures
(in /var/www/vhosts/app.com/httpdocs/releases/20110908191805)
** Invoke item_statistics:update (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute item_statistics:update
rake aborted!
private method `chomp' called for nil:NilClass
/opt/ree/lib/ruby/gems/1.8/gems/parallel-0.5.8/lib/parallel.rb:144:in `work_in_processes'
/opt/ree/lib/ruby/gems/1.8/gems/parallel-0.5.8/lib/parallel.rb:211:in `join'
/opt/ree/lib/ruby/gems/1.8/gems/parallel-0.5.8/lib/parallel.rb:211:in `wait_for_threads'
@rdavila
rdavila / ar_extension.rb
Created September 6, 2011 16:20
Problem to log AR queries to DB
class ActiveRecord::ConnectionAdapters::MysqlAdapter
def execute(sql, name = nil, skip_logging = false)
log(sql, name) { @connection.query(sql) } unless skip_logging
rescue ActiveRecord::StatementInvalid => exception
if exception.message.split(":").first =~ /Packets out of order/
raise ActiveRecord::StatementInvalid, "'Packets out of order' error was received from the database. Please update your mysql bindings (gem install mysql) and read http://dev.mysql.com/doc/mysql/en/password-hashing.html for more information. If you're on Windows, use the Instant Rails installer to get the updated mysql bindings."
else
raise
end
@rdavila
rdavila / gist:1195843
Created September 5, 2011 20:25
sql logger
ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
def log_with_syspanel_logger(sql, name, &block)
if Thread.current["syspanel.sql.logger.enabled"]
Thread.current["syspanel.sql.logger.enabled"] = false
SyspanelSqlLog.create(:sql => sql, :name => name)
end
log_without_syspanel_logger(sql, name, &block)
end
@rdavila
rdavila / config.log
Created August 18, 2011 22:43
Can't install postgres on Snow Leopard 10.6.8
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by PostgreSQL configure 9.0.4, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.0.4 --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-python --with-perl --with-ossp-uuid --datadir=/usr/local/Cellar/postgresql/9.0.4/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.0.4/share/doc/postgresql ARCHFLAGS='-arch x86_64'
## --------- ##
## Platform. ##
@rdavila
rdavila / git_prompt_bash
Created December 11, 2010 00:35
git_prompt_bash
function prompt {
local LIGHT_RED="\[\033[1;31m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local NO_COLOUR="\[\033[0m\]"
local TITLEBAR='\[\033]0;\u@\h\007\]'
source ~/.git-completion.bash
export GIT_PS1_SHOWDIRTYSTATE=true
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
<%
output = `cd #{Rails.root} && git branch`
branch = output.select { |e| e =~ /\A\*.+/ }.first
actual_branch = branch[/\*\s(.+)/, 1]
%>
development:
adapter: sqlite3
database: db/<%= actual_branch %>_db