WordPress from PHP to HHVM

This blog was using nginx+php5.5+mysql and I’ve been reading about hhvm and it`s 100% compability with WordPress.

So it’s worth to test.

OK, what I was doing is basically installing hhvm using this guide

sudo apt-get install software-properties-common
sudo apt-key add --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
sudo add-apt-repository 'deb http://dl.hhvm.com/ubuntu trusty main'
sudo apt-get update
sudo apt-get install hhvm

Since hhvm is also fastcgi compatible, all I do is changing my nginx sites configuration to

location ~ \.(hh|php)$ {
    fastcgi_keep_conn on;
    fastcgi_index  index.php;
    fastcgi_param  $SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;

Restart hhvm and restart nginx to make sure the configuration got reloaded. And done!

Home Automation By Presence Detection

Some friends asking me about my Homebred setup for my home automation – It’s been a while since I promise to write about it – so here you go. (will open the code as soon as I can make it readable for public and clean it up from my custom setups)

The setup is simple, nothing fancy.

It’s using tricky simple presence detection – a.k.a detecting MAC address of my phone and trigger scripts based on that. The weakness of it that it will need DDWRT router use other router that list connected clients MAC address, but you will need to adjust the scrapper code to login and scrap your router interface)

Presence Detection

Install DDWRT on your router. Make sure the setting to expose info page


After this is enabled. It will expose Info.htm that you can use to scrap for information about your router. See the Wireless clients table on the bottom of the Info.htm page


Create daemon that check DDWRT status page on some interval and check for the existence of specific MACs. If some specific MACs is detected, go to a folder and run all scripts.

The Presence Script

The daemon itself is a Nodejs script that run on my Raspberry Pi. It run using cron on some certain interval.

I use Nodejs script for easy development effort :). For request Nodejs have Request and for scrapping it have Cheerio that makes all scrapping needs as easy as creating jQuery selector. For the DDWRT info page.

var request = require('request'); 
var cheerio = require('cheerio');
request('', function (error, response, body) { 
    if (!error && response.statusCode == 200) { 
        var $ = cheerio.load(body); 
        var clients = $('#wireless_table tr'); 
        // loop for clients - do the necessary MAC detection here. Don't forget to save it to external flag file so you can create event 
        // `onEnter`, `onExit` etc 
        // I save list of MACs that need to be checked in a simple JSON file 

When the above script detect an event, it will try to list all executable script in a folder – For example I have /opt/MYMACADDRESS/enter.d/ and /opt/MYMACADRESS/exit.d/ so when my MAC is detected as entering, it will executes all executable scripts in /opt/MYMACADRESS/enter.d/*

In Nodejs, it’s as easy as

//  loop for scripts and execute it using the code below
child = exec(scriptFileName, function (error, stdout, stderr) { 
    console.log('stdout: ' + stdout); 
    console.log('stderr: ' + stderr); 
    if (error !== null) { 
       console.log('exec error: ' + error); 

So I can create many scripts using shebang notation in the folder and those will be executed accordingly.


The scripts are fine tuned to my home setup. But it can be anything. Here’s some Ideas

  1. Set transmission torrent client to unlimited /usr/bin/transmission-remote -D && /usr/bin/transmission-remote -U (when I am at work)
  2. Set transmission to 0kb/sec /usr/bin/transmission-remote -d 0 && /usr/bin/transmission-remote -u 0 (when I am at home)
  3. Bash script that update Dynamic DNS provider with my new IP – It used to twit my public IP to a protected twitter account 🙂
  4. Twit to the protected twitter account if some specific MACs is entering my wifi network
  5. Turn on Air Conditioner by accessing IR arduino trough raspberry GPIO
  6. Wake On Lan my gaming PC by utility called powerwake powerwake

Non DDWRT Router

Well the idea can be applied to other router interface. Most router use basic authentication to access the internal web application. In Nodejs it’s as easy as (or use basic auth bearer Token)

request.get('').auth('username', 'password', false);

And then tweak your scrapper accordingly to harvest for MAC address or static IPs.

The New Begining


I remember it was 1995, I was young, around 10-11 years old kid with identity issue. What Identity issue you may ask? One example is – I used to ask myself Who Am I? What is the purpose of living?. I used to identify it as an identity issue because when I ask that kind of question to older people. most of them shrug, laugh or telling me that someday I’ll figure it out (with loud laugh or simple smirk of course)

Is it wrong for a 10 years old to get the answer of it? the purpose of their life? How old a person can get the real answer of their purpose of life? 20? 30? 40? or by the deathbed?

Continue reading The New Begining