Skip to content

Instantly share code, notes, and snippets.

View evansb's full-sized avatar

Evan Sebastian evansb

  • Singapore
View GitHub Profile
@evansb
evansb / tut2.ml
Created September 1, 2014 07:11
Tutorial 2 CS2104
(* Tutorial 2 : Recursion & Higher-Order Functions *)
(*
OCaml Reading Resources
tutorial:
http://ocaml.org/learn/tutorials/
introduction:
http://www.cs.jhu.edu/~scott/pl/lectures/caml-intro.html
@evansb
evansb / thread_guard.cpp
Created December 3, 2014 15:28
C++ multi threaded programming notes
#include <iostream>
#include <stdexcept>
#include <thread>
/* Thread guard is an RAII for thread that ensures
* join is called when the function that creates
* the thread goes out of scope.
*/
class ThreadGuard {
@evansb
evansb / .vimrc
Last active August 29, 2015 14:10
set encoding=utf-8
scriptencoding utf-8
set nocompatible
filetype off
"let $PATH='/Users/evan/.opam/system/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/evan/School/Haskell/.cabal-sandbox/bin:/Users/evan/.cabal/bin'
if has("gui_running")
set guifont=Source\ Code\ Pro\ Medium:h14
@evansb
evansb / bundles.vim
Last active August 29, 2015 14:10
bundles
" Here come the bundles
Bundle 'gmarik/vundle'
Bundle 'Valloric/YouCompleteMe'
Bundle 'Lokaltog/powerline-fonts'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'MarcWeber/vim-addon-mw-utils'
Bundle 'Raimondi/delimitMate'
Bundle 'bling/vim-airline'
Bundle 'bling/vim-bufferline'
@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
@evansb
evansb / memoize.hs
Last active August 29, 2015 14:12
Memoization hack in Haskell, using unsafe IO operation.
module Memoize (memoize) where
import Debug.Trace
import Data.Hashable
import System.IO.Unsafe
import qualified Data.HashTable.IO as H
type HashTable k v = H.CuckooHashTable k v
@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
@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

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:

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