Tuesday, July 31, 2007

Unit test with transaction in rails

  uses_transaction :test_something_with_transaction
  def test_something_with_transaction
    ...
  end

Tuesday, July 24, 2007

missing key: categories: Cannot read the portsdb!

[asoboo@turbine-02 /usr/local/sites/asoboo.com/current]$ sudo
portupgrade -a
[Updating the portsdb <format:bdb_btree> in /usr/ports ... - 17433
port entries found
.........1000.........2000.........3000.........4000.........5000.........6000.........7000.........8000.........9000.........10000.........11000.........12000.........13000.........14000.........15000.........16000.........17000....
..... done]
[missing key: categories] [Updating the portsdb <format:bdb_btree> in
/usr/ports ... - 17433 port entries found
.........1000.........2000.........3000.........4000.........5000.........6000.........7000.........8000.........9000.........10000.........11000.........12000.........13000.........14000.........15000.........16000.........17000....
..... done]
missing key: categories: Cannot read the portsdb!
/usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:567:in `open_db':
database file error (PortsDB::DBError)
from /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:736:in `port'
from /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb:924:in
`all_depends_list'
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:915:in `tsort_build'
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:907:in `each'
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:907:in `tsort_build'
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:929:in `sort_build'
from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:933:in `sort_build!'
from /usr/local/sbin/portupgrade:694:in `main'
from /usr/local/lib/ruby/1.8/optparse.rb:755:in `initialize'
from /usr/local/sbin/portupgrade:210:in `new'
from /usr/local/sbin/portupgrade:210:in `main'
from /usr/local/sbin/portupgrade:1981


portupgrade moved from /usr/ports/sysutils/portupgrade to
/usr/ports/ports-mgmt/portupgrade, one way to fix this is:

cd /usr/ports/ports-mgmt/portupgrade
make clean all install

Or I think portupgrade -f portupgrade might do.

Monday, July 23, 2007

spawn-fcgi.c.211: child exited with: 127, Unknown error: 127

# ./script/process/spawner fcgi -e staging -p 7000 -i 5
=> Starting FCGI dispatchers
Checking if something is already running on 0.0.0.0:7000...NO
Starting dispatcher on port: 0.0.0.0:7000
exec: /usr/local/sites/somesite/releases/20070723060143/public/dispatch.fcgi:
not found
spawn-fcgi.c.211: child exited with: 127, Unknown error: 127


fixed by changing dispatch.fcgi

#!/opt/local/bin/ruby

to

#!/usr/local/bin/ruby

/tmp/502/nl.uu.phil.SSHAgent.socket (Errno::ENOENT)

ssh login when Capistrano deployment failed with that message. Running
(on Mac OS):

$ ssh-agent bash
$ ssh-add
and then running cap tasks fixed the problem for now.

undefined method 'gem' for main:Object

gem update --system

Sunday, July 22, 2007

Kill all processes with full command name and args

sunfmin@sunfmin-laptop:~$ pgrep -f "ssh -L 8080:google.com:80 sunfmin@localhost"
sunfmin@sunfmin-laptop:~$ pkill -f "ssh -L 8080:google.com:80 sunfmin@localhost"

Thursday, July 12, 2007

link folder to external repository [ svn propedit svn:externals vendor ]

export SVN_EDITOR="mate -w"
svn propedit svn:externals vendor

and input like the following to the popped editor

rails http://dev.rubyonrails.org/svn/rails/tags/rel_1-2-3
radiant http://dev.radiantcms.org/svn/radiant/tags/rel_0-6-2/radiant/

this would make the folder like this.
vendor
  |--rails
  |--radiant


The ownership of a file may only be altered by a super-user

chown -R www:www sandbox/
chown: sandbox//conf/authz: Operation not permitted
chown: sandbox//conf/passwd: Operation not permitted
chown: sandbox//conf/svnserve.conf: Operation not permitted
chown: sandbox//conf: Operation not permitted
chown: sandbox//dav/activities.dir: Operation not permitted
chown: sandbox//dav/activities.pag: Operation not permitted

->

sudo chown -R www:www sandbox/

The ownership of a file may only be altered by a super-user for obvious
     security reasons.


Monday, July 09, 2007

Let BitTorrent works on Ubuntu with Azureus Client.

1. Set Local ASDL Router to allow NAT
    Access 192.168.0.1 or something
2. Let Ubuntu to allow the port Azureus uses.
#iptables -I INPUT -p tcp --dport 57656 -j ACCEPT
#iptables -I INPUT -p udp --dport 57656 -j ACCEPT

Saturday, July 07, 2007

Rails Development On Ubuntu

h1. Installation

Switch to root user

h2. Install Ruby, Rails

apt-get install ruby rdoc irb libyaml-ruby libzlib-ruby ri
apt-get install rubygems
gem update --system
gem install rails -y

h2. Install Mongrel, MySQL

apt-get install mysql-server-5.0

apt-get install build-essential
apt-get install ruby1.8-dev
gem install mongrel
gem install mysql


h2. Install emacs(snapshot 22.0), ruby-mode, emacs-rails


gem install emacs-snapshot
cd  $HOME/.emacs.d/
svn co http://svn.ruby-lang.org/repos/ruby/trunk/misc/ ruby
svn co svn://rubyforge.org/var/svn/emacs-rails/trunk rails


Add this code in $HOME/.emacs


(setq load-path (cons "~/.emacs.d/ruby" load-path))
(setq load-path (cons "~/.emacs.d/rails" load-path))
(require 'rails)



h2. Resources

Install Rails On Ubuntu
Rails On Emacs

Monday, June 11, 2007

Fix [ruby: no such file to load -- ubygems (LoadError)] in E-TextEditor

Go to the cygwin bash prompt. If you don't know how to get there, use Start -> Run -> c:\cygwin\cygwin.bat.

Type:
echo unset RUBYOPT >> .bashrc

Type:
. .bashrc

Type:
irb

If you see:
irb(main):001:0>

Friday, April 27, 2007

Input Japanese with WATIR

One more tip. You better use
$ie.text_field(:name,'txtPcode').value = 'KANJI'
instead of
$ie.text_field(:name,'txtPcode').set('KANJI')

TextField#set method fails on japanese characters.

Tuesday, April 17, 2007

Debug with Eclipse and Tomcat

Add the following line to startup.bat
 
set CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
 
Eclipse
 
Add <Remote Java Application>
Host:localhost, Port 5005
 

Friday, March 23, 2007

You have Office, You have Tools to Edit Database through ODBC - MSQRY32.EXE

C:\Program Files\Microsoft Office\OFFICE11\MSQRY32.EXE
 
メニュー
レコード −> 編集の許可

Friday, March 02, 2007

Archive My Directory for Mediamax - Less than 10M per file ;-)

winrar_path = "C:/sunfmin/Programs/WinRAR"
rar_root_path = "C:/sunfmin/Install/Books"
#Mb
split_size = 8 #Mb

#============================================

require 'find'

split_size_byte = split_size * 1024 * 1024
Find.find(rar_root_path) do |f|

    if File.file?(f) and File.size(f) > split_size_byte
        dirname = File.dirname(f)
        Dir.chdir(dirname)
        file_name = File.basename(f)

       
        rar_file_name = file_name[0, file_name.rindex('.')] + ".rar"
       
        winrar_exe = winrar_path + "/Rar.exe a -o+ -v#{split_size}m \"#{rar_file_name}\" \"#{file_name}\""
        puts "=========================================================="
        IO.popen(winrar_exe) do |out|
            puts "OOOOO======>>> #{rar_file_name}"
            puts out.readlines
        end


    end
end

 

 

Tuesday, February 20, 2007

CSE+PostgreSQL問題

 
現象1:
 
DBエラー詳細:
FATAL: datamase ""test"" does not exist

 
回答1:
下記のURLで公開されている「日本語Windows版 libpq」入れなおしたところ
http://www.interwiz.koganei.tokyo.jp/software/PostgreSQL/libpq-6.5jp.zip
 
現象2:
fe_sendauth: authentication type 5 not supported
回答2:

install_dir\data\pg_hba.confを開いて

# IPv4 local connections:
host    all         all         127.0.0.1/32          md5

↓

# IPv4 local connections:
host    all         all         127.0.0.1/32          trust

 

 

Tuesday, February 13, 2007

移動またはコピーしようとしている数式またはシートには、移動またはコピー先のワークシートに既にある名前'●●●'が含まれています。この名前を使用しますか?……

上記のような現象であるとしても、定義された名前が存在してこそ。

元となるブックで定義があるのではないかと推測します。覚えがなくても。 まずは下記は確認されましたか? >名前定義の確認は元のブックの全てのシートで使用状況も含めて行ってください。 不都合の起こるほうのブックを調べても解決にはなりません。   確認のためにコピー(移動)元のブックで下記のプロシージャを実行してみるのも 良いかもしれません。(アクティブなブックが対象になります)   Sub NameListPrint() Dim i As Long Dim Sh As Worksheet Set Sh = Worksheets.Add With ActiveWorkbook For i = 1 To .Names.Count Sh.Cells(i, 1).Value = .Names(i).Name Sh.Cells(i, 2).Value = "'" & .Names(i).RefersTo Next i End With End Sub   名前定義があれば挿入されたシートに定義状況が列記されます。 あとは、下記で一気に名前定義を削除。 (これもアクティブなブックが対象)   Sub NamesDelete() Dim i As Long With ActiveWorkbook For i = .Names.Count To 1 Step -1 .Names(i).Delete Next i End With End Sub   マクロを使う以外では、 「問題となる名前が名前定義ダイアログボックスでも発見できないときは 挿入>名前>定義 で一度名前を(適当でよいので)定義してみて、 それを削除するとエラーが出なくなる」 という情報もあったけど、現象そのものが再現ができないので未確認。

Sunday, February 11, 2007

Install languages (Chinese, Japanese, Korean) on Fedora 6

After you install finished, remeber to restart.

For Fedora Core 4, 5 and 6, the packages are fonts-Japanese, fonts-Chinese, and fonts-Korean. The command to enable these fonts is

yum install fonts-japanese fonts-chinese fonts-korean


Thursday, January 04, 2007

Change my ip config between office and home

Execute an bat is more convenient than open Internet Protocol(TCP/IP) Properties dialog to change ip config again and again.
  • SetOfficeIP.bat
netsh interface ip set address name="Local Area Connection" source=static addr= 172.16.96.158 mask=255.255.255.0
netsh interface ip set address name="Local Area Connection" gateway= 172.16.96.254 gwmetric=0
netsh interface ip set dns name="Local Area Connection" source=static addr= 172.16.8.3 register=PRIMARY
netsh interface ip add dns name="Local Area Connection" addr= 172.16.8.13 index=2
netsh interface ip set wins name="Local Area Connection" source=static addr=none

  
  • SetHomeIP.bat 
netsh interface ip set address name="Local Area Connection" source=dhcp
netsh interface ip set dns name="Local Area Connection" source=dhcp register=PRIMARY
netsh interface ip set wins name="Local Area Connection" source=dhcp