Tuan Anh

container nerd. k8s || GTFO

Fix unable to download huge files with varnish

I recently stumble against a problem with my varnish setup. I couldn’t download any file (huge ones) from my webserver (nginx). The problem only seems to occur with varnish enabled.

A little Google-fu, I found that the problem indeed was caused by varnish because varnish was intefering (timeouts and post-processes) with the request from client.

The fix is simple: let client and server talk directly without varnish interfering using pipe.

sub vcl_recv {
  # condition to trigger pipe
  if (req.url ~ "^/path/or/file/extension/or/whatever/condition/you/have/") {
    return (pipe);
sub vcl_pipe {
  set bereq.http.connection = "close";

Try wget your files again. It should be fixed now.

Lift - an app that put your goals into action

Lift is an app that help you to form/track/analyze new habits. This is part of my new experiment to become a better self. Some of the stuff I like to do it more often and more regular like: pushup every morning, drink more water, learn new language, talk to one stranger a day, etc.. for starters.

I’m still very much in the process of learning, tweaking this method. But that’s the beauty of it. Becoming a better you than yesterday is not just a habit, it’s a way to improve life.

Localization with jekyll

Do you want to create a multilingual blog with jekyll? Here’s an easy way to setup jekyll to have content in multiple languages.

Create localized string data file

Create a folder named _data if you don’t already have one. Inside that folder, create a localization data file and name it messages.yml.

mkdir _data
touch messages.yml

Edit messages.yml and add localized strings. For the moment, I will just create a simple phrase and 2 localized strings in English and Vietnamese for testing purpose.

    example: "example"
    example: "Ví dụ"

Display localized strings on post/page

Now you need to capture the locale of the current page. You can do it either by capturing the url (if you organize posts by folders of language’s name) or from the page variable. To make it easy in this port, i will use the current page’s locale variable; if not specified then default to ‘en’.

locale: "vn"

Get the localized string with this syntax

{{ site.data.messages.locales[locale].example }}

And that’s it. Go back and add more localized strings, update templates and publish changes. Your website is now multilingual.

To make it even more visitor-friendly, you can create a separate RSS feed for each one of the language.

Alternatively, you can use jekyll-multiple-languages-plugin1, though I’m not a big fan of using plugin when not I don’t really need to.

  1. http://rubydoc.info/gems/jekyll-multiple-languages-plugin/1.2.5/frames 

My favorite tiling window manager for OS X

The problem of window manager has been with us ever since GUI and multitasking were introduced. Despite being considered as a most modern OS, OS X failed short when it comes to window manager, especially when compared with Linux. I’ve tried many so-called tiling window managers for OS X. All have failed for me so far but Amethyst.

To name a fews that I’ve tried: SizeUp, Spectacle, DoublePane, Slate, BetterSnapTool and some others… Most of them are not tiling but just simple window managers.

I’ve tried Amethyst before but it was not stable enough for daily usage at the time. I like the concept every much though. I later settled on SizeUp and Witch combo for window manager. They suck. But they suck the least at the time. And most importantly, it wasn’t really tiling at all.

About Amethyst

Tiling window manager for OS X similar to xmonad. Was originally written as an alternative to fjolnir’s awesome xnomad but written in pure Objective-C. It’s expanded to include some more features like Spaces support not reliant on fragile private APIs.

A quick screencast to show basic features of Amethyst

Getting started with Amethyst

Basic usage of Amethyst is very well-covered in its documentation on GitHub. I won’t go into details here. Some commonly used shortcuts are:

  • mod1 - option + shift

  • mod2 - ctrl + option + shift

  • mod1 + space — cycle to next layout

  • mod1 + j - focus the next window counterclockwise

  • mod1 + k - focus the next window clockwise

  • mod1 + return - swap the focused window with the main window

  • mod1 + h - shrink the main pane

  • mod1 + l - expand the main pane

That’re probably all you need to know to get started with Amethyst. Go figure some more when you’re familiar with the new tool. All of them are configurable in .amethyst configuration file in your home directory.

Amethyst is probably the best tiling window manager for OS X right now. It’s simple, intuitive and very lightweight with a low learning curve. You don’t have to learn a whole lot of new shortcuts to make the best out of Amethyst. It’s currently the top app on my software recommendation list.

Post scheduling with jekyll

First, update your _config.yml and set future to false. By doing this, jekyll will not publish any post with future date.

future: false

Setup a cronjob to check and rebuild the site if there’re posts to be published. Since I already setup a hook on post-receive (trigger on receving a git push) to rebuild the site, I’m going to set a cronjob to execute this script instead of writing something new. The content of the post-receive looks like this.

# post-receive
#!/bin/bash -l

jekyll build --source $TMP_GIT_CLONE --destination $PUBLIC_WWW

Cronjob that execute post-receive every hour at 0 minute, everyday.

@hourly /path/to/my/post-receive

The only downside of this is you need to be able to setup cronjob. GitHub Pages and shared hostings are probably not going to work in this case. You will need to verify this yourself.

How to setup Discourse local dev environment on OS X

I find this the easiest way to install Discourse on OS X for local development purpose. The idea is this: you install Ubuntu as a VM and setup Discourse on top of that.

Install Vagrant

Setup Vagrant is as easy as double click the installer and a couple of next click. I have a license for Parallels 9 so I use Parallels as default provider. You can use VMWare if you own one or VirtualBox for free if you don’t feel like paying.

I use puphpet’s Ubuntu 14.04 x64 as base box but literally, anything Ubuntu 14.04 would work. Ubuntu 14.04 is recommended version by Discourse.

You can use PuPHPet online GUI configurator to create a configuration of your own.

vagrant plugin install vagrant-parallels
mkdir discourse-local
cd discourse-local
vagrant init puphpet/ubuntu1404-x64
vagrant up --provider=parallels
vagrant ssh

Install Discourse with Docker

Follow this tutorial on Discourse Meta to setup Discourse on your Vagrant box.

Discourse should be up and running on your Vagrant box’s IP address after this.

jekyll full-text search without jQuery or plugin

I did a quick search for full-text search solutions for jekyll (or any static websites). A notable fews have come up in search result:

A quick look at the plugin’s dependency, I give up right away even though I only need that on search page. For the very same reason I opted for jekyll - a static site generator, I want my site to load as fast as possible. Adding a bunch of dependencies like that is against the purpose. I rather go for DuckDuckGo as I’m currently doing.

Dependencies for the jQuery plugin are as follows.

  • jQuery
  • lunr.js
  • Mustache.js
  • date.format.js
  • URI.js


Too bad the service is no longer available.


The most decent service I found so far. You sign up, add your feed URL so that the service can start indexing your website, add jQuery and tapir.js and you’re good to go.

Search API:


tapir.js looks like a pretty short and simple js file. Adding jQuery dependency on it, is totally overkill.

Exercise for next week: I’m going to replace DuckDuckGo search with Tapir’s search in a few days once I’m done converting Tapir’s jQuery plugin to a pure js solution.

CloudFlare to offer free-SSL by mid-October

We’re on track to roll out SSL for all CloudFlare customers by mid-October. When we do, the number of sites that support HTTPS on the Internet will more than double. That they’ll also rank a bit higher is pretty cool too.

CloudFlare is the coolest free CDN option out there. They responds so quick to the new Google’s HTTPS as a ranking signal.

link bài gốc

Make your jekyll blog a little bit more SEO-friendly

Content is the king but making the site a bit more SEO-friendly (or should I say Google-friendly?) doesn’t hurt.

Load speed

Relevant link: Optimize the hell out of your website for PageSpeed.


Help Google’s bots crawl your site better. jekyll provides it as a plugin.

Structure data markup

Use Google’s structure data markup helper to generate structure data markup code. Use structure data testing tool to verify it afterward.


Google recently announced that they are taking HTTPS as a ranking signal. StartSSL offers free SSL that is included in root SSL of most major browers. CloudFlare is also going to offer free-SSL to all customers (mid-October). I’m going to wait for CloudFlare a bit since I’m already using CloudFlare for this blog.

jekyll plugin directory

Jekyll plugin directory Wiki