Skip to content

Instantly share code, notes, and snippets.

View mwhittaker's full-sized avatar

Michael Whittaker mwhittaker

View GitHub Profile
@mwhittaker
mwhittaker / gitdown
Created March 21, 2014 06:18
gitdown
#! /bin/sh
usage() {
echo "usage:"
echo " gitdown <markdown file>"
}
if test $# -lt 1; then
usage;
exit;
@mwhittaker
mwhittaker / bind.cpp
Created March 28, 2014 01:48
Simple C++ Bind
#include <iostream>
#include <vector>
template<typename F>
int operator>>=(int i, F f) {
if (i == 0) {
return i;
}
return f(i);
}
@mwhittaker
mwhittaker / bind.rs
Created June 8, 2014 02:11
Rust Option Bind
// Option bind for rust 0.10
fn inv(f: f32) -> Option<f32> {
if f == 0.0 {
None
}
else {
Some(1.0 / f)
}
}
@mwhittaker
mwhittaker / client.go
Last active November 16, 2023 06:01
Go Echo Server and Client
package main
import (
"fmt"
"net"
"os"
"time"
)
const (
@mwhittaker
mwhittaker / monad.rs
Created July 12, 2014 21:47
Syntactic sugary monadic bind and map
#![feature(macro_rules)]
macro_rules! map(
() => ({});
($a:expr) => ($a);
($a:expr -> $b:expr) => ($a.map($b));
($a:expr -> $b:expr -> $($c:expr)->*) => (map!($a.map($b) -> $($c)->*));
)
macro_rules! flatbind(
@mwhittaker
mwhittaker / beamercolorthememongo.sty
Created July 29, 2014 23:47
MongoDB Beamer Color Theme
\DefineNamedColor{named}{mongobrown}{RGB}{61, 41, 30}
\DefineNamedColor{named}{mongogold} {RGB}{129, 102, 75}
\DefineNamedColor{named}{mongogreen}{RGB}{55, 140, 40}
\DefineNamedColor{named}{darkgray}{cmyk}{0,0,0,0.90}
\mode<presentation>
\setbeamercolor{alerted text}{fg=red}
\setbeamercolor*{palette primary}{bg=mongobrown,fg=white}
\setbeamercolor*{palette secondary}{fg=white,bg=mongogreen}
\setbeamercolor*{palette tertiary}{fg=white,bg=darkgray}
@mwhittaker
mwhittaker / Makefile
Last active December 18, 2015 20:15
OCaml Testing
all: main_ounit.byte main_qcheck.byte main_pa_ounit.byte
main_ounit.byte: main_ounit.ml
corebuild -pkg oUnit main_ounit.byte
main_pa_ounit.byte: main_pa_ounit.ml
corebuild -pkg oUnit,pa_ounit,pa_ounit.syntax main_pa_ounit.byte
main_qcheck.byte: main_qcheck.ml
corebuild -pkg qcheck main_qcheck.byte
@mwhittaker
mwhittaker / Makefile
Created April 4, 2015 17:49
Async Unit Tests
default: all
all: compile test
compile:
cs3110 compile -t -p core -p async main.ml
cs3110 compile -t -p core -p async main_test.ml
test: compile
cs3110 test main_test.ml
@mwhittaker
mwhittaker / README.md
Last active March 14, 2020 18:12
Google Cloud Platform
@mwhittaker
mwhittaker / monad.rs
Created April 19, 2015 02:31
Rust Maybe Monad
use std::ops::Shr;
use Maybe::{Nothing, Just};
#[derive(Debug)]
enum Maybe<A> {
Nothing,
Just(A)
}
impl<A, B, F> Shr<F> for Maybe<A> where F: Fn(A) -> Maybe<B> {