# Mercurial Wrong Architecture Error on Mac OS X

If you install Mercurial(hg) via brew install mercurial, it succeeds to install, but when you run hg command, it fails with the following error message:

# Switch Netgear WNDR4300 From DD-WRT to Open-WRT

DD-WRT is a really nice way to free your router. It has a polished web interface, gives you far greater control than most proprietary firmware, and is supported on a large number of devices. However, Open-WRT is better! In my installed version of DD-WRT, ssh doesn’t work, and I can not install an external driver like rtl8187 for my Alfa AWUS036H. After seaching Google for some time, I realise that I need to change the operating system, even though installing DD-WRT cost me several hours.

# Root Android 5 in a Hacker Way

So why bother to root an Android device?

Because Android’s permission control system is so weak and unsatisfied. Any app may apply more permissions than need, and if you really need some apps but don’t like to give them some permissions, there is no way to use them with selected permissions unless to root the device. Aother drawback is the battery usage. Apps like to live as long as they can. They don’t want to die or be killed. In my experience, the battery usage for a constant time increases almost linearly for the number of apps installed. So to save battery and make a fair enviroment for all apps installed, you need manual control of apps, which needs a root access of a device.

Before ROOTing, install adb and fastboot from Android’s official website.

# Diversity and Possibility

Diversity and Possibility, two of the most important things to me.

That’s why I use Nexus (that can not be bought directly in my country). That’s why I use both Chromebook and Macbook. That’s why I use Dvorak keyboard layout. That’s why I joined big companies, middle companies and start-ups. That’s why I learn different kinds of languages.

I will pursue them for all my life, and that’s why I came to California a second time.

# How to Tip Properly in the US

It’s really a headache problem for a non-local person to tip properly. Before I come to the US, I have no experience about this. Unfortunately, I didn’t do any preparation about tipping before I come here. Fortunately, I find this table :D

# POJ 3468 a Simple Problem With Integers

Like POJ 3264 Balanced Lineup, segment tree is used.

The point is not to push down delta value to descendents, just keeping it on current node if the addition is for all its descendents.

Source code:

# POJ 3264 Balanced Lineup

This is a classic range minimum query and range maximum query problem.

Segment tree, with $$O(\log_2{n})$$ updating complexity and $$O(\log_2{n})$$ query complexity, is a perfect data structure for this problem.

Actually this is really easy once segment tree is imported.

Source code:

# Phonetic Alphabet

Today I study phonetic alphabet, which is really helpful the moment like pronounsing B as D.

# Open Source Python Based Wiki: First Wiki

First Wiki is a wiki written in Python. I write this because I counln’t find a beautiful wiki in Python.

First Wiki is based on shire, which is a web framework based on Tornado Web Server, MongoDB and Bootstrap.

First Wiki is open source, license is https://github.com/leonsim/firstwiki/blob/master/LICENSE. Source code is hosted on GitHub.

# Resetting Default Input Method in Mac OS

I became a Dvorak guy. Before that, I had initialized my Mac to a U.S. keyboard layout. After I changed my Mac to Dvorak keyboard layout, everything worked like a charm except the login window was still the U.S. layout. This frustrates me a lot. So today I spend a little time to reslove this issue.

# How to Get Coordinate of a ClickableSpan Inside a TextView

I have a TextView with many ClickableSpan.

On click on a ClickableSpan, I have to get the coordinate on screen of it (to show a custom View at his position).

The problem is that the onClick() method of the ClickableSpan gives me in parameter a View, the TextView which contains the ClickableSpan.

Thanks to Google, I find this solution. This helps me to win a Leopard Buffet. :D

# Write LaTeX in Octopress With MathJax

The easiest method is to add by Mathjax CDN, but the drawback are it’s not always stable and it doesn’t work if you want to develop offline and want to preview via the rake preview command. So I have to embed a customized version of Mathjax into Octopress. With this method, I can preview equations offline and it’s more stable – it doesn’t depend on the public CDN of Mathjax. OK, DIY start.

# Wolfram Language Is Close to Release

I’m excited to receive a message from Wolfram Language Team today:

Today I’m thinking about questions of those website using http protocol. When user logins in a http website, how to protect the password’s security. The conclusion is it is not easy to do so, because I haven’t figured out a method to prevent the possibility of man-in-the-middle attack without a PKI infrastructure. Maybe in the future, with the use of quantum cryptography, we can do that easily, but currently it’s hard.

Nevertheless, we still can make the process of login more securier. One approach is to hash password, and only transmit the digest instead of the plain password. To use this method, don’t forget to change salt frequently enough. But now I want to use another approach, just for fun.

# Shire - a Framework Based on Tornado Web & MongoDB

Merry Christmas!

Today, I open sourced a project named shire via Github.

shire is a web framework based on Tornado and MongoDB.

# My Certificate for Digital Analytics Fundamentals

Ok, when my command git submodule foreach --recursive git pull origin master --recurse-submodules is still running, I write this blog.

Yesterday, I received an email from Google Analytics that reminded me that day is last day to earn your certificate for Digital Analytics Fundamentals. Here is the email:

Since HTML5 is currently widely supported, and it’s a standard, it’s time to use it. Users who don’t have a modern browser should have one now. And browsers are free, why not use a faster and more standard one?

Uploading files was not supported by HTML for a long time. For example, you can not post a new file to server via Ajax. Actually you can do this, but in a hack way or with Flash. There is not even an elegent way to do this. But this will not happen any more. Things move forward. We have HTML5 now.

With HTML5, we can implement an uploading file server easily. Let me show you.

# Converting Text Files From One Operating System to Another in Python

Linux and modern OS X Macs end their lines with the same character, the LF. To cut down on confusion, think of OS X Macs and Linux as being interchangeable. They are interchangeable in terms of the end-of-line character. Whilse Microsoft Windows does things yet another way. Under Microsoft Windows, lines end with a combination of 2 characters – a CR followed by a LF. Symbolically, this is represented as CRLF or carriage return, line feed.

There are issues when you cooperate with others using different operating systems. So I write two Python script to resolve this issue. They also deals with BOM in text files which is automatically added by Windows platforms.