2012-11-15

LINUX - ubuntu 12.04 安裝 hime

因為 gcin12.04 有問題, google 了一下大家都推用 hime 來取代 gcin;
然而在 Ubuntu Software Center 裝好 hime 後, 發現他的中文化不完全,
有些軟體如 text editor, terminal...etc 都無法輸入中文

2012-10-15

LINUX - 讓 error log 有顏色

example :
Util_Reporter::log(LOG_MARK."\033[1;31m LIGHT_RED \033[m !!!", LOG_PATH);
Util_Reporter::log(LOG_MARK."\033[1;32m LIGHT_GREEN \033[m !!!", LOG_PATH);
Util_Reporter::log(LOG_MARK."\033[1;34m LIGHT_BLUE \033[m !!!", LOG_PATH);
Util_Reporter::log(LOG_MARK."\033[1;33m YELLOW \033[m !!!", LOG_PATH);
Util_Reporter::log(LOG_MARK."\033[1;35m Light Purple \033[m !!!", LOG_PATH);
Util_Reporter::log(LOG_MARK."\033[1;36m Light Cyan \033[m !!!", LOG_PATH);
Util_Reporter::log(LOG_MARK."\033[1;37m WHITE \033[m !!!", LOG_PATH);

ref
http://chunchaichang.blogspot.tw/2011/07/printf.html
http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html

2012-10-14

LINUX - find 指令

example :
find . -name '*.webm'
find /home/www/nas/home8/upload_8 -name '*.mkv'

2012-10-13

CODE - php 字串取代

example :
$path = '/home/nas/webhd_14/e2/c3/10107664/50012/sync/a3/string';
$path = preg_replace('/home\/nas/', 'net', $path);
# output: /net/webhd_14/e2/c3/10107664/50012/sync/a3/string
$str = 'hello.@.@world';
$key = preg_replace(array('/\./', '/\@/'), '_', $str);
# output: hello||||world

2012-08-31

MAC - 設定 home & end 鍵

外接 keyboard 後發現其 home, end 鍵跟我想的不一樣
在 mac 下好像變成"頁首"與"頁尾", 實在太不習慣
google 了一下, 找到以下的方法

2012-08-30

MAC - 使用 ps2 鍵盤 + usb mouse

看起來 keyboard & mouse 分別使用哪一種連接方式有差的樣子,
以下紀錄 ps2 keyboard + usb mouse 的使用情境

2012-08-28

LINUX - 使用 ffmpeg 在影片加上 padding

要解決「LINUX - 使用 ffmpeg 合併(連接)影片」裡的直/横影片問題
參考 youtube 的做法, 把直的影 scale 成横式的影片, 再利用 padding 的方式補上黑色的底

2012-08-18

CODE - php 檢查字串的編碼

本來是要用來檢查 mediainfo parsing 後的字串, 以便轉成 xml 時不會有誤
雖然後來沒這麼做, 但還是把這段檢查紀錄一下

2012-08-17

LINUX - 利用 ffmpeg 與 MP4Box 將影片的聲音抽離

如題, 有時從 youtube 抓下來的 mv 影片我們只需要 audio 的部份,
要達成這個目的可以使用 ffmpegMP4Box 來做到

2012-08-16

LINUX - MediaInfo 使用筆記

mediainfo --help 的內容如下
--Inform=...  Specify a template (BETA)
Usage: "MediaInfo --Inform=[xxx;]Text FileName"

xxx can be: General, Video, Audio, Text, Chapter, Image, Menu
Text can be the template text, or a filename
     Filename must be in the form file://filename

See --Info-Parameters for available parameters in the text
(Parameters must be surrounded by "%" sign)

Example: "MediaInfo --Inform=Video;%AspectRatio% FileName"

Example: "MediaInfo --Inform=Video;file://Video.txt FileName"
and Video.txt contains 
"%DisplayAspectRatio%"        for Video Aspect Ratio.

Example: "MediaInfo --Inform=file://Text.txt FileName"
and Text.txt contains
"Video;%DisplayAspectRatio%"  for Video Aspect Ratio.
"Audio;%Format%"              for Audio Format.

2012-07-23

CODE - php xml to array

code as below
//$xml = implode('', $output);
$xmlObj = simplexml_load_string($xml);
$json = json_encode($xmlObj);
$arr = json_decode($json, true);
print_r($arr);

cf : http://jaspreetchahal.org/php-xml-to-array-simplest-way/

2012-07-17

2012-07-16

2012-05-11

MAC - 將 3gs 刷回 4.3.3

在 3gs 跑 ios5 本來已經不太快了, 又亂裝了一些 cydia 的東西,
造成只要開 sbsetting 就會 hang 個半分鐘... 決定刷回 4.3.3 再 jb
過程紀錄如下~

2012-05-09

TOOL - 電腦硬體故障聲音


CODE - 用 java 發 get 的 http request

...
String getUrl = "http://xx.xx/test.php?sn=xx&path=xx";
URL url = new URL(getUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
loggerHelper.log("Contents of get request");
// 取得 return 值
String lines;
while ((lines = reader.readLine()) != null){
    loggerHelper.log("lines: "+lines);
}
reader.close();
connection.disconnect();
...

cf :
http://www.jiucool.com/java-sending-http-requests-get-and-post-method-request/
http://www.exampledepot.com/egs/java.net/post.html

2012-05-07

LINUX - shell 的字串取代

sample 1 :
# 將號嗎間的空白改由 @@ 取代, 這樣多筆才能順利傳進 php 裡
# MOBILES 是變數
argv=${MOBILES/ /@@}

sample 2 :
# 將號嗎間的空白改由 @@ 取代, 這樣多筆才能順利傳進 php 裡
# /home/MOBILE_CONFIG.sh 是一個 file
sed -e "s/@@/\ /g" /home/MOBILE_CONFIG.sh



LINUX - sudo 成 root 時, 也載入 profile 設定

as title
sudo -u root bash -l



2012-05-04

TOOL - editor 的垂直選取

mac
sublime - 按 mouse 中間那顆就可以了

windows
notepad++ - alt + mouse 左鍵



cf : 



LINUX - 用 tail 顯示 log 的倒數 n 行

ex : 顯示 error.log 的倒數五行
tail -n 5 /home/logs/php/error.log


[options]
-c:--bytes=N 指定輸出檔案最後的 "N" 個字元組。
-n:--lines=N 指定輸出檔案最後 "N" 行。
-f:持續顯示檔案更新的資訊。
-q:--quiet, --silen 不輸出檔案名稱的訊息。
+n:從第n 行開始顯示到檔案結尾。


cf : http://blog.xuite.net/altohorn/linux/17259888




LINUX - 查看作業系統種類及 kernel

lsb_release -a


2012-04-16

LIFE - 早中期唐氏症篩檢的比較


中期唐氏症血清篩檢及羊膜穿刺檢查,在台灣已經有數十年的檢查歷史,而早期唐氏症篩檢是這近幾年來才開始推行的檢查,國內目前有部份醫院在做,尚未普及到全部的醫療院所,這3項檢查各有不同,孕婦要看自己的意願以及狀況,來決定是否都要做。

2012-03-28

LIFE - 五穀漿做法

材料:
1.以糙米為主
2.適量的薏仁、紫米、紅豆、綠豆(當然也可以加入其他五穀雜糧,個人習慣大概選用五種左右)
3.南杏或芝麻(或其他堅果類,我通常只搭配選用一種,我喜歡單純的口味)
4.糖(個人習慣用楓糖漿,因為喜歡它獨特的香甜)

做法:
用電子鍋把1及2的材料煮成稀飯,然後連同3及4的材料放入果汁機,如果太稠就加些開水,打成稠稠類似米漿、玉米穠湯的口感。

cf :
http://mypaper.pchome.com.tw/tc0927e/post/1283021202
http://lihaw.pixnet.net/blog/post/3153...9B%8B%E9%A4%85

2012-03-21

LIFE - 碩士班

xdite - 我不會唸碩士
vgod - 我為什麼要念博士 <= 但他是在 MIT 唸啊, level 不同於一般人...Orz

你想過怎樣的人生, 重視什麼樣的事情, 是由你自己決定的 !
我們都在追求更好的生活 ! 加油吧 !

2012-03-15

MAC - about battery tips


a) Fully charge your MacBook.
b) Once fully charged, leave it plugged in for at least another 2 hours.
c) Remove the MagSafe power adapter, and use your computer until you get the battery level warning message.
d) Ignore that message and keep running your notebook.
e) Eventually the machine will go to sleep.
f) Do NOT plug it in. Instead, let it sleep for at least 5 hours.
g) After the time has passed, plug it back in, and let it fully charge.
h) Once fully charged, your battery has been properly calibrated.


以下電池校正資訊來源為 Apple,適用於 PowerBook G4 (15 吋、雙層 SD)、MacBook (所有機型)、MacBook Pro (所有機型)、MacBook Pro (17 吋) (所有機型) 以及 MacBook Air。

 1. 插入電源轉換器並充足 PowerBook 電池的電力,直到電源轉換器上的指示燈或 LED 變成綠色,且選單列中

   的螢幕計量器指出電池已充足電為止。

 2. 讓電池保持在充足電力的狀態下至少兩小時。在此期間只要插上電源轉換器,仍然可以使用電腦。

 3. 在電腦的電源仍開啟時拔除電源轉換器,開始使用電池的電力讓電腦運轉。您可在這段時間內使用電腦。

   電池電力降低時,螢幕上會出現電池電力不足的警告對話框。

 4. 這時請儲存所有工作。請繼續使用電腦。如果電池電力非常低,電腦會自動進入睡眠狀態。

 5. 關閉電腦,或讓電腦處於睡眠狀態至少五小時。

 6. 接上電源轉換器,在電池再次充足電力之前都不要將其拔除。

注意:電池校正約一個月做一次或 30 個充電循環做一次即可,常常校正可能會對電池產生不良影響。


cf : http://www.macuknow.com/node/1289


MAC - 更改開檔的預設程式


CODE - 用 PHP Simple HTML DOM Parser 來抓網頁內容

利用 PHP Simple HTML DOM Parser 來抓網頁內容, 如下圖

CODE - php 觀察記憶體用量 & 釋放記憶體

2012-03-03

MAC - 使用 svn


LINUX - zypper 使用紀錄

ex : 重裝 php

LINUX - ssh 連線後的 can't set the locale... 錯誤

ssh 連線後顯示 can't set the locale; make sure $LC_* and $LANG are correct
原本想不理它, 但好像會導致某些操作或指怪怪的....
解法如下 :

MAC - 用 Welly 上 bbs


CODE - 正規表示式

參考
http://atedev.wordpress.com/...-regular-expression/
http://blog.roodo.com/linpapa/archives/8398099.html
http://www.webtech.tw/info.php?tid=46


CODE - 調整 php 程式 timeout 時間的上限

有二個方法

LINUX - curl 與 wget 的使用範例

LIFE - 「獵魔教士3D」觀感


2012-03-02

2012-02-16

CODE - 多筆查詢的 java sample code

很久沒寫了, 突然要寫還真是花了很多時間
把以前寫的 code 翻出來記到 blog, 方便以後再碰到~

2012-02-03

LINUX - 增加 php 的 configure 的參數

若碰到以 tar ball 安裝好的 php 需要補增參數時, 做法如下
以增加 --enable-pcntl 為例

2012-01-16

MAC - .bashrc 位置

在 mac 下要使用 ~/.bash_profile 來存放常用的 alias 指令

MAC - 更改電腦名稱

拿到 MBA 時的預設電腦名稱好長,改的方法如下

System Preferences -> SharingComputer Name

誰會想到會在 Sharing 裡啊 = =
沒想到連改這個都要查姑狗...


2012-01-04

CODE - 修正 php 的 DOS 問題

DOS 利用了 insert array 時的大量的 Hash Collision 造成 CPU 100%
幾乎所有語言都不能倖免 (除了 Perl)

紀錄一下同事提出的解決方式