wtf is a thunk?

What is a thunk?

  1. ALGOL thunks in 1961

  2. thunk is a function that encapsulates synchronous or asynchronous code inside.

  3. thunk accepts only one callback function as an arguments, which is a CPS function.

  4. thunk returns another thunk function after being called, for chaining operations.

  5. thunk passes the results into a callback function after being excuted.

  6. If the return value of callback is a thunk function, then it will be executed first and its result will be send to another thunk for excution,
    or it will be sent to another new thunk function as the value of the computation.

React Router

history is required.

What we did above is we mounted a Router to the DOM, it is now going to take Routes. A route takes a path (URL) and shows a component on that path.


If you want to navigate anywhere within the site, you use Link. You’ll only use actual href when you want to move away from the site. A link looks like this:

You will not be making any server requests to go to any of these different links/pages.

Nested Routes

You can have nested routes just like you can have nested components

What the could above will do is that it’ll load the Users route/component inside the Main route/component.


IndexRoute let’s you render props.children. It’s aimed at setting a default UI that opens when you are at the route.


You can also pass props, like so:

iOS, Bluetooth Low Energy (BLE), CoreBluetooth and Swift – for noobs

This talk by Yoav Shwartz on the site and this post by Ryan Jones on Medium are the best starting points I have come across.

The official documentation by Apple on CoreBluetooth is in Objective-C, which sucks because Objective-C looks like gibberish to me and i want to write Swift code. You can still read the docs though, they have listed best practices to work with BLE and CoreBluettoth.

You do need to have an iOS device in order to use CoreBlueooth, it is not supported in the Simulator. It was, originally, but they removed it after a year because BLE got more advanced and it was difficult to remove inconsistencies between Mac and iPhone implementations, or sumthin’ like that..

Look at other people’s Swift code dealing with CoreBluetooth on Github.

Install/Upgrade Node.js on Raspberry Pi (Raspbian Jessie)


Run this one command in Terminal:

This will automatically run a script i wrote that takes care of removing existing Node.js stuff, downloading and installing the latest version, and cleaning up afterwards. It also confirms the Node.js version once the installation is done.

The Node.js version that comes pre-installed with Raspbian Jessie is old. If you check the version using node -v, it’ll give you v0.10.29. The latest ARM-version of Node.js as of this writing is v4.2.1. Let’s remove the old and install the latest version available on our Raspberry Pi.

Remove existing Node.js

Run the following commands one by one:

Install latest Node.js ARM-release



That’s it, you now have the latest Node.js version available for the Raspberry Pi. You can confirm the version using node -v.

Re-install Node-RED

We uninstalled Node-RED as part of removing Node. If you want to re-install it, you can do so by running the following command:


Linux is 20 years old. The web is less than 7000 days old. Together they have changed human civilization more rapidly than any pair of invention in the history of the world.

Eben Moglen

Automated MySQL Backups to Amazon S3 with AutoMySQLBackups

This how-to will teach you how to take automated backups of all your MySQL databases and send them to Amazon S3.

Access (Logins) required

  1. root login for the server (sudo is required to run automysqlbackup, root is req. to add to root user’s cron)

  2. admin login for the mysql server (to provide for backup config file)

  3. IAM access keys to use with s3cmd (to configure s3cmd)

sudo is required to run the AutoMySQLBackup script, so when adding the command to cron, you’d need to add it to the root user’s cron (so that it runs successfully on set intervals without asking for a password).


  1. AutoMySQLBackup

  2. s3cmd

  3. SSH client (Terminal on Mac / putty on Windows)

Installing S3cmd on Debian

Check the Repos page for install on other systems.

  1. Import S3tools signing key:
    wget -O- -q | sudo apt-key add -
  2. Add the repo to sources.list:
    sudo wget -O/etc/apt/sources.list.d/s3tools.list
  3. Refresh package cache and install the newest s3cmd:
    sudo apt-get update && sudo apt-get install s3cmd

Run s3cmd --configure to add IAM access keys for Amazon S3.

Installing AutoMySQLBackup

Download and extract the latest tarball and run the install script.
1. Create a directory where you want to download and extract the AutoMySQLBackup file and move to that directory.
sudo mkdir /automysqlbackup && cd /automysqlbackup
2. Download automysqlbackup (v3.0_rc6) to the server. (Check Sourceforge for the latest version of AutoMySQLBackup. As of this writing v3.0_rc6 is the latest)

  1. Extraxt the downloaded tarball tar zxvf automysqlbackup-v3.0_rc6.tar.gz
  2. Run the installer ./

By default it will install the configuration files in /etc/automysqlbackup and the executable files in /usr/local/bin.

Configuring AutoMySQLBackup

Edit the /etc/automysqlbackup/myserver.conf file to customise your settings.
The myserver.conf file is VERY well documented, all you have to do is read and it’ll tell you what setting is supposed to do what and how you should configure it. You do not need to edit beyond the basics. What you generally edit are basic settings (username, passsword, host and backup directory), database settings (which ones to backups, which ones to not), rotation settings (when to backup), and notification settings (who and what to tell when a backup is complete).

Adding AutoMySQLBackup to Cron

Edit crontab sudo crontab -e and add the following at the end.