星期一, 12月 07, 2009

work around with vimdiff + cvs diff

We'd like to make cvs's diff output colorful.

If you're vim people, you could do it in 2 ways.



  • Redirect cvs diff to vim by "| vim -".

    Then change highlight settings in .vimrc as follows:




    • hi diffAdded ctermfg=Yellow ctermbg=DarkGray guifg=Yellow


    • hi diffRemoved ctermfg=Red ctermbg=DarkGray guifg=Red




  • Or, you could use vimdiff by running the script(cvsvimdiff.sh) in the end.

    This script let you enjoy vimdiff's block diff with cvs.

    Usage: "cvsvimdiff -r version1 -r version2 filename"

    Besides, you should change color scheme to make a comfortable displays of vimdiff.




    • hi DiffAdd term=reverse cterm=bold ctermbg=green ctermfg=white


    • hi DiffChange term=reverse cterm=bold ctermbg=cyan ctermfg=black


    • hi DiffText term=reverse cterm=bold ctermbg=gray ctermfg=black


    • hi DiffDelete term=reverse cterm=bold ctermbg=red ctermfg=black





The following is cvsvimdiff.sh. You can create it and put it in your PATH.



#!/bin/bash

#

# Copyright (C) 2005-2006,

# Stefano Zacchiroli

# Enrico Tassi

#

# This is free software, you can redistribute it and/or modify it under the

# terms of the GNU General Public License version 2 as published by the Free

# Software Foundation.

#



vimdiff="vimdiff"

suffix="vimcvsdiff"

rev1="HEAD"



if [ "$1" == "-g" ] ; then

vimdiff="gvimdiff -f"

shift 1

fi

if [ "$1" == "-r" ]; then

rev1="$2"

shift 2

fi

if [ "$1" == "-r" ]; then

rev2="$2"

shift 2

fi



files="$1"

if [ -z "$files" ]; then

files=$(cvs -n update -r HEAD 2> /dev/null | grep -e "^[MU]" | cut -c 3-)

fi

for f in $files; do

if ! [ -f $f ]; then break; fi

patch=`mktemp $prefix.XXXXXX`

orig=`mktemp $prefix.XXXXXX`

trap "rm -f $patch $orig" EXIT



if ! [ -z "$rev2" ]; then

tmp1=$f.$rev1

tmp2=$f.$rev2

cvs up -p -r $rev1 $f > $tmp1

cvs up -p -r $rev2 $f > $tmp2

$vimdiff $tmp1 $tmp2

rm -f $tmp1 $tmp2

else

cp "$f" $orig

cut -d '/' -f 2 < CVS/Entries | grep "^$f\$" > /dev/null || break

cvs diff -r $rev1 -u "$f" > $patch

if ! [ $? -eq 1 ]; then break; fi

cp "$f" $orig

patch -R -p0 $orig $patch

$vimdiff $orig $f

fi

done


星期日, 11月 22, 2009

iphone addressbook 排序方式


iphone的contacts有很多種排序方式。比如筆劃、拼音、英文字母排序等。以OS 3.1.2而言,排序方式是照系統語系設定;繁中=筆劃,簡中=拼音,英語=字母。然而,筆劃排序不受大眾所喜愛。(除了很熟字典的人,誰會用筆劃排序阿Orz) 所以就出現了許多workaround;像是在last name寫" C.陳"。如此的確可以讓contact照拼音排序,不過又醜又麻煩。



後來,我查到了contact中有隱藏欄位「Phonetic Last/First Name」。如果在OS X中的AddressBook加入此欄位,並且在Phonetic Last Name中打上羅馬/漢語拼音。那麼就會照拼音排序嘍~!

這似乎是個perfect solution ?



不。當以上的方式,碰上了iphone voice control,一切就變了樣。以3.1.2而言,Voice control已經可以獨立設定語系。可是當你用中文發音之後,voice control的reply竟然是讀phonetic name..... 以小弟的聽力,實在是很難確認是哪個人名,還得看iphone螢幕確認一次。這麼一來,voice control的實用性大幅下降。



所以,要兼顧2者的實用性,最好的方式就是將contact排序與系統語系分開設定。

以下就教你,如何自訂contact的排序方式~



原來contact中的排序方式,是寫在以下的plist中。



/System/Library/Frameworks/AddressBook.framework/xxx.lproj/ABContactSections.plist


所以只要把想要的排序方式從A語系copy到目前的系統語系,就能轉換成所要的排序方式!



比如我想要讓英語界面下的addressbook以簡中的拼音方式排序,那麼就進入ssh



iphone#cd /System/Library/Frameworks/AddressBook.framework/Englist.lproj/

iphone#mv ABContactSections.plist ABContactSections.plist.origin

iphone#ln -s ../zh_CN.lproj/ABContactSections.plist ABContactSections.plist


然後重開機,或是把系統語系換成別的再換回來。即可生效!

星期六, 11月 21, 2009

Iphoto 09 face recognition - rescanning faces

Since my iphoto is a mass, I dont want to recognize faces before finishing photo organization.
After the work done, I just cant find the option of "rescanning faces" !

How thankful as I saw the tips of enable rescanning in apple-support-discussions by BobbrkerMyHero.

Here comes the solution of rescanning faces.
**Before we start I recommend you BACKUP your iphoto with time machine or manually, or whatever you want to do. If you don't back it up and for some reason it doesn't work, don't blame me**

If you want to rescan the faces in your library this is all you need to do:

***CLOSE IPHOTO BEFORE YOU START THIS***
Open finder, go to your pictures folder.

-Find the "iPhoto Library"
-Right click (control click) on it
-Click "Show Package Contents"
-Find the files that hold the face detection information
Should be something like:
"face_blob.db"
"face.db"

-You need to move these files out of the folder, you can either delete them, or just move them to the desktop just in case something goes wrong.
-Open iPhoto back up, and it should rescan for faces!
-If everything goes correctly, you can delete the old files you moved to your desktop if you didn't delete them before.

星期二, 11月 10, 2009

[WTF]iphone contact + google contact + facebook photo

目前還沒有看到傻瓜化的app能做到iphone + google + facebook sync
原因不外乎是google本身提供的name只有一個欄位, 且sync時只會把"完全"一樣的contact合併。
除非平常就把google contact整理的很好,不然.... sync下去只會讓iphone內更亂而已

另外, 以中文語系的使用者而言,按姓氏拼音/筆劃排序,是比較實用的方式。
不過目前iphone採用中文界面=筆劃,英文=phonetic(預設未開啟此欄) last name sorting

更有趣的是,如果你喜歡用聲控撥號,那麼phonetic last/first name會影響到iphone 3gs內部的發音。如果單純使用last/first name,那3gs的聲控還算完美。

以聲控+contact排序而言,看來是需要一套app能不依賴phonetic欄位,將contact以喜愛的方式排序,如此就能兼顧兩種功能。

星期日, 9月 06, 2009

Windows Media Player 12 with srt

I'm using win7 x64, coreavc 1.9.5, wmp 12.

when I install the k-codec pack x32, the wmp12 will only detect the embedded subtitles (through direct vobsub x32). no matter what file name of srt in the same folder, the wmp12 just cant detect it!

Now I found a solution. It perfectly solves the subtitle problem for a few srt files with a mkv (embedded subtitles).
Just download

K-Lite Codec Pack 64-bit

And you'll find out the wmp12 works fine with a direct vobsub x64 version.

btw..
I think it's time to switch from wmp classic to wmp12.
In my expierence, when playing large video files, the performance of wmp12 is better than classic player.
1. wmp12 is faster than classic player as program start to play.
2. wmp12 is faster than classic plaer as we seek to any point.

the simple classic player has poor I/O efficiency as loading hd rip files( 4G+ ).

========== 9.11 newly added=======
Solution for Windows media player 12 + coreavc + directvobsub(k-lite pack x32)

It's strange that wmp12 can't detect .srt files when loading coreavc.
there's a solution in coreavc's forum:
unselect the "preferred decoder" in coreavc's configuration.
then, directvobsub is loaded !

Windows Media Player 12 with CoreAVC filter

久違的技術文章!!
自從升級到了win7之後,還未試過看h.264...
結果今天才剛碰 就遇到問題。

雖安裝了coreavc 但是內建的wmp12不賞臉。
播放後,就是只用windows寫的video filter解碼
google了網路的解法,沒有total solution. 有些人是改registry,不過此法對我無效...
然而劇情極轉直下,在更新k-codec pack時,看到了下面一行...

Tools: Preferred Filter Tweaker for Windows 7

這可是9/1之後才有的好東西阿~XD
執行後直接改filter,馬上跟win7的機車filter說bye bye