Skip to content

Instantly share code, notes, and snippets.

View nicolashahn's full-sized avatar

Nicolas Hahn nicolashahn

View GitHub Profile
-- main.hs
import Data.Monoid ((<>))
import Graphics.Gloss
import Graphics.Gloss.Interface.IO.Game
import Math.Geometry.Grid
import Math.Geometry.Grid.Square
import Data.List
import System.Random
import System.Random.Shuffle
@nicolashahn
nicolashahn / cmps112asg5
Created May 6, 2015 22:19
cmps112 asg5
For this assignment, you will create an interpreter for a minimal imperative WHILE language in Haskell.
First, copy the following definitions into a new file called hw5.hs.
-- Necessary imports
import Control.Applicative ((<$>),liftA,liftA2)
import Data.Map
import Text.Parsec
import Text.Parsec.Expr
import Text.Parsec.Language (emptyDef)

Keybase proof

I hereby claim:

  • I am nicolashahn on github.
  • I am nickhahn (https://keybase.io/nickhahn) on keybase.
  • I have a public key ASDQvw94Kfz_5xNcpmsFEZ61JZpmvWvO-pyBTjFC2MWD1Ao

To claim this, I am signing this object:

@nicolashahn
nicolashahn / lisp.py
Created March 6, 2018 08:12
lisp parser
def token_to_atom(token):
''' ints, floats converted, everything else string '''
if token[0] in '1234567890':
if '.' in token:
return float(token)
return int(token)
return token
def tokens_to_tree(tokens):
''' take out parens, nest lists '''
import sys
import numpy as np
import operator
# def discriminant(a,b,c):
# return (b**2) - 4*a*c
# def quadratic(a,b,c):
# """Compute roots from a polynomial of the form ax^2 + bx + c."""
# ops = [operator.add, operator.sub]
@nicolashahn
nicolashahn / computer.glsl
Created June 15, 2018 17:34 — forked from bdon/computer.glsl
rc computer
//https://thebookofshaders.com/edit.php
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
alert();
]0;fish /Users/nhahn(BWelcome to fish, the friendly interactive shell
[?2004h]0;fish /Users/nhahn(B⏎(B
❰nhahn❙~❱✔≻(B tt(Bm(Bux(Bux(Bx(Btmux(B (B -V(B
(B[?2004l]0;tmux /Users/nhahn(B
[?1049h[?1h=[?12l[?25h[?1000l[?1002l[?1006l[?1005l(B[?12;25h[?12l[?25h[?1003l[?1006l[?2004l]112[?1006h[?1002h[?25l




@nicolashahn
nicolashahn / alacritty.recording
Last active May 23, 2019 13:52
Reproduce rendering bug in alacritty and vim without tmux
]0;fish /home/nhahn(BWelcome to fish, the friendly interactive shell
[?2004h]0;fish /home/nhahn(B⏎(B
❰nhahn❙~❱✔≻(B vv(Bim(Bim(Bvim(Bm  .tmux.conf(B.tmux.conf(B.tmux.conf(Bv(Bimrc(Bimrc(Bmrc(Brc(Bc(B
(B[?2004l]0;vim /home/nhahn(B
[?1006h[?1002h[?2004h[?1049h[?1h=[?2004h[?12h[?12l[
use std::collections::HashMap;
use std::fmt::Debug;
use std::hash::Hash;
use KeyDiff::{Added, Changed, Removed};
#[derive(Debug)]
enum KeyDiff<V: PartialEq> {
Added(V),
Removed(V),
Changed(V, V),