Tuan Anh

container nerd. k8s || GTFO

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
./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
./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.
  }, 1000);

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

process.on('SIGINT', function() {

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.


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.


The Codeless Code - Fables and Kōans for the Software Engineer

An illustrated collection of (sometimes violent) fables concerning the Art and Philosophy of software development, written in the spirit of Zen kōans

link bài gốc

MusicBrainz Picard

Picard is a cross-platform music tagger written in Python.

Great piece of software. Usually, I just add all music files I grab from the Internet through Picard before adding into iTunes for syncing.

link bài gốc

A collective list of Manchester United players' autobiographies

Autobiographies/biographies of ManUtd’s players that I’ve read so far.

Title Type Player Link
Alex Ferguson: My Autobiography Autobiography Alex Ferguson Download
Managing My Life: My Autobiography Autobiography Alex Ferguson Download
David Beckham: My Side Autobiography David Beckham Download
Cantona: The Rebel Who Would Be King Autobiography Eric Cantona Download
Red: My Autobiography Autobiography Gary Neville Download
Back from the Brink: The Autobiography Autobiography Paul McGrath Download
2sides: Rio Ferdinand - My Autobiography Autobiography Rio Ferdinand Download
The Second Half Autobiography Roy Keane Download
Giggsy: The Biography of Ryan Giggs Biography Ryan Giggs Download
Wayne Rooney: My Story So Far Autobiography Wayne Rooney Download

Đặ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