Next Spaceship

Driving into future…

Automatically Backup MongoDB With AWS CLI

| Comments

After searching google, the information about backuping MongoDB is neither obselete or complicated. So this article is about a new practice on automatically backup MongoDB with AWS’s offical tool AWS CLI. It’s more straight forward and more compatable with the new Amazon S3 server (supporting the newest v4 signature).

Before that, let’s review some existing methods. One method is use the open source project s3cmd. Originally it doesn’t support the v4 signature, and after a long time, it finally supports v4 signature. The issue is it still doesn’t support the China region S3 server. Due to the maintainer is only one person and he doesn’t have enough time on this project, I guess it will another long period of time to fix this. Another method is to use mongodb-s3-backup. After a little modification, it can handle Chinese region S3 server well, but it doesn’t support v4 signature.

So I just creat a new script:

Upgrade Http Site to Https (for Free)

| Comments

Even though the serieze of HeartBleeding bugs makes HTTPS (SSL) look vulnerable, I still believe after bugs fixed, HTTPS is more secure than HTTP. Actually we can archieve this in a few simple steps with technologies like OpenSSL, free certificate provider, nginx configuration.

Setting Up MongoDB Replication on EC2 With Ubuntu 14.02

| Comments

To setup a meteor production environment on EC2, we need to install mongoDB as the main database. To use the MUP(Meteor Up tool), it’s easier to use Ubuntu operating system.

This article is about how to setup mongoDB replication on EC2 with Ubuntu 14.02 LTS. Basically, it’s the combination of the following articles:

Upgrade Linux

| Comments


emerge --sync
emerge --update --deep --with-bdeps=y --newuse world
revdep-rebuild -ip

Don’t forget to read news:

eselect news list


apt-get update
apt-get upgrade
apt-get dist-upgrade

Red hat

yum update

Compile Customized Vim on Mac OS

| Comments

For Mac OS developers, it’s essential to build your own arsenal. For most Linux utilities missed on Mac OS, just use homebrew to install. There is one exeption I make: Vim.

There is an integrated Vim on Mac OS, and also several brew version of Vim for choose. However, sometimes you find you have to compile Vim by source code, for getting the latest version of Vim, for customizing some configuration, for using some special features, or something else.

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.