Skip to content

Instantly share code, notes, and snippets.

@gatlin
gatlin / bylaws.diff
Created November 16, 2012 20:56
CHEA Bylaws diff
1c1
< Article I
---
> Article I Name, Purpose, and Offices
3c3,4
< Name, Purpose, and Offices
---
> Section 1 Name
> The name of the corporation is Community Housing Expansion of Austin, Hereinafter called the Corporation.
5c6,7
@gatlin
gatlin / monads.lhs
Created November 25, 2012 21:07
My explanation of monads
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](https://gist.github.com/4145341). 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
@gatlin
gatlin / 1Readme.md
Created December 5, 2012 22:29
yet another fucking lisp

Untitled language

The goal of this language is to include all the things I like and to build them axiomatically. The core language has:

  • it's a lisp, so it has s-exprs
  • fexprs, with vau, wrap, and unwrap
  • lexical scope; expressions can mutate immediate lexical environment under TBD conditions
  • no shared state
  • primitive integer, floating point, boolean, and unicode types
@gatlin
gatlin / perlxkcdpass.sh
Created December 15, 2012 22:28
Using the `Crypt::XkcdPassword` Perl module, this is an obvious but still useful one-liner for password generation.
perl -MCrypt::XkcdPassword -E 'say Crypt::XkcdPassword->make_password'
{-
This is a simple simulation of OT with Cloud in which all slaves generate
and apply random operations. It should work in theory. In practice, however
I wasn't apply to test it because my installation of distributed-process is
apparently broken. Specifically, `spawn` doesn't seem to work (I tested it
with some examples from the Well-Typed blog).
This code depends on https://github.com/timjb/haskell-operational-transformation.
-}
@gatlin
gatlin / humanoid.cpp
Created April 26, 2013 19:02
A quick overview of creating simple classes in C++, with example usage of abstract base classes and the iostream library.
#include <iostream>
using namespace std;
/***
* Humanoid
* An abstract base class for other lifeforms
*/
class Humanoid {
protected:
@gatlin
gatlin / isgd.sh
Created April 27, 2013 19:00
Nifty perl one-liner for shortening URLs on the command line via is.gd. Requires WWW::Shorten::IsGd
alias isgd="perl -MWWW::Shorten::IsGd -le 'print makeashorterlink shift'"
@gatlin
gatlin / Makefile
Last active December 20, 2015 07:49
I think I'm doing this correctly so far
all: sexp
sexp: sexp.y sexp.l
yacc -d sexp.y
lex sexp.l
gcc -o sexp lex.yy.c y.tab.c -ly -ll
clean:
rm -rf *.{c,o,h}
rm sexp
@gatlin
gatlin / stripe.hs
Last active December 29, 2015 06:59
A point-free (pointless?) little program to calculate how much to invoice clients to get a desired amount after Stripe's fees.
module Main where
import System.Environment
main :: IO ()
main = getArgs >>= parse >>= display . roundMoney . charge
charge :: Fractional a => a -> a
charge = (/ 0.971) . (+ 0.3)
Writing a billing system in Haskell, using Stripe and Heroku
===
*This post is written in literate Haskell, meaning the source can be turned
into a blogpost or a working program. You can view the [source][source].
[source]: https://gist.github.com/gatlin/7754289
Normally clients pay me with checks, but recently one informed me that they
really really really like *really really* super prefer some kind of online