Next Spaceship

Driving into future…

Automatically Mount an Amazon EBS Volume

| Comments

After you attach an Amazon EBS volume to your instance, it is exposed as a block device. You can format the volume with any file system and then mount it. After you make the EBS volume available for use, you can access it in the same ways that you access any other volume. Any data written to this file system is written to the EBS volume and is transparent to applications using the device.

Note that you can take snapshots of your EBS volume for backup purposes or to use as a baseline when you create another volume. For more information, see Amazon EBS Snapshots.

Use the following procedure to make the volume available. Note that you can get directions for volumes on a Windows instance from Making the Volume Available on Windows in the Amazon EC2 User Guide for Microsoft Windows Instances.

Switch Netgear WNDR4300 From DD-WRT to Open-WRT

| Comments

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

| Comments

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

| Comments

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

| Comments

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 3264 Balanced Lineup

| Comments

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:

Resetting Default Input Method in Mac OS

| Comments

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

| Comments

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

| Comments

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.

Encrpyt Login Password With RSA

| Comments

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.

My Certificate for Digital Analytics Fundamentals

| Comments

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:

Upload File With HTML5

| Comments

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

| Comments

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.