Tuan Anh

container nerd. k8s || GTFO

Go Native - Calling C++ From NodeJS

I don’t usually have the need to do this but it would be fun practice to build a npm module by packaging some C++ libraries.

link bài gốc

Atom is slow but that's okay

I started using Atom from one of those early beta build. I wasn’t impressed. At that time, it was really slow (still is), taking several seconds just to load the app, freeze frequently when I tried to open log file (few MBs) and a bunch of other small bugs here and there. So I went back to Sublime and just keep an eye on Atom once in awhile (I left it in /Applications untouched)

Recently, a colleague of mine was trying to convince me to try Atom again. So I fire up terminal, rm -rf ~/.atom and update the app.

You should remove old Atom config since Atom is very actively developed and may have changed a lot since last you tried the app.

Atom feels much more polished this time. Despite the slow startup time still there, I feel very compelled to stick with Atom this time. I understand that Atom probably never going to achieve Sublime’s speed (due to its nature) but that’s ok. Here’s why:

Atom’s UI is closely resemble Sublime

The interface and everything is closely resemble Sublime so the learning curve is rather shallow. In fact, few people wouldn’t know they are looking at Atom or Sublime without glancing at the menubar.

Atom has done so many right things out of the box

Atom has done so many right things right out of the box. Stuff like keyboard shortcuts feel a lot more intuitive than Sublime.

I know, i know that we can re-map Sublime shortcuts as well. I did exactly that at first but working right out of the box still feels a lot nicer.

The older I get, the lazier I become when it comes to tinkering with settings to get it right. I remember my 18-yo self would plays with all kind of registry keys on Windows XP for the fun of it. I’m not like that anymore. I just want to forget about the editor and start coding.

Atom is very extensible

Most of the packages I used in Sublime is available on Atom as well; or at the very least, the equivalent exists.

I pretty much use vanilla Atom (default theme, default colorscheme) with a few packages installed: atom-alignment, atom-fuzzy-grep, auto-detect-indentation and highlight-selected. I highly recommend you to checkout atom-fuzzy-grep package. It allows you to use the_silver_searcher for fuzzy search your project. It’s freaking awesome and fast. Check it out.

Atom is actively developed by GitHub and community

It’s not that Sublime is abandoned but Atom development is much more active. It’s backed by GitHub and a huge open-source community vs few developers of Sublime. You know, the bus factors thing.


If you haven’t checked Atom in while (or at all), you should probably do. That’s my advice, coming from a hardcore Sublime fan.


Efficient branching workflow with git flow

Why aren’t you using git flow provides a nice overview on why you and your team should adapt using git flow in your workflow.

Keep this cheatsheet somewhere in case you need a quick reference.

link bài gốc

Hello, HotelQuickly!

hello HotelQuickly

I’m very excited to let you know that I’m joining HotelQuickly as Node.js developer, working on their next generation API. I’m totally psyched about this as I have a chance to work with great people, dealing with mind-boggling challenges.

This is going to be fun.

Meanwhile, you can download HotelQuickly now for iPhone, Android or BlackBerry 10; get 500 THB credit by redeeming voucher code TANHB9.


Cancelling $http request in AngularJS

It’s as simple as this. Basically you return a promise (canceller) and let those who call your service ability to cancel via canceller.resolve('reason goes here'). Alternatively, you can provide a function cancel which does the same as canceller.resolve() if you don’t want to expose the canceller promise.

.service('MyService', function($http, $q) {

  this.canceller = $q.defer()

  this.my_func = function(params) {
    params.timeout = canceller.promise
    return {
      promise: $http.get(url, params),
      canceller: canceller      
    }
  }

})

To verify if your code is working as expected, you can check in Network tab in Developer Tools. The request will be marked with status as cancelled.


How to install ZeroMQ on Ubuntu

Before installing, make sure you have installed all the needed packages

sudo apt-get install libtool pkg-config build-essential autoconf automake
sudo apt-get install libzmq-dev

Install libsodium

git clone git://github.com/jedisct1/libsodium.git
cd libsodium
./autogen.sh
./configure && make check
sudo make install
sudo ldconfig

Install zeromq

# latest version as of this post is 4.1.2
wget http://download.zeromq.org/zeromq-4.1.2.tar.gz
tar -xvf zeromq-4.1.2.tar.gz
cd zeromq-4.1.2
./autogen.sh
./configure && make check
sudo make install
sudo ldconfig

Verify to see if zeromq installed correctly

I’m familiar with Node.js so I’m going to use the Node.js hwserver example from zeromq’s website. If you see “Listening on 5555…”, you’re good to go.

// Hello World server
// Binds REP socket to tcp://*:5555
// Expects "Hello" from client, replies with "world"

var zmq = require('zmq');

// socket to talk to clients
var responder = zmq.socket('rep');

responder.on('message', function(request) {
  console.log("Received request: [", request.toString(), "]");

  // do some 'work'
  setTimeout(function() {

    // send reply back to client.
    responder.send("World");
  }, 1000);
});

responder.bind('tcp://*:5555', function(err) {
  if (err) {
    console.log(err);
  } else {
    console.log("Listening on 5555…");
  }
});

process.on('SIGINT', function() {
  responder.close();
});

My first Hackathon

So I went to my first hackathon this weekend and it was fun. There are plenty of pizza, soda, beer for everyone. Chances to meet up with many awesome, cool people from various places.

AngelHackBKK

The way I think of hackathons is like: a contest to see which team can come up with the coolest idea and quickly create a working prototype for it by glueing libraries and datasets together. Well, it’s exactly like that.

Hackathons is exhausting

The suffix -athons pretty much speaks for itself. One whole weekend with intensive work, lack of sleep and lots of caffein/red bulls to keep you awake. Some may argue that it’s a hackathon, it’s an occasional event to let people push themselves. Even I’m competitive but I’m definitely not the type of guy that can pull up 48 hours straight no-sleep to work on something. I’m just not that guy.

AngelHackBKK AngelHackBKK AngelHackBKK

Hackathon projects are far from usable

Stuff created at Hackathons are far from usable and usually don’t survive pass the hackathon weekend. Very fews manage to emerge into something bigger. In order to do that, they require a substantial amount of time and development efforts after the hackathons.

Projects from hackathons are not really answers for existing problems. I mean like, how can we do that by showing up in the morning, hear someone pitching idea, jump in and design a solution without any prior research. Hard problems exist for a reason; it’s because they are hard.

What hackathons are good for?

However, I definitely enjoy it less of a competition and more of a social event. I get to grab a drink, talk with a bunch of like-minded people.

Also, it feel good to be able to come up with a working prototype of some new cool idea we have. Working with a team you ain’t familiar with. I have to execercise different parts of my skillset which I don’t normally use at work; working with different stack/domain; quickly patch here and there to be able to catch the code freeze timeline.


In short: hackathons can be fun; they inspire us working on new ideas, pushing our own boundaries but it shouldn’t be a regular thing. Also, think of more its social aspect rather than a competition. It’s more fun that way.

P.S.: Our team got second prize. Maybe next time.


Vì sao tôi thích xài email hơn là điện thoại

Phone call leaves no trace

Tôi cũng không rõ cái này là tốt hay xấu nữa nhưng theo kinh nghiệm bản thân thì xấu nhiều hơn tốt.

Tôi hay quên nên đã từng gặp khá nhiều trường hợp cãi nhau vì bạn B quả quyết đã nói/bàn vấn đề đó qua điện thoại. Bởi vậy sau này tự tập cho bản thân thói quen sau khi bàn bạc gì đó qua phone thì sẽ viết 1 email follow-up để tóm tắt lại những ý đã bàn qua cuộc gọi vừa rồi.

Hơi rắc rối hơn phải ko? Thay vì vậy thì cứ bắt đầu từ email luôn cho rồi.

Phone call is awkward

Gọi điện thoại cho ai đó cũng như kiểu tới nhà người khác và bấm chuông mà ko hẹn trước vậy. Ví dụ này xem ra hơi quá nhưng đại ý là vầy. Nếu không thực sự cần thiết và không quá gấp thì tôi thấy ko nên gọi.

Một vấn đề nữa là nhiều khi bạn cũng không biết được người nhận cuộc gọi đang làm gì, có tiện nói chuyện hay không nữa.

Bài học là: Nếu thực sự cần gọi thì nên hẹn trước thời gian.

Email is a better communication channel

Tôi diễn đạt kém. Bởi vậy tôi thấy sử dụng email giúp tôi thể hiện ý tôi muốn 1 cách tốt hơn. Tôi có thể đọc đi đọc lại nhiều lần, chỉnh sửa cho tới khi thấy ngắn ngon và súc tích. Gọi điện thoại thì ko được như vậy.


Cũng vì các lý do trên mà tôi ít sử dụng Phone.app hơn và thay vào đó là email app trên Dock. Tôi cũng chẳng nhớ mình bỏ Phone.app ra ngoài từ khi nào. Có lẽ là cũng khá lâu rồi và tôi không hề cảm thấy bất tiện.


Markdown table sucks. Let's use jekyll's data files instead

Creating a table in markdown sucks, especially if the table is quite big with some styled elements. Back before knowing data files, I came up with a plugin to help with this. First, I create folder to keep my JSON data files. I wrapped it in a simple plugin to generate inline javascript call (AJAX) to render the table upon finish loading.

{% jsontable myjsonfilename %}

This works as expected but it’s only feasible for simple table structure. Sometimes, I want a specific table structure for a specific post. Data files are perfect for this purpose.

Data files structure is simple, easy to maintain and accessible throughout your blog via site.data.datafilename.

There’s an example on jekyll’s documentation if you want to take a look.


Tắt tiếng của tab ở Chrome

Ever notice the volume icon on Chrome tab and wonder why you can’t click to mute it before? Well, you can now. Just copy and paste the code below to see hidden flags in Chrome, enable it and relaunch Chrome afterward. You can now click the volume icon to mute that particular tab.

chrome://flags/#enable-tab-audio-muting