Wednesday, October 17, 2012

Microsoft SQL Server Lock table for some duration

-- Declare a I_LOCK_YOU procedure
BEGIN TRAN I_LOCK_YOU;

-- simply select any table we intend to lock.
SELECT TOP (1000) * FROM VOUCHER.TICKET TKT (HOLDLOCK) JOIN VOUCHER.TRANS TRN (HOLDLOCK) ON TRN.TKT_ID = TKT.TKT_ID
WHERE TRN.STAT_ID = 3;

-- You can sleep as long as you like.
WAITFOR DELAY '00:00:04';

COMMIT TRAN I_LOCK_YOU;

Tuesday, July 03, 2012

Microsoft SQL Server Command Line Tool SQLCMD

SQL Server Command Line Tool SQLCMD can be download from here:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=16978

1. In the above website, search for "Native Client" --> Microsoft® SQL Server® 2008 R2 Native Client

2. In the above website, search for "sqlcmd" --> Microsoft® SQL Server® 2008 R2 Command Line Utilities

The SQLCMD utility allows users to connect to, send Transact-SQL batches from, and output rowset information from SQL Server 7.0, SQL Server 2000, SQL Server 2005, and SQL Server 2008 and 2008 R2 instances. The bcp utility bulk copies data between an instance of Microsoft SQL Server 2008 R2 and a data file in a user-specified format. The bcp utility can be used to import large numbers of new rows into SQL Server tables or to export data out of tables into data files.
Note: This component requires both Windows Installer 4.5 and Microsoft SQL Server Native Client

Install items 1 and 2.

SQLCMD.exe can be found here: C:/Program Files/Microsoft SQL Server/100/Tools/Binn/SQLCMD.EXE

Thursday, May 17, 2012

Office Word 2007 single double line spacing

Ask: The default setting creates double spacing between lines. How do I have the default be single spacing?

Source: http://support.microsoft.com/kb/921174

To do this, follow these steps:


1. Click the Home tab.

2. Click Change Styles in the Styles group, point to Style Set, and then click the style set that you want to use.

To change the default formatting of your document, such as the line spacing and paragraph spacing, to the default formatting that is used in earlier versions of Word, click Word 2003.

3. To set the style set as the default style set in Word 2007, click Change Styles in the Styles group, and then click Set as Default.

Tuesday, February 14, 2012

Backup Outlook Email PST file

Microsoft Outlook Email storage .pst file is a proprietary format. Surprisingly no other email client can import the pst file itself right away. 2 best way I found to backup Microsoft Outlook Email stores in .pst file.

Both methods require Microsoft Outlook installed locally on the PC.


(A) Backup Outlook email to GMail.
1. Setup Gmail IMAP inside Outlook.
http://www.howtogeek.com/howto/microsoft-office/use-gmail-imap-in-microsoft-outlook-2007/
http://support.google.com/mail/bin/answer.py?hl=en&ctx=mail&answer=12103
2. Transfer email from Outlook to Gmail. It takes long time to move email 1 by 1. But once it is done, you realize all the emails with related topic are threaded together in Gmail way. And it is very easy to search your email inside GMail.

(B) Backup Outlook to email Thunderbird.
http://support.real-time.com/tbird/outlook_import.html
http://kb.mozillazine.org/Import_.pst_files

Sunday, February 12, 2012

Macau mobile plan comparison 比较澳门流动电话套餐

Task: Trying to look for mobile plan + data usage.

Observation:
Pay-per-use data usage charges expensively with low data flow, e.g. 1-2G free per month only, extra usage MopP0.02/KB till Mop500 maximum. Unlimited data usage charges Mop318/Mop418(with new phone) per month.

CTM
https://www.eservices.ctm.net/cportal/base/public/mobiweb/MobiwebLeftNav.iface?pathZh=/mobiweb/tariffplans/zh/serviceplan.html


Smartone
http://www.smartone.com/mo/tc/mobile-services/price-plans/integrated-voice-and-data-plans/pricing.jsp
iphone 4S: http://iphone.smartone.com/jsp/mo/iPhone4S/tchinese/price.jsp


Three.com.mo (和記電訊,和記黃埔集團成員)
http://three.com.mo/plan/month However it doesn't show the data plan.

Visit the shop, the current promotion (12 Feb 2012), 18 months contract, early termination penalty Mop200:
帶機轉台/上台優惠
Mop63/1100分鐘,送全套增值服務(來電等待、來電顯示、電話會議、來電轉駁)

Auto incremental data usage:
Mop23, 200MB
Mop48, 400MB
Mop68, 1G
Mop88, 2GMop188, unlimited data

Meaning, if user uses 300MB that month, the bill falls into Mop48; if user uses 500MB, the bill falls into Mop68, automatically. Even if user uses more than 2G, the maximum bill is Mop188.

iphone 4: http://iphone.three.com.mo/tariff?type=iphone4
iphone 4S: http://iphone.three.com.mo/tariff?type=iphone4S

Thursday, December 15, 2011

Using Wireless@SG in Changi airport

Although I already have mobile number registered with Wireless@SG long time ago and I have been using it occasionally, I cannot login Wireless@SG in Changi airport.

Then I clicked the Forget Password link. An instruction pops out, asking me to approach information counter? Feeling quite strange, I walked to information counter and tell them I want access to Wireless@SGThe staff immediately gave me a paper with 4 hour validity random username and password.

Clever. Problem solved.

Wednesday, November 30, 2011

How to open chm file in Windows?



For many years, I cannot open CHM file in Windows. I never knew why. I thought, the CHM file was old or outdated or generated with old compiler or wrong encoding.

Until one day I am so fed up, I search for solution. Surprisingly, there are some softwares offer to open CHM file, including a plug-in in Firefox to open CHM file. However, the Firefox plugin still cannot open some CHM file correctly, there are missing pages or images.

Finally, I come across this simple solution:

I read somewhere, for security reason, Windows cannot open downloaded CHM file automatically. We have to right click the file -> Properties -> General tab -> [Unblock] button.

Tuesday, August 23, 2011

native2ascii vs ascii2native

In Java, to display Chinese character, we need to convert Chinese word to Unicode format.
e.g. 你好 becomes \u4F60\u597D.

We can use the following command to do conversion:
(Source: http://javaphoon.iteye.com/blog/148403)
native2ascii -encoding gb2312 test_native.properties > test_ascii.properties
native2ascii -reverse -encoding gb2312 test_ascii.properties > test_native2.properties

This is the online conversion tool:
http://code.cside.com/3rdpage/us/javaUnicode/converter.html

Friday, July 15, 2011

OCR = Optical Character Recognition, 文字扫描辨识软体

A friend asked me, how to scan a Chinese print out into editable Word document?

I recall, some scanner software comes with OCR software, meaning the scanner can scan the graphic and directly covert the output into text.

However is there a way if the scanner doesn't provide OCR software?

After some information gathering and research...
http://fish.pixnet.net/blog/post/22621207
http://www.info-artist.net/2009/10/ocr.html

Good news is, Microsoft Office Document Imaging (exists inside All Programs -> Microsoft Office -> Microsoft Office Tools) is the OCR tool.

Bad news is, it doesn't seems to support Chinese right away. So need to install the language engine:
http://www.microsoft.com/downloads/zh-tw/confirmation.aspx?FamilyID=DD172063-9517-41D8-82AF-29C38F7437B6&displaylang=zh-tw

Then, I realize I cannot open graphic file (e.g. jpg, gif, etc) directly inside Microsoft Office Document Imaging. There is this software JOCR.exe which is able to make use of Microsoft libray to do conversion.
http://philtzki.pixnet.net/blog/post/5189840
http://download.cnet.com/JOCR/3000-2192_4-10768898.html

Updated 29-01-2012:
Or the easier method, use online free OCR service:
Google Keyword: ocr online chinese
http://free-online-ocr.com
http://www.sciweavers.org/free-online-ocr
http://googlesystem.blogspot.com/2009/09/google-docs-ocr.html

Updated 22 Feb 2012:
This one seems more powerful. It can scan different languages, such as Chinese and produce different file formats, including Excel. Login using Google/Facebook account.
http://finereader.abbyyonline.com

Saturday, November 27, 2010

k-lite cannot play rm rmvb file RealAudio COOK

When I install K-Lite Mega Codec Pack 6.5.0 on WinXP SP3, Windows Media Player and Media Player Classic can play rmvb/rm files smoothly.

After I install Real Player ver 14 Hexlix Powered, WMP and MPC failed to render rmvb/rm files. It shows the following errors:

C:\Downloads\Movie\movie.rmvb::Output 00 (Audio Stream)

Media Type 0:
--------------------------
Audio: RealAudio COOK 44100Hz stereo

AM_MEDIA_TYPE:
majortype: MEDIATYPE_Audio {73647561-0000-0010-8000-00AA00389B71}
subtype: Unknown GUID Name {4B4F4F43-0000-0010-8000-00AA00389B71}
formattype: FORMAT_WaveFormatEx {05589F81-C356-11CE-BF01-00AA0055595A}
bFixedSizeSamples: 1
bTemporalCompression: 1
lSampleSize: 14880
cbFormat: 112

WAVEFORMATEX:
wFormatTag: 0x2004
nChannels: 2
nSamplesPerSec: 44100
nAvgBytesPerSec: 0
nBlockAlign: 930
wBitsPerSample: 16
cbSize: 0 (extra bytes)

pbFormat:
0000: 04 20 02 00 44 ac 00 00 00 00 00 00 a2 03 10 00 . ..D¬......¢...
0010: 00 00|2e 72 61 fd 00 05 00 00 2e 72 61 35 00 00 ...raý.....ra5..
0020: 00 10 00 05 00 00 00 4e 00 18 00 00 03 a2 00 00 .......N.....¢..
0030: 00 00 00 07 55 67 00 00 00 00 00 10 03 a2 00 ba ....Ug.......¢.º
0040: 00 00 00 00 ac 44 00 00 ac 44 00 00 00 10 00 02 ....¬D..¬D......
0050: 67 65 6e 72 63 6f 6f 6b 01 07 00 00 00 00 00 10 genrcook........
0060: 01 00 00 03 08 00 00 25 00 00 00 00 00 06 00 05 .......%........

I un-install all. No matter how I change the installation steps, i.e. install RealPlay first then K-Lite, or install K-Lite first then RealPlayer, or install older version of K-Lite, or Real Alternative, the result is the same. Once RealPlayer is installed, K-Lite is broken.

Official FAQ says:
http://www.codecguide.com/faq_mpc.htm#item23
Q: RealMedia files (.rm .rmvb) freeze or play without sound

A: MPC is not fully compatible with RealPlayer 11 and 12.

or C:/Program Files/K-Lite Codec Pack/Info/faq_playback_issues.htm#item32
Q: RMVB files play without sound

A: You are probably missing a decoder for RealAudio COOK. You can install that by following these steps:

Download the Windows version of binary codec pack for MPlayer.
http://www.mplayerhq.hu/design7/dload.html#binary_codec
Extract these files from the .zip archive: cook.dll, pncrt.dll, sipr3260.dll, drv33260.dll, drv43260.dll
Put those files in this folder: C:\Windows

It seems redundant as K-Lite itself is the bundle of media libraries, why do we need to download additional binary from 3rd party? And the above steps are troublesome.

The easier way and solution is that:

1) Install K-Lite Mega Codec Pack (contains Real Alternative) or Real Alternative first. You'll see the following directory:
C:\Program Files\K-Lite Codec Pack\Real\Codecs

2) Save a copy of this [Codecs] directory. Because it'll somehow disappear when RealPlayer is installed, or you install K-Lite after RealPlayer, this folder won't exist (I don't remember clearly).

3) Then, install RealPlayer. As expected, WMP and MPC cannot play rmvb/rm properly (without sound, missing RealAudio COOK)

4) Go Control Panel -> System -> Advanced tab -> [Environment Variables] -> edit Path

Add the following path:
%path%;C:\Program Files\K-Lite Codec Pack\Real\Codecs

Adding the above path, [Codecs] folder is visiable to Windows. Now you try to play rmvb/rm with WMP and MPC, it will play smoothly again.

Monday, October 25, 2010

Search in Open Source

Sometimes I find it is quite helpless/having good life/cheating being a software engineer myself. In the daily work, I rely so much on 3rd party library. A lot of implementations are already widely available in Internet. I don't really have to do anything from scratch.

However if I am required to do from scratch? In fact I don't know how. The theory and spec can be very thick... the basic implementation can be very complicated... the simple thing itself can be a PhD project.

... ...

Anyway, the summary is, not only to search the keyword in Google. There are great developers in Japan (http://sourceforge.jp/) and China. And maybe other non-English speaking countries too, such as Russia, just that I don't know.

Monday, September 13, 2010

IIS on Windows 7 / Vista / XP Pro

A project may propose using Webservices. So here I find how easy it is to enable IIS on Windows.

For Windows 7 / Vista, it is a build-in feature:
http://learn.iis.net/page.aspx/28/installing-iis-7-on-windows-vista-and-windows-7/
http://www.howtogeek.com/howto/windows-vista/how-to-install-iis-on-windows-vista/

For Windows XP Pro, it can be installed free:
http://www.webwiz.co.uk/kb/asp_tutorials/installing_iis_winXP_pro.asp

Monday, August 30, 2010

How to install GCJ: GNU Compiler for Java?

In Windows world, there is no single GCJ installation.exe that installs GCJ.

GCJ exists inside Cygwin. So we have to install Cygwin. Detailed Step here:
http://www.mcclean-cooper.com/valentino/cygwin_install/

Cygwin contains many components. It is not a good idea to install all and fill up the harddisk. How to decide which one to install?

My feeling is, choose only those components needed.

For example, I am clear that I want to use gcj ( GNU Compiler for Java ). So in the Cygwin-setup Search box, I type in “java” keyword. I choose only Devel/gcc-java.

The good thing is, when I click Next button, all the dependencies will be automatically chosen. Hence only the minimum set of components will be downloaded and installed.

When I am using gcj, along the way I’ll hit additional error, e.g. “cannot find…” missing libraries.

Error Message:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -liconv
collect2: ld returned 1 exit status

Then, I’ll launch Cygwin-setup again to install the missing library.

Keyword to install:
libiconv

Tuesday, July 13, 2010

Detect Brower Javascript Version

The following Javascript will show which version of Javacript the browser supports.
http://javascript.about.com/library/bljver.htm

Surprisingly, IE8 on Windows 7 only supports up to version 1.3. No wonder some Javascripts which work on Firefox (up to 1.8), Safari and Chrome (up to 1.7) do not work on IE8.










Friday, June 25, 2010

GIMP transparent background

It is quite easy to do transparent background with GIMP.

Clear demo is here:
http://www.fabiovisentin.com/tutorial/GIMP_transparent_image/gimp_how_to_make_transparent_image.asp

Note: Save as GIF (transparent background capable)

Thursday, April 15, 2010

Windows 7 and Java JDK 1.6 Timezone issue

Same piece of Java program running on Windows 7 and JDK 1.6, the date time related routine returns TIME ZONE :Greenwich Mean Time, which is wrong.

Insteads of going into source code level to add in timezome "GMT+8" routine, we can alter the timezone properties at command line level.

java -Duser.timezone="GMT+8" .....
or
java -Duser.timezone="Asia/Singapore" .....


Reference:
http://bugs.sun.com/view_bug.do?bug_id=6456628

Wednesday, March 17, 2010

Free Audio Sound Card Recorder

This software, is able to record input sound into computer with various formats.

http://www.freeaudiorecorder.net/Files/FreeAudioRecorderSetup.exe

Using tips:
1. To reduce noise, set the recording volume to 10.

Sunday, March 14, 2010

Powepoint PPT to Video VCD / JPG JPEG convert conversion

If we really have to go somewhere with TV but without projector and computer, to give the presentation, how to do?

1) Convert PPT to Video DVD

There are a few Powepoint PPT to Video DVD convert conversion software. However, it seems all of them need to pay.

http://www.mydigitallife.info/2007/10/09/how-to-convert-powerpoint-presentation-ppt-to-video-avimpeg-flash-and-cddvd/

I am using this one:
http://www.ppt-to-video-converter.com/downloads/smart-ppt-converter-setup.exe

Note: To maintain the quality, only DVD is accepted.

2) Convert PPT to picture JPEG

Most of the DVD players today can show JPEG file. So covert PPT to picture JPEG file will do also.

Note: name of JPEG file as
01.jpg
02.jpg
03.jpg
...
10.jpg

So that the sequence of the pictures will remain in order.

Thursday, January 21, 2010