Skip to content

Instantly share code, notes, and snippets.

View kamil-adam's full-sized avatar

Kamil Adam kamil-adam

View GitHub Profile
(function($) {
// Used by dateinput
$.expr = {':': {}};
// Used by bootstrap
$.support = {};
// Used by dateinput
$.fn.clone = function(){
var ret = $();
@fumieval
fumieval / lazy.scm
Created March 28, 2012 05:05
Lazy K (unlambda style) interpreter for lazier
(load "lazier.scm")
(load "prelude.scm")
(load "prelude-numbers.scm")
(lazy-def '(main input) '(parse-unlambda i input))
(lazy-def 'parse-unlambda
'((lambda (x) (x x))
(lambda (self cont input)
((nth (car input) dispatch-list) (self self) cont (cdr input)) )))
@Nabb
Nabb / gist:2396963
Created April 16, 2012 07:40
Whitespace Assembler
"":d;
[]:VAR;
{|2>~2base(;{" \t"=}%n+}:LB;
{|~F}:N;{..abs<\2base+{" \t"=}%+"\n"+}:F;
{n%{{1<"#"=!}1$!!*},{"|"%~}%{
:|' '/0=.58,48>-\,1>{'-'-}*"PUSH"or:I;[
["PUSH"{" "N}]
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@codebrainz
codebrainz / c99.l
Created June 14, 2012 23:49
C99 Lex/Flex & YACC/Bison Grammars
D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E ([Ee][+-]?{D}+)
P ([Pp][+-]?{D}+)
FS (f|F|l|L)
IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
%{
#include <stdio.h>
@dholbrook
dholbrook / Tree.scala
Created June 21, 2012 17:59
Scala binary tree
/**
* D Holbrook
*
* Code Club: PO1
*
* (*) Define a binary tree data structure and related fundamental operations.
*
* Use whichever language features are the best fit (this will depend on the language you have selected). The following operations should be supported:
*
* Constructors
@egonSchiele
egonSchiele / reader.hs
Created June 10, 2013 20:51
Reader monad example
import Control.Monad.Reader
hello :: Reader String String
hello = do
name <- ask
return ("hello, " ++ name ++ "!")
bye :: Reader String String
bye = do
name <- ask
@rgrinberg
rgrinberg / Inisec.hs
Created August 17, 2013 06:02
simple ini parser using attoparsec
{-# LANGUAGE OverloadedStrings #-}
module Inisec where
import Prelude as P
import Data.Attoparsec.Text
import Data.Text.IO as T
import Data.Text
import Control.Applicative
data Section = Section
{ entries :: [(Text, Text)]
@nadult
nadult / parser.hs
Created November 3, 2013 11:38
C-like language parser in Haskell.
module Parser(parseProgram) where
import Text.Parsec.Expr
import Text.ParserCombinators.Parsec
import Text.ParserCombinators.Parsec.Error
import qualified Text.ParserCombinators.Parsec.Token as P
import Text.ParserCombinators.Parsec.Language
import Control.Monad
import Tokens