Setting Up L2TP VPN to Bypass Great Firewall Of China Jan 11, 2017

Last month, I traveled to China for the second time. Unlike my first trip, this time I am more prepared to bypass the great firewall of China.

During my first trip in China, I was mainly relying on simple SSH tunnel to get access to Gmail and all other blocked services. This solution is unrealiable because I couldn’t use it on my Android phone. Aside from that, I also kept having constant dropouts which explained in this blog post http://blog.zorinaq.com/my-experience-with-the-great-firewall-of-china/

... ➦
HAProxy as a reverse proxy for cloudinary images Dec 05, 2016

We are using in one of our applications Cloudinary to host and resize images on the fly. We are also using Cloudflare for our CDN and DNS management.

I was given a task to setup a CNAME subdomain in CloudFlare to forward the request to Cloudinary. This way we can still have the benefit of serving static images from CDN as well as reducing the Cloudinary bandwidth usage.

My solution is to set HAProxy as a reverse proxy which responsible to fetch images from Cloudinary server. You can see the overview diagram below:

... ➦
HAProxy and A/B Testing Apr 13, 2016

Few weeks ago, I was given a task to create an A/B test using HAProxy. I need to make HAProxy to split traffic between two different applications ( Rails and NodeJS )

In this blog post, I’ll explain how to achieve this.

Create ACL for the page you want to A/B test

The first step you have to do is to create an ACL for the URL you want to A/B test. In this example, the URL path is /ab-test-path

... ➦
Create new user on Amazon AMI and give it root access Mar 09, 2016

Setup your new EC2 instance on AWS and choose Amazon AMI.

SSH to your instance using your private key

ssh -i <path-to-your-pem-file> ec2-user@<ec2-endpoint-or-ip>

Change to root

sudo su

Create new group for your user ( in this case my group name is ‘dev’ )

groupadd dev

Create new user and assign it to your recently created group

useradd -g dev dev

Give the username root access

visudo

Add this to the bottom of the file

dev     ALL=(ALL)       NOPASSWD:ALL

Delete the password for ‘dev’ user

... ➦
Import JSON to Elasticsearch using jq Feb 16, 2016

This is based on http://kevinmarsh.com/2014/10/23/using-jq-to-import-json-into-elasticsearch.html

Install jq first on Mac

brew install jq

Import the JSON file to Elasticsearch index

cat file.json | jq -c '.[] | {"index": {"_index": "bookmarks", "_type": "bookmark", "_id": .id}}, .' | curl -XPOST localhost:9200/_bulk --data-binary @-

Check for the list of indexes http://localhost:9200/_cat/indices?v

See the list of records http:/localhost:9200//bookmarks/_search

Reopen Last Commit in Git Jan 20, 2016

Run the command below if you want to reopen the last commit in your git

1
git reset --soft HEAD~

This is useful if you miss something in your last commit. Instead of creating new commit and squashing it, you can open last commit and fix it there.

Copying Files Between Two S3 Buckets Oct 16, 2015

Today, I have to copy files from one S3 bucket to another S3 bucket which sitting in separate AWS account.

Initially, I was thinking to use S3 clients ( Tranmit or Cyberduck ) to download the files first and manually upload the files again to the other S3 Bucket. However, this approach will consume a lot of bandwidth and really slow if you have a lot of files in your S3 bucket.

... ➦
Create SSH Tunnel To Backup PostgreSQL Database Aug 31, 2015

Today, I was trying to create a backup of production database. The problem is we have two different version of PostgreSQL running on production and these databases can only be accessed from front end(FE) server. We have older version of PostgreSQL client installed in all FE server which means I can’t use it to run pg_dump.

SSH Tunnel to the rescue

One solution to this problem is to create a SSH tunnel. Since I have the latest version of PostgreSQL client installed in my machine, I can run pg_dump locally which will connect to the database through SSH tunnel.

... ➦
Rails Engines and Vim May 03, 2015

At the moment, I am working on a Ruby on Rails projects using Rails Engines ( you can read more about Rails Engines here: http://guides.rubyonrails.org/engines.html ). In this post, I’ll share my tips and trick on how to configure your vim to work with Rails Engines.

NERDTree Bookmark

I am using NERDTree Bookmark to quickly jump between different engines. If you are using NERDTree, you can create a bookmark by putting your cursor on one of the Rails Engines directory and use the command below:

... ➦
Symbolic Links With Vagrant Windows Oct 27, 2014

There are few known limitations when using Vagrant on Windows machine. One of these limitations is the lack of symbolic links support on synced folder.

Symbolic links are used heavily by NPM to create shortcut for the libraries. I posted more details about this here: http://blog.rudylee.com/2013/10/24/fix-npm-symlink-problem-in-vagrant/

Most of the time, you can get away with ’npm –no-bin-link’ solution. However, you need more robust solution if you are using complex tools such as Grunt or Yeoman.

... ➦