Skip to content

Instantly share code, notes, and snippets.

View teburd's full-sized avatar

Tom Burdick teburd

View GitHub Profile
%% @author Tom Burdick <[email protected]>
%% @copyright 2011 Tom Burdick
%% @doc Sine wave generating trace handler. Useful for fun and testing.
%% @end
-module(plot_trace_sine).
-behaviour(plot_trace_handler).
-export([init/1, units/1, rate/1, length/1, samples/3, terminate/2]).
@teburd
teburd / gist:1281520
Created October 12, 2011 15:27
erlang startup
#!/bin/sh
cd `dirname $0`
erl +P 1000000 -smp -sname myapp -setcookie myapp -pa $PWD/ebin $PWD/apps/*/ebin $PWD/deps/*/ebin +Ktrue +A32 +S8 -boot start_sasl -s myapp
@teburd
teburd / validate.erl
Created November 4, 2011 15:23
Erlang Validation
%% @author Tom Burdick <[email protected]>
%% @copyright 2011 Tom Burdick
%% @doc Data Validation.
-module(validate).
%% api
-export([validate/2, has_errors/1, errors/1, values/1]).
-ifdef(TEST).
@teburd
teburd / person.erl
Created December 3, 2011 15:03
mnesia example
-module(person).
-export([init/0, insert/0, read/1]).
-record(person,
{name, %% atomic, unique key
age, %% age
married_to, %% name of partner or undefined
children }).%% list of children
@teburd
teburd / gist:1445137
Created December 7, 2011 22:52
cowboy rest
%% @author Tom Burdick <[email protected]>
%% @copyright 2011 Tom Burdick
%% @doc Nyuro Web Default Handler.
-module(nyuro_web_default).
%% cowboy_http_handler api
-export([init/3, rest_init/2, content_types_provided/2, to_html/2]).
@teburd
teburd / gist:1654535
Created January 21, 2012 23:42
What...
2012-01-21 17:42:24.382
request unknown request {http_error,<<"{\"name\":\"Whatever\",\"identifier\":\"None\",\"purity\":5}GET /system/samples/1 HTTP/1.1\r\n">>}
- - - - - - - - - - - - - - - - - - - - - - - - - -
rest_SUITE:sample failed on line 167
Reason: {badmatch,{ok,400,
[{"Server","Cowboy"},
{"Date","S...}
@teburd
teburd / gist:1654566
Created January 21, 2012 23:55
Bad Test
----------------------------------------------------
2012-01-21 17:54:38.552
replying with 403 for url <<"/system">>, method 'GET', headers [{'Host',
<<"localhost">>}]
----------------------------------------------------
2012-01-21 17:54:38.553
replying with 200 for url <<"/system">>, method 'GET', headers [{'Host',
<<"localhost">>},
{'Cookie',
@teburd
teburd / gist:1654680
Created January 22, 2012 00:13
Bad Keep Alive Socket with Cowboy and REST
----------------------------------------------------
2012-01-21 18:13:08.464
get to "/system", headers [], body [], socket undefined
=PROGRESS REPORT==== 21-Jan-2012::18:13:08 ===
supervisor: {<0.218.0>,corbel_session_sup}
started: [{pid,<0.397.0>},
{name,"session_bUgx1WNf"},
{mfargs,
@teburd
teburd / minmax.erl
Created February 27, 2012 22:35
Min Max Problem
-module(minmax).
-behaviour(gen_server).
-record(state, {range={undefined, undefined}}).
-export([test/0, start_link/0, range/0, stream/1]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
@teburd
teburd / .zshrc
Created February 29, 2012 15:29
zshrc
# Colors
autoload -U colors && colors
# Autocomplete
zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
autoload -Uz compinit && compinit
# Auto correct
setopt correctall