Friday, September 28, 2007
Thursday, September 20, 2007
FInd slow actions in a Rails app
cat log/development.log | awk '/Completed/ { print "[" $3 "] - " $0 }'
| sort -nr
Thursday, September 13, 2007
Don't override to_json like this
class String
def to_json
"'#{self}'"
end
end
Because of this , The RJS totally don't work
and You get "unterminated string literal" because of not escaped javascript.
Wednesday, September 12, 2007
Show all files in the Finder
Open Terminal, type this command, and press Enter:
defaults write com.apple.Finder AppleShowAllFiles YES
Sunday, September 09, 2007
Ways to run ruby tests
2. rake -T test
3. ruby test/unit/product_test.rb
4. ruby test/unit/product_test.rb -v
5. ruby test/unit/product_test.rb -n /create/ -v
6. rake test:units TESTOPTS="-v -n/create/"
Possibility with scoped_proxy
scoped_proxy :admins, :find => { :conditions => ['role = ?', 'super_user'] }
scoped_proxy :has_login do |login|
{ :find => { :conditions => ['login = ?', login] } }
end
scoped_proxy :no_op do
nil
end
end
# This gives you the first administrator of the system
User.admins.find(:first)
# This counts the administrators
User.admins.count
# All users with a given login
User.has_login('foo').count
User.has_login('foo').find(:all, :order => 'created_at desc')
# And finally, I give you the no op
User.no_op.find(:all) # => User.find(:all)
Thursday, September 06, 2007
psql: FATAL: IDENT authentication failed for user
$ psql -U gateadmin template1
psql: FATAL: IDENT authentication failed for user "gateadmin"
Why?
It looks like you would rather use password authentication than the
default IDENT-based auth (it's default in Debian distro of postgres
anyway). IDENT will only let you in when you do *not* use -U, ie,
your postgres user name is the same as your Unix user name. Change
this in pg_hba.conf, and don't forget to SIGHUP or restart the
postmaster afterwards.
regards, tom lane
Solution:
Just modify pg_hba.conf like this (change to trust)
local all trust
host all 127.0.0.1 255.255.255.255 trust