Skip to content

Instantly share code, notes, and snippets.

@yonatanmn
yonatanmn / Trie.js
Created April 18, 2016 16:20
Trie for autocomplete in JS
function wordToLtrsArr(w){return w.split('')}
function tail(arr){return arr.slice(1)}
function goTo(o,wp){
if(!wp.length){return o}
var firstLetter = wp[0];
var point = o[firstLetter];
@pyrtsa
pyrtsa / .ghci
Last active August 2, 2018 15:43
.ghci — Essential parts of my Haskell REPL config.
-- Show loaded modules in window title and use a green "λ>" as prompt.
-- Subsequent lines of multi-line commands shall begin with " |".
:set prompt "\SOH\ESC]0;GHCi: %s\BEL\ESC[32;1m\STXλ>\SOH\ESC[0m\STX "
:set prompt2 "\SOH\ESC[32;1m\STX |\SOH\ESC[0m\STX "
-- Paste and evaluate text from the OS X clipboard. (The pasted text also
-- prints in yellow unless pasting quietly using :paste-quiet.)
:set -package process
:def paste \_ -> do { paste <- System.Process.readProcess "pbpaste" [] ""; let cmd = if '\n' `elem` paste then ":{\ntype Ö = ()\n" ++ paste ++ "\n:}" else paste in putStrLn ("\SOH\ESC[33m\STX" ++ paste ++ "\SOH\ESC[0m\STX") >> return (":cmd return " ++ show cmd) }
:def paste-quiet \_ -> do { paste <- System.Process.readProcess "pbpaste" [] ""; let cmd = if '\n' `elem` paste then ":{\ntype Ö = ()\n" ++ paste ++ "\n:}" else paste in return (":cmd return " ++ show cmd) }
@chrisdone
chrisdone / typing.md
Last active May 9, 2024 15:27
Typing Haskell in Haskell

Typing Haskell in Haskell

MARK P. JONES

Pacific Software Research Center

Department of Computer Science and Engineering

Oregon Graduate Institute of Science and Technology

@pseudomuto
pseudomuto / list.c
Created August 25, 2013 16:30
Blog Code: Implementing a Generic Linked List in C
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "list.h"
void list_new(list *list, int elementSize, freeFunction freeFn)
{
assert(elementSize > 0);
list->logicalLength = 0;