tag:blogger.com,1999:blog-81420213988055820002008-07-19T18:09:43.954+08:00navyblueshellingfordshellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comBlogger100125tag:blogger.com,1999:blog-8142021398805582000.post-81349675223947095802008-07-18T23:07:00.005+08:002008-07-19T18:09:43.972+08:00欄多愁善感 淌 一點點
青春歲月 落 一片片
彷彿存在母體操縱的世界
深深地難以自拔
於沒有方向的原點
燈火玲瓏處
憑欄人
獨倚
何是回首時
for A.L.
shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-87727179624245470212008-07-14T10:46:00.011+08:002008-07-14T18:36:58.722+08:00天守閣之徘當王牌已然從天而降
剩下的也只剩下祈求上蒼
天守閣的銅牆鐵壁阿
且看我是否是那德川家康
夜月,燈火,今夜亦瘋狂
---謹致 A.L.(J)
shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-83983705783011549702008-07-12T22:06:00.004+08:002008-07-12T22:34:58.743+08:00restful 與 form_for不可以在 /news/new 的 view 裡面寫 form_for @news ~"~
shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-51770041608763711162008-06-03T13:01:00.004+08:002008-06-03T13:08:16.052+08:00operate existed tables in railsJust need specify table name and primary key in Model. All attribution in tables will appear automatically.
class ModelName < ActiveRecord::Base
self.table_name = "table_name"
self.primary_key = "primary_key"
end
shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-78973503107364979172008-05-24T16:28:00.006+08:002008-05-24T16:50:40.633+08:00tree implement in rubyJust for fun, but it work well.
01 #!/usr/bin/env ruby
02 #
03 #
04
05
06 def tree(dirname, indent = " |")
07 puts dirname + "/" if indent == " |"
08 dir = Dir.open dirname
09 for f in dir
10 if f == "." || f == ".."
11 next
12 elsif File.directory? dirname+"/"+f
13 puts indent + "-" + f + "/"
14 tree( dirname+"/shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-11987588486510843282008-05-23T15:29:00.008+08:002008-05-23T20:17:15.956+08:00closure tipclosure is so fun.
well design for meta programming.
note 1:
01 #!/usr/bin/env ruby
02
03 class Hash
04 def find_all
05 temp_hash = {}
06 each {|key,value| temp_hash[key] = value if yield(key,value) }
07 temp_hash
08 end
09 end
10
11 square = { 0 => 0, 1 => 1, 2 => 4, 3 => 9 }
12
13 new = square.find_all { |key,value| key > 1 }
14 puts shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-50130327636654410072008-05-20T23:14:00.006+08:002008-05-20T23:27:20.020+08:00Mac OS X Terminal tipleopard terminal use xterm-color as default, but conflict with linux when ssh. The backspace act as delete(kill word at right not left). Mac OS hint provide a good solution, Copy /usr/share/terminfo/78/xterm-color on mac to ~/.terminfo/x/ on linux box. Not affect linux default setting. It saves my emacs in screen environment :D
shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-43922247612514061782008-05-17T00:56:00.006+08:002008-05-18T11:21:38.404+08:00sample schemehello, world! here
#!/usr/bin/guile -s
!#
(write "hello, world!")
define function
(define square (lambda (n) (* n n) ) )
(write (square 3) ) ; output 9
link1: The Scheme Programming Language 3/e
link2: Scheme Tutorial
shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-9888312468503561362008-05-13T23:57:00.000+08:002008-05-14T22:58:22.460+08:00shelling.idv.tw買了 shelling.idv.tw,不過什麼都還沒配置 :Dshellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-24870038732653654662008-05-12T22:08:00.005+08:002008-05-13T16:07:48.534+08:00self.pmsome convenient usage I prefer. :p
package PackageName;
use self;
use strict;
my @args;
sub new {
@args = args;
for (@args) {
blah~!
}
bless {}, self;
}
1;
self.pm++
shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-11414036195267902712008-05-12T21:57:00.000+08:002008-05-12T22:08:11.237+08:00some vimsomething is fun from learning the vi editor 6/e:
dwelp change two words
xp change two alphabetsshellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-86445713656030168632008-05-04T18:50:00.003+08:002008-05-04T18:58:45.616+08:00內灣出遊微記昨日帶友人繞過大半個新竹,一直以來都不喜新竹風物,常感食衣住行皆不盡人意,即便與大學同學出遊也甚感無聊,但昨日與友人暢遊內灣,吃盡美食,甚感愉快。看來在一個地方生活是否能讓人滿意,最重要的仍然是人。shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-62951908905607873382008-04-26T10:59:00.006+08:002008-04-26T17:47:03.988+08:00learning perl review ch2
scalar:
1.233, 2E-3, 3e45
# exponential float
123_123_234
# integer with underscore
0377, 0xff, 0b1111
# octal => 0, hexadecimal => 0x, binary => 0b
"hello,"."world!"
# concatenate with .
"hello" x 3
# repeat 3 time with x
"20fred" * 3
# ignore string when transform
$str = $str . "blah"; === $str .= "blah";
$int = shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-47638316057250200722008-04-25T20:29:00.005+08:002008-04-25T20:50:37.488+08:00boring comparisonshow complex data structure in perl and ruby
perl
#!/usr/bin/env perl
use warnings;
use Data::Dumper;
$a = ["a", "b", "c", { "key" => "value" } ];
print Dumper $a;
ruby
#!/usr/bin/env ruby
a = ["a", "b", "c", { "key" => "value" } ]
puts a.inspectshellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-85701864702954061292008-04-19T19:04:00.003+08:002008-04-19T19:07:58.308+08:00has_many() function noteif has_many :order
order.delete_all just set foreign key null
order.destroy_all clear all sub record
shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-76297159279918328192008-04-18T18:08:00.005+08:002008-04-18T18:25:58.434+08:00apache2 and mongrel cluster on debianEnable apache2 proxy
$ sudo a2enmod proxy proxy_http proxy_balancer
Configure Proxy in a virtual host
/etc/apache2/site-enabled/default add
DocumentRoot "RailsApp/public"
# even only RailsApp also work
ProxyPass / balancer://localhost/
ProxyPassReverse / balancer://localhost/
< proxy balancer://localhost/ >
BalanceMember http://localhost:3000
BalanceMember http://localhost:3001
shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-30492387759822855912008-04-17T13:52:00.010+08:002008-04-18T16:12:38.114+08:00rss feed in railsNote for the Way to create Atom and RSS 2.0 feed.
$ ./script/generate controller feed
Suppose that the model we want show in feed is Post
class FeedController < ApplicationController
def rss
@rss = @@post
end
def atom
@atom = @@post
end
private
@@post = Post.find :all,
:order => "update_at", :limit => 10
end
Then write the view.
app/view/feed/shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-54950038672059716682008-04-15T23:25:00.006+08:002008-04-15T23:49:07.414+08:00rails helper blockWrite for memo.
To set a helper in the form
<% helper_name do %>
<div>blah</div>
<% end %>.
The definition is
def helper_name(&block)
content = capture(&block)
concat("what we want write before block".block.binding)
concat(content,block.binding)
concat("what we want write after block",block.binding)
end
By the way, partial is the way do the same thing once. if the outer shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-16962664747577877582008-04-13T21:11:00.008+08:002008-04-13T21:46:21.168+08:00spakitThe rails plugin spakit means Single Page Application KIT. It can transform rails app into single page app but not modify app structure in large scale by loading content of other controller into primary controller.
The installation step is from handlino.com
$ sudo gem install spakit
$ cd railsapp/vendor/plugins/
$ gem unpack spakit
$ mv spakit-version spakit
now installation finished.
Before shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-64666734763143950632008-04-13T10:37:00.002+08:002008-04-13T10:49:10.717+08:00annotate modelsThe plugin used for adding column annotate into model file is introduced in Ralls Bible. Write for note. the newer introduction at http://pragdave.pragprog.com/pragdave/2006/02/annotate_models.html. Just two step to use it.
1.script/plugin install http://repo.pragprog.com/svn/Public/plugins/annotate_models
2. rake annotate_models
And all model now with column annotate at file head.shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-36294676053823298142008-04-05T20:06:00.002+08:002008-04-05T20:13:23.843+08:00.bashrc and screen on leopardLeopard does not put .bashrc in user home directory as default. It is not convenient when using screen because screen only load ~/.bashrc but not /etc/bashrc. So copy the latter as my .bashrc.shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-32210821117111173202008-04-05T11:18:00.003+08:002008-04-05T11:25:06.111+08:00debian package hyperlinkIf writing <a href=”apt:package_name”>package_name</a> in html, On click the hyperlink, debian will install it.shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-17269926436029413512008-04-05T00:20:00.004+08:002008-04-05T00:28:24.275+08:00openid resourceReport by solidot.org: openid resource. Noticeable point is blogger.com is one of the openid provider. It is a little surprising to me.shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-76235388341619670832008-03-31T17:03:00.003+08:002008-07-19T01:36:22.866+08:00the rainin my heart, in my heart...
the hope
on the cloud, on the cloud...
the dream
far away, far away...
the tomorrow
sing the same, sing the same...
shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.comtag:blogger.com,1999:blog-8142021398805582000.post-82925774826781533452008-03-25T23:29:00.003+08:002008-03-25T23:42:17.752+08:00.sqlitercI never notice that sqlite3 also support rc file. Write all convenient setting you like as ".header on"...etc in it. and never set it again when using sqlite3.shellinghttp://www.blogger.com/profile/03349665394793041301noreply@blogger.com