Next Spaceship

Driving into future…

From GPU Computing to Cryptocurrency Miner

| Comments

OpenCL (Open Computing Language) is a new framework for writing programs that execute in parallel on different computing devices (such as CPUs and GPUs) from different vendors (AMD, Intel, ATI, Nvidia etc.). The framework defines a language to write “kernels” in. These kernels are the functions which are to run on the different computing devices. In this post, I explain how to get started with OpenCL and how to make a small OpenCL program that will compute the sum of two lists in parallel. After that, I will show you how to write a GPU Cryptocurrency miner with the help of OpenCL based on the knowledge we just learned.

Southeast Asia’s Diversity in Language.

| Comments

English, Bahsa Indonesia, Bahasa Malaysia, Burmese (Zawgyi), Thai, Vietnamese, Chinese, Khmer.

Even if we count Simplified Chinese and Traditional Chinese as one language, we still have eight languages that are widely used in Southeast Asia.

What We Use Make Who We Are

| Comments

For a start up, for a tech team, or for a community, what we use make who we are. They are the source of culture and they show what we believe.

Which operating system, Windows, Linux or OS X, do you use as the default developing environment? Which operating system do you use as the production environment, Debian based, Red hat based, or Gentoo? Which cloud server do you use, AWS or other? Which language do you use as the main backend language, Python, Ruby, Node.js, or Java, PHP, C++? Which infrastructure do you use?

Integrate Everything Into Slack

| Comments

Slack is gradually becoming the standard for modern office communication. While you may argue that technically Slack is no different than, say, IRC – the polished experience is what makes it stand out in the crowd of messaging services. Using less gentler words, Slack is killing email for office communications. And has built in support for code snippets with syntax highlighting. Boom.

Actually, Slack is more than just a communication tool. What makes it extraordinary is it provides the possibility to integrate everything and make your workflow complete. In this post we’re highlighting some of the most useful new workflows that Slack is enabling. All these are currently heavily in use in our team, and we find they are exceptionally helpful.

How to Be a Good Tech Lead for a Start Up

| Comments

To be a good tech lead in a start up is totally different from being CTO at a mature big company. There are numerous theories and technologies about managment in big companies. Unfortunately, there are not so much knowledges about how to lead a technical start up. Today, I’m gonna to give my advices. Hope they will inspire you.

I’m gonna talk this in 9 respects. They are not all ordered by importances, even though some are.

Cast Android and iPhone Screen Onto Macbook

| Comments

This guides is for casting Android and iPhone Screen onto a Macbook or other computers through a USB cable. If you’re searching a wireless solution, this is not. Actually after searching a lot, I find no good solution for wireless cast, so I admit this is a compromise solution. After all, fluency and resolution are more important.

Proxy All TCP Traffic on a Remote Server

| Comments

Even though SOCKS is a higher level protocol and more appropriate for doing proxy thing, there are no easy solution for building a global proxy for a Linux server except doing that on a router. For a remote server, normally a cloud server, it’s not always convenient to access the router. So after several tries, I decide drop the SOCKS solution, and simply use Linux’s iptables.

The easiest way I find from my recent research is with shadowsocks-libev. Shadowsocks-libev is a lightweight secured SOCKS5 proxy for embedded devices and low-end boxes. Shadowsocks-libev is written in pure C and only depends on libev and OpenSSL or PolarSSL. The use of mbedTLS is added but still for testing, and it is not officially supported yet.

9 Most Useful Jenkins Plugins

| Comments

To your disappointment, I’m not gonna to show up some theme plugins even though I do think there are much space for Jenkins to improve in this scope. I’m gonna to show you something that really really useful, much more useful than that kind of simple theme plugins.

Throttle Concurrent Builds Plugin

This plugin allows for throttling the number of concurrent builds of a project running per node or globally.

Atlassian License Analytics

| Comments

Bitbucket Server, Jira, Confluence, Crowd etc, so many excellent software come from a same company — Atlassian. Some of them are technically designed well (even though not best), so they are good study cases. These days I’m interested in the license generating algorithm, so I dig into them for studying. Its license algorithm is DSA. Theoritically, it’s impossible to know the private key, so the private key can be think as unknown and safe. Without private key, it’s impossible to generate the corresponding signature for raw text. In this way, it makes sure that every issued license is from the owner.

To better understand the relationship between orignal text and the license text, I write a Python code to uncover the original text from a license text.

Modify Java .class in a .jar

| Comments

Sometimes I need to know what’s inside to figure out a best solution, like modifying a Java .class file in a .jar file. After searching google and stack overflow for a while, I found this question is little cared, and almost all information is not complete. So I wrap them up and make the whole process runnable.

Transform All Files to UTF-8

| Comments

I wrote a blog several years ago about transform all files in a folder recursively from one encoding to another. Today I decide to solve this issue more completely.

I wrap all this to a Python egg package, upload it to PyPi, and everyone who want to use this don’t need to copy & paste code any more. Just install it and use it.

pip install toutf8

This ships with a shell command, so after installing, just type


to transform a single file to UTF-8 encoding, or


POJ 1020 Anniversary Cake

| Comments

This is a simple search problem. With some pruning job it’s sufficient to pass test cases.

The biggest possible area of cake is \(16 \times 10 \times 10\), so the biggest possbile side of cake is \(40\).

Image a cake as a matrix with rows and colums. Each element of this matrix is a 1x1 cell. The problem can be translated to if there exists a method to fill this matrix with squares.

Now fill the matrix in this order: find the lowest leftmost empty cell \(C_{i,j}\). Find successive cells \(C_{i,j}, C_{i, j+1}, \dots, C_{i, j+w}\) with the same height as \(C_{i,j}\).

Choose a square and put it into an area with left upper cell as \(C_{i, j}\). If this can not construct a solution, backtrack to use another squre, otherwise continue to the end and get a solution.

Calculate Distance Between Latitude/Longitude Points

| Comments

This page presents a variety of calculations for latitude/longitude points, with the formula and code fragments for implementing them.

All these formula are for calculations on the basis of a spherical earth (ignoring ellipsoidal effects) – which is accurate enough for most purposes [In fact, the earth is very slightly ellipsoidal; using a spherical model gives errors typically up to 0.3%].


This uses the haversine formula to calculate the great-circle distance between two points – that is, the shortest distance over the earth’s surface – giving an “as-the-crow-flies” distance between the points (ignoring any hills they fly over, of course!).

Haversine formula: \(haversin{\left(\dfrac{d}{r}\right)} = haversin{\left(\phi_2-\phi_1\right)} + \cos{\phi_1}\cos{\phi_2}\,haversin{\left(\lambda_2-\lambda_1\right)}\)


\(haversin(\theta) = \sin^2\left(\dfrac{\theta}{2}\right) = \dfrac{1-\cos(\theta)}{2}\)

\(d\) is the distance between the two points (along a great circle of the sphere)

\(r\) is the radius of the sphere

\(\phi_1\), \(\phi_2\): latitude of point 1 and latitude of point 2

\(\lambda_1\), \(\lambda_2\): longitude of point 1 and longitude of point 2

Downgrade MongoDB From 3.0 to 2.6

| Comments

Due to a Meteor bug (actually it’s a bug from MongoDB nodejs driver, but the bug has already been fixed by the nodejs driver, while the issue is Meteor is referencing an old version of this driver), I have to downgrade MongoDB from 3.0.5 to 2.6.10. Normally this is a trival work, but it cost me a whole afternoon to do this, because there are serveral traps in there, so I decide to write this blog to help other people who meet the same issue with me.

The main problem is MongoDB 3.0 uses a new version of authentication algorithom SCRAM-SHA-1, while 2.6 uses an old version MONGODB-CR. Actually there are other methods besides these two. These two are the default configuration. If one upgrades MongoDB from 2.6 to 3.0, the authentication schema version can be upgraded by authSchemaUpgrade from 3 to 5, and in the same time the authentication algorithom will be upgraded from MONGODB-CR to SCRAM-SHA-1. However, when one downgrades MongoDB from 3.0 to 2.6, you can not use authSchemaUpgrade to downgrade the authentication schema, and it will remain in 5 and the authentication algorithm will remain in SCRAM-SHA-1, which are not supported by MongoDB 2.6. So yes, without additional work, you are not able to log into the database.

This article provides a method to solve this issue, which is not documented by MongoDB official website (and appearantly not documented in anywhere).

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