如果你在 svk mirror 時,出現類似 “xxx is not a mirrored path.” 或 “xxx 不是一個映射路徑。” 的錯誤時,請使用 svk propedit svm:mirror // 指令進行編輯,將有問題的路徑移除之後,就不會有問題了。
解法參考自:
trinity.vim
前兩天想說找找看 Vim 有沒有 GNU Global 的 plugin 時,看到了 trinity.vim。
這個 plugin 整合了三個 plugin:Source explorer, taglist, NERD tree 在 Vim 模擬出接近 Source Insight 的效果。
有用過 Source Insight 的人,相信都知道很難找到替代品,我前幾年也曾經試圖找過,但都一直沒找到。
這個 plugin 真的不錯,讓Vim更好用了~
有優點當然也有缺點:
- Source explorer 裡呼叫 ctags 的地方是寫死的,所以如果你的 ctags 放在別的地方,最好自行去搜索有呼叫到 ctags 的地方,加上路徑。
- 把 Source explorer 打開的時候,速度會變慢,這是因為它試圖利用 ctags 資料庫去找跟游標所在位置有關的程式片段。我自己是比較少用,不能用對我影響不大。
以 bash script 為 sqlite database 產生 C/C++ struct
最近寫的一個 bash script,用來幫你把 sqlite database 裡的 table schema 轉成 C/C++ struct。
這裡只處理 text 與 integer 型態,text 轉成 wstring/string,integer 則轉為 int。轉換的工具是使用 awk/sed。
只要稍稍改動一下,也適用在其他語言上。
#!/bin/bash
if test -z "$1"
then
echo "You need to specify the database file name."
exit -1
fi
db=$1
dbname=`basename $1 .db`
tables=`sqlite3 $db ".table"`
output="db_${dbname}_schema.h"
touch $output
cat >> $output <> $output
sqlite3 $db ".schema $table" | awk '/^\ /{printf("%s %s;",$2,$1);}' | sed -e 's/,/\ /g' | sed -e 's/text/db_string /g' | sed -e 's/integer/int /g' >> $output
struct_name=`echo $table | awk -f cap.awk`
echo "}$struct_name;" >> $output
echo "" >> $output
done
cat >> $output << EOF
#endif
EOF
# call "astyle" to format the code. Beside "astyle", you can use "indent".
astyle $output
exit 0
Project.vim
同事最近拋棄了 Source Insight 3,開始用 Vim 寫 code,所以有人跟我一起研究了。
他最近介紹我一個 plugin : project – Organize/Navigate projects of files (like IDE/buffer explorer),看起來不錯用,他可以把某個目錄下所有檔案都建立為專案檔,讓你可以快速瀏覽所有檔案,不過美中不足的是他沒有把 CVS、.svn、_svn 等目錄過濾掉,我在 VimDirListing 函數裡添加了兩行把這些目錄過濾掉。
這是原來的樣子:
if isdirectory(glob(fname))
let {a:dirvariable}={a:dirvariable}.a:padding.fname.a:separator
let {a:dircount}={a:dircount} + 1
else
" other stuff
改過以後:
if isdirectory(glob(fname))
if fname != 'CVS' && fname != '.svn' && fname != '_svn'
let {a:dirvariable}={a:dirvariable}.a:padding.fname.a:separator
let {a:dircount}={a:dircount} + 1
endif
else
如果你懶得看英文的話,對岸的朋友翻譯了該 plugin 的文檔:VIM-Project Plugin – I Know you Know – C++博客
Ubiquity command – findbook(更新)
上一版沒有對 uri 作 encoding,所以找中文時會出錯,現在補上,只要呼叫 Ubiquity 內建的 encodeURIComponent() 就行了…
CmdUtils.CreateCommand({
name: "findbook",
contributors: ["elleryq"],
license: "MPL",
description: "讓買書變成更簡單的決定!",
takes: {"書名關鍵字": noun_arb_text},
icon: "http://findbook.tw/favicon.ico",
execute: function(directObject) {
Utils.openUrlInBrowser( "http://findbook.tw/search?keyword_type=keyword&q=" + encodeURIComponent(directObject.text) );
}
});
Ubiquity command – findbook
Ubiquity已經很多人介紹了,這裡是分享一個 commands,如果你有用 Findbook 的話,可以用用看…
安裝 command 方法很簡單,打開 Ubiquity Command Editor 後,把下面的程式碼貼上去即可:
CmdUtils.CreateCommand({
name: "findbook",
author: { name: "elleryq"},
contributors: ["elleryq"],
license: "MPL",
description: "讓買書變成更簡單的決定!",
takes: {"書名關鍵字": noun_arb_text},
icon: "http://findbook.tw/favicon.ico",
execute: function(directObject) {
Utils.openUrlInBrowser( "http://findbook.tw/search?keyword_type=keyword&q=" + directObject.text );
}
});
foxyproxy 自動組態指令碼的小問題
因為有在用 foxyproxy 的關係,昨天遇到一個問題,就是 foxyproxy 突然無法解析 pac 檔案了。Log 裡面有這樣的訊息:
TypeError: invalid ‘in’ operand this._sandBox
我試了好久,也找了好久,最後找到官方這篇討論串:PAC support,討論串裡面,作者很熱心想要解決,可是在他那邊複製不出這個問題,所以後面他就乾脆說,有遇到問題的,可以寫信跟他要測試版的 foxyproxy 試試看~
我實在是懶得寫信去要,所以就繼續試,結果無意中被我試出一個 workaround,於是趕緊貼上討論串給其他人參考。
今天去看的時候,發現有人說我的 workaround 有效~蠻令人高興的。
我的 workaround 就是,先把 foxyproxy 關閉,接著重新去把你的樣式設定為”使用自動組態指令碼”,然後關閉。接著再切換你剛剛設置的樣式,就行了。
如果沒有先把 foxyproxy 關閉的話,在關閉的時候會出現錯誤訊息。
在 .reg 表明要移除 key
謝謝你,Rob van der Woude!
原來在 .reg 裡面也可以表明要移除某個 key。
參考Rob van der Woude的這篇文章:Batch files – Use REGEDIT to add, read or delete registry values,只要這樣寫就行了:
;表明移除整個 DummyTree
[-HKEY_CURRENT_USER\DummyTree]
;表明移除指定項目
[HKEY_CURRENT_USER\DummyTree]
"ValueToBeRemoved"=-
文章裡面還有許多其他關於 registry 的技巧喔~
以 public key 進行 SSH 登入
首先,謝謝你!HowToForge。
環境:以下都是從電腦 A 要登入到 Server B (Linux)
步驟:
- 先為電腦A產生Private/Public key
- Linux: 用 ssh-keygen
- Windows: 用 puttygen.exe
- 把產生好的 Public key (用 ssh-keygen 的話,通常是 id_dsa.pub﹔用 puttygen.exe 的話,它就在上面的方塊裡。)附加到 Server B 登入帳號的 .ssh 目錄下的 authorized_keys2 裡面,如果沒有 authorized_keys 就自己建一個!舉例來說,如果你帳號是 xyz,那麼就是 $HOME/.ssh/authorized_keys 。
- 收工。
Banshee hack
從 src/Core/Banshee/Services/Banshee.Database/BansheeDbFormatMigrator.cs 的InitializeFreshDatabase()裡面可以看到 Banshee 建立了這些 table:
- CoreConfiguration
- CoreTracks
- CoreArtists
- CoreAlbums
- CorePlaylists
- CorePlaylistEntries
- CoreSmartPlaylists
- CoreSmartPlaylistEntries
- CoreRemovedTracks
- CoreTracksCache
- CoreCache
並且針對各個 Table 建立了必要的 Index (好吧,我的疑慮解除了,其實 Banshee 有幫建檔的音樂作索引,那還要繼續看下去嗎?)
BansheeDbFormatMigrator.cs 裡面還可以看到以 Migrate_ 開頭的函式前面有 [DatabaseVersion] 這個 Attribute,這些函式是用來作 Migrate(升級)的函式,Banshee 會先檢查 CoreConfiguration table 的 DatabaseVersion 欄位,看目前 Database 是什麼版本,然後再決定要怎麼去作升級(這部份可以參考 Migrate(), InnerMigrate())。
存取資料庫的部份被包在 src/Core/Banshee.Services/Banshee.Collection.Database下的各個以 AlbumInfo 結尾的檔案裡面,裡面都大同小異,provider 成員為主要的提供者,這裡會傳入 ServiceManager.DbConnection 讓 BansheeModelProvider 的 instance 能根據此 connection 去存取資料庫。
所有的 connection 都是由 ServiceManager.DbConnection (src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs) 而來,而 DbConnection 其實只是一個服務 (src/Core/Banshee.Services/Banshee.Database/BansheeDbConnection.cs),在 ServiceManager 被初始化(static ServiceManager())的時候被註冊進去。
BansheeDbConnection 繼承自 HyenaSqliteConnection (src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteConnection.cs),從 HyenaSqliteConnection.cs 看起來似乎是為了要把存取資料庫這整個部份獨立為 Thread 以提昇 UI 效率,所以才另外作 Hyena.Data.Sqlite。
不過最終底層還是 Sqlite 3。
Banshee 的 Main() 在 Client 類別 (src/Client/Nereid/Nereid/Client.cs),Client 繼承自 GtkBaseClient (src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs),扣掉註解不到 30 行…
補充1:HACKING Guide
補充2:我看的 code 是目前最新的版本,後來看過 0.13 的資料庫,發現的確沒有建 Index。