Skip to content

Instantly share code, notes, and snippets.

main([N]) ->
loop(decrement(list_to_integer(N))).
loop(stop) ->
ok;
loop(F) ->
loop(F()).
decrement(0) -> stop;
decrement(N) ->
@mokele
mokele / gist:3974484
Created October 29, 2012 16:07
PropEr/Quickcheck example in Javascript
var Proper = {};
function even_number() {
return LET([integer()],
function(i) {
return i * 2;
}
);
}
@mokele
mokele / gist:3927134
Created October 21, 2012 14:31
XGoban spec for TIC-TAC-GO - which is not an interesting game
var goban = XGoban('#goban', {
geometry: {
width: 10, height: 10,
points: [
[4, 2, [3]], // 0
[6, 2, [4]], // 1
[2, 4, [3]], // 2
[4, 4, [0, 2, 4, 7]], // 3
[6, 4, [1, 3, 5, 8]], // 4
@mokele
mokele / gist:3925275
Created October 20, 2012 23:46
XGoban spec for Milton Keynes Go
var goban = XGoban('#goban', {
svg: "http://mokele.co.uk/miltonkeynes/miltonkeynes.svg",
geometry: {
width: 540, height: 540,
points: [
// 0-1
[212, 27, [3]], [279, 28, [6]],
// 2-3
[139, 54, [3, 4]], [209, 60, [0, 2, 5]],
// 4-8
eigs$ wc -l apps/{go,goweb}/src/*.erl
22 apps/go/src/go.erl
155 apps/go/src/go_account.erl
94 apps/go/src/go_accounts.erl
16 apps/go/src/go_app.erl
134 apps/go/src/go_chat.erl
36 apps/go/src/go_chat_sup.erl
125 apps/go/src/go_db.erl
373 apps/go/src/go_db_list.erl
62 apps/go/src/go_email.erl
01:22:27.052 [error] ** Handler goweb_http_handler terminating in websocket_handle/3
for the reason error:{case_clause,[{<<"ab0c8543407f401e917bbd0782174c3b">>,<0.157.0>,<0.159.0>}]}
** Message was {text,<<"{\"chatMessage\":{\"match\":\"ab0c8543407f401e917bbd0782174c3b\",\"message\":\"my system is to create a pseudo-account for each anonYMOUS session, and a real one for each openid login.\"}}">>}
** Options were []
Sep 30 21:09:31 Stevens-MacBook-Air.local Cloud[68570]: -[__NSDictionaryM name]: unrecognized selector sent to instance 0x10035fe50
Sep 30 21:09:31 --- last message repeated 1 time ---
Sep 30 21:09:31 Stevens-MacBook-Air.local Cloud[68570]: (
0 CoreFoundation 0x00007fff87da7716 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8f166470 objc_exception_throw + 43
2 CoreFoundation 0x00007fff87e3dd5a -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
3 CoreFoundation 0x00007fff87d95c3e ___forwarding___ + 414
4 CoreFoundation 0x00007fff87d95a28 _CF_forwarding_prep_0 + 232
5 Cloud 0x000000010000c8d0 Cloud + 51408
6 Cloud 0x000000010000c477 Cloud + 50295
geometry(Size) ->
Area = Size * Size,
lists:map(
fun(N) ->
{N, neighbours(N, Size, Area)}
end,
lists:seq(1, Area)
).
neighbours(N, Size, Area) ->
check_ko(#move{
point = #point{x = X2, y = Y2},
taken_points = [#point{x = X1, y = Y1}]
}, #move{
point = #point{x = X1, y = Y1},
taken_points = [#point{x = X2, y = Y2}]
}) ->
{error, ko_not_allowed};
check_ko(_, _) ->
ok.
-module(goban).
-export([
init/0,
init/2,
set_point_state/2,
place_stone_at/5,
move/2,
undo_move/2,
key/1,