Tuan Anh

container nerd. k8s || GTFO

Đặc quyền con người qua trò ném giấy vào thùng

dac quyen con nguoi qua tro nem giay

(…) when conservatives go on about “equality of opportunity, not equality of outcome,” they’re either blinded to the fact that equality of opportunity doesn’t exist or they’re aware of that fact and simply being disingenuous.

Be aware of the opportunities that we enjoy, which others may not. Our success might not be merely our own, can hopefully instill in us some empathy for people who didn’t have similar opportunities.

link bài gốc

Về một thách thức trong quá trình học hỏi

Mỗi đất nước, dân tộc, văn hóa, thậm chí mỗi cá nhân là một vũ trụ phức tạp, chứ không phải là những nhân vật của một vở kịch tuyên truyền thô thiển: người này giỏi, người kia kém, trắng đen rõ ràng và bất biến. Thách thức trong quá trình học hỏi là nhận biết được sự phức tạp, những xung đột, những chấn thương, bế tắc, những năng lượng của một quốc gia, một nền văn hóa.
Ngược lại, càng mù quáng, tôn sùng vô điều kiện một cái gì đó thì lại càng dễ thất bại. Và khi vỡ mộng, người ta lại càng vội vã tuyên bố phải “thoát” nó ngay lập tức để chạy tới tôn thờ một cái mới. Tâm thế đó là tâm thế của những kẻ mất tự do.

Nói chung là mỗi nền văn hóa đều có điểm tích cực và tiêu cực. Nên học hỏi 1 cách có lựa chọn thay vì tôn sùng mù quáng.

link bài gốc


We all want Love.

There’s always someone for somebody.

Be vulnerable. Break down your walls. Open up.

Be kind to yourself.

It will come. It will happen. Don’t try to find it, somebody’s gonna find you.

Choose your relationships. Value those who are important to you.

Do not take them for granted, ever.

And most of all, love. Always.

Managing multiple SSH tunnels is easy with Secure Pipes

I know we can easily get away with a single command line but this app makes it so much easier for dealing with multiple ssh tunnel. Also, without the hassle of going to Network Preferences to toggle socks proxy. This is the best app I tried so far.

Secure Pipes - Free

link bài gốc

Official Oracle driver for Node.JS

Currently at v0.2. node-oracledb makes use of C API for performance which makes it more like a “thick client”. That mean you are required to install Oracle’s client lbiraries1. Though versioned as 0.2, node-oracledb already supports a lot of features such as connection pooling, statement caching, client-result caching, etc…

node-oracledb is not yet available through npm. You will have to clone and run npm install manually by yourself. Windows support is still pretty rough but I don’t actually care much. I don’t have much need for Windows server these days anyway.

link bài gốc

Atom switches to io.js

Great news for io.js team. There are quite a few big names in OSS joining the io.js train already, namely NW.js, Atom.

To be fair, I don’t want io.js to merge back to nodejs if they succeed. The more I read about nodejs and Joyent, the more I hate them. io.js should just proceed on their own.

As for Atom, it still fails to impress me after a long time. Loading application alone (no project) is approx~ 2 seconds for me1 which is unacceptable. Code editor should be fast. If they can’t even sort this out, I don’t think I would bother trying their regex search or anything else performance-required.

  1. I’m using a Macbook Air mid-2011. 

link bài gốc

Incremental regeneration in latest jekyll build

jekyll is an awesome static generator but its regenetion time is totally unexceptable. It works well when you have small number of posts but start to degrade as number of posts increases. Actually, I don’t care about it much when I git push to the repo because my VPS is using SSD-cached but previewing the site at localhost is such a pain.

So when I take a look at jekyll again today and see this pull request, I’m so excited and couldn’t help but clone the repo and rebuild jekyll to test it out myself.

git clone https://github.com/jekyll/jekyll.git
gem build jekyll.gemspec
gem install jekyll*.gem

A quick look at jekyll reveals that it now has a file named .jekyll-metadata to keep track of mtime of the change file and their dependencies.

  mtime: 2015-01-31 12:31:57.000000000 +07:00
  - /Source/myawesomeblog.com/_layouts/post.html
  - D:/Source/myawesomeblog.com/_includes/head.html
  - D:/Source/myawesomeblog.com/_includes/header.html
  - D:/Source/myawesomeblog.com/_includes/footer.html
  - /Source/myawesomeblog.com/_layouts/default.html

I tested the beta gem on an old PC of mine with 5400rpm HDD to see how much speedup the new build offers. Prior this, when using jekyll serve, the regeneration speed is really slow. It takes minutes (literally minuteS) for a site with barely over 100 posts.


It does actually speedup. A quick change in a single file now takes 17 to 40 seconds to regenerate (of total ~100 posts). Still no where near the speed I expect but it’s a big step up from where it was. I’ll take it :)

This pull request is expected to be in jekyll 2.6.0 release.

BitTorrent Sync as an alternate backup solution

I’ve heard so many good feedbacks about BitTorrent Sync. The only complain seems to be how it isn’t open-source. Today, I’ve decided give BitTorrent Sync (btsync) a whirl to see what all the hypes are about.

The way it works is you first select a folder you want to share. btsync will create two keys: one for readonly access and the other one for read/write access. You then pass on the key to the person you want to share the file with. They paste it to their btsync client and that’s all, btsync will do the rest.

Here I thought why don’t I use it to backup stuff to my VPS. My Dropbox is just a bit over 70GB and the 50GB free space promo is going to expire soon. I’m going to need to offload some stuff elsewhere, namely Camera Uploads. BitTorrent Sync seems to the perfect fit for this kind of thing. Plus, I have quite a lot of free space on my VPS.


So I installed btsync on my VPS. It’s as simple as download the file and extract. You will get an executable btsync.

# generate a sample config
./btsync --dump-sample-config >> btsync.conf
./btsync --config btsync.conf

btsync by default will start on port 8888. I then create an Apache2’s virtualhost, bind it to port 8888 in order to access its webui.

From my local machine, I add a folder to btsync, copy its readonly access key and add it to my server’s btsync webui. Tick Override any changed files on the server.


BitTorrent Sync doesn’t support document revision yet so Dropbox is still far superior. But the sync speed it offers is just amazing, leaving Dropbox in the dust.

Though I don’t trust my server keeping my data safe, it doesn’t hurt to have one more alternative backup. You definitely shouldn’t use it as your sole backup solution.

Theming Apache's mod_autoindex directory listing

By default, your shared folder with mod_autoindex enabled looks like this.

apache fancy index

The icons looks like they were from Windows 3.1 era. I am by no mean a designer but looking at this seriously make me want to vomit.

I decided to take a quick look at mod_autoindex’s documentation and grab some free icons from Dribbble to make it better.

Turns out, it’s easier than I thought. Theming is supported out-of-the-box with mod_autoindex. I just have to copy some icons (frequently used file types) and add a few lines in my Apache’s vhost config. I can even inject CSS too. Every element already has proper id and class so I can just inspect the page and customize to my liking.

IndexIgnore /_theme # hide _theme folder
AddIcon /_theme/icons/blank.png ^^BLANKICON^^
AddIcon /_theme/icons/folder.png ^^DIRECTORY^^
AddIcon /_theme/icons/upper_level_directory_icon.png ..

AddIcon /_theme/icons/image.png .png .jpeg .gif .jpg
DefaultIcon /_theme/icons/fallback_icon.png

IndexStyleSheet "/_theme/style.css" # injecting CSS
HeaderName /_theme/header.html # customize header
ReadmeName /_theme/footer.html # footer

Here’s how mine looks like after.

apache mod autoindex

If you’re too lazy for this stuff and just want a decent looking theme, take a look at Apaxy. Follow the installation instruction there.

Some of the most useful tips I learn when working with NodeJS

modules management with npm

Nodejs comes with an amazing package manager called npm. Start a project with npm init which will then create a configuration file named package.json, keeping track of all the modules your project is using. You don’t have to manually manage this file yourself. If you want to add a package to package.json you can add --save parameter when installing it.

npm install koa-static --save

Also, you should ignore npm_modules folder when git push because whoever clone the repo can do npm install by themselves. npm_modules folder can grow pretty big so no one would want to git clone the whole thing.

pm2 instead of forever

When you start learning about NodeJS, you may notice that node process may exit unexpectedly when errors are not handling properly. forever is a node package that ensure node process will run continuously in the background. But forever is very limited. It doesn’t have support for clustering, very limited logging and monitoring.

I later found out a much leaner solution called pm2. Compare to forever, pm2 looks like a full solution for deployment with builtin clustering support, terminal configuration and better logging support. In fact, ever since, I only use pm2 for my production server.

Enabling clustering with pm2 is as easy as

pm2 start app.js -i 0

Using 0 means that pm2 will utilize number of threads equals to number of your CPU’s cores. You can specify the no. of child process as you want, ideally one per processor core.

As for local development, I prefer nodemon to keep track of changes in my application and automatically restart the server.

Fuck callbacks

For starters, callbacks are nightmare. Many popular frameworks still make use of callback heavily which creating the sense for newbies that it is the correct way of doing things in nodejs. It’s not. Over the last 2 months, I’ve started using Q, async, bluebird and then generators. Of those, generator seems to be the most elegant solution, producing much more readable code than callbacks.

Debugging with node-inspector

I’m pretty sure most nodejs starters will use console.log() everywhere to debug the application. I did that. It was ok for quick debugging but sometimes, you need a little more than just console.log. node-inspector is a node package based on Blink Developer Tools that let you debug right in your favorite browser.

Install node-inspector and use node-debug app.js for debugging.

npm install node-inspector -g
node-debug app.js

The end

These are some of the things that I’ve learnt in the last 2 months working with nodejs. Nodejs is an amazing platform but it can be a pain sometimes. These tips save me a lot of times and make developing in nodejs so much more bearable.