2009-08-24

當兵天數

基於過幾天就要去當兵和當完兵可以清楚的知道自己剩下多少天,就參考別人寫的簡單弄了一個js來提醒自己和告知他人。
/* 計算已經服役天數 */
var now = new Date();
var day = new Date(2009,9-1,1);
/* 這個是入伍日期,上面的寫法是:我在 2007 年 10 月 17 入伍 */
day = (now.getTime()- day.getTime())/(24*60*60*1000);
/* 現在時間減去入伍時間,為 Unix 系統時間,毫秒 */
day = Math.ceil(day);
/*傳回指定數字或運算式的最小整數 */
if (day < 0)
document.write("距離國軍Online 登入還有<strong>" + day*-1 + "</strong> 天");
else
document.write("已經在國軍Online <strong>" + day + "</strong> 天");
view raw 當兵天數.js hosted with ❤ by GitHub
謎之聲:這樣置中很難看耶,你不是要弄樣式,快一點阿!

2009-08-21

vimrc 設定檔

參照今年coscop,c9s大大演講的議題和投影片
Vim Hacks
View more documents from c9s.
整理和弄出自己的vimrc,也為了讓gvim上看的字體更大一些,閱讀起來比較容易,也弄了gvimrc的設定檔。 成品GVIM看起來大概會像這樣 (圖片內容有簡單的介面介紹).vimrc on gvim
" Gvim 專用設定檔
" 設定顏色
"color torte
colorscheme ir_black
set t_Co=256
" 設定字型
set guifont=Consolas:h16
" 設定寬度
set columns=90
" Make command line two lines high
set ch=2
" Hide the mouse when typing text
set mousehide
view raw gvimrc hosted with ❤ by GitHub
" **********熱鍵設定區**********
" 樹狀檔案列表 NERD Tree
map <F2> :NERDTreeToggle<CR>
" 最近使用檔案列表(MRU)
map <s-F2> :MRU<CR>
" Tag list
map <F3> :TlistToggle<CR>
" Update file
"map <F4> :up<CR>
" Save all buffer files
"nmap <s-F4> :wall<CR>
" Clear last used search hightlighting
nnoremap <silent> <C-l> :nohl<CR><C-l>
" AutoComple Open or close
imap <F6> <ESC>:AutoComplPopDisable<CR>
imap <s-F6> <ESC>:AutoComplPopEnable<CR>
" Setup SrcExplToggle
map <F7> :SrcExplToggle<CR>
" 呼叫 HexMode 做16進位顯示
nnoremap <C-H> :Hexmode<CR>
inoremap <C-H> <Esc>:Hexmode<CR>
vnoremap <C-H> :<C-U>Hexmode<CR>
" 呼叫 vim menu
source $VIMRUNTIME/menu.vim
set wildmenu
set cpo-=<
set wcm=<C-Z>
map <s-F3> :emenu <C-Z>
" // The switch of the Source Explorer
nmap <F4> :SrcExplToggle<CR>
" // Set the height of Source Explorer window
let g:SrcExpl_winHeight = 8
" // Set 100 ms for refreshing the Source Explorer
let g:SrcExpl_refreshTime = 100
" // Set "Enter" key to jump into the exact definition context
" let g:SrcExpl_jumpKey = "<ENTER>"
" // Set "Space" key for back from the definition context
let g:SrcExpl_gobackKey = "<SPACE>"
" // In order to Avoid conflicts, the Source Explorer should know what plugins
" // are using buffers. And you need add their bufname into the list below
" // according to the command ":buffers!"
let g:SrcExpl_pluginList = [
\ "__Tag_List__",
\ "_NERD_tree_",
\ "Source_Explorer"
\ ]
" // Enable/Disable the local definition searching, and note that this is not
" // guaranteed to work, the Source Explorer doesn't check the syntax for now.
" // It only searches for a match with the keyword according to command 'gd'
let g:SrcExpl_searchLocalDef = 1
" // Do not let the Source Explorer update the tags file when opening
let g:SrcExpl_isUpdateTags = 0
" // Use 'Exuberant Ctags' with '--sort=foldcase -R .' or '-L cscope.files' to
" // create/update a tags file
let g:SrcExpl_updateTagsCmd = "ctags --sort=foldcase -R ."
" // Set "<s-F4>" key for updating the tags file artificially
let g:SrcExpl_updateTagsKey = "<s-F4>"
" Buffer Explorer / Browser key
" '\be' (normal open) or
" '\bs' (force horizontal split open) or
" '\bv' (force vertical split open)
" Comment Mode 也可用 bash 的key binding
cmap <c-a> <home>
cmap <c-e> <end>
cnoremap <c-b> <left>
cnoremap <c-d> <del>
cnoremap <c-f> <right>
cnoremap <c-n> <down>
cnoremap <c-p> <up>
cnoremap <esc><c-b> <s-left>
cnoremap <esc><c-f> <s-right>
" 分頁移動設定
"map tn :tabnext<CR>
"map tp :tabprev<CR>
map te :tabnew
map tc :tabclose<CR>
" Normal Mode時,可用tab及shift-Tab做縮排
nmap <tab> v>
nmap <s-tab> v<
" Visual/Select Mode時,也行
vmap <tab> >gv
vmap <s-tab> <gv
" 上下移動行內容
nnoremap <A-j> :m+<CR>==
nnoremap <A-k> :m-2<CR>==
inoremap <A-j> <Esc>:m+<CR>==gi
inoremap <A-k> <Esc>:m-2<CR>==gi
vnoremap <A-j> :m'>+<CR>gv=gv
vnoremap <A-k> :m-2<CR>gv=gv
" **********環境設定區**********
" 設定背景顏色為黑色
set background=dark
" colors darkblue
" 關閉 vi 兼容模式
set nocompatible
" Set mouse
set mouse=a
" 打開語法效果
syntax on
" 依檔名打開語法效果
filetype on
" 自動寫入buffer狀態
set autowrite
" 顯示行號
set number
" Show command line
set showcmd
" 設定tab顯示符號 空白顯示符號
set lcs=tab:>-,trail:-
" 顯示製表位(^I)和行尾標誌($)
set list
" 顯示現在的模式
set showmode
"沒有備份檔案
set nobackup
" 自動設定標題
set title
" 設定 tab 對齊的字元數
set tabstop=4
" 狀態列顯示游標所在處之行列狀態
set ruler
" 自動縮排
set autoindent
" 聰明的縮排
set smartindent
" 用空白來當作tab
set expandtab
" 自動縮排為以四空格為基準
set shiftwidth=4
set smarttab
set fdm=indent
set fdc=4
" 設定自動換行
set wrap
" 尋找時,符合字串會反白表示
set hlsearch
" 加強式尋找功能,在鍵入 patern 時會立即反應移動至目前鍵入之 patern 上
set incsearch
" 底下的command status line為兩行
set cmdheight=2
" 總是顯示資訊
set laststatus=2
" Line highlight 設此是游標整行會標註顏色
set cursorline
" Column highlight 設此是遊標整列會標註顏色
"set cursorcolumn
" 自動重新載入vimrc
autocmd! BufWritePost .vimrc source %
autocmd! BufWritePost .gvimrc source %
autocmd! BufWritePost _vimrc source %
autocmd! BufWritePost _gvimrc source %
" 設定最後編輯的位置,再次開檔案就會移動到那行
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
" 設定狀態列訊息
highlight User1 ctermfg=red
highlight User2 term=underline cterm=underline ctermfg=green
highlight User3 term=underline cterm=underline ctermfg=yellow
highlight User4 term=underline cterm=underline ctermfg=white
highlight User5 ctermfg=cyan
highlight User6 ctermfg=white
" %1* -> User1's highlight, %2*->User2's highlight
" = -> Separation point between left and right aligned items.
" < -> Where to truncate line if too long. Default is at the start.
set statusline=%4*%<\ %1*[%F]
set statusline+=%4*\ %5*[%{&encoding}, " encoding
set statusline+=%{&fileformat}]%m " file formatoptions
" 設定GitBranch前置字串
let g:git_branch_status_text=" "
" 設定GitBranch讀不到時顯示字串
let g:git_branch_status_nogit=""
set statusline+=%{GitBranchInfoString()}
set statusline+=%4*%=\ %6*%y%4*\ %3*%l%4*,\ %3*%c%4*\ \<\ %2*%P%4*\ \>
" 設定檔案編碼清單
set fencs=utf-8,big5,bgk,euc-jp,utf-16le
" 設定編碼
set fenc=utf-8
" 內部編碼
set enc=utf-8
" Terminal編碼
set tenc=utf-8
" 設定自動折合模式
set foldmethod=syntax
" 方便中文重排設定
set formatoptions=mtcql
" 將註解由深藍色變綠色
hi Comment ctermfg=Green
" taglist config
let Tlist_Use_Right_Window=1
let Tlist_File_Fold_Auto_Close=1
" 設定 Omni completion
autocmd FileType c set ofu=ccomplete#Complete
autocmd FileType cpp set ofu=cppcomplete#Complete
autocmd FileType php set ofu=phpcomplete#CompletePHP
autocmd FileType python set ofu=pythoncomplete#Complete
autocmd FileType javascript set ofu=javascriptcomplete#CompleteJS
autocmd FileType html set ofu=htmlcomplete#CompleteTags
autocmd FileType css set ofu=csscomplete#CompleteCSS
autocmd FileType xml set ofu=xmlcomplete#CompleteTags
" tags config
set tags+=./tags
" c autotidy by indent
autocmd FileType c :set equalprg=indent
" Folding : http://vim.wikia.com/wiki/Syntax-based_folding see comment by Ostrygen
au FileType cs set omnifunc=syntaxcomplete#Complete
au FileType cs set foldmethod=marker
au FileType cs set foldmarker={,}
au FileType cs set foldtext=substitute(getline(v:foldstart),'{.*','{...}',)
au FileType cs set foldlevelstart=2
" Quickfix mode: command line msbuild error format
au FileType cs set errorformat=\ %#%f(%l\\\,%c):\ error\ CS%n:\ %m
" **********功能區**********
" clever tab completion
fun! KeywordComplete()
let left = strpart(getline('.'), col('.') - 2, 1)
if left =~ "^$"
return "\<Tab>"
elseif
left =~ ' $'
return "\<Tab>"
else
return "\<C-N>"
endfun
inoremap <silent> <Tab> <C-R>=KeywordComplete()
fun! OmniComplete()
let left = strpart(getline('.'), col('.') - 2, 1)
if left =~ "^$"
return ""
elseif left =~ ' $'
return ""
else
return "\<C-x>\<C-o>"
endfun
inoremap <silent> <S-Tab> <C-R>=OmniComplete()
" ex command for toggling hex mode - define mapping if desired
command -bar Hexmode call ToggleHex()
" helper function to toggle hex mode
function! ToggleHex()
" hex mode should be considered a read-only operation
" save values for modified and read-only for restoration later,
" and clear the read-only flag for now
let l:modified=&mod
let l:oldreadonly=&readonly
let &readonly=0
let l:oldmodifiable=&modifiable
let &modifiable=1
if !exists("b:editHex") || !b:editHex
" save old options
let b:oldft=&ft
let b:oldbin=&bin
" set new options
setlocal binary " make sure it overrides any textwidth, etc.
let &ft="xxd"
" set status
let b:editHex=1
" switch to hex editor
%!xxd
else
" restore old options
let &ft=b:oldft
if !b:oldbin
setlocal nobinary
endif
" set status
let b:editHex=0
" return to normal editing
%!xxd -r
endif
" restore values for modified and read only state
let &mod=l:modified
let &readonly=l:oldreadonly
let &modifiable=l:oldmodifiable
endfunction
set diffexpr=MyDiff()
function! MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
" Smooth scrolling
map <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y>
map <C-D> <C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E>
" vim: ts=2:
view raw vimrc hosted with ❤ by GitHub
環境:
  • Mac OSX
  • Vim 7.2.22
  • GVim 7.2.160

2009-08-09

推薦Firefox

連到我的抓火狐推薦頁!
從別人那邊發現了這個好用的推薦頁面,可以自訂自己喜愛的插件還可以把個人認為最重要的三個特點凸顯出來。若你還沒用Firefox的話,那就是該來試試看的時候了!
謎之聲:那Chrome怎麼辦?!

2009-04-13

舊文章匯入

自從從Wordpress搬到Blogger已經是很久之前的事情了(不想考)

剛剛才突然想到這件很重要的事情,還好有之前做到一半的半成品所以現在做起來是如此的輕鬆 :P

目前剩下的工作是整理標籤,這樣一來才可以說是匯入工作完全完成

記錄一下,我自己轉換的過程

  1. 從Wordpress匯出XML(WXR)
  2. 試著使用軟體讀取這個XMl檔,遇到很多格式上的問題。主要都是comment的留言沒加上<![CDATA[]]>的標籤,所以被當作是XML的一部份而誤判。這個部份我是使用w2b的讀檔功能來作測試的謎之聲:這個時候就過了好長的一段時間
  3. 使用http://wordpress2blogger.appspot.com/這個工具,把剛剛整理好的東西讀入,並且把輸出的檔案存在自己知道的地方
    從Wordpress匯入文章 - Wordpress2Blogger conversion utility
  4. 打開Blogger的資訊主頁,並且選擇設定
    從Wordpress匯入文章 - Blogger資訊主頁
  5. 再選擇匯入網誌這個功能
    Wordpress匯入文章 - Blogger 基本設定
  6. 再來選擇剛剛網站輸出的XML檔,照圖片上輸入英文(天殺的難),最後按下匯入網誌即可
    Wordpress匯入文章 - Blogger 匯入網誌

後記:整個過程最難的地方應該是輸入那個認證;網站輸出的檔案我試著用編輯器去讀過,除了Vim之外都會開到當機。可能是因為檔案完全沒有換行,一行到底的原因。最好在輸入前就處理好,輸出後的那個鬼東西丟給Blogger就行了。


謎之聲:你竟然現在才弄好,真的很糟耶你

2009-02-24

Mac 介面整理 Space篇

Mac的介面使用容易,但不經整理還是一樣雜亂無章。經過幾天的使用後,目前使用介面是這樣

desktop20090224_1

之前試著使用4個桌面,後來覺得還是太少就把桌面提升到9個。在這9個桌面我用下面的分類,左上是網頁、上面是聊天軟體、右上是BBS、左邊是檔案管理、中間是寫Code或是報告用、右邊Vmware、左下是iTunes、下面是aMule或BT、右下是遊戲區。

在Expose的設定如下
My Expose

左上是桌面、右上是所有視窗、左下是Dashboard、右下是Space。

左上除了關視窗滑鼠比較少移動過去(我都用鍵盤或滑鼠熱鍵關),然而左下方也是除了用Dock才會有機會過去那邊、右邊則是用來快速換視窗和Space的方法,會這樣設定也跟自己是右撇子有關。

我在使用Space的時候發現,在出現9宮格的時候還是可以使用顯示所有視窗功能。這個技巧在找尋自己剛剛開過的視窗相當有用。

因為軟體都被分類好了,在使用上除了使用滑鼠移動到右下切換之外,還可以直接使用下方的Dock來快速切換。這樣就可以省下一個動作而達到快速工作效果。

desktop20090224_3
而且若覺得自己還需要管理工作內容的話,或許可以用左上的4格Space來放置不同的工作要求。分別是重要而且緊急的、重要但是不緊急的、不重要但是緊急的、不重要也不緊急的。

這樣配置的話在處理完左上視窗的內容之後,在Space的地方直接把做完的桌面畫Z字型「拉」到右下(四格中的右下)的那個位置,這樣一來就可以使工作順序(桌面)重新整理過,而且也不會忘記處理事情而發生困境。但是我本人並沒有做到,看我自己的Space使用內容大概就可以略知一二。

謎之聲:你還敢說勒(打)

2009-02-21

Mac OS X x86安裝簡記

Mac 桌面 20090221

前陣子換了電腦,突然有想要灌OSx86的想法,隨手就找到iPC OSx86 10.5.6 Universal PPF5 (Final) 這個版本

在準備好心情和一本書之後,就直接對我目前在用而且能用的電腦直接下手。放入燒好的光碟,然後重開機格式化。

雖然是這樣盤算著,但卻怎樣都沒辦法正確讀取。上網翻了文章發現是燒錄光碟速度的問題,花了時間用4倍重新燒錄新片就解決。


因為之前就使用過,就直接選定好本來M$的主硬碟直接下手,整顆格式化!(叔叔有練過小朋友不要學喔)

安裝上完全沒有任何的問題,但是在重新開機之後竟然讀不到硬碟開機的部份。沒辦法手邊沒有其他可用電腦,就拿出ubuntu Live CD上網查文章

然後在這篇文章發現是格式化那邊的選項問題,因為一開始我就試過選「GUID 磁碟分割區表格」,卻不能夠正確開機。所以再次的格式化後使用「主開機記錄」即可

在完全跑完之後OSX需要設定鍵盤,但是我沒有準備好一隻USB鍵盤並且當場插下去竟然也測不到更不用說本來插的PS/2鍵盤,是完全不能用的狀態。在不得已的情況下只好拿出一隻usb鍵盤,並且重灌一次

這樣弄好之後就可以正確的開機,然後再把剩下驅動程式安裝依照自己的硬體裝好就行。唯一要注意的重點就是,每一種硬體只能選擇一種,要不然不能夠正確的安裝。

語系預設是英文,只要去「System Preferences」->「International」裡面把繁體中文拉到第一順位,並且重新登入後就是中文介面

也因為我有用一隻PS/2的鍵盤,所以有安裝PS/2的Hack。不過看上面的選項,PS/2的滑鼠和鍵盤只能選一種使用,然後再重開機之後就可以正確使用

其他使用的軟體就之後再寫文章吧 :P


硬體列表:
CPU: Intel E7400
Motherboards: GA-P31-DS3L
Graphics Cards: Nvidia 8800GTS 320MB
RAM: Transcend 2G DDR2 800 X2
Soundcard: Creative Live 5.1
Harddisk: WD 80G ,WD 200G, WD500G