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
class cont:
def __init__(self, fn):
self.fn = fn
def __call__(self, *args, **kwargs):
return (lambda: self.fn(*args, self, **kwargs))
class tailrec:
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
# Script to launch jackd and reroute PulseAudio through it. And optionally
# start fluidsynth.
# Usage (assuming this script is named `audio`, is in your PATH, and is
gatlin /
Created Oct 10, 2012
Uninstall Haskell from Mac OS X
# source:
sudo rm -rf /Library/Frameworks/GHC.framework
sudo rm -rf /Library/Frameworks/HaskellPlatform.framework
sudo rm -rf /Library/Haskell
rm -rf .cabal
rm -rf .ghc
rm -rf ~/Library/Haskell
gatlin / imperative.lhs
Last active Sep 16, 2019
Imperative Programming in Haskell
View imperative.lhs
How to add imperative programming to a pure functional language
Many people bemoan languages such as Haskell for not supporting imperative
programming; they decry the need for math in their computer science.
![Math? In my computer? Yeah right.](
I'm here to tell you that not only does Haskell make imperative programming a
cinch, but safe and correct as well. Follow along! This post is written in
View powerlist.hs
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
View write_to_fd.c
/* Helper function which writes a string to a file descriptor.
static gboolean
write_to_fd (int fd, const gchar *message) {
gsize bw;
GIOChannel *channel = g_io_channel_unix_new (fd);
GString *message_str = g_string_new (message);
g_string_append (message_str, "\n");
g_io_channel_write_chars (channel,
gatlin /
Created Jul 19, 2019
Use VLC without a UI to cast videos to chromecast
if [ -z "$1" ]; then
echo "Please specify a media file as the first argument."
exit 1
gatlin / gist:d89ee5442c10ca59ac9a8b621392ed10
Created May 1, 2019
Oleg's CK machine macro system - ever so slightly easier to find cross device here
View gist:d89ee5442c10ca59ac9a8b621392ed10
; Composable syntax-rules macros via the CK abstract machine
; We demonstrate (mutually-) recursive, higher-order applicative
; macros with clausal definitions, defined in the style that looks very
; much like that of ML or (strict) Haskell.
; We write composable, call-by-value--like macros without
; resorting to the continuation-passing-style and thus requiring no
; macro-level lambda. The syntax remains direct-style, with
; nested applications.
View free-compiler.hs
- Example of using free constructions to build a flexible little compiler.
- The goal here is not necessarily efficiency but readability and flexibility.
- The language grammar is represented by an ADT; however, instead of
- recursively referring to itself it instead references a type variable.
- We derive instances of 'Functor' and 'Traversable' for this type.
gatlin / monads.lhs
Created Nov 25, 2012
My explanation of monads
View monads.lhs
It's said that all Haskell programmers eventually write a blog post explaining
Monads. Today I fulfill my destiny. The basic format is ripped from "Learn You A
Haskell For Great Good," but these are my own crappy examples.
This blog post is literate Haskell; you can get it
[here]( You can import it into ghci and type
the functions to see their output (`ghci monads.lhs`). For this to work, we'll
need to import one module for use later:
> import Control.Applicative
You can’t perform that action at this time.