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
View import-export-node.md

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.

View deploying-sailor-to-heroku.md

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
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
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
View README.md

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
paulcuth / README.md
Last active Aug 13, 2017
Lua port of Slimdown.
View README.md

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
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
[[{"driverNumber":1,"duration":121790},{"driverNumber":3,"duration":125239},{"driverNumber":2,"duration":125298},{"driverNumber":10,"duration":125768},{"driverNumber":5,"duration":127046},{"driverNumber":4,"duration":127716},{"driverNumber":9,"duration":127937},{"driverNumber":6,"duration":128740},{"driverNumber":15,"duration":129128},{"driverNumber":11,"duration":129804},{"driverNumber":19,"duration":130567},{"driverNumber":7,"duration":131135},{"driverNumber":8,"duration":131346},{"driverNumber":14,"duration":131810},{"driverNumber":16,"duration":132738},{"driverNumber":12,"duration":133007},{"driverNumber":20,"duration":133869},{"driverNumber":18,"duration":134774},{"driverNumber":21,"duration":134824},{"driverNumber":22,"duration":135978},{"driverNumber":23,"duration":136626},{"driverNumber":17,"duration":137676}],[{"driverNumber":1,"duration":117127},{"driverNumber":2,"duration":116963},{"driverNumber":10,"duration":117795},{"driverNumber":5,"duration":119307},{"driverNumber":9,"duration":118701},{"drive
@paulcuth
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
[
{
"driverNumber":7,
"tyres":[
"supersoft",
"medium",
"medium"
]
},
{
@paulcuth
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 [http://www.fia.com/championship/fia-formula-1-world-championship/2013/2013-australian-grand-prix-event-information].
View 2013-race-1-lap-times.json
[
[
{
"driverNumber":1,
"duration":99646
},
{
"driverNumber":4,
"duration":101714
},
You can’t perform that action at this time.