Skip to content

Instantly share code, notes, and snippets.

@LewisJEllis
LewisJEllis / getRelativeTimeString.ts
Last active November 8, 2024 00:35
Simplified getRelativeTimeString
// from https://twitter.com/Steve8708/status/1504131981444980739
// simplified to a function body of 8 tidy lines
// no loop needed, no 2d array of 3-tuples needed
// just 2 arrays, a findIndex call, and some indexing :)
export function getRelativeTimeString(
date: Date | number,
lang = "en"
): string {
const timeMs = typeof date === "number" ? date : date.getTime();
@LewisJEllis
LewisJEllis / gist:1ac2e10e9309b3f59017
Last active July 2, 2016 01:12
Highland reduce example
var express = require('express');
var _ = require('highland');
var fs = require('fs');
var app = express();
function chain(s, f) {
return s.flatMap(_.wrapCallback(f))
}
app.post('/process-file', function(req, res) {
@LewisJEllis
LewisJEllis / workshop.py
Created July 19, 2013 13:44
Python crash course workshop given at Canada/USA Mathcamp 2013
# CanadaUSA Mathcamp Python Workshop
# Given by Lewis Ellis and Lucas Garron
print 'hello'
a = 3
print a
a = 5
print a
b = 3.6