Skip to content

Instantly share code, notes, and snippets.

View lennym's full-sized avatar

Leonard Martin lennym

View GitHub Profile
@lennym
lennym / rules.md
Last active March 23, 2020 16:39
Segment of the Day Rules and Scoring

Heathside Segment of the Day Challenge

The aim of this challenge is to provide some social-distancing compatible motivation for people training solo while group sessions are off. It is not to be taken seriously.

Every evening a segment will be nominated to be the "Segment of the Day" for the following day. All you need to do to be included is to go and run the segment before 9pm that day.

Rules

  1. Be considerate to others using the paths.
  2. Don't run in groups.
@lennym
lennym / index.js
Created November 26, 2019 23:51
Parkrun Finish Modelling
const log = require('terminal-overwrite');
const toSeconds = t => {
const [minutes, seconds] = t.split(':');
return (minutes * 60) + (+seconds);
};
const TOKEN_RATE = 1.5;
const TOKEN_SWAP = 3;
const FINISHERS = 800;
const React = require('react');
const ErrorMessage = require('./error');
const Log = require('./log');
const Progress = require('./progress');
class Upload extends React.Component {
componentWillMount() {
this.reset();
function version () {
git checkout master && git pull origin master && npm version $@ && git push origin master --tags && npm publish;
}

Hitting cmd+s when editing this doc should save the doc and not the webpage.

Github have already overridden tab in this view, so why not cmd+s too?

const express = require('express');
const app = express();
const router = express.Router();
router.get('/foo', (req, res, next) => {
res.locals.foo = 'bar';
next();
});
router.get('/bar', (req, res, next) => {
res.locals.bar = 'foo';
@lennym
lennym / README.md
Last active August 26, 2016 15:04
Musings on software testing...

Yesterday, the occasionally brilliant comic strip commitstrip published this comic:

It set me thinking specifically about the topic of software testing. In particular, "what are we trying to achieve when writing tests for our softare?"

As the comic astutely points out, a piece of software is logically speaking little more than a documentation of the requirements of the software. Further to this, what we do when we write tests for our software is represent those requirements in another form, and check to see that both our software and the tests align in their interpretation.

These requirements on any level are defined simply a set of inputs, and their corresponding outputs. And largely what we do when we write tests is attempt to enumerate a subset of available inputs, and assert on their expected outputs, where the software will attept to do less enumeration, more abstraction

const assert = require('assert');
const sandbox = require('./sandbox');
function myAsyncFn (callback) {
setTimeout(() => {
callback(null, 5);
}, 500);
}
describe('async things', () => {
const simple = require('simple-mock');
const AWS = require('aws-sdk');
const S3 = (new AWS.S3()).constructor.prototype;
describe('store', () => {
beforeEach(() => {
simple.mock(S3, 'getObject').callbackWith(null, mockResult);
});
afterEach(() => {
simple.restore();