Skip to content

Instantly share code, notes, and snippets.

Paul Cuthbertson paulcuth

Block or report user

Report or block paulcuth

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Running ES6 in Node

The latest versions of Node do support most of the ES6 syntax. However, notably, they still do not support import and export expressions. In order to use these espressions we can turn to Babel.

Babel provides a wrapper around Node that automatically translates a given source file before running it in the normal Node application installed on your machine. This wrapper application is called babel-node and is provided in the babel-cli package.

However, import and export translators are not in the core Babel functionality, we'll need to add a preset. The translators needed here are in the es2015 Babel preset.


Deploying Sailor to Heroku

Getting set up

Heroku basics

You will need to create an Heroku account if you don't have one already. You'll also need to install the Heroku Toolbelt, which includes the Heroku CLI that we'll be using shortly.

Sailor basics

Follow the installation instructions for your platform in the Sailor docs, but essentially all you need is the sailor CLI.

paulcuth / shim-global.lua
Last active Dec 9, 2017
A choice of quick cheats for those that don't have time to keep referring to the ESP8266 GPIO pin -> IO index map.
View shim-global.lua
-- You could setup global vars:
for k,v in ipairs{3,10,4,9,2,1,nil,nil,nil,11,12,nil,6,7,5,8,0} do _G['GPIO'..k-1]=v end
-- and use them like this:
gpio.mode(GPIO2, gpio.OUTPUT)
gpio.write(GPIO2, gpio.WRITE)
paulcuth / init.lua
Last active Aug 29, 2015
Creates a web server that controls a shift register on an ESP8266.
View init.lua
gpio.write(8,0) --> Input
gpio.write(9,0) --> Clock
current = 8;
function set (val)
local zeros = 0
local ones = 0
if (val < current) then

This is a little experiment and my first Lua project aimed at performance in LuaJIT.

Most of the code is bootstrap, but at the bottom you'll find some tests followed by some benchmarking code.

I'm surprised to find that the benchmarking code runs 4x faster with the tests included than when they're removed. In fact, just removing the print() statement at the end of the tests makes the benchmark run a lot slower. Why is this?

(Unfortunately, I haven't been able to reduce the code sample and still maintain the same behaviour.)

paulcuth /
Last active Aug 13, 2017
Lua port of Slimdown.


This is a Lua port of of jbroadway's PHP project of the same name.

A very basic pattern-based Markdown parser. Supports the following elements (and can be extended via slimdown.addRule()):

  • Headers
  • Links
  • Bold
View gist:7656951
paulcuth / 2013-race-2-lap-times.json
Created Mar 24, 2013
Malaysia Grand Prix race data in JSON format.
View 2013-race-2-lap-times.json
paulcuth / 2013-race-1-tyres.json
Last active Dec 15, 2015
Tyre choices for 2013 Australian Grand Prix in JSON format.
View 2013-race-1-tyres.json
paulcuth / 2013-race-1-lap-times.json
Created Mar 19, 2013
Lap times for 2013 Australian Grand Prix in JSON format. Translated automatically from data made public by the FIA [].
View 2013-race-1-lap-times.json
You can’t perform that action at this time.