Skip to content

Instantly share code, notes, and snippets.

Leonard Martin lennym

Block or report user

Report or block lennym

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
lennym / index.js
Created Nov 26, 2019
Parkrun Finish Modelling
View index.js
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;
View upload.jsx
const React = require('react');
const ErrorMessage = require('./error');
const Log = require('./log');
const Progress = require('./progress');
class Upload extends React.Component {
componentWillMount() {
View .bash_version
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?

View express-test.js
const express = require('express');
const app = express();
const router = express.Router();
router.get('/foo', (req, res, next) => { = 'bar';
router.get('/bar', (req, res, next) => { = 'foo';
lennym /
Last active Aug 26, 2016
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

View example-test.js
const assert = require('assert');
const sandbox = require('./sandbox');
function myAsyncFn (callback) {
setTimeout(() => {
callback(null, 5);
}, 500);
describe('async things', () => {
View aws-stubbing.js
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(() => {
lennym / app.js
Created Jul 19, 2016
Express middleware mounting patterns
View app.js
const app = require('express');
module.exports = app;
You can’t perform that action at this time.