tjy 錄音剪接
tjm 修改網頁產生器,解決掉簡體問題
Trackback URL: http://blog.fhl.net/trackback.php?id=212
php的iconv是個非常好用的函數,可以輕易達成繁簡體轉碼的功能, 但是這個函數有個缺點,當我們輸入「【囧男孩】為什麼你要一直笑呢?」這段字,由於 「囧」這個字不是gb2312支援的字,結果整個輸出會變成「【」,後面的字串全部會消失,而且 php端沒有任何錯誤信息(return也不會變成 false)。
為了解決這個問題,我用了轉回來的字串長度作為檢驗標竿,看看轉回來的字串是否正確,如果不正確,就用二分逼近法,先把正確的部份轉出來,把不正確的部份用遞迴方式繼續切割下去轉,最後把那個造成問題的字換成「?」,這樣就解決了問題。
<?php
function trangb($str)
{
$nstr=iconv('utf-8','big5',$str);
if (iconv_strlen($str,'utf-8')!=iconv_strlen($nstr,'big5'))
$nstr=riconv('utf-8','big5',$str);
$pnstr=iconv('big5','gb2312',$nstr);
if (iconv_strlen($nstr,'big5')!=iconv_strlen($pnstr,'gb2312'))
$pnstr=riconv('big5','gb2312',$nstr);
$nstr= iconv('gb2312','utf-8',$pnstr);
return $nstr;
}
function riconv($loc1,$loc2,$str)
{
$i=iconv_strlen($str,$loc1);
if ($i<=1)
return '?';
$blen=(int)($i/2);
$elen=$i-$blen;
$bstr=iconv_substr($str,0,$blen,$loc1);
$nbstr=iconv($loc1,$loc2,$bstr);
if (iconv_strlen($bstr,$loc1)!=iconv_strlen($nbstr,$loc2))
$nbstr=riconv($loc1,$loc2,$bstr);
$estr=iconv_substr($str,$blen,$elen,$loc1);
$nestr=iconv($loc1,$loc2,$estr);
if (iconv_strlen($estr,$loc1)!=iconv_strlen($nestr,$loc2))
$nestr=riconv($loc1,$loc2,$estr);
return $nbstr.$nestr;
}
echo trangb("【囧男孩】為什麼你要一直笑呢?");
?>
Trackback URL: http://blog.fhl.net/trackback.php?id=211
我最近買了一台Nokia E65(因為以前的手機掉到地上一台變成兩台,沒救了,又等不到google的手機平台出現),這台機器蠻好用的,可惜鍵盤很小,要輸入資料的話會耗掉半條命。因此只能在大電腦上輸入,再靠同步的方式輸入手機。
不過Nokia原廠的程式只能與XP、Vista同步,其實一開始我並不討厭Vista,我的電腦也裝了一個Vista,但是Vista開機實在太慢了。加上我的Linux上面自從跑了VirtualBox、裝了XP之後,實在是不需要再開進去Vista。好啦!於是每次我都是因為要更新聯絡人或行事曆才忍耐好幾分鐘,等Vista開機,輸入完、同步完又開回Linux,這樣實在有點笨笨的。
於是,昨天我下定決心要想辦法讓Nokia E65跟Linux上的Evolution同步,這樣我就可以完全擺脫Vista。很不幸的google裡面找到的東西都是 Ubuntu的說明(看來Fedora真的是危險了) ,害我自己K menu搞了一個晚上才搞定。為了怕忘記,再這裡寫個小抄。
第一步,先搞定藍芽連接
yum install bluez-utils bluetooth gnome-bluetooth
service bluetooth start
vi /etc/bluetooth/hcid.conf 編輯一下內容,讓手機跟電腦配對上(蠻容易的,莫名其妙就好了)
用 sdptool browse 來看一下手機的藍芽 address
通常是
00:17:E3:xx:xx:xx 這樣的形式
第二步,設定同步
先裝他個一大堆 opensync 的plugin
yum install libopensync-plugin-evolution2.i386 libopensync-plugin-file.i386 libopensync-plugin-synce.noarch libopensync.i386 libopensync-devel.i386 libopensync-plugin-gnokii.i386 libsyncml-0.4.5-2.fc9.i386 libopensync-plugin-syncml-0.35-4.fc9.i386
然後開始
msynctool --addgroup nok 建立group
msynctool --addmember nok evo2-sync 設定第一個成員是 evolution
msynctool --addmember nok syncml-obex-client 設定第二個成員是手機的控制系統
msynctool --configure nok 1 設定 evolution修改成
<?xml version="1.0"?>
<config>
<address_path>file:///home/username/.evolution/addressbook/local/system</address_path>
<calendar_path>default</calendar_path>
<memos_path>default</memos_path>
<tasks_path>default</tasks_path>
</config>
記得要把 username 改成自己的id,其實那一段就是定義自己的evolution資料庫放哪裡
msynctool --configure nok 2 設定手機的資訊
<?xml version="1.0"?>
<config>
<!-- (Only for bluetooth) The bluetooth address if the bluetooth mode is selected -->
<bluetooth_address>00:17:xx:xx:xx:xx</bluetooth_address>
<!-- (Only for bluetooth) The bluetooth channel to use. `sdptool browse $MAC` to search for the correct channel -->
<bluetooth_channel>14</bluetooth_channel>
......
<recvLimit>10000</recvLimit>
<maxObjSize>0</maxObjSize>
<!-- XXX: Currently you need to write this by your own.
Later it's planned to create such entries on the fly during
the discovery() call. Example database field:
-->
<database>
<name>Contacts</name>
<objtype>contact</objtype>
<objformat>vcard21</objformat>
</database>
<database>
<name>Calendar</name>
<objtype>event</objtype>
<objformat>vevent10</objformat>
</database>
紅色部份就是要改的,不過我還無法同步「待辦事項」,這個對我來說比較不重要....
msynctool --sync nok --conflict i 設定好了就可以同步了
這個同步系統比較陽春(不過會成功就好了),需要自己處理一下衝突的狀況,上面那個 --conflict i 就是要求
如果兩筆資料一樣,就不要忽略不處理,不然每次都會問我要怎麼辦,這樣會回答的半死。
以後只要定期 msynctool --sync nok --conflict i 即可
Trackback URL: http://blog.fhl.net/trackback.php?id=207
1.資料轉入: 必須下 update unv set txt=replace(txt,'‧',''); 把「‧」刪除,否則會造成轉換錯誤
2.語言選擇: config.php GBCODE=1 就是簡體 GBCODE=0 就是繁體
3.字型檔案: 放在 home directory的 pfont與 gfont中,要複製到 parsing與 parsing檔案中
4.default版面選擇: gen_hb.php裡面有兩個 if ($st==0 && $tab==1) 要同步修改,第一個st 控制strong number的位置、tab控制格式
5. 產生的指令 wget --timeout=300000 http://xxx.xxx.xxx.xxx/gen_hb.php &
要加 timeout,不然會出現問題
Trackback URL: http://blog.fhl.net/trackback.php?id=202
這個問題我解了好久,簡單的作法是採用
http://googlemapsbook.com/2007/01/22/extending-gmarker/
http://googlemapsbook.com/2007/03/06/clickable-labeledmarker/
的解決方案
下載 http://google-maps-api.googlegroups.com/web/labeledMarker.js?gda=CyI1HkAAAAApUqsX-WXty5Tu-XmbEKmxnfu1955LlIyxx9ZaA58t_DE72RpmLLwWH5dSX_LoXxYH1DI0V7_0lrJuE6jdmmyJ
之後,用以下的方法引用即可
<script src="labeledmarker.js" type="text/javascript"></script>
......
var point0 = new GLatLng(32.810166495054,35.448489560853);
var mark0=new LabeledMarker(point0,{title:"加利利",labelText:"加利利"});
map.addOverlay(mark0);
Trackback URL: http://blog.fhl.net/trackback.php?id=200
Linux啟動方式
可能要 export LD_LIBRARY_PATH=/usr/local/lib
Windows啟動方式:先去 http://arrozcru.no-ip.org/ffmpeg_builds/ 抓下執行檔來
直接執行exe檔即可
Windows上抓 Webcam 影像
ffmpeg.exe -f vfwcap -r 15 -i 0 -vframes 1 aaa%d.jpg 抓一張jpg
ffmpeg.exe -f vfwcap -r 15 -i 0 aaa.mpg 錄 mpeg檔案
Linux上抓Webcam影像
/usr/local/bin/ffmpeg -r 15 -f video4linux2 -s 320x200 -i /dev/video0 -vframes 1 aab%d.jpg
/usr/local/bin/ffmpeg -r 15 -f video4linux2 -s 320x200 -i /dev/video -vframes 1 aab%d.jpg
上面都是抓一張影像,一定要給影像長寬
/usr/local/bin/ffmpeg -r 15 -f video4linux2 -s 320x200 -i /dev/video abc.mpg 則是錄檔案
Linux上錄製 mjpeg格式的指令格式,windows 只要執行檔即可
/usr/local/bin/ffmpeg -f mjpeg -i http://user:password@xxx.xxx.xxx.000/axis-cgi/mjpg/video.cgi -r 25 out.mpg
/usr/local/bin/ffmpeg -f mjpeg -i http://user:password@xxx.xxx.xxx.000/axis-cgi/mjpg/video.cgi -r 25 -t 600 out.mpg
加上 -t 600 就會限制只錄十分鐘
Trackback URL: http://blog.fhl.net/trackback.php?id=198
| « | 十月 2008 | » | ||||
|---|---|---|---|---|---|---|
| 一 | 二 | 三 | 四 | 五 | 六 | 日 |
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | ||