Skip to content

Instantly share code, notes, and snippets.

Working from home

Thomas Foster thomasfoster96

Working from home
View GitHub Profile
View form-example.js
// ⚠️ This is NOT the React Hooks API
const key = Symbol();
function Form() {
// ...
const name = useFormInput(key, "name");
const surname = useFormInput(key, "surname");
// ...
return (

Keybase proof

I hereby claim:

  • I am thomasfoster96 on github.
  • I am thomasfoster96 ( on keybase.
  • I have a public key ASDCAbD60YhJmYb8J9dRvtrYNFA_qnfxOv5nmjaKtgakZwo

To claim this, I am signing this object:

thomasfoster96 / index.html
Last active Mar 26, 2018
Batman By-election Visualisation
View index.html
<!DOCTYPE html>
<link rel="stylesheet" href="./styles.css">
<div id="map">Hello World!</div>
thomasfoster96 / index.js
Created Jun 28, 2016
An ECMAScript to English transpiler.
View index.js
function transpile(token){
case "Literal":
switch(typeof token.value){
case "string":
return `"${token.value}"`;
case "boolean":
return `${token.value ? "true" : "false"}`;
case "null":
return "nothing";
thomasfoster96 /
Last active Feb 26, 2016
Political Hashtags Directory
View index.js
/* Template string as function.
* Pros: Only has access to parameters.
* Cons: Have to make a module.
import {template} from './template-string-as-function.js';
let page = template({
title: "10 Wierd Template String Tricks",
thomasfoster96 / graph.js
Last active Aug 29, 2015
Data structures.
View graph.js
class Graph {
adjList = new Map()
constructor(iterable, directed = true){
for(let node of iterable){
this.adjList.set(node, new Map());
thomasfoster96 / script.js
Created Jun 15, 2015
Expressions-only ECMAScript
View script.js
// This gist plays around with a subset of ECMAScript6 (ES2015) that only uses expressions (except for the 'Program' const declaration).
/* Some rules:
* Arrow functions that evaluate an expression are the only kinds of functions allowed.
* All variables are declared as function parameters.
* If you want to scope variables, use the following format of an arrow function in parentheses:
* No return statement - the last expression in a list of expressions is what is returned.
* No Generators :( Or async/await :(
View do-until-loop.js
* The until version of doWhileLoop.
function untilLoop(condition, body){
return untilLoop(condition,body);