Skip to content

Instantly share code, notes, and snippets.

@paulcuth
paulcuth / tfl-tube-data.json
Created July 28, 2011 09:47
TfL tube line & station data in JSON format.
var lines = {
B: 'Bakerloo',
C: 'Central',
D: 'District',
H: 'Hammersmith & Circle',
J: 'Jubilee',
M: 'Metropolitan',
N: 'Northern',
P: 'Piccadilly',
@paulcuth
paulcuth / instanceof.lua
Last active August 12, 2021 12:40
Implementation of instanceof in Lua
function instanceOf (subject, super)
super = tostring(super)
local mt = getmetatable(subject)
while true do
if mt == nil then return false end
if tostring(mt) == super then return true end
mt = getmetatable(mt)
@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 / 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 / 2013-race-1-lap-times.json
Created March 19, 2013 14:50
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].
[
[
{
"driverNumber":1,
"duration":99646
},
{
"driverNumber":4,
"duration":101714
},
@paulcuth
paulcuth / 2013-race-1-tyres.json
Last active December 15, 2015 03:59
Tyre choices for 2013 Australian Grand Prix in JSON format.
[
{
"driverNumber":7,
"tyres":[
"supersoft",
"medium",
"medium"
]
},
{
@paulcuth
paulcuth / 2013-race-2-lap-times.json
Created March 24, 2013 15:56
Malaysia Grand Prix race data in JSON format.
[[{"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 / gist:7656951
Last active December 29, 2015 10:29 — forked from daurnimator/gist:7627513
@paulcuth
paulcuth / README.md
Last active August 13, 2017 20:25
Lua port of Slimdown.

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

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.)