Skip to content

Instantly share code, notes, and snippets.

@themattchan
themattchan / homework-sty
Last active May 11, 2016 04:19
[DEPRECATED: see https://github.com/themattchan/latex-styles] My LaTeX CS/Math homework style as a YASnippet
# -*- mode: snippet; require-final-newline: nil -*-
# name: homework-sty
# key: homework
# binding: direct-keybinding
# --
\documentclass[10pt,letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage[parfill]{parskip} % line break instead of indentation
\usepackage[margin=1in]{geometry}
\usepackage{float} % use attribute [H] to force images to stay where they should be
@themattchan
themattchan / KdTree.java
Last active March 3, 2016 08:54
Coursera Algs pt 1 Hw 5, example for my blog post.
import edu.princeton.cs.algs4.*;
import java.util.*;
public class KdTree {
private abstract class Node implements TreeApply {
protected Point2D point;
public abstract void apply (TreeFunction function);
}
private interface TreeFunction {

Keybase proof

I hereby claim:

  • I am themattchan on github.
  • I am mattchan (https://keybase.io/mattchan) on keybase.
  • I have a public key whose fingerprint is 43B9 F9E7 C56E D3BF 1063 7CFC 013F 7CA0 4EBC 8427

To claim this, I am signing this object:

#! /usr/bin/runhaskell
{-# LANGUAGE FlexibleContexts #-}
module Lib where
import Diagrams.Prelude
import Diagrams.Backend.PGF.CmdLine
pipeline :: Diagram PGF
pipeline = foldr1 (|||) labelledBlocks
where
gnuindent -kr -l80 -ut -i8 -ts8 -sob *.c *.h
# cribbed from scripts/Lindent from kernel
gnuindent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1
@themattchan
themattchan / Box.after.hs
Last active March 10, 2017 02:55
CSE 130 discussion week 6
{-# LANGUAGE FlexibleInstances #-}
-- | Fun with typeclasses
module Box where
import Prelude hiding (Functor(..), Applicative(..), Monad(..), Monoid(..), (.))
infixr 6 <>
--------------------------------------------------------------------------------
-- * Parametricity and typeclasses
-- see https://www.schoolofhaskell.com/school/starting-with-haskell/introduction-to-haskell/5-type-classes
@themattchan
themattchan / Game.v
Created July 25, 2017 03:14 — forked from arthuraa/Game.v
Basic combinatorial game theory
Require Import Coq.Lists.List.
Open Scope bool_scope.
(* This is a direct definition of CGTs, using just one inductive type
instead of a pair of mutually-inductive types *)
Inductive game := Game {
left_moves : list game;
right_moves : list game
{-# LANGUAGE
DataKinds
, TypeApplications
, TypeFamilies
, TypeOperators
, TypeInType
, KindSignatures
, ExistentialQuantification
, InstanceSigs
, ScopedTypeVariables
{-# LANGUAGE ExistentialQuantification, RankNTypes #-}
module Main where
{-@ LIQUID "--higherorder" @-}
import Language.Haskell.Liquid.ProofCombinators
import Data.Functor.Const
import Data.Functor.Identity
type Lens s t a b = forall f. Functor f => (a -> f b) -> (s -> f t)
{-# LANGUAGE DeriveFunctor #-}
import Control.Arrow ((&&&))
import Data.Bifunctor
-- Recursion Schemes for Dynamic Programming
-- Kabanov and Vene, Mathematics for Program Construction 2006
-- Basic stuff
newtype Mu f = In { out :: f (Mu f) }