Skip to content

Instantly share code, notes, and snippets.

@paulcuth
paulcuth / 2013-race-1-pit-stops.json
Last active December 15, 2015 03:38
Pit stop 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].
[
{
"driverNumber":5,
"name":"J. BUTTON",
"team":"Vodafone McLaren Mercedes",
"lap":4,
"stop":1,
"duration":22282
},
{
@paulcuth
paulcuth / base64Encode.js
Created November 29, 2011 23:20
JavaScript implementation of base64 encoding.
function base64Encode (data) {
var encoded = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
chars, bin,
output = '',
i;
while (data) {
chars = data.substr (0, 3) + String.fromCharCode (0, 0);
bin = '';
@paulcuth
paulcuth / init.lua
Last active August 29, 2015 14:10
Creates a web server that controls a shift register on an ESP8266.
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.)