Recently in Programming Category

Script Sample:
wget -qO- "http://maps.google.com/maps/geo?q=台中市中山路1號&output=csv"

Output:
200,8,24.1371957,120.6842909
(3rd column is latitude, 4th is longitude)

PHP Sample:
$ch = curl_init();
$address="台中市中山路1號";
curl_setopt($ch, CURLOPT_URL, "http://maps.google.com/maps/geo?q=$address&output=csv");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output=explode(',',curl_exec($ch));
curl_close($ch);
echo "Latitude: $output[2]
Longitude: $output[3]
";

Output:
Latitude: 24.1371957
Longitude: 120.6842909

ref. Google API 透過 HTTP 進行地理編碼

UTF-8 CSV for Excel

user-pic
Vote 0 Votes

本來以為 Excel 不支援 UTF-8 的 CSV,
一直都是轉成 Big5 輸出, 但是遇到像「喆」這種 Big5 中沒有的字, 就會有掉字問題.

原來只要在加入 BOM 檔頭, Excel 就可以正常讀取,
PHP 加入 fputs($fp,"\xEF\xBB\xBF");

但是 Excel 似乎沒辦法存 UTF-8 格式的 CSV.

ref. PHP匯出 Excel可讀的UTF-8編碼CSV檔案

FancyUpload

user-pic
Vote 0 Votes

FancyUpload 是一套 Flash + Ajax 的檔案上傳程式,
無名 也是用這個元件, 滿不錯的.
Queued Photo Uploader Demo

中文化辭彙搜尋已修復

user-pic
Vote 0 Votes

看到 這篇, 才知道 中文化辭彙搜尋 已經掛了很久了,
原因是 DreamHost 那邊取消了 register_globals,
而中文化辭彙搜尋是 2004 年寫的,
是用 $query 變數, POST 變數代不進來, 當然也搜尋不到任何東西,
改成 $_POST["query"] 就 OK 了.

王大頭,0912345678
這個 CSV 檔在 Excel 打開, 電話會變成數字 912345678
若要保留前面的 0, 必需這樣表示
王大頭,="0912345678"

ref. Excel vs. Leading Zero & Space

Firefox Preferences Editor

user-pic
Vote 0 Votes

Firefox Preferences Editor is a CLI tool for batch configure Firefox about:config preferences. (Source Code)
Note:

  • Please close Firefox before using this tool.
  • If preference name exist, it just append another new line to the end of prefs.js,
    Firefox will arrange prefs.js, so don't worry about duplicate entry.

    Usage: ffprefs {preference name} {value}
    e.g.
    ffprefs browser.startup.homepage http://www.google.com
    ffprefs browser.cache.disk.parent_directory r:\

    v0.2 Update: Read %APPDATA% environment variable instead of %USERPROFILE%, support Windows 2000/XP/2003/Vista/2008/7

  • 寫了一個程式可以快速移除所有的 Windows Live 程式
    Uninstall All Windows Live Software (Source Code)
    它會去 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
    找 DisplayName 有包含 Windows Live 字串的, 然後用 MsiExec /passive /uninstall GUID 的方式移除, 適用所有的版本.

    PHP MySQL Improved Extension

    user-pic
    Vote 0 Votes

    在 PHP 下用 pcntl_fork 同時存取 MySQL Server, 必需用 mysqli
    用一般的 mysql function 會出現 MySQL server has gone away 的錯誤訊息.
    範例:
    $mysqli=mysqli_init();
    mysqli_real_connect($mysqli,$dbhost,$dbuser,$dbpassword,$dbname) or die ('Unable to connect');
    $result=mysqli_query($mysqli,$sql);

    ref. MySQL Improved Extension

    Get MySQL Field Comment

    user-pic
    Vote 0 Votes

    show full fields from table_name
    可以取得 MySQL 的欄位註解,
    註解輸入中文名稱, 在寫程式時用上面的方式取得註解, 非常方便.
    ref. 取得MySQL表單的註解

    Mail Subject Encoding

    user-pic
    Vote 0 Votes

    根據 RFC 2047 的規範, Mail Header 中的 Non-ASCII Text 要用這個格式
    「=?charset encoding?encoding code?header content?=」
    encoding code 有可能是 b (base64編碼) 或 q (QP編碼)
    例如:「測試郵件」編碼後就變成「=?UTF-8?B?5ris6Kmm6YO15Lu2?=」
    用 PHP 的話可以用 mb_send_mail(), 會自動幫你編碼.

    ref. 石頭閒語:PHP mail() and charset encoding question

    About this Archive

    This page is an archive of recent entries in the Programming category.

    Photo is the previous category.

    Shell is the next category.

    Find recent content on the main index or look in the archives to find all content.