Skip to content

Instantly share code, notes, and snippets.

View shino's full-sized avatar

Shunichi Shinohara shino

View GitHub Profile
-module(couchdb_btree_vs_dets).
-author('cooldaemon@gmail.com').
-export([test/0, test/1]).
test() -> test(1000).
test(Count) ->
KVs = lists:map(
fun (N) -> {N, {foo, bar, baz}} end,
lists:seq(1, Count)
-module(lists_vs_func_vs_comp).
-author('cooldaemon@gmail.com').
-export([test/0]).
test() ->
Seqs = lists:seq(0, 500000),
lists:foreach(
fun
({F, TargetName}) ->
@shino
shino / gist:16871
Created October 15, 2008 06:29
simple counter (just loop)
-module(simple_counter1).
-export([count_to/1, increment/2, test/0]).
count_to(Target) ->
increment(0, Target).
increment(Target, Target) ->
Target;
increment(Count, Target) ->
increment(Count + 1, Target).
-module(simple_counter3).
-behaviour(gen_server).
-export([start_link/0]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2]).
-export([terminate/2, code_change/3]).
a
-export([increment/0, stop/0]).
-export([count_to/1, test/0]).
class Sandbag1
def self.add1
define_method(:hoge1){ puts "The method :hoge1 is called."; }
end
def self.remove1
undef_method :hoge1
rescue NameError => e
# puts e
end
-module(mnesia_repl_and_frag).
-compile([export_all]).
-record(store, {key, value}).
%% Usage:
%% Start secondary node, at first. Not a typo :-)
%% Then start primary at another node.
%% Sample for mnesia fragmentation with load balancing.
-module(mnesia_repl_and_frag2).
-compile([export_all]).
-record(store, {key, value}).
primary() ->
net_kernel:start([localnode(1), longnames]),
%% Trial for mnesia fragmentation with local_content
%% The answer is NEGATIVE.
%% fragmentation with local_content does NOT work.
-module(mnesia_frag_and_local).
-compile([export_all]).
-record(store, {key, value}).
-module(overload_handler_sample).
-auther(shino.shun@gmail.com).
-compile(export_all).
%% -record(rec, {k, v1, v2, v3}).
main() ->
%% Mnesia 開始前には subscribe してもアラートは受け取れない
subscribe_to_mnesia(before_mnesia_start),
-module(mnesia_index_as_ets).
-export([main/0]).
-include_lib("eunit/include/eunit.hrl").
-record(kv, {key, value}).
main() ->
mnesia:start(),