Instantly share code, notes, and snippets.

View bikemath.md

Bike Math!

Note: For the sake of clarity I'll probably write things you already know. It's just as much to eliminate communication errors as it is for me to keep track of what the fuck I'm even talking about. It does not imply any kind of judgment of what I assume about you :)

Here's the math behind gears and how they are used to efficiently rotate wheels. The same principles underlie how cars work but the mechanisms are

View 1-js-lenses.md

What is a lens?

Note: you can copy the file 2-lenses.js below over to repl.it and play along from home!

A lens in programming, much like a lens in the real world, allows you to focus in on a small part of a larger whole and then do something with or to

View fullwidth.js
'use strict';
let str = "anime is for losers";
let fw = Array.prototype.map
.call(str, (c) => c === ' '
? ' '
: String.fromCodePoint(c.codePointAt(0) + 0xFEE0))
.join('');
console.log(fw);
View ot.hs
{- |
Operational transformation in Haskell using (co)free (co)monads.
-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
import Data.List (splitAt)
import Control.Monad
View list_essay_code.js
'use strict';
/**
* Our little list implementation
*/
///// The foundation
let nil = (f) => (x) => x;
let cons = (h) => (t) => (f) => (x) => f(h)(t(f)(x));
let foldr = (list) => (f) => (x) => list(f)(x);
View module_boilerplate.js
/**
* ECMAScript module boilerplate
*
* (c) 2016 Gatlin Johnson <gatlin@niltag.net>
* with significant credit to github user @cwmyers
*
* Follow this template and your module will be compatible with browsers or any
* number of sophisticated ES dependency systems.
*
* INSTRUCTIONS
View my_prelude.hs
{- * Foundational functions -}
id :: a -> a
id x = x
const :: a -> b -> a
const x y = x
fix :: (a -> a) -> a
fix f = f (fix f)
View orca.hs
{-
This came from looking at the source for the orc package on hackage.
I wanted to know why it works, and to see if I can come up with an
alternative implementation which does cool things, and possibly provide
a mechanism for orchestrating non-linear tube computations.
-}
-- | Pilfered from the orc package on Hackage.
-- The original is specialized to one MonadIO instance.
-- Also this looks suspiciously like a continuation monad.
View frp_free.hs
import Control.Applicative
import Data.Time (UTCTime, getCurrentTime)
import Control.Monad.Trans.Free
import Control.Comonad
import Control.Comonad.Trans.Cofree
import Data.Functor.Identity
type Next = IO
View hackagedocs
#!/usr/bin/env bash
###
# hdoc
# (c) Gatlin Johnson <gatlin@niltag.net>
#
###########
# Available under the following license:
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE