Skip to content

Instantly share code, notes, and snippets.

View evansb's full-sized avatar

Evan Sebastian evansb

  • Singapore
View GitHub Profile
@evansb
evansb / shunt.hs
Created June 6, 2014 14:22
Shunting Yard Algorithm in Haskell
module Main where
import Data.Char
import Data.Map
-- Shunting - Yard algorithm for Reverse Polish Notation
data Token = Number Int | ParenOpen | ParenClose
| AddOp | MulOp | DivOp | SubOp
deriving (Show, Eq)
@evansb
evansb / Cont.hs
Created January 18, 2015 13:14
Continuation Passing Style in Haskell
{-# LANGUAGE InstanceSigs #-}
import Control.Applicative
import Control.Monad
import Control.Monad.Trans.Writer
-- Here is a direct style pythagoras function
-- There are two noticeable things in the function body.
-- 1. Evaluation order of x * x vs y * y is unknown/implicit.
-- 2. We don't care what happens to the final value (implicit continuation).
pyth :: (Floating a) => a -> a -> a
type DataProvider<TKey extends string, TData> = {
getData(): TData
}
type ProvidedData<K1 extends string, T1> = { [key in K1]: T1 }
function getDataFromProviders<K1 extends string, T1>(p1: DataProvider<K1, T1>): ProvidedData<K1, T1>
function getDataFromProviders<K1 extends string, T1, K2 extends string, T2>(p1: DataProvider<K1, T1>, p2: DataProvider<K2, T2>): ProvidedData<K1, T1> & ProvidedData<K2, T2>
function getDataFromProviders(...providers: DataProvider<any, any>[]): {[name: string]: any } {
@evansb
evansb / avl.hs
Last active March 26, 2017 16:33
Purely Functional AVL Tree
module AVLZipper (singleton, empty , fromList , maximum , minimum) where
import Prelude hiding (minimum, maximum)
import Control.Applicative hiding (empty)
import Control.Monad
import Control.Monad.Trans.State
import Control.Monad.Trans.Identity
import Debug.Trace

Keybase proof

I hereby claim:

  • I am evansb on github.
  • I am evansb (https://keybase.io/evansb) on keybase.
  • I have a public key whose fingerprint is E018 7B67 E241 2D5D 693C 6F72 6214 1251 AB9D F1E4

To claim this, I am signing this object:

@evansb
evansb / .vimrc
Last active December 22, 2015 08:49
My .vimrc
set nocompatible
filetype off
if has("gui_running")
set guifont=Source\ Code\ Pro\ for\ Powerline:h12
set linespace=3
endif
set rtp+=~/.vim/bundle/vundle
@evansb
evansb / Makefile
Created July 1, 2014 14:24
CP stuff
TARGET=TARGET_NAME
CC=clang++
CFLAG=-Wall -O3 -g -DNDEBUG
SRC=$(shell find . -name *.cpp)
OBJ=${SRC:.cpp=.o}
all: $(OBJ)
./$(TARGET) $(TARGET).input $(TARGET).output
diff $(TARGET).output $(TARGET).model
module.exports = React.createClass
mixins: [UITheme]
getInitialState: ->
items: []
isInfiniteLoading: false
filter: null
firstTimeFetch: true
hasNoMore: false
componentWillMount: ->
FilterStore.listen (filter) =>
Conventions: When I specify "simple" as result it means simply return all json of format { table_field_name: table_field_value }
GET /achievements
Table: achievements
Return list of all achievements.
GET /annotations/:code_id
Table: annotate
@evansb
evansb / BST.ml
Created January 1, 2015 17:17
Binary Search Tree in OCAML
open Core.Std
module type COMPARABLE = sig
type t
val compare : t -> t -> int
end
module type NODE = sig
type 'a t