Archive for 軟體分享

jQuery Plugin – 台灣郵遞區號 3+2 版本

 

twzipcode32

自從 3 碼版本釋出後,就有詢問 3+2 版本的可能性,考慮到當時惰性發作所以一直沒有動工,直到這次狠下心來直接改寫才有雛型產生。

這個版本主要是使用中華郵政所提供的 XML 並以縣市為單位分成數十個 json,用 Ajax 方式以期效能上不會拖累太多。

基本功能如同舊版一樣,也加上了 1.3 之後更新的手動輸入功能,不過 3+2 改為符合的縣市路名單一號碼有多筆記錄對應時,僅列出符合的記錄。

目前僅測試於 IE8/ Firefox 3.6 / Google Chrome 5

jQuery Plugin – 台灣郵遞區號 3+2 版本


年底縣市合併後勢必會再改版,所以現在是做心酸的 XD

jQuery 台灣郵遞區號外掛 v1.3

twzipcode v1.3 加入了輸入郵遞區號取得縣市名稱的功能,以及 zipSel, zipReadonly 兩個選項。

下載位址:

[C#] KMClear – 鍵鼠清潔輔助器

首先,這不是能自動幫你清潔鍵鼠的工具 XD
它只是鎖定鍵盤滑鼠讓你在開機的時候可以清潔而已

KMClear - 鍵鼠清潔輔助器

支援平台:Windows 7, 2008, XP, 2003
環境需求:.Net FrameWork 3.5
檔案下載:KMClear.exe(11KB)
源碼下載:KMClear.zip(112KB – Visual C# 2008 Express)

這類程式有兩個重點要處理,一個是全螢幕執行,另一個就是鍵盤攔截。
全螢幕執行比較簡單,完全不需要 API:

  1. private void Form1_Load(object sender, EventArgs e)
  2. {
  3.     this.SetVisibleCore(false);
  4.     this.FormBorderStyle = FormBorderStyle.None;
  5.     this.Left = (Screen.PrimaryScreen.Bounds.Width / 2 - this.Width / 2);
  6.     this.Top = (Screen.PrimaryScreen.Bounds.Height / 2 - this.Height / 2);
  7.   this.SetVisibleCore(true);
  8. }

另一個則是需要借助 Low-level API 的鍵盤攔截:

  1. using System;
  2. using System.Diagnostics;
  3. using System.Runtime.InteropServices;
  4.  
  5. namespace KMClear
  6. {
  7.     internal class HookAPI
  8.     {
  9.         /* API Assign */
  10.         [DllImport("user32.dll", SetLastError = true)]
  11.         public static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, uint threadId);
  12.  
  13.         [DllImport("user32.dll", SetLastError = true)]
  14.         public static extern bool UnhookWindowsHookEx(IntPtr idHook);
  15.  
  16.         [DllImport("user32.dll", SetLastError = true)]
  17.         public static extern IntPtr CallNextHookEx(IntPtr idHook, int nCode, IntPtr wParam, IntPtr lParam);
  18.  
  19.         [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  20.         private static extern IntPtr GetModuleHandle(string lpModuleName);
  21.  
  22.         public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);
  23.  
  24.         private static IntPtr hKeyboardHook = IntPtr.Zero;
  25.         private HookProc KeyboardHookProcedure;
  26.  
  27.         private const int WH_KEYBOARD_LL = 13;
  28.         private const int WM_KEYDOWN = 0x0100;
  29.  
  30.         /// <summary>
  31.         /// Start Keyboard Hook Process
  32.         /// </summary>
  33.         public void HookStart()
  34.         {
  35.             if (hKeyboardHook == IntPtr.Zero)
  36.             {
  37.                 using (Process curProcess = Process.GetCurrentProcess())
  38.                 {
  39.                     using (ProcessModule curModule = curProcess.MainModule)
  40.                     {
  41.                         KeyboardHookProcedure = new HookProc(KeyboardHookProc);
  42.                         hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProcedure, GetModuleHandle(curModule.ModuleName), 0);
  43.                         if (hKeyboardHook == IntPtr.Zero)
  44.                         {
  45.                             HookStop();
  46.                             throw new Exception("SetWindowsHookEx failed.");
  47.                         }
  48.                     }
  49.                 }
  50.             }
  51.         }
  52.  
  53.         /// <summary>
  54.         /// Stop Keyboard Hook Process
  55.         /// </summary>
  56.         public void HookStop()
  57.         {
  58.             bool retKeyboard = true;
  59.             if (hKeyboardHook != IntPtr.Zero)
  60.             {
  61.                 retKeyboard = UnhookWindowsHookEx(hKeyboardHook);
  62.                 hKeyboardHook = IntPtr.Zero;
  63.             }
  64.             if (!(retKeyboard)) throw new Exception("UnhookWindowsHookEx failed.");
  65.         }
  66.  
  67.         /// <summary>
  68.         /// Keyboard Hook Process
  69.         /// </summary>
  70.         /// <param name="nCode"></param>
  71.         /// <param name="wParam"></param>
  72.         /// <param name="lParam"></param>
  73.         /// <returns></returns>
  74.         private IntPtr KeyboardHookProc(int nCode, IntPtr wParam, IntPtr lParam)
  75.         {
  76.             if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
  77.             {
  78.                 int vkCode = Marshal.ReadInt32(lParam);
  79.                 Console.WriteLine((System.Windows.Forms.Keys)vkCode);
  80.                 return new IntPtr(1);
  81.             }
  82.             return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);
  83.         }             
  84.  
  85.     }
  86. }

我的常用 js 函式庫

※ 2010-03-02 補充:

Object prototype 改寫會導致 jQuery 出現異常,所以必須將 Object.prototype.isArray 註解或刪掉。
請參考:Prototyping Object in Javascript breaks jQuery? – StackOverflow

整理了一支我常用於網站開發的 js 函式庫,也包含了對字串、日期、陣列物件的 Prototype 增強函數,採 MIT 授權釋出,歡迎任意使用。

源碼:lib.common.js(16 KB)
壓縮:lib.common-min.js(9 KB)

Prototype: String

  1. var url = 'http://essoduke.org/?s=測試';
  2. var x = 'Test 測試';
  3. var y = '<strong>HTML</strong>';
  4. var z = '&;lt;strong&;gt;HTML&lt;/strong&gt;';
  5.  
  6. /* trim: 移除字串前後空白 */
  7. x.trim(); // result: Test
  8.  
  9. /* bytes: 取得字串 bytes 長度 */
  10. x.bytes(); // result: 9
  11.  
  12. /* empty: 是否為空 */
  13. x.empty(); // result: false
  14.  
  15. /* left: 取字串左側 n 個字元 */
  16. x.left(4); // result: Test
  17.  
  18. /* right: 取字串右側 n 個字元 */
  19. x.right(4); //result: t 測試
  20.  
  21. /* HTMLEncode: 編碼 HTML 標籤 */
  22. y.HTMLEncode(); // result: &amp;lt;strong&amp;gt;HTML&amp;lt;/strong&amp;gt;
  23.  
  24. /* HTMLDecode: 還原被編碼的 HTML 字串 */
  25. z.HTMLDecode(); // result: <strong>HTML</strong>
  26.  
  27. /* URLEncode: 進行 URL 編碼 */
  28. url.URLEncode(); // result: http%3A%2F%2Fessoduke.org%2F%3Fs%3D%E6%B8%AC%E8%A9%A6

Prototype: Array

  1. var arr = [1, 2, 2, 3, 4, 4, 5];
  2.  
  3. /* unique: 刪除重複的元素 */
  4. arr.unique(); // result: 1, 2, 3, 4, 5
  5.  
  6. /* remove: 刪除第 n+1 個元素 */
  7. arr.remove(3); // result: 1, 2, 2, 4, 4, 5
  8.  
  9. /* find: 尋找符合內容元素的鍵值 */
  10. arr.find(2); // result: 1, 2

Prototype: Date

  1. var x = new Date();
  2.  
  3. /*
  4. * DateDiff: 計算傳入日期的差異
  5. * @param string cDate : 要比較的日期
  6. * @param string mode: 計算類型 y=年, m=月, w=周, d=日
  7. */
  8. x.DateDiff('2010-01-01', 'd'); // result 56
  9.  
  10. /* DateAdd: 加上或減去指定的日期時間間隔
  11. * @param string interval : 時間間隔單位 y, m, d, w, h, n, s, l
  12. * @param integer numer: 時間間隔單位次數,可為正數或負數
  13. * @param string pattern: 回傳的時間格式(非必要,預設 'yyyy-MM-dd hh:mm:ss')
  14. */
  15. x.DateAdd('d', 100); // result '2010-06-06 11:21:47'
  16.  
  17. /*
  18. * format: 格式化日期
  19. * @param string interval : 引數可參考 http://php.net/manual/en/function.date.php
  20. */ 
  21. x.format('Y m j'); // result '2010-02-26'

Prototype: Object

  1. /* isArray : 判斷是否為陣列 */
  2. var x = [1, 2, 3];
  3. x.isArray() // result 'true'
  4. var x = 'Test';
  5. x.isArray() // result 'false'

Functions

  1. var web = new COMMON();
  2.  
  3. /* regexp: 驗證常用欄位 account, password, email, url, ip, date, time, number, twid 台灣身份證 */
  4. web.regexp('i.am@god.com', 'email'); // 驗證電子郵件
  5. web.regexp('http://test.com', 'url'); // 驗證網址
  6. web.regexp('10.10.10.10', 'ip'); // 驗證 IP
  7.  
  8. /* timestamp2time: 將 timestamp 轉為時間日期格式 */
  9. web.timestamp2time(1267155821); // result 'Fri Feb 26 2010 11:46:30 GMT+0800 (Taipei Standard Time)'
  10.  
  11. /* timestamp: 取得 timestamp */
  12. web.timestamp();
  13.  
  14. /* leftPad: 字串左邊補零 */
  15. web.leftPad('100', 6); // result '000100'
  16.  
  17. /* ie: 檢查是否為 IE */
  18. web.ie();
  19.  
  20. /*
  21. * benchmark: 效能測試
  22. */
  23. web.benchmark.start(); // 開始計算
  24. [.....]
  25. web.benchmark.stop(); // 結束計算並返回執行秒數
  26.  
  27. /*
  28. * cookie: cookie 操作
  29. */
  30. web.cookie.get('index'); // 取得 cookie[index] 內容
  31. web.cookie.set('index', '100'); //設置 cookie[index] 為 100
  32. web.cookie.remove('index'); // 移除 cookie[index]
  33.  
  34. /*
  35. * debug: inline 方式顯示傳入變數內容或列舉子物件
  36. * ※此方法需使用 <a href="http://jquery.com/">jQuery Library</a>,建議 1.3.2 以上版本
  37. */
  38. var x = 'String';
  39. web.debug(jQuery); // 列舉 jQuery 所有內容
  40. web.debug(x); //顯示 x 變數內容

解決 TeamSpeak 3 中文化後字體過小的問題

如果在安裝 TeamSpeak 客戶端中文化後發生字體變成「標楷體」以及過小的問題,可以下載這個檔案解決:

default.qss(1KB 右鍵另存)

或是將下列文字加入「X:\Teamspeak Client\style\default.qss」,若熟悉 CSS 語法也可以自行更改。

  1. QAbstractScrollArea, QCheckBox, QComboBox, QDockWidget, QFrame,
  2. QGroupBox, QHeaderView, QLineEdit, QListView, QMainWindow, QMenu,
  3. QMenuBar, QProgressBar, QPushButton, QRadioButton, QScrollBar,
  4. QSizeGrip, QSlider, QSpinBox, QSplitter, QStatusBar, QTabWidget,
  5. QTabBar, QTableView, QToolBar, QToolBox, QToolButton, QToolTip, QTreeView {
  6.     font:normal 12px PMingLiu;
  7. }

說明:這個檔案為預設佈景主題的樣式檔,改寫各個元素所使用的字型及大小為 12px 新細明體。

另外補上目前最完整的正體中文化(戰地秘境版已停止更新):
下載:Teamspeak 3 Client 正體中文語系(ZIP 98KB 右鍵另存)

Pages: 1 2 3 4 5 6 Next

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds. Valid XHTML and CSS.