Visual Studio Code Zip / Portable Version for Windows

Recently I was given an exercise to work on Node.js. A few years ago I was using Aptana Studio on Node.js. So after these few years I guess there should have some IDE or editor available for Node.js. So I ended up found Visual Studio Code and Atom.

I tried both Visual Studio Code and Atom, and I choose Visual Studio Code at this moment because the autocomplete suggest is much more better than Atom.

For software that I use, I usually prefer portable version. I found someone has made one, but I don’t like unofficial release. I looked again and lucky found a post here which mentioned that there is a portable version of Visual Studio Code.

After further checking, it is actually a zip version and officially the download link is located deep inside the FAQ section of Visual Studio Code.

Anyway for those who like no installer version, below is the link to download it directly.

Edit 2016-08-13: Finally the they have provided the Zip archive download link in their download page.


Spam Spam Spam

I just discovered an unapproved comment in my mailbox. The comment look fine, but strange.


So I google it, and ended up finding a bunch of websites with similar comments. One website even take the question seriously and answered the question in a blog post.

I still not quite sure why people make such comments. Maybe leaving the link to their website. Anyway, this comment is marked as spam by me.

Error 1918 when Installing MySQL ODBC Connector 5.3.6 on Windows

It is somewhat a frustration that even the official website at the time of writing this doesn’t correctly list out the dependency software.

Anyway in short, make sure you have installed Visual C++ Redistributable Packages for Visual Studio 2013 if you are installing MySQL ODBC Connector 5.3.6.

The official website and many other website I found only mentioned to install Microsoft Visual C++ 2010 Redistributable Package. Some websites even gave an inappropriate installation instruction to user. Although Microsoft Visual C++ 2010 Redistributable Package might be required for older version of ODBC connector, but definitely not version 5.3.6.

Also, it is better if you are installing the latest version of Visual C++ as well. Many website I found (such as this, this, this and this) are still providing link to the old version of Visual C++ even a new version is already available at the time of their writing. You may check the latest version of Visual C++ at Microsoft website here but, even the official website cannot be trusted as I can find a more updated version of Visual C++ 2015 here at the time of writing this article…

In summary, trust yourself.

2015 in review

Year 2015 will soon pass (in Hong Kong). It is a busy year in a way that I don’t have spare time to work on my Android apps. Too bad I only recall bad things happen in my life this year, although I also had a 3 week cycling trip at Taiwan which keep me busy throughout the year for preparing and post-trip processing.

Hopefully next year I can spend some time in Android app next year and also with my family.

Anyway as usual, a report of my site in year 2015. Too bad I only posted 4 posts this year.

The stats helper monkeys prepared a 2015 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 12,000 times in 2015. If it were a concert at Sydney Opera House, it would take about 4 sold-out performances for that many people to see it.

Click here to see the complete report.

Surprise because of FullSync

Today out of a sudden I got an email question on FullSync. I didn’t recall I wrote an app called FullSync, so my first thought is, the email was sent to a wrong email address.

But something didn’t sound reasonable. If the email was sent to a wrong email address, why it was to my email address but not others?

So I Google and dig up what happened. Ended up I found that one of my commit to my forked FullSync source code was merged to the project branch by the developer, and my name is added to the special thanks of FullSync.

Well that’s something that I didn’t expect, but good that I did some contribution. However too bad that the project seems no longer active these few years.


My commit at my forked source code was merged to FullSync

Reading UTF File with BOM to UTF-8 Encoded std::string in C++11 on Windows

I got a task from boss and during the task I need to write a C++ function to read a text file into UTF-8 encoded string. I can’t believe this easy task in high level language like VB.NET cost me 2 days to figure the solution out. Some solutions use libraries like UTF8-CPP or ICU, while some use Windows API. These ways works but I don’t quite like them because:

  1. Usability, some solutions work good for most characters but failed to handle non-BMP characters
  2. Portability, we are foreseeing our code will be migrated to Linux, use of Windows API means adding work to our migration work in the future
  3. Dependency, I don’t want to depend on third-party library, especially the C++ function later will integrated with the program which only depend on very few third-party library.

Surprisingly there is not much solution that I am satisfied from the Internet, but good that at the end I still able to figure the code out. It still used one Windows API function though, but it is much easier to port to Linux already than ten functions. Anyway here it is:

// Reading ASCII, UTF-8, UTF-16LE, UTF-16BE with auto BOM detection using C++11 on Windows platform
// Code tested on Microsoft Visual Studio 2013 on Windows 7
// Part of the code is referencing

#include <stdio.h>
#include <tchar.h>
#include <string>
#include <fstream>
#include <sstream>
#include <locale>
#include <codecvt>
#include <iostream>
#include <io.h>
#include <fcntl.h>

#define TEXT_FILE_PATH      "D:\\test.txt"
#define ENCODING_ASCII      0
#define ENCODING_UTF8       1
#define ENCODING_UTF16LE    2
#define ENCODING_UTF16BE    3

std::string readFile(std::string path)
	std::string result;
	std::ifstream ifs(path.c_str(), std::ios::binary);
	std::stringstream ss;
	int encoding = ENCODING_ASCII;

	if (!ifs.is_open()) {
		// Unable to read file
		return result;
	else if (ifs.eof()) {
	else {
		int ch1 = ifs.get();
		int ch2 = ifs.get();
		if (ch1 == 0xff && ch2 == 0xfe) {
			// The file contains UTF-16LE BOM
			encoding = ENCODING_UTF16LE;
		else if (ch1 == 0xfe && ch2 == 0xff) {
			// The file contains UTF-16BE BOM
			encoding = ENCODING_UTF16BE;
		else {
			int ch3 = ifs.get();
			if (ch1 == 0xef && ch2 == 0xbb && ch3 == 0xbf) {
				// The file contains UTF-8 BOM
				encoding = ENCODING_UTF8;
			else {
				// The file does not have BOM
				encoding = ENCODING_ASCII;
	ss << ifs.rdbuf() << '';
	if (encoding == ENCODING_UTF16LE) {
		std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> utfconv;
		result = utfconv.to_bytes(std::wstring((wchar_t *)ss.str().c_str()));
	else if (encoding == ENCODING_UTF16BE) {
		std::string src = ss.str();
		std::string dst = src;
		// Using Windows API
		_swab(&src[0u], &dst[0u], src.size() + 1);
		std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> utfconv;
		result = utfconv.to_bytes(std::wstring((wchar_t *)dst.c_str()));
	else if (encoding == ENCODING_UTF8) {
		result = ss.str();
	else {
		result = ss.str();
	return result;

You can also find the above code at

Building Linux RPM Package from Source Code

Sometimes for some reasons you might not be able to find RPM package that you needed on the Internet. In that case you have to build the binary by your own. Certainly an easy way is just build the binary and install it, but a better way is to build a RPM package so that it is distributable and can be under Linux package management. So below is the steps for building RPM package from source code, referencing from with some changes.

# Step: 1
# Install rpmbuild

yum install rpm-build

# Step: 2
# Create rpmbuild folders in your home directory

mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

# Step: 3
# Download the source file

wget -P ~/rpmbuild/SOURCES ""
tar -xzvf ~/rpmbuild/SOURCES/git- -C /tmp

# Step: 4
# Prepare the .spec file, and made any necessary changes
# If the source file did not include .spec file, you have to prepare one by your own
ls -l /tmp/git-*.spec
cp -p /tmp/git- ~/rpmbuild/SPECS
vim ~/rpmbuild/SPECS/git.spec

# Step: 5
# Build rpm
# If you get any errors during build, it is usually because of dependencies. Simply
# install the dependencies with `yum install [dependency]` and run rpmbuild again.

rpmbuild -ba --define "_topdir %(echo $HOME)/rpmbuild" ~/rpmbuild/SPECS/git.spec

You can also find the above code at