Skip to content

Instantly share code, notes, and snippets.

pick(L) ->
finch:pick_one(L).
basic_random_test() ->
List = lists:seq(1,100),
Vals = [{pick(List),pick(List)}||_ <- lists:seq(1,30)],
?assertNot(chi2:chi80(Vals)),
true.
@zkessin
zkessin / index.html
Created February 5, 2015 05:09
canvas test target
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Canvas test page</title>
</head>
<body>
budgets = new Backbone.Budget.Collection(window.budget)
list =
width : 320
view : "datatable"
id : "budget_list"
backbone_collection : budgets
select : true
scroll : false
columns :[
-define(GET(Field),
{Field, list_to_binary(wf:q(Field))}).
-define(GET_JSON(JSON_TERM),
fun(Field) when is_atom(Field) ->
FieldB = erlang:atom_to_binary(Field,utf8),
Val = proplists:get_value(FieldB, JSON_TERM),
{Field, Val}
end).
-module(json_test).
-include_lib("eqc/include/eqc.hrl").
-include_lib("eunit/include/eunit.hrl").
-compile(export_all).
-include("erlog_test.hrl").
json_test() ->
{ok, ERLOG_STATE} = erlog:new(),
Data = [{<<"test">>, 12345}],
?assertMatch({{succeed,_},_}, erlog:prove(ERLOG_STATE, {length, Data, {'Len'}})).
@zkessin
zkessin / split.pl
Last active August 29, 2015 14:04
%-*- Prolog -*-
split(Head, Tail, HeadLength, FullList) :-
length(Head, HeadLength),
append(Head, Tail, FullList).
?- split(H,T, 3, [a,b,c,d,e,f,g,h,i,j,k,l]).
H = [a, b, c],
T = [d, e, f, g, h, i, j, k, l].
-module(erl_cache_tests).
-include_lib("proper/include/proper.hrl").
-include_lib("eunit/include/eunit.hrl").
-compile(export_all).
keys() ->
[
"AAAAAAAA",
"8BFE5E9B",
"59665E9E",
prop_render() ->
{ok, online_users_dtl} = erlydtl:compile_file("templates/online_users.dtl", online_users_dtl, []),
?FORALL(Rs,
list(presence()),
begin
{ok,HTML} = vest_current_users:render(Rs),
mochiweb_html:parse(iolist_to_binary(HTML)), %% assert that it is valid HTML
[_Prefix,Rows,_Suffix] = HTML,
length(Rows) =:= length(Rs)
end).
@zkessin
zkessin / poset.pl
Last active August 29, 2015 14:02
Code for partially ordered sets in prolog
connected(A,B) :-
edge(A,B).
sib(A,B) :-
path(C,A,_),
path(C,B,_),
\+path(A,B,_),
\+path(B,A,_).
ancestor(A,B) :-
@zkessin
zkessin / .travis.yml
Created May 15, 2014 13:59
.travis.yml for using QuickCheck
language: erlang
notifications:
disabled: true
install:
- wget http://www.quviq.com/downloads/eqcmini.zip
- unzip eqcmini.zip
- export ERL_LIBS=eqcmini
script: