發表文章

在一筆 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