Skip to content

Instantly share code, notes, and snippets.

Gatlin Johnson gatlin

Block or report user

Report or block gatlin

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
@gatlin
gatlin / audio
Last active Oct 6, 2019
Shell script to make jackd and pulseaudio (and optionally fluidsynth) coexist with minimal interruption to my youtubing. Also it Works For Me™ on my laptop, will keep working on it
View audio
#!/bin/bash
###
# Script to launch jackd and reroute PulseAudio through it. And optionally
# start fluidsynth.
#
# READ THE NOTES PLEASE
###
# Usage (assuming this script is named `audio`, is in your PATH, and is
@gatlin
gatlin / output.txt
Last active Oct 26, 2016
applicative parser built with Tubes
View output.txt
Code: (+ 5 5)
Free (AApp (Free (ASymbol "+")) [Free (ANumber 5),Free (ANumber 5)])
---
Code: (lambda (x) (* x x))
Free (ALambda [Free (ASymbol "x")] (Free (AApp (Free (ASymbol "*")) [Free (ASymbol "x"),Free (ASymbol "x")])))
---
Code: ((\ (x) (* x x)) 5 (+ 10 2))
Free (AApp (Free (ALambda [Free (ASymbol "x")] (Free (AApp (Free (ASymbol "*")) [Free (ASymbol "x"),Free (ASymbol "x")])))) [Free (ANumber 5),Free (AApp (Free (ASymbol "+")) [Free (ANumber 10),Free (ANumber 2)])])
---
Code: '(1 2 3)
@gatlin
gatlin / pid.lhs
Created Aug 17, 2016
Streaming PID controller in Haskell
View pid.lhs
PID controller in Haskell
===
A major project I want to embark on at some point in the future is making a
quadrotor. I've made one before but I was at the mercy of a lot of off-the-shelf
software that I'm not altogether sure was entirely correct, either.
So I want to eventually program a quadrotor (or similarly awesome robot thing)
and I would really enjoy doing it in Haskell. It has a low footprint and is
already used in other real time settings.
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

@gatlin
gatlin / 1-js-lenses.md
Last active Sep 19, 2017
Simple implementation of lenses in JavaScript
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)
You can’t perform that action at this time.