Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Hall benji6

View GitHub Profile
@benji6
benji6 / index.html
Last active Jul 27, 2020
index.html boilerplate
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="theme-color" content="{{ themeColor }}">
<meta name="viewport" content="initial-scale=1, width=device-width">
<title>{{ title }}</title>
<script defer src="index.js"></script>
<link href="style.css" rel="stylesheet">
</head>
View vs-code-settings.json
{
"editor.minimap.enabled": false,
"editor.scrollBeyondLastLine": false,
"editor.tabSize": 2,
"editor.wordWrap": "on",
"explorer.confirmDelete": false,
"explorer.confirmDragAndDrop": false,
"editor.accessibilitySupport": "off",
"editor.formatOnSave": true,
"extensions.ignoreRecommendations": false,
View jingleBells.js
const audioCtx = new AudioContext
const gain = audioCtx.createGain()
gain.connect(audioCtx.destination)
gain.gain.value = 0.2
const noteDuration = 0.2
const notes = [
[659.25, 1], [659.25, 1], [659.25, 2],
[659.25, 1], [659.25, 1], [659.25, 2],
[659.25, 1], [783.99, 1], [523.25, 1], [587.33, 1],
[659.25, 4],
@benji6
benji6 / computeHash.js
Created Dec 27, 2018
Compute cache busting hash
View computeHash.js
const crypto = require('crypto')
const computeHash = data =>
crypto
.createHash('md5')
.update(data)
.digest('base64')
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=+$/, '')
View .npmrc
init-license=MIT
init.author.name=Ben Hall
init.version=0.0.0
View move2dPoints.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WASM</title>
<style>
html {
height: 100%;
}
body {
View lazyIterablesShowAndTell.js
// imlazy show and tell
// utils
const compose = (...fns) => x => fns.reduceRight((acc, f) => f(acc), x)
const log = (x, ...xs) => (console.log(...[x + ':', '\n', ...xs, '\n']))
// Generator expression
const oneTwoThreeGenerator = function * () {
yield 1
yield 2
View analyze.js
// there's got to be a better name for this function
const analyze = (xForms, data) => Object.keys(xForms).reduce(
(acc, key) => Object.assign(acc, {[key]: xForms[key](data)}),
{}
)
// it allows application of multiple transformations to a single value
// and combines the results of those transformations into a single object
const rectangleSideLengths = [3, 4]
const area = ([a, b]) => a * b