Skip to content

Instantly share code, notes, and snippets.

@amtal
amtal / gist:669875
Created November 9, 2010 21:43
*.erl
::::::::::::::
t.erl
::::::::::::::
-module(t).
-export([go/0, l/0, run/1]).
%% @doc load
l()->
net_adm:ping('a@ak-desktop'),
net_adm:ping('b@ak-desktop'),
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
import Data.Vector as V
import Data.Word
import Data.Bits
data Instr = Seed Word32
| Mutate Word32
| JmpFwd Word16
| JmpRev Word16
@amtal
amtal / gist:873987
Created March 17, 2011 08:02
Augment code with tracing capability!
> (c 'trace)
#(module trace)
> (l 'trace)
(#(module trace))
> (: trace start)
IN [ myfunc, x=0 ]
IN [ myfunc, x=1 ]
IN [ myfunc, x=2 ]
IN [ myfunc, x=3 ]
OUT[ myfunc, x=3 => 0 ]
%% @doc Function description.
-spec f( Item::type() % description of item
, Action::type() % yet another description
...
) -> type() % blah
f(Item,Action) ->
We couldn’t find that file to show.
ak@rifter:~/code/erl/erlang_rebar_example_project$ rebar generate-upgrade previous_release=dummynode_first -v
DEBUG: Rebar location: "/home/ak/bin/rebar"
DEBUG: Entering /home/ak/code/erl/erlang_rebar_example_project
DEBUG: Available deps: []
DEBUG: Missing deps : []
DEBUG: Predirs: ["/home/ak/code/erl/erlang_rebar_example_project/apps/dummy_app",
"/home/ak/code/erl/erlang_rebar_example_project/rel"]
DEBUG: Entering /home/ak/code/erl/erlang_rebar_example_project/apps/dummy_app
DEBUG: Available deps: []
DEBUG: Missing deps : []
{excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)",
"^.git/.*"]},
{excl_archive_filters, [".*"]},
@amtal
amtal / homework.lisp
Created April 11, 2011 21:19
I like helping people
(defmodule homework (export letters))
(defun lut (x)
(: lists nth (- x (car '"/"))
'("0"
"1" "abc" "def"
"ghi" "jkl" "mno"
"pqrs" "tuv" "wxyz")))
(defun letters
(defmacro bin-parser ((cons name raw-clauses)
(flet ((fun-clause
((list (list* cmd chan match) body)
`((,cmd ,chan (binary ,@(: lists map (fun bin-chunk 1) match))) ,body))
((x) (error `(what_is_this ,x))))
(bin-chunk
(((list name n)) (when (is_integer n))
`(,name little integer (size ,(* 8 n))))
(((list name 'float))
`(,name little float))
(defmodule egs_proto (export (parse_packet 1) (dsl_test 0)))
;; Subset of binaries.
;;
;; Looks like little-endian 32 bit floats are hella broken.
;; Unsure why.
(defmacro egs-prot (chunks
(flet* ((chunk2bin
(((list name n)) (when (is_integer n))
`(,name little integer (size ,(* 8 n))))