Skip to content

Instantly share code, notes, and snippets.

@kevsmith
kevsmith / gist:127352
Created June 10, 2009 17:01
Parsed sphinx search results
[{doc_id,616},
{weight,3},
{attrs,[{<<"name_sort">>,47},
{<<"organization_type_id">>,1},
{<<"deanery_id">>,1},
{<<"created_at">>,{{2007,9,5},{12,46,45}}},
{<<"updated_at">>,{{2009,1,16},{2,11,36}}},
{<<"lat">>,39.851016998291016},
{<<"lng">>,-75.7154769897461},
{<<"sphinx_internal_id">>,308},
Result: [97,"dditive"]
Result: {nonterminal,"additive"}
Result: 97
Result: 100
Result: 100
Result: 100
Result: 100
Result: 105
Result: 105
Result: 116
-module(test_datatypes).
-define(UNSUP_ERR, {error, unsupported_javascript_return_type}).
-include_lib("eunit/include/eunit.hrl").
string_test_() ->
[{setup, fun() -> ok = markatta_driver:start() end,
fun(_) -> markatta_driver:stop() end,
[fun() ->
We couldn’t find that file to show.
-define(TIMEOUT, 60000).
-behavior(ssh_channel).
%% API
-export([start_link/2, send/2, send_wait/2, close/1, get_data/1]).
%% ssh_channel API
-export([init/1, handle_call/3, handle_cast/2, handle_msg/2]).
-export([handle_ssh_msg/2, code_change/3, terminate/2]).
-module(packer).
-export([pack/1, test/0]).
pack(Data) ->
pack(Data, []).
test() ->
[[a, a, a], [b, b, b]] = packer:pack([a,a,a,b,b,b]),
[[a,a,a,a], [b], [c, c], [a, a], [d], [e, e, e, e]] = packer:pack([a,a,a,a,b,c,c,a,a,d,e,e,e,e]),
#!/usr/bin/env escript
%% -*- erlang -*-
-mode(compile).
-export([foo/0]).
foo() ->
5.
main([]) ->
perdido:xoo-modules ksmith$ xoo
xoo 0.0.1 [V8: 1.3.16 (candidate)]
> xoo.require('file')
true
> xoo.require('www')
true
> www.withURL('http://news.ycombinator.com/', function(data) { file.writeFile('/tmp/index.html', data); })
> xoo.print("Hello, world!")
Hello, world!
>
perdido:erlang ksmith$ xoo
xoo 0.0.1 [V8: 1.3.16 (candidate)]
> xoo.require('erlang')
true
> xoo.print('Result: ' + erlang.bert.decode(erlang.bert.encode('Hello, world')))
Result: Hello, world
>
@kevsmith
kevsmith / gist:222656
Created October 30, 2009 19:55
Unexpected Erlang behavior
-module(dog).
-export([new/1, woof/1]).
new(Name) -> {dog, Name}.
woof(Self) ->
{dog, Name} = Self,
io:format("~p says 'woof!'~n", [Name]).