若常用 github ,Github::Import 會是一個很方便的模組。不需要為了新建 repo 而再到 github.com 上頭 create , 然後下幾個常常重複的指令。
模組安裝完成後,會提供你 github-import 這個 script. 使用的流程以我 import cpan module 舉例:
module-starter 之後。可以下
git init
git add something
git ci -a
之後便可以直接使用 github-import import
github-import --username [username] --token [api_token] --add-remote --push-mode all
而 API token 可以在 github 上頭的 account page 上找到。
更方便的方法是,直接在 git config 設定好,之後就只需要輸入 github-import 即可。
此外補充一點,若參見 github::import 的文件,若要直接使用 git 的設定檔,對 git config 記得加上 --global 的參數,文件上頭沒寫到。
See also:
perldoc Github::Import
github.com
2009年2月27日星期五
2009年2月20日星期五
vim - 實做符合自己需求的 commenter
這是一段很簡單的 vim script , 用來插入 perl 的 comment 符號 ,單純的檢查行是否以 # 開頭,如果有就 strip 掉。如果沒有就 comment 起來。此 function 適用於 visual mode, 透過呼叫 getline('.') 來取得目前處理行的內容。
使用這段 comment function 請使用 visual map
讀者可利用類似的技巧來打造自己需求的 commenter 。譬如說,加入 fold marker 之類的東西。
此外可以透過 a:firstline 以及 a:lastline 來比對是否為開始行或結束行。
function! _perl_comment()
let l = getline('.')
if l =~ '^#'
exec 's/^#//g'
else
exec 's/^/#/g'
endif
endfunction
使用這段 comment function 請使用 visual map
vmap ,c :call _perl_comment()<CR>讀者可利用類似的技巧來打造自己需求的 commenter 。譬如說,加入 fold marker 之類的東西。
此外可以透過 a:firstline 以及 a:lastline 來比對是否為開始行或結束行。
2009年2月18日星期三
SVK - branch management
svk 提供了快速簡潔的 Branch 管理,若 Project Source 的結構有照 /trunk /branches
or /tags ,則可以使用 svk branch --create / --rm / --push / --pull /
--merge 等操作,相當方便。
欲設定 property 可用
svk br --setup //mirror/Porject
建立 branch:
svk br --create Feature
Merge Branch:
svk br --merge trunk Feature
建立 Tag:
svk br --tag --create 1.0rc1
刪除 branch:
svk br --rm Feature
也可直接建立 Local Branch:
svk br --create LocalBranch --local
or /tags ,則可以使用 svk branch --create / --rm / --push / --pull /
--merge 等操作,相當方便。
欲設定 property 可用
svk br --setup //mirror/Porject
建立 branch:
svk br --create Feature
Merge Branch:
svk br --merge trunk Feature
建立 Tag:
svk br --tag --create 1.0rc1
刪除 branch:
svk br --rm Feature
也可直接建立 Local Branch:
svk br --create LocalBranch --local
2009年2月16日星期一
vim - move current window to a new tab page
I didn't see it before ,which is very useful.
*CTRL-W_T*
CTRL-W T Move the current window to a new tab page. This fails if
there is only one window in the current tab page.
When a count is specified the new tab page will be opened
before the tab page with this index. Otherwise it comes after
the current tab page.
2009年2月14日星期六
gvim - winresizing and svkdo for macvim
here are some new configuration for my mac gvim
" svk
function! _SVKDO()
let action = input( "svk action to " . expand('%') . " : " )
if strlen( action ) < 1
echo "no action"
return
endif
exec "!svk " . action . " " . expand('%')
endfunction
command! SVKDO :call _SVKDO()
nmap <D-k> :SVKDO<CR>
" window size key for macbook
if has('gui_mac')
nmap <silent> <D--> :resize -3<CR>
nmap <silent> <D-=> :resize +3<CR>
nmap <silent> <D-]> :vertical resize +5<CR>
nmap <silent> <D-[> :vertical resize -5<CR>
nmap <silent> <D-\> <C-w><C-w>
nmap <silent> <D-;> gT
nmap <silent> <D-'> gt
endif
2009年2月12日星期四
Jifty app 之後?- 使用 Template::Declare
在 Jifty 如果要使用 Template::Declare 來作為 View 的 Render 而不是 Jifty 所預設的 Mason 的話,需要以下步驟。
編輯 etc/config.yml
修改 TemplateClass 為 MyApp::View
接著在 lib/MyApp/View.pm 繼承 Jifty::View::Declare , 如下
編輯 etc/config.yml
修改 TemplateClass 為 MyApp::View
接著在 lib/MyApp/View.pm 繼承 Jifty::View::Declare , 如下
use Jifty::View::Declare -base;這樣就會取代原本預設的可愛小馬,顯示你的 "index.html" 樣板。會喜歡 Template::Declare 的原因在於,可以很有組織性的將樣板模組化,分為許多細部區塊,並且重複利用。在語法上的優點則是不需要浪費氣力輸入許多的角括號,Tag 間要插入程式碼也不需另外處理,整個程式結構也比較清晰。
use Jifty::View::Declare::Helpers;
template '/index.html' => page {
# insert template::declare here
show 'something';
};
private template 'something' => sub {
# sub template
};
2009年2月9日星期一
App::Nopaste Module
App::Nopaste CPAN 模組提供了 command-line 介面讀入 STDIN 自動貼到 Nopaste Service 上頭。
$ cpanp -i App::Nopaste
使用
$ cat jifty.patch | nopaste -n c9s -s Pastie
接著會傳回 Nopaste 的網址。
2009年2月2日星期一
Perl 5.10
這是舊聞。
Perl5.10 似乎已經普遍的存在於各類 Unix-Like OS 中了。 Ubuntu 目前的 Intrepid 也預設使用 Perl5.10.
Perl5.10 新增了許多功能,包括在 regexp engine , syntax , performance 方面的改進,像是 say, fieldhash , state, given, smart matching 之類等等的東西。 (我好像一年前有寫過 ? XD)
perl.com: A Beginner's Introduction to Perl 5.10
perl.com: A Beginner's Introduction to Perl 5.10 part 2
Perl5.10 似乎已經普遍的存在於各類 Unix-Like OS 中了。 Ubuntu 目前的 Intrepid 也預設使用 Perl5.10.
Perl5.10 新增了許多功能,包括在 regexp engine , syntax , performance 方面的改進,像是 say, fieldhash , state, given, smart matching 之類等等的東西。 (我好像一年前有寫過 ? XD)
perl.com: A Beginner's Introduction to Perl 5.10
perl.com: A Beginner's Introduction to Perl 5.10 part 2
2009年2月1日星期日
perl module for xhtml
在茫茫的 CPAN 大海中搜尋簡單好用可靠的且支援 selector 的 xhtml module 還真是不容易。要不是 Encoding有問題,要不就是 selector 沒辦法用 - 字元,要不,就會出現一些異常的問題。
關於這幾種需求,列出兩個我覺得不錯好用的 Module。
Miyagawa 有寫過 Web::Scraper Module,支援 CSS Selector , XPath,語法簡潔。但看 cpan 上的 Synopsis 可能還不夠,這邊還有另外的範例。
Ingy 的 pQuery ( Perl Port of jQuery ) : 利用 HTML::TreeBuilder 以及 HTML::Entities 寫出這樣巧妙模組,有好用的 find() , each() 等等。此外要注意的是,從檔案載入 UTF-8 encode 的檔案,要先用 Encode::decode_utf8 處理一下,中文parse 出來才不會有問題。
訂閱:
文章 (Atom)