Setting up a Unix environment in Windows


  • Get consolez
  • get cygwin, and apt-cyg
  • Map windows’ version of software so they can be run in the shell. e.g. vim

This post will talk about how I set up my Windows development console and how it integrates nicely with a Unix workflow.

My laptop’s hardware incompatibility (overheating GPU and a non-working fingerprint reader) when running Linux is the main motivation for this setup. I find that the Unix terminal is more conducive for programming than the Windows’ terminal for some reasons. So because I am stuck with using Windows for now, I really like being able to emulate a Unix environment as much as possible.

Most common way to do so is to install a Unix environment such as cygwin or mingw, or if you install git, you’ll have git bash. However, these are quite spartan and feels more like a clutch rather than a proper tool. I also wanted to be able to use tabs and have my home directory similar to that of Windows. In short, I wanted those terminals to be a drop-in replacement for cmd.

Then I found console. Firstly, it has tabs, which makes things awesome (aside: It really amazes me that tabbed windows explorer isn’t a thing even up till Windows 8, when tabbed browsers was already a thing as early as Windows XP). Secondly, it allows you to launch different types of shell, both cmd and those terminals mentioned above. That is great because now I can bind a shortcut key like ctrl + alt + t to launch console, and go into a Unix environment. Later on I found a fork of console called consolez, which has many awesome features like keybinding for hiding/revealing the console, running cmd with elevated privileges, windows snap. The last one means I can break out of the 80 by 25 window, which makes vim look awesome.

However, such emulators fall short of the Unix terminal because not all POSIX softwares are available by default, eg ssh. Furthermore, installing a software on such terminal is not as simple as apt-get install <package> in Linux. Luckily, for cygwin, there is apt-cyg, which allows you to install software by typing apt-cyg install <package>.

Still, that is not a silver bullet, some software deals with the windows libraries and the above method just doesn’t work. In that case, a simple solution will be to install the windows binary version, and then copy the executable file into the /usr/bin directory for the terminal.

For example, I wanted to run mysql console from cygwin. But it was not installed by default. Using apt-cyg install mysql gave me some error when running it which I suspect is because the system calls don’t match up exactly between the two environment. However, because I already have mysql installed via wamp, I simply copied the binary from wamp/bin/mysql/mysql<version>/bin to cygwin/bin and viola, I was able to run mysql inside cygwin successfully.

That concludes this post. This has made my life working in the command line so much more pleasurable in Windows.

Video downloader for wimp and dump and are two websites that contain videos from various sources and are updated daily. When I see a video I like, I want to be able to download it and save it for future (watch it again on long train journeys, for example). So as a weekend project, I wrote a userscript that will generate a link to download the video as seen in the screen shot below.



My Android phone build for 2014

About a year ago, I posted my phone build. One year later, I have decided to update it. Currently, it is running MIUI V5 3.12.20 and I love the fresh user interface. See screenshots below.

Searching Chinese words easily

I have taken a renewed interest in re-learning my Mandarin and I have used some apps to help me.
HanPing Chinese dictionaryOffline Dictionary, Google PinYin inputtasker, secure settings and its helper,

Offline dictionary allows one to do a English-Chinese translation, which is very useful. To understand the Mandarin phrase better, I use Hanping dictionary, which allows pinyin and handwritten search. Normally, the handwritten search is a feature only for the pro version (along with other features); However, my friend told me a fix: the free app by Google allows one to input text by drawing the characters, and this can be fed directly into the Chinese dictionary. However, it is very troublesome to have to switch inputs every time I want to search a word, and switch it back for my daily use. This is where tasker comes in. In tasker, one can create triggers and automate the phone. Combined with secure settings, I was able to trigger an input switch on starting the Dictionary app and switching it back on closing the app [source]. Now I have a seamless system that allows me to search up unfamiliar terms easily.

Using taskers

Taskers is like a programming language for android phones, it can help automate so many things on the phone. Check out some recipes here.

At the moment I am using the following profiles:

  • Switch off 3G and wifi at night (0000 – 0800)
  • Switch to 3G when out of house as determined by my GPS location, switch to wifi otherwise

Some debugging

My GPS was originally unresponsive, it took forever to get a location. I did some searching and I found that this post fixed my problem.


My current phone build

It is wise to re-install the ROM of android phones once in a while – doing this will not only remove unnecessary clutter that slows the phone down, it also provide new features that come with updates. I have been harbouring this though of installing a new ROM for some time, since the start of the year actually, but have always been busy with other things. Today I finally found the time to do it, and it took me a good 3/4 of a day.

This post is mainly to log my process for future reference. It contains links to resources as well as some app recommendation that is useful to readers. This is by no means a complete walk-through of how to install a custom ROM, I would recommend google and xda forum for that. This is more of an outline of a possible phone build and how I use my phone.

Starting point

I remember installing a custom rom (HTC revolution HD) on my HTC sensation XE about a year and a half ago from this website. I went back to the same website to see what are the latest ROMs available and was quite excited to see ROMs with the new android version. I initially installed Codename Lungo but then encountered some problems with the search key – it doesn’t launch google search, and it was also missing some default useful apps such as torch and calculator, which can be useful at times. So I decided to install CM10.1 AOSP instead. Both ROMs gave my device a new breath of life. The previously slow and unresponsive phone has transformed into a very modern and responsive phone. I was very pleased. To me, speed is the utmost importance and phone features come second since I only use my phone for a very limited purpose and I just want it to do those functions well. The ROM exceed my expectation by giving it a very nice UI (credit goes to the new JellyBean android version).

The selection

After using my phone for a year and testing different apps along the way, my phone has chalk up some random junk in the memory. In exchange, I know what apps I must have and what apps I can do without. A good rule of thumb is if I can’t name or describe the app without looking at my phone, I probably won’t use it again.

My main criteria for apps are:

Cross platform

My workflow involves rotating between my computer, tablet, and phone and I want to be able to access my data on all platforms without any unnecessary hassle. This is also precisely the reason why I looked into tiddlyWiki in the past.

Works offline

I do not have a data plan so I cannot rely on apps that requires the internet to function. Due to the lack of wireless connection in my room, I set up wireless hotspot with my computer for my other devices to connect to. I want my devices to be in sync when they are connected to this network.

Effortless synchronisation

It is not difficult to manually ensure that files are up-to-date but the human memory is not to be trusted with such task. The third criteria is that updated data should be accessible across devices. While there are cloud storage services like dropbox and its likes around, I feel uneasy uploading huge amount of data to be synchronised over the internet – for security and speed reasons.

The necessities

I’ve filtered the list of apps that I needed to the following:

* Offline dictionary

An offline dictionary which does translation to other languages as well. I took up learning German and French over the past year and this dictionary has served me very well.

* HanPing – A mandarin dictionary which can detect handwriting

* WikiDroyd (replaced now by aard)

An offline version of wikipedia (and other encyclopedia). Knowledge is power and wikipedia is the best source of free information.

* Epistle (replaced now by draft) – A text editor that can synchronise with dropbox

I like to take notes – I take notes when I read a book, visit museum, contemplate over life. This is my digital pen and paper. The physical pen and paper suffers the risk of damage and getting lost and also the lack of searchability but this solves all these problem. The best thing is it is lightweight since it’s just text and it synchronises smoothly with dropbox, making my notes accessible across all devices. Using a markup language like Markdown is an option to record notes.

* SweetHome wifi – A tool to synchronise photos with the computer over wifi automatically

Occasionally, I take photographs with my phone. However, over the past few years I realised I am very disorganised with the photos taken. I can never be sure whether the photos in my phone has already been transferred and kept on my computer or not. This app solves the problem by synchronising my photo album with a folder on my computer automatically every time I connect to a selected network (in this case my wifi hot spot). It has been working great and I can seamlessly access photos I’ve taken on my computer without bothering with connecting the phone to the computer and switching to USB mode.

* Draw – A simple blackboard to allow drawing

* Detexify – An app that converts handrawn symbols to latex

* AndTidWiki – An offline tiddywiki reader

* Memoires – A dairy to record significant events

* AirDroid

An app to access phone data via a computer. This app makes it easy for me to access my files and clipboard. I’ve used it mainly to access and modify the clipboard when I’m in my room, it can also be used outside of my room as long as the computer that access it is connected to the same wifi network.

* K-9 Mail – An app to get my mail across multiple accounts

* Opera Mini – Internet browser that is fast and supports sync

* Dolphin browser – Another good internet browser. I compartmentalise my internet surfing so I use two browsers.

* Swiftkey

My favourite keyboard replacement. It predicts words well, allows multiple words prediction, and also a swipe-to-delete-word function which is nifty. I think the way to type fast in the phone world is to delete the whole word and retyping it rather than by locating the error by using our oversized thumb or index figure or by using auto correct like with iOS.

* SyncMe – Another app to synchronise the phone and the computer. This is used to synchronise other folders.

Boldface apps are those that I use almost every time I use my phone and I would recommend it to people.

The fluff

Next come some system tweaks and apps that are good to have, often existing without me knowing.

* AdAway – removes pesky ads
* CamScanner – take picture of documents
* AnkiDroid – Flash card app (cross platform)
* Cipher tools – useful tool to decipher text
* ConnectBot – SSH terminal
* Soundhound – A song recognition app
* Dropbox and Boxcryptor – Cloud storage and encryption tool

Some debugging

As with most hacks, things rarely work out of the box. I encountered some problems here which I subsequently solved.

Unable to install app because there is not enough space

This occurs when you install an app but it says there is not enough space even though there is clearly enough space when one checks the storage. This can be solved by using a file manager and deleting the file associated with the app found in /data/app.

Unable to get into recovery using adb

I don’t really know why this is happening (probably a different driver is needed). But there is an option called advanced reboot which allows the phone to reboot into recovery without adb. Need to activate developer mode by going to “about phone” and continuously pressing build number.

Final words

I am extremely happy with my new phone, it’s like a modern phone in a body of an old phone. I realised I didn’t elaborate as much as I intended to so I’ll probably do that next time if I feel like it.