網頁

2011年12月22日 星期四

FreeBSD IP Alias: Setup 2 or More IP address on One NIC

Set ip alias using ifconfig command line utility

Login as the root user.

Now, use ifconfig command as follows to set alias:
# ifconfig lnc0 192.168.1.5 netmask 255.255.255.255 alias
Persistent IP Alias Configuration

Edit file /etc/rc.conf to setup persistent ip aliasing option by appending following configuration, so that next time FreeBSD comes up (after restart/shutdown) it will create alias for you:
ifconfig_lnc0_alias0="192.168.1.5 netmask 255.255.255.255"

Finally, Restart FreeBSD network service using network restart script:
# /etc/rc.d/netif restart && /etc/rc.d/routing restart
Display alias and real ip using ifconfig lnc0 command:
# ifconfig lnc0

2011年12月21日 星期三

Subversion on NFS

svn repos置放於NFS上時所造成的問題,當commit時發生錯誤,如下:

svn: Commit failed (details follow):
svn: Can't get exclusive lock on file '/storage/openfoundry/repos/ntoutest/db/txn-current-lock': Operation not supported

處理方式
/etc/rc.conf 加入以下三行,重新啟動系統

nfs_client_enable="YES"
rpc_lockd_enable="YES"
rpc_statd_enable="YES"

FreeBSD主機校時與時區設定

主機校時設定:

開機時,就校時乙次:
在 /etc/rc.conf 中加入:
ntpdate_enable="YES"
ntpdate_flags="clock.stdtime.gov.tw"

開機後,定時校時:
crontab 簡介:
在 /etc/periodic/ 資料夾中有三個目錄:

drwxr-xr-x 2 root wheel 1024 10 Giu 21:34 daily
drwxr-xr-x 2 root wheel 512 10 Giu 21:34 monthly
drwxr-xr-x 2 root wheel 512 10 Giu 21:34 weekly

而 /etc/crontab 中亦已定義每日、每週、每月定時分別執行各該目錄下的程序檔案。

我選擇每月定時校時:
編輯 /etc/periodic/monthly/190.ntpdate 檔,內容如下:
#!/bin/sh
echo
echo '主機校時:'
/usr/sbin/ntpdate clock.stdtime.gov.tw

chmod +x /etc/periodic/monthly/190.ntpdate

心血來潮時,手動校時。只有 root 才能做校時設定哦:
ntpdate clock.stdtime.gov.tw

2011年12月14日 星期三

Ubuntu gedit add plugin

Download plugin from Gedit/Plugins
Copy files to .local/share/gedit/plugins/ or /usr/lib/gedit/plugins/
Use plugin from gedit > edit > preferences > plugins > select your plugin.

e.g.
regular expressions plugin
download: regex_replace-gedit3.tar.gz
Copy files to .local/share/gedit/plugins/ or /usr/lib/gedit/plugins/
start gedit > edit > preferences > plugins > put a checkmark on "regular expressions"

2011年8月10日 星期三

網頁中的元素到底誰bind了那些event呢?

看到這篇JQuery之軛提到,用jQuery等Library,許多event是用bind的,到最後bind了什麼都不知道,也不好Debug。

所以想來找找有什麼方法可以知道,什麼元素bind了什麼event。

先看最後知道可以的工具,就是Firefox的Firebug(此時是Firefox5),
在HTML檢視下,可以看到某Button,後面附加了jQuery16208644716556509593=Object { events={...}, handle=function()},點一下就可看到其bind的事件了,真是了不起。

再來看看用程式的方法,如何查看,這裏只有jQuery的部份,例如以下,button bind兩個事件click及blur,然後程式用$.data,可以查詢events:



然後以下找到的這段程式,可以往下探索物件的結構
http://stackoverflow.com/questions/5357442/how-to-inspect-javascript-objects,
目的是想知道除了event名稱外,其內容為何?
測試結果是簡單的程式碼ok,複雜的不行,例如:jQuery.proxy(...),然後查到的結困,可能很難看得懂。
但這程式實際測試會掛掉或錯誤,原因在於物件層次太深太雜,就像跑不完一樣,
所以要看你查詢的物件狀態,若是範例中的document,其MAX ITERATIONS,可能得設為1才能正常運作。



2011年3月25日 星期五

Ruby19 encoding issues

ruby1.9 encoding issues

To upgrade without any errors you should add this line at the top of all your ruby scripts:

# encoding: utf-8

otherwise it’ll throw SyntaxErrors: “invalid multibtyte char (US-ASCII)”

Also you should use mysql2 gem (or new versions of pg and sqlite-ruby) in your application, otherwise you’ll see:

Encoding::CompatibilityError: incompatible character encoding: UTF-8 and ASCII-8BIT

from:http://def-end.com/post/3065938198/ruby1-9-encoding-issues

Ruby執行系統指令

如果是要直接呼叫系統指令,底下有幾種方式可以呼叫系統指令

`` # 就是在鍵盤上"ㄅ"左邊那個按鍵,通常跟"~"印在一起
%x() # 括號也可以用雙引號代替,像是%x""或者%x!!
exec # 透過exec來執行系統指令的話,會在執行結束後一併結束Ruby
system # 用法跟exec一樣,但是結束指令時並不會一併結束Ruby

來源:http://ithelp.ithome.com.tw/question/10000145

2011年1月28日 星期五

Google docs無法建立舊文件格式,怎麼辦?

Google docs無法建立舊文件格式,怎麼辦?
如何使用Google docs的舊文件格式。(可以設定CSS及編輯HTML的版本)

其實很簡單,先拿一份舊文件,再按"檔案"->"建立副本"即可
如果要讓History很乾淨,就把這份副本"清單淨",然後再建立副本。

不過這種舊格式,將來會被Google怎麼處理?實在是不知道。

2011年1月15日 星期六

Ruby heredoc note





From: Ruby Language Reference Manual - Syntax

Passenger-top 0.3 released

passenger-top is like unix top command for passenger.

Ruby on Rails passenger has passenger-status can view instance status. but I wanted it similar to top command, so I created this project.

Download
checkout or download “passenger-top.rb“

How to use?