Friday, November 22, 2013

移除Windows 8的默認輸入法 Remove Default Input Method in Windows 8

在Windows 8裡,當你安裝慣用的輸入法后,就會自動出現難以移除的默認輸入法。
So in Windows 8, after you installed your beloved input methods, there will be default input methods that are automatically added, and refusing to be removed.


若你不懂得使用Registry Editor,請另請高明代勞,免得把系統搞亂。
A word of precaution: if you don't know how to operate Registry Editor, find someone to do it for you to avoid system malfunction. Here's how to remove it.

  1. Win+R打開Run窗口。輸入regedit,按OK
    Press Win+R to open the Run dialog. Type regedit and click OK.
  2. 展開到這里:HKEY_CURRENT_USER\Software\Microsoft\CTF\TIP
    Expand this key: HKEY_CURRENT_USER\Software\Microsoft\CTF\TIP
  3. 這時你必須展開你要移除的輸入法。如果你安裝了幾個語言的輸入法,你可能需要試幾下來找到正確的輸入法。
    At this point, you have to expand the Input Method that you want to remove. If you use multiple languages and have a few default input methods, you may have to experiment a bit to find the correct one.

  4. 雙點Enable。在出現的窗口中輸入0,然后按OK
    Double-click Enable. A dialog will appear. Enter 0 and click OK.

  5. 現在按Win+Space,討厭的輸入法不見了!
    Press Win+Space now, the silly input method is no longer there!











Monday, November 4, 2013

要買馬車嗎?來看檳城新報



算我孤陋寡聞,一直誤以為光華是檳城最早的報紙,其實應該是1895年8月8日創刊的《檳城新報》(Penang Sin Poe)。據說檳城新報在新馬淪陷前夕停刊,應該是1941年12月7日吧?

最棒的是,我們還可以看到當年的報紙,且是從1895年8月10日到1941年9月30日,就在新加坡國立大學圖書館。但不必跑去新加坡,直接就可以下載!上面的馬車就是1895年8月10日的廣告之一。

報頭上有清朝年號:大清光緒廿一年 乙未六月二十日。地址是“中街第二百三十號二百三十二號門牌”。就在Beach Street,但為什么叫“中街”?原來Beach Street不同路段有不同的中文名,總共有六個。早期的報紙連標點符號都沒呢!

1919年12月29日,“夢中孽緣”小說連載。這時清朝已經完蛋,進入民國了。報頭還有孔子紀年,就是孔子誕生開始算起的年份,由公元前551年開始。1919年就是551+1919=2470。標點符號也出現了!



1930年2月7日某頁有則啟事:“關仔角副刊今天出版,刊在第十頁,望閱者注意! ”。旁邊還有個“異禽發現”!還有“檳”字不知怎么却變成“梹”了。
但這“異禽”到底是什么東東?我來試著還原:
異禽發現
身長六十尺   翅寬二丈
飛如閃電    聲若雷鳴
據x日居民陳洪報告云。xx該處上空。恒有怪鳥飛旋。時高時低。身長度幾六十尺。飛如閃電。聲若雷鳴。動物家李君聞訊。特於前日上午駕輪抵陳家坐候。未幾。忽聞軋軋聲自遠飛來。陳x呼曰。“異禽至矣”。李急仰視。則飛機也。李知陳之錯誤。實由視官不良。乃出其眼鏡令戴而視之。則與圖畫中之飛機。無稍差異。因笑x李曰。“x習聞其聲而弗察其形。竟誤以為怪鳥,今而x知眼鏡之不可少x”。乃急往檳城新街亞東眼鏡公司配制一具云。

哈哈,這根本就是亞東的廣告帖!



這就是第十頁啦!看到“我們的關仔角”嗎?還是你在注意“双桃煙”啊?



這是圖書館保存的最后一份檳城新報:1941年9月30日,離新馬淪陷和停刊還有兩個月。報頭上寫著:報費 梹城報合光華報每月【一元九角】。我也不知道兩份報紙是什么關系,不過謝詩堅先生說“及后《檳城新報》承入《光華日報》”。


 大家没事就去下載讀讀當年檳城舊聞吧!


P/S: 本篇文章也帖在佳禮

Thursday, October 17, 2013

Installing Android ADB driver in Windows 8.1 64-bit when all else fails

For some reason I just couldn't get my machine to recognize Xperia J in Windows 8.1 64-bit. Even after installing latest Sony PC Companion (2.10.174).  Device Manager kept showing yellow exclamation mark to an 'Android'.

Here's the solution, but I don't promise it will work on your device!

1. Find out your device's VID and PID

  1. Open Device Manager, right-click that Android with yellow exclamation mark and click Properties.
  2. Go to Details tab.
  3. In Property, select Hardware Ids.
  4. Right-click the value and click Copy.
  5. Paste the value somewhere.


2. Download Android USB Driver

  1. Run Android SDK Manager.
  2. Expand Extras, tick Google USB Driver, click Install packages.
  3. After installation, look for the driver location by hovering mouse over Google USB Driver. The location will appear in the tooltip.


3. Modify android_winusb.inf

  1. Go to the usb driver location, for example in the above picture it is c:\Android\android-studio\sdk\extras\google\usb_driver
  2. Make a backup copy of android_winusb.inf
  3. Open android_winusb.inf with a text editor. Notepad is fine but Notepad++ is better, it will syntax highlight the inf file!
  4. Look for [Google.NTx86], and insert a line with your device's hardware ID that you copied above, for example
  5. [Google.NTx86]
    
    
    
    ; ... other existing lines
    
    
    
    ;SONY Sony Xperia J
    %CompositeAdbInterface% = USB_Install, USB\VID_0FCE&PID_6188&MI_01
    
    
  6. Look for [Google.NTamd86], and insert the same lines, for example:
  7. [Google.NTamd64]
    
    
    
    ; ... other existing lines
    
    
    
    ;SONY Sony Xperia J
    %CompositeAdbInterface% = USB_Install, USB\VID_0FCE&PID_6188&MI_01
    
    
  8. Save the file.

4. Disable driver signing

  1. Run Command Prompt as an administrator
  2. Paste and run the following commands:
    bcdedit -set loadoptions DISABLE_INTEGRITY_CHECKS
    bcdedit -set TESTSIGNING ON
    
    
    
    
    
  3. Restart Windows.

5. Install driver

  1. Open Device Manager, right-click that Android with yellow exclamation mark and click Update Driver Software.
  2. Click Browse my computer for driver software.
  3. Enter or browse to the folder containing android_winusb.inf, eg: C:\Android\android-studio\sdk\extras\google\usb_driver
  4. Click Next.
  5. The driver will install.
  6. Run adb devices to confirm your device is working fine.

6. Re-enable driver signing

  1. Run Command Prompt as an administrator
  2. Paste and run the following commands:
    bcdedit -set loadoptions ENABLE_INTEGRITY_CHECKS
    bcdedit -set TESTSIGNING OFF
    
    
    
  3. Restart Windows.
  4. Run adb devices to reconfirm!

Sunday, September 22, 2013

error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

Had this error when building a Qt program in Visual Studio 2012:
error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
There was a main() in main.cpp, which was included and compiled in the project. So what happened?
Turned out that qtmaind.lib was removed from Linker Dependencies, added it back and problem solved. Don't ask me why I removed it in the first place :)

Here's my general way to solve this particular linker error when playing with Qt in Visual Studio:
  1. Ensure main() is defined in a file (eg: main.cpp).
  2. Ensure the file (eg: main.cpp) is included in the project.
  3. Ensure the file is really being compiled, type some garbage and build. If there are errors in the file then it's being compiled.
  4. Right-click the project and click Properties.
  5. Go to Configuration Properties -> Linker
    1. Go to Input, ensure Additional Dependencies has one of this entry:
      • qtmaind.lib (for Debug build)
      • qtmain.lib (for Release build)
    2. Go to System, ensure SubSystem is correct.
    3. Go to Advanced, ensure Entry Point is correct. The default is blank. Usually you don't mess with it and leave it blank.


Friday, October 21, 2011

Run minimized batch file in Task Scheduler

I have a batch file scheduled in Windows Task Scheduler. The problem is it will always popup a window when running. Yes I want to see the window but I want it minimized instead of blocking my current view. Should an error occurs the batch file will pause and I will attend to it.

Some suggested using third-party program to minimize the window. Some suggested using Windows Script.

The solution is simple, use this: cmd /c start "title" /min "batch file"
For example: cmd /c start "Backup" /min "d:\my documents\scripts\backup.bat"

Be cautious that the start command will treat the first double-quoted string as title. So if you do this: 
  • cmd /c start /min "d:\my documents\scripts\backup.bat" 
you will just get a command prompt window entitled "d:\my documents\scripts\backup.bat" without the batch file running. Thus it's a good idea to always put a title to prevent scratching your head later.

There is one problem though, that you have to put an exit at the end of your batch file. Otherwise the batch file window will stay there when it is finished.

This is how you convert the above command into the Action of a scheduled task:
  1. Put "cmd" in Program/script.
  2. Put the rest in Add arguments (optional), eg: /c start "Hello" /min "d:\my documents\scripts\backup.bat"




Saturday, September 24, 2011

Rebuild SQLite driver for Qt in Visual Studio 2010

The default build of SQLite driver in Qt does not have some features such as full text search. You can add the features yourself by rebuilding it. This is how I rebuild using Visual Studio 2010:
  1. Download latest SQLite amalgamation source code from http://www.sqlite.org, eg: http://www.sqlite.org/sqlite-amalgamation-3070800.zip
  2. Run Visual Studio
  3. Click Qt -> Open Qt Project File (.pro)...
  4. Select  the Qt SQLite project, eg: c:\Qt\4.7.4\src\plugins\sqldrivers\sqlite\sqlite.pro
  5. If somehow the project is not opened in Solution Explorer, check the Output window for hints.
  6. In Solution Explorer, open sqlite3.c, right-click on the file tab and select "Open Containing Folder".
  7. Make a backup of that folder.
  8. Extract SQLite source code to that folder, overwriting everything.
  9. Back to Visual Studio.
  10. Right-click sqlite project and click Properties.
  11. Under Configuration, select Debug.
  12. Go to Configuration Properties -> C/C++ -> Preprocessor.
  13. Click "Preprocessor Definitions". Click the down arrow at the far right. Click 
  14. Put whatever SQLite compilation option you want. Here's mine:
    • SQLITE_THREADSAFE=1
    • SQLITE_ENABLE_FTS3
    • SQLITE_ENABLE_FTS3_PARENTHESIS
    • SQLITE_ENABLE_FTS4
    • SQLITE_ENABLE_RTREE
    • SQLITE_ENABLE_UPDATE_DELETE_LIMIT
    • SQLITE_SOUNDEX
  15. Under Configuration, select Release. Visual Studio will prompt you to save. Click "Yes".
  16. Add the same definitions as Debug.
  17. Close any running applications that uses SQLite, such as Qt Assistant.
  18. Rebuild both Debug and Release. Remember to Rebuild, not just Build, Visual Studio may not detect the changes.
  19. If you get error C1033 ("cannot open program database c:\Qt\4.7.4\src\plugins\sqldrivers\sqlite\vc100.pdb"), make sure the folder and files are not read-only.
  20. These files will be created. Check their modified dates to be sure:
    1. C:\Qt\4.7.4\src\plugins\sqldrivers\sqlite\debug\qsqlited4.dll
    2. C:\Qt\4.7.4\src\plugins\sqldrivers\sqlite\release\qsqlite4.dll
  21. IMPORTANT: qssqlite4.dll and qsqlited4.dll may be created in C:\Qt\4.7.4\src\plugins\sqldrivers\sqlite\release (or debug). If this happens, move it to C:\Qt\4.7.4\plugins\sqldrivers\ and overwrite the existing one. When you debug in Visual Studio, the DLL from this folder will be loaded, even though you have copied the SQLite DLL to your project output.


"WARNING: Can't find the Qt version that's associated with this project."

Updated in Sept 2013 for Qt5.

I don't know why. I am always haunted by this whenever I use a new Qt version:
"WARNING: Can't find the Qt version that's associated with this project. Defaulting to <some Qt version> instead. Please assign a valid Qt version to this project in the Qt project settings."

It happens when you are trying to build and you get it in the build Output window. Trying to change the version using Qt Visual Studio Add-in doesn't help.

My workaround:
  1. Open your project file in a text editor. The project file is the one with "vcxproj" extension, eg: AwfulProject.vcxproj
  2. Look for one of these:
    • For Qt4, QtVersion_x0020_Win32
    • For Qt5, Qt5Version_x0020_Win32
  3. Change it to the Qt version you desire, for example:
    • For Qt4, QtVersion_x0020_Win32="4.7.4"
    • For Qt5, Qt5Version_x0020_Win32="5.1.1"
  4. Save the file.
  5. Reopen the project in Visual Studio.
  6. Remember to change other Qt projects that this project depends on.