發表文章

目前顯示的是 12月, 2014的文章

在一筆 Query 內,加入多筆資料到資料庫中

INSERT INTO example                  (id, name, value, other_value) VALUES (100, 'Name 1', 'Value 1', 'Other 1'),                 (101, 'Name 2', 'Value 2', 'Other 2'),                 (102, 'Name 3', 'Value 3', 'Other 3'),                 (103, 'Name 4', 'Value 4', 'Other 4'); 其中欄位名稱是可以省略的,如: INSERT INTO example VALUES (100, 'Name 1', 'Value 1', 'Other 1'),                 (101, 'Name 2', 'Value 2', 'Other 2'),                 (102, 'Name 3', 'Value 3', 'Other 3'),                 (103, 'Name 4', 'Value 4', 'Other 4');

Git - 同時 push 到多個 remote

倘若 Repository 中有多個 Remote 而且希望一次 push 操作同時丟到多個 Remote 上,可以輸入以下指令來編輯 config : $: git config -e 先前你如果已經設定好偏好的編輯器,則會使用設定好的編輯器進行編輯 。在檔案下方建立一個新的 Entry ,例如: [remote "all"] url=ssh://user@server/repos/g0.git url=ssh://user@server/repos/g1.git 然後 push 改指定 all 這個 Remote 名稱,就會發現同時丟往這兩個位置了!

如何更改 Git config 的編輯器

執行 git config -e ,預設是打開 GNU Nano 編輯器,不過操作上不太順手,可以更改設定,改為自己喜歡的編輯器: $: git config core.editor <editor name> 編輯器可以是任意的,環境變數中找得到的,如果沒有就要自己加進去。

遇到 "Error: Unable to initialize GTK+, is DISPLAY set properly?" 的解決方式

在 Linux Console 下執行圖形應用程式,如果打不開且出現錯誤訊息如下: $:  Error: Unable to initialize GTK+, is DISPLAY set properly? 試著執行以下指令: $:  declare -x DISPLAY=":0.0" 經驗法則 在 SUSE 上以 sudo 去執行程式而遇到這種狀況,可以試試改用 su -c <cmd> 即可成功開啟。

用 DJGPP 編譯 SQLite

$: cd path/to/sqlite $: ../configure --host=i586-pc-msdosdjgpp config_BUILD_CC=gcc config_TARGET_ CC=i586-pc-msdosdjgpp-gcc --disable-tcl --disable-threadsafe 其中  i586-pc-msdosdjgpp   是 cross compiler 的前綴,編譯完成後,可以用 file 查看物件檔屬性: $:  file where.o 80386 COFF executable not stripped - version 30821

在 Ubuntu 64bit 編譯 32 bit 程式

安裝所需 Libraries: $: sudo apt-get install gcc-multilib libc6-i386 lib6-dev-i386 編譯時加上 -m32 參數: $:  gcc -m32 a.c -o a

php/symfony - 在 ubuntu 執行 composer install 出現 "ext-curl *", "ext-gd *", "lib-icu" 的相依錯誤訊息

圖片
如圖,剛下載的專案在新的環境中需要執行 composer install 來安裝所需的套件,此時很可能會出現缺少某些系統套件,在 ubuntu 可以利用 aptitude 安裝這些套件: ext-curl * $: sudo aptitude install php5-curl ext-gd *  $: sudo aptitude install php5-gd lib-icu *  $: sudo aptitude install php5-intl 縮成一行: $: sudo aptitude install php5-curl php5-gd php5-intl

Mac OSX 上如何擷取螢幕?

Mac OS X 內建的 Screen Shot 熱鍵超好用,不需要安裝其他軟體,就能滿足各種快速抓圖的需求。 Command + Shift + 3 抓取整個螢幕畫面並儲存到桌面 Command + Shift + 4 選擇一個畫面區域後儲存到桌面 Command + Shift + 4、放開、再按空白鍵 選取一個視窗後儲存到桌面 Command +  Control  + Shift + 3 Command +  Control  + Shift + 4 Command +  Control  + Shift + 4、放開、再按空白鍵 功能同上;但多一個 Control 鍵,會儲存到剪貼簿而不直接存檔 如果要抓取整個視窗畫面,多按一個空白鍵切換成視窗選取模式,這樣就不會抓到視窗以外的內容,而且抓圖後還會自動將背景設為透明化、並加上陰影,效果真的非常棒! 對於進階使用者,想要在程式或 Shell Script 中自動抓圖,則可以搭配 Mac OS X 內建的「screencapture」指令: # 直接抓取整個畫面存檔 screencapture ~/screenshot.png # 抓取單一視窗畫面 screencapture -w ~/screenshot.png # 抓取單一視窗畫面、背景不要加陰影 screencapture -ow ~/screenshot.png 其他參數可以參考:   -c         force screen capture to go to the clipboard   -C         capture the cursor as well as the screen. only in non-interactive modes   -d         display errors to the user graphically   -i         capture screen interactively, by selection or window                control key - causes screen shot to go to clipboard                space key   - toggle between mouse selectio