Friday, September 28, 2007

Outbound Port25 Blocking

sudo postconf -e relayhost=mail.qb3.so-net.ne.jp

Thursday, September 20, 2007

FInd slow actions in a Rails app

# Show a list of actions sorted by time taken. Useful for finding slow actions.
cat log/development.log | awk '/Completed/ { print "[" $3 "] - " $0 }'
| sort -nr

from: http://snippets.dzone.com/posts/show/4440

Thursday, September 13, 2007

Don't override to_json like this

I don't know why our project override this method
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

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

1. rake
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

class User < ActiveRecord::Base
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

Everytime I log in using normal user, I got this message:

$ 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