Archive for March, 2009

Code posting plugin for wordpress users

任何有 blogging 的程式設計者,除了相當有興趣/耐心的人會自己寫一套 code posting interface 之外,我想大部分的人都是想要找一個好得 plugin 可以把自己的心得漂漂亮亮的 share 給讀者吧。由於自己是 WordPress 的使用者,所以我想推薦 Code snippet 這個 plugin。

其實 code 的 highlight / 顏色,順不順眼就端看個人爽快( 自己是蠻滿意他本來的設定的 ),要改也可以自己去微調( 或是大調整 )。不過他支援相當多種語言的呈現,這點倒是替我省了不少功夫。

範例如下:

[code lang="php"]
<?php
echo “Hello world!’;
?>
[/code]

會變成以下的狀態呈現:

<?php
// This shall print the hello world text :P
echo "Hello world!";
?>

算是相當好用呢!

,

4 Comments

Javascript Debugging

Gugod 大的方法,相當之聰明阿。Memo 一下:

If you are using IE and/or do not have a good debugger or console.log-ish style of tool, here’s some other quick and good alternatives to alert():

windows.status = message;
location.hash = message;
jQuery("input[type='text']").val(message);

They are better because they are all non-blocking statements.

Ref from: Gugod’s blog

, ,

No Comments

最近入手物

最近買了些『自己高興』的東西,意思就是…不怎麼實用(或是說價格和實用度不成比例?)

首先是我最愛的 Georg Jensen – Keyring crafted in stainless steel, Design:Andreas Mikkelsen

這是官方照:

GJ - Keyring

但是他真的很奇怪,要照不照正面…補一張正面我自己拍的:

GJ - Keyring face

另外就是 Giorgio Fedon 的 card case:

GF - Card case

最後就是…最宅的…Realforce 的 Red Esc 以及 遊戲用 WASD …五顆鍵帽,1.2 K 左右…那顆紅色的最貴…五百多塊…我跟 Othree 失心瘋兩人團購 囧:

Key

, , , ,

No Comments

Palm Pre

不多說,我會買。

, , ,

No Comments

Convert a MySQL DB from latin1 to UTF8

For work, I have to convert my very old database from latin1 based( with big5 in it ) to UTF8.

My Enviornment:

  • OS: Gentoo
  • Python: Python 2.4.3
  • MySQL: MySQL 5.0.70-log Gentoo Linux mysql-5.0.70-r1
  • Old encoding: latin1(big5)
  • Try to convert to: UTF8

And here’s my solution, and memo.
Assume your private parameters as following:

  • Your old db name: your_old_db
  • Your new db name: your_new_db
  • Your mysql account: your_db_acc
  • Your mysql server’s ip or dn: your_db_host
# dump out a sql through latin1 charset
mysqldump -u wwwuser -p –default-character-set=latin1 your_old_db > output.sql

# — fix origin output.sql’s big5 problem here ( do some regex replacement, it depends ) —

# convert the "real storage encoding" from "big5" to utf8, latin1 is just a tag note in db
piconv -f big5 -t utf8 output.sql > utf8.sql

# replace all charset and collate in sql file, and delete the line which include "SET NAMES latin1"
# for matching, the longer the better ex: match from "type=Mxxx….", you could do this from the beginning of each single line
sed -e ‘s/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/g’ -e ‘s/CHARSET=gbk/CHARSET=utf8/g’ -e ‘s/ collate gbk_bin//g’ -e ‘s/ COLLATE=gbk_bin//g’ -e ‘/SET NAMES latin1/d’ utf8.sql > utf8_after_sed.sql

# echo SET NAMES utf8 to a new file named tmp.sql
echo "SET NAMES utf8;" > tmp.sql

# merge the two files
cat utf8_after_sed.sql >> tmp.sql

# rename the file to utf_final.sql, just a clarify
mv tmp.sql utf8_final.sql

# import to a new unicode based db, we’re done here
mysql -h your_db_host -u your_db_acc -p –default_character_set utf8 your_new_db < utf8_ultimate.sql

Thanks sooooooo a lot for Tib‘s kindly provide his consultation.

, , , ,

No Comments

澳洲大堡礁保育員

澳洲大堡礁( Great Barrier Reef )徵保育員,之前新聞報的頗大的,聽說是 the best job in the world. :P

Great Barrier Reef

共有 50 個人入圍,最酷的是,其中有個台灣人( Claire )喔!所以不要老是覺得搶不贏外國人吧!雖然我看她票已經很多了,但是還是請大家投自家人一票吧!

更何況,她的自薦影片,真的拍得很不錯阿,不是嗎?

, , , ,

No Comments

程式設計師的格言

此篇為 but 翻譯的文章,很久以前看過,剛又看到一次。由於新 blog 網址我真的連不上,所以只好先連舊的。此文有理至極,推薦給每個軟體界的程式設計師、PM、SE、業務、客戶。

引文如下:

(版本2 2008/10/12更新)

譯註
SE是日本軟體公司裡程式設計師的頭子。自己不太寫程式,主要工作是跟客戶確認規格。
程式設計師多半自己不面對客戶。
跟PM又不一樣。(有什麼比較貼切的職稱翻譯嗎?)

—————

1
每天有24小時。
所謂的「今天之內」,是指到明天早上為止。
Read the rest of this entry »

, , , , , ,

No Comments