2009年12月31日 星期四

Eclipse 啟動 Tomcat 超過 45秒會出現 timtout 訊息

編輯
/workspace/.metadata/.plugins/org.eclipse.wst.server.core/servers.xml

修改
start-timeout="45"

Flash Builder 4 中文快速入門 (簡中)

需用 Adobe Reader 9 開啟
http://www.airia.cn/flashbuilder/fb4Qbook/source/

Tutorial: DisplayShelf Component in Flex

類似 itune 的找 CD 功能
http://www.quietlyscheming.com/blog/components/tutorial-displayshelf-component/

2009年12月29日 星期二

使用 a2enmod 指令啟用 Apache 模組

a2enmod ssl
a2enmod userdir
a2enmod rewrite
a2enmod suexec
a2enmod include

http://philipatswarchy.wordpress.com/category/technical/ssl/

隱藏 Apache, PHP 的版本

php.ini
expose_php = off

httpd.conf
ServerSignature Off
ServerTokens Prod

http://www.backup.idv.tw/viewtopic.php?t=821

2009年12月28日 星期一

骨折不宜多補鈣?!

http://hospital.kingnet.com.tw/essay/essay.html?category=%B9D%C5%A5%A4%A3%B6%EE%BB%A1&pid=5218

初生兒可吃益生菌嗎?

小孩從出生就都會吐奶,又常常打膈、脹氣,是不是腸胃比較不好?親友建議可以讓孩子食用益生菌,對他會不會比較ok?謝謝。

http://hospital.kingnet.com.tw/essay/essay.html?pid=21539&category=%B9D%C5%A5%A4%A3%B6%EE%BB%A1

XHProf: A Hierarchical Profiler for PHP

應該類似於 xdebug,不支援 windows
http://pecl.php.net/package/xhprof/

2009年12月11日 星期五

Java Exception: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionfactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]

簡而言之,就是缺少 javassist.jar
http://jboss.org/javassist/downloads/

設定 Tomcat Hot Deploy

編輯 %CATALINA_HOME%\conf\context.xml
加入下面兩項 attributes,不然無法 hot deploy
<Context>
<Context antijarlocking="true" antiresourcelocking="true"></context>
直接用 Ant 部署,只要更新 webapps 下面的 *.war 之前,先刪除 war 即可。

<property name="warfile" value="foo"/>    
<property name="deploydir"  value="c:\tomcat\webapps"/>

<delete file="${deploydir}\${warfile}.war"/>
<delete file="${deploydir}\${warfile}.war"/>
        <copy todir="${deploydir}" overwrite="true">
        <fileset dir=".">
            <include name="*.war"/>
        </fileset>
</copy>

測試環境是 Tomcat 5.5, win32

2009年12月8日 星期二

Eclipse 裝 Hibernate Tool

http://download.jboss.org/jbosstools/updates/stable/

MySQL Workbench for ER Modeling

發現 mysql 官方多了一項工具,裡面含有 DBDesigner4

MySQL Workbench

http://dev.mysql.com/downloads/select.php?id=8

2009年12月7日 星期一

2009年12月4日 星期五

MacBook Pro 安裝 OpenSolaris 2008.05

http://weblogs.java.net/blog/bleonard/archive/2008/05/_opensolaris_20.html

在 console 下寄送 email (Linux/Win32)

mailsend
http://www.muquit.com/muquit/software/mailsend/mailsend.html

Linux Kernel 之 Intel CC patch

聽說有的情況可以快 40%,平均也有 8~9%
http://www.linuxdna.com/
http://www.linuxjournal.com/content/linuxdna-supercharges-linux-intel-cc-compiler

如果 Linux 死機 : SysRq Key

To recover from a frozen linux system
Press and hold down ALT + SysRq (PrintScn) button and type phrase R E I S U B with 1 second interval between each letter.
Your system will magically recover from the crash and reboot itself.

http://alejandrocuervo.com/reisub/
http://linuxtoy.org/archives/what-to-do-if-linux-crash.html

在 Linux 下查詢 process 開了哪些檔案

lsof
http://ph7spot.com/musings/leveraging-lsof

2009年12月2日 星期三

Barcode in Java/PHP

PHP
php-barcode (Win32, Unix-Like 都可用)
http://www.ashberg.de/php-barcode/
設定 genbarcode 的位置,若與 php code 放同目錄的話
$genbarcode_loc="genbarcode.exe";

Java
barbecue 
http://barbecue.sourceforge.net/
整包 war 放到 ap server 即可使用其 servlet
經測試,在 jboss-402 下面運作正常

以上都是從 web 生成 image,若是在 Linux Desktop 使用,據說有 kbarcode
http://www.kbarcode.net/

2009年12月1日 星期二

Virtual Private Server (VPS) 的性能比較

VPS 性能比較
http://blog.gslin.org/archives/2009/11/30/2173/
http://journal.uggedal.com/vps-performance-comparison

http://www.linode.com/
記憶體較少,但速度較快

其他不在比較之內,但看似不錯的方案

可用 Ubuntu 9.04, 使用 RAID-10
http://www.slicehost.com/

2009年11月26日 星期四

Lazarus - is an open source development environment that strives to be Delphi compatible

http://wiki.lazarus.freepascal.org/Screenshots

過去常常用到 Delphi,編譯很快速,Linux 版本的話有 Kylix,不再出新版,可以說已經沒有前景可言
Lazurus 有點像是支援多平台的 Delphi,看到它的 screenshot 感覺好親切!

Disable VNC or setup for Localhost access only and use an SSH tunnel

同學說要裝 VNC,由於被同事教育的結果,聽到 VNC 就覺得很刺耳
據說 VNC 經常有漏洞傳出,印象中,之前有個洞是,免密碼就能登入
在我們公司,禁止安裝 VNC 在 server 上面

若真的要用,建議加上 SSH port forwarding,然後只有本機 IP 能連 VNC
http://security.fnal.gov/CriticalVuln/vnc.html
這樣外部 IP 無法直接對 VNC port 連線,安全性大增,而且是 SSH tunnel

有 sshd for win32, 非商用免費 http://www.bitvise.com/download-area.html
client 用 putty http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

PS. 之前玩 Google 提供的 Hadoop 主機,也是用 SSL port forwarding 去看 Hadoop 的網頁

2009年11月25日 星期三

轉貼: Windows 7 使用技巧

http://blog.joytown.tw/2009/09/07/545

10、從隨身碟安裝
28、有效解決Windows 7下刪除檔案提示被佔用
33、解開32位元Win 7記憶體4GB限制

Apache CouchDB: The CouchDB Project

Apache CouchDB
http://couchdb.apache.org/

Ubuntu 9.10 server 有支援這個 DB,據 Apache 網站說它是個 document-oriented database,總之跟平常用的 relation database 不一樣,但真正讓我感興趣的是,它是用 Erlang 開發的, 或許能透過這專案來學習 Erlang

另一個我知道用 Erlang 開發的 DB 就是 Mnesia,不過據聞不合適儲存大量資料 (待實驗)

Firefox 附加元件 - JSONView

https://addons.mozilla.org/zh-TW/firefox/addon/10869

Normally when encountering a JSON document (content type "application/json"), Firefox simply prompts you to download the file. With the JSONView extension, JSON documents are shown in the browser similar to how XML documents are shown. The document is formatted, highlighted, and arrays and objects can be collapsed. Even if the JSON document contains errors, JSONView will still show the raw text.
Once you've got JSONView installed, check out http://brh.numbera.com/software/jsonview/example.json to see the extension in action!

Find Open Source Alternatives to commercial software | Open Source Alternative - osalt.com

這個網站專門收集一些 Open Source 專案,做為 Commercial Software 的替代方案

http://www.osalt.com/

另外,排名在前十名的 Clonezilla 是台灣人開發的!~

Sunon 建準電機 - 世界最小的風扇Mighty Mini Fan & Blower

這家公司相當有誠意,如果你 NB 風扇掛點
可以拍照寄過去,他們免費提供替代風扇 (如果有類似的規格)
詳情請看
http://www.sunon.com.tw/contact/contact_NB_TC_new.htm

本來我的 Sony VAIO V505 GTP 風扇不太會動
結果我拆機灌上矽油後,風扇回復原來的強勁,又是一尾活龍,我就沒去拿免費風扇~
若有需要更換 NB 風扇、鼓風扇的話,可以跟他們聯絡看看

這是網路找到的 V505 分解圖片
http://blog.sina.com.cn/s/blog_4fe80eb101007ww9.html

如果大台北地區的朋友需要清理 VAIO V505 的風扇,歡迎聯絡我
其他 NB 沒拆過,相信也不會有人想給我當白老鼠 >.<

Firefox 附加元件 - Live HTTP Headers

平常要 debug ajax, web 多半用 fiddler,也算是相安無事
不過,如果要追 HTTPS 下的 request/respone header 就沒辦法再用 fiddler


若還有跳頁 (redirect page)的話,將連 FireBug 也不能用,HTTP Request Log 會被清掉

這時要改用 Live HTTP Headers 這個 Firefox 的 add-on

https://addons.mozilla.org/zh-TW/firefox/addon/3829

但同事特別提醒,水能載促舟亦能覆舟
 

網頁相容性測試 for Internet Explorer Versions from 5.5 to 8

Requirement


Windows 7, Windows Vista or Windows XP with IE7 minimum (Windows XP/IE6 config has some problems and IE8 instance do not work under XP without IE7)

Known problems and limitations :

  • The Previous/Next buttons are not working properly
  • Focus is not working properly
  • Java applets are not working
  • Flash is not working on IE6 instance in user mode : A solution is to launch IETester as admin user and Flash will work.
  • CSS Filters are not working correctly in user mode : A solution is to launch IETester as admin user and CSS Filters will work.
程式下載:
http://www.my-debugbar.com/wiki/IETester/HomePage

2009年11月24日 星期二

HAProxy - The Reliable, High Performance TCP/HTTP Load Balancer

朋友在問有關 Load Balance 的問題,找到了 HAProxy
也有人推 nginx (讀作 engine x) http://nginx.org/en/

上線前要預估需要 "未來" 會用到多少硬體資源是相當困難的,特別是 public site
與其瞎子摸象亂買主機,不如弄一個比較容易擴充的架構 (high scalability)
debian lenny 裡面,只要 apt-get 即可安裝





SGI NUMAlinkR Interconnect Fabric

MPI latency: 1 usec, short msg
Bandwidth per link (unidirectional, MB/s): 3200

拿來跑 MPI 程式,會相當過癮

Virtualization - Solaris Zones, Xen, V-Server, KVM, Proxmox VE

X86 伺服器虛擬化的三種技術

朋友想買 SUN 主機玩 Zones,我們對半虛擬化環境做了一些討論
因為需求是要單一主機,安裝大量的 VM 環境,像是 vmware 這種全虛擬化的作法,就暫時不考慮,必竟硬體資源有限。朋友的目標是單一主機 200+ 個獨立環境。

目前看到下面幾種 "半虛擬化" 環境

Solaris Zones
據朋友說,resource (如 memory) 會是共同的,有點像是 SGI 的 global shared memory,用 solaris 的好處之一是可以用 ZFS。據說,OpenSolaris 也支援 Zones 但 Resource Control 未支援 (還要再查資料),有分 Small Zones/Big Zones,Big Zones 跟 chroot 相當神似。
BigAdmin: Solaris Containers (Zones)
Zones - Siwiki
Zones Resource Controls - Siwiki
Zones Best Practices - Siwiki
Xen
半虛擬化,只能跟 host 環境相同,全虛擬化才能裝異質 OS。
[Howto] XEN paravirtualization
鳥哥的 Linux 私房菜 -- 利用 Xen 進行虛擬機器的製作
V-Server
http://linux-vserver.org/Welcome_to_Linux-VServer.org
http://wiki.debian.org.tw/index.php/VServer
需要 patch linux kernel,印象中有些 linux hosting 的廠商有提供 root 權限,估計就是用這個部署的。
KVM
在 Ubuntu 下面很好裝 (待試),官網甚至有說明文件
https://help.ubuntu.com/community/KVM
http://www.vzpedia.com/1974.html
http://thundersha.blogspot.com/2008/07/ubuntu-kvmgui-sector2.html
Proxmox VE
http://pve.proxmox.com/wiki/Main_Page
http://www.pigo.idv.tw/archives/492
OpenVZ
http://wiki.openvz.org/Main_Page


其他


由 Eclipse 啟動 Tomcat 的 work 目錄

有時 jsp 會丟出這種 exception
java.lang.NullPointerException
org.apache.jsp.changepwd_jsp._jspService(changepwd_jsp.java:56)

這時就需要看一下 changepwd_jsp.java,可以用 file search 的工具去找
或是查看 work 目錄,預設為 \Tomcat\work
若是 tomcat 由 eclipse 啟動,work 目錄則為

\Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\work\

CSS Media Types

可以對依顯示、列印、行動裝置,設定不同的 CSS,算是相當妙~

http://www.w3schools.com/CSS/css_mediatypes.asp

screen, print 都容易測試,手邊沒有 handheld device 可以試,不知道是否也有效


另外,跳頁可以用 (含列印)

<p style="page-break-before:always;"> </p>

2009年11月22日 星期日

免費電子書:使用開源軟體-自己動手寫作業系統

電子書
http://share.solrex.cn/WriteOS/index_cht.html

作者 Blog
http://blog.solrex.cn/

Object-Oriented Programming With ANSI-C

Object-Oriented Programming With ANSI-C 簡稱 OOC
在某些情況下,無法使用 c++,只能用 pure c
但是又希望 c 能有些更高級的特性

英文版
http://www.planetpdf.com/codecuts/pdfs/ooc.pdf

簡中翻譯
http://wiki.chinaunix.net/index.php/OOC

apt-add,輕鬆又懶惰的使用 APT

參加 2009 Ubuntu Party 台北場,Mosky 介紹了一個好物
由作者自己介紹,可說是相當難得的機會

apt-get 相當好用,這也是我一直粘在 debian 的原因
但是,在某些情況還是有麻煩之處
例如,增加第三方 source、備份
目前看來,apt-add 似乎都解決了~



全文出處 (作者之 Blog)
http://moskyat.pixnet.net/blog/post/26260613

ATI MOBILITY RADEON LX with Ubuntu 9.10

在我的 Sony VAIO V505GTP 上面安裝 ubuntu 9.10 有些程式畫面會亂掉,kubuntu 也有此情況
若安裝 OpenSolaris 2009.6跑 LiveCD,畫面都正常

安裝 xubuntu 9.04 版,畫面正常,直接用 apt-get 升級到 9.10,部分程式畫面錯亂
修改 grub,把 kernel 切到 9.04 所附的 2.6.28,畫面還是亂掉,目前猜測是某些 library 有問題

題外話,9.10 用到 Nvidia 卡,開機後畫面會黑掉的問題,在此記錄一下
http://blog.solrex.cn/articles/fix-black-screen-problem-of-ubuntu-9-10.html

2009年11月20日 星期五

Speed Up for Ant / 加速 Ant 編譯

make -j 可以有效利用多核 CPU 來平行編譯程式碼

>man make
-j [jobs], --jobs[=jobs]
Specifies the number of jobs (commands) to run simultaneously.  If there is more than one -j option, the last one is effective.  If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously.

ant 之於 java,就如同 make 之於 c/c++

ant 應該也有類似的作法 ?
可以使用 
http://ant.apache.org/manual/CoreTasks/parallel.html
不過,跟 make -j 一樣要小心使用,以免非預期的事情發生...

2009年11月19日 星期四

sleep 指令

有時因為某些原因,會希望在 win32 的 .bat 裡面暫停一小段時間
直覺想到 linux 下面的 sleep 指令,但 win32 沒有,我用 gcc 寫了一個
也可以去找 Cygwin,內附眾多GNU Utilities,應該有 sleep
但都太麻煩...
同事的解法,我覺得還不錯,雖不能夠很精確控制 sleep 時間,但是有時是夠用的

> ping 127.0.0.1 -n 10

傳統 win32 的 batch file 真的是相當不便,難怪 ms 要搞個 PowerShell
有 shell 才容易自動化,這也是我喜歡 linux 的很大原因,有此特性將便於管理。

什麼是功率因素校正 (PFC)

晚上要去買 power,研究規格時看到 "主動式 PFC" 這項,英文稱 Active PFC
簡單說,就是比較省電,做的虛功比較少

可以參考海韻電子的網站
http://www.seasonic.com/support/c_a01.jsp#01

流著野貓的血液

http://event.beardude.com/2009/alleycat/

去年就參加過一次,相當好玩~
今年當然也要參加

Android Native Code 的繪圖方法

先記錄一下,也許之後用得到~

文章出處
http://heaven.branda.to/~thinker/GinGin_CGI.py/show_id_doc/404

Google Calendar 式樣的 Web 元件 : ZK Calendar

http://zcal.zkoss.org/

台灣人寫的,實在厲害!
正準備用來開發公司內部的行事曆

作者介紹
http://www.ithome.com.tw/itadm/article.php?c=47400

2009年11月18日 星期三

Multi-NIC Bonding on Linux 合併多張網卡

合併多張網卡,找一天實作看看,看在一張 10GB 的網卡要幾萬元的分兒上~ 若成功就賺到!

1.http://ericbbs.blogspot.com/2008/01/debian-and-ubuntu-with-26-kernel.html

2.http://forum.ubuntu.org.cn/viewtopic.php?f=24&t=30467

3.http://www.geego.com.tw/tech/05.html


Debian/Utuntu:

apt-get install ifenslave

vi /etc/network/interfaces
auto lo
iface lo inet loopback

iface eth0 inet dhcp
iface eth1 inet dhcp

auto bond0
iface bond0 inet static
address ........
netmask 255.255.255.0
gateway ........
up ifenslave bond0 eth0 eth1
down ifenslave -d bond0 eth0 eth1

vi /etc/modules
bonding

安裝 Subclipse , Eclipse with SVN

Subclipse 太舊,以致 eclipse 無法匯入 SVN project,一匯入就跳出 eclipse。

新增更新點,更新 subclipse
http://subclipse.tigris.org/update_1.6.x