Skip to content

Instantly share code, notes, and snippets.

@mtornwall
mtornwall / gist:5429419
Created April 21, 2013 12:22
simple erlang app start
start_graph(App) ->
case application:start(App) of
ok ->
ok;
{error, {already_started, App}} ->
ok;
{error, {not_started, AppDep}} ->
start_graph(AppDep),
start_graph(App) % Try again
end.
@mtornwall
mtornwall / gist:5262940
Created March 28, 2013 13:01
Fizzbuzz on the PDP-8 I'm not exactly a PDP-8 hacker, so I suspect this code is far from optimal, but it does get the job done.
/ To assemble:
/ $ palbart -l fizzbuzz.pal
/ To run, install the SimH emulator collection and run:
/ $ pdp8
/ sim> load fizzbuzz.bin
/ sim> go 200
*10
X1, 0 / Autoincrement register for TTY printing
@mtornwall
mtornwall / gist:4555164
Created January 17, 2013 10:45
Gets rid of Erlang electric arrows in Emacs. Finally I can write cases and function clauses in one line without screaming in frustration.
;; Disable the electric arrow, but keep comma and semicolon
(setq-default erlang-electric-commands
'(erlang-electric-comma
erlang-electric-semicolon))
@mtornwall
mtornwall / gist:4215852
Created December 5, 2012 14:23
erlang scoping fun
test(Derp) ->
case Derp of
true -> OhYes = yes;
false -> OhYes = no;
end,
io:format("~p~n", [OhYes]).
@mtornwall
mtornwall / gist:3214525
Created July 31, 2012 07:32
sory emiliuru
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
PROMPT='%{$fg[$NCOLOR]%}%m %{$fg[blue]%}%~%{$reset_color%} ➤ %{$reset_color%}'
RPROMPT='%{$fg[blue]%}%p $(git_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX=""
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_CLEAN="✔"
ZSH_THEME_GIT_PROMPT_DIRTY="✗"
@mtornwall
mtornwall / gist:3076921
Created July 9, 2012 14:39
riak+utf8 index weirdness
#!/usr/bin/env escript
%% -*- coding: utf-8 -*-
%% TODO: Set up paths to riakc, riak_pb and protobuffs below.
%%! -pa /path/to/riakc, riak_pb and protobuffs
%% My output:
%% Indices before put: [{"band_bin","Mötley Crüe"}].
%% Indices after put: [{"band_bin",
%% [77,195,131,194,182,116,108,101,121,32,67,114,195,131,
%% 194,188,101]}].
@mtornwall
mtornwall / pyrror.py
Created May 15, 2012 18:14
perror utility in python
#!/usr/bin/env python
import sys
import os
def usage():
print 'usage: {} [errno]'.format(sys.argv[0])
sys.exit(1)
if __name__ == '__main__':