This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(foo). | |
-export([drop/2]). | |
drop([], Elem) -> []; | |
drop([Elem|T], Elem) -> drop(T, Elem); | |
drop([H|T], Elem) -> [H | drop(T, Elem)]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Without using partial | |
(defn sums-to-n? [n] | |
(fn [coll] | |
(= n (reduce + coll)))) | |
(def f (sums-to-n? 10)) | |
(f [1 2 3]) ; false | |
(f [1 2 3 4]) ; true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(foobar). | |
-behaviour(gen_fsm). | |
-define(SERVER, ?MODULE). | |
-export([init/1, handle_event/3, handle_sync_event/4, handle_info/3, terminate/3, code_change/4, one/2, two/2, three/2, first/0, second/0, third/0]). | |
-compile(export_all). | |
start_link() -> | |
gen_fsm:start_link({local, ?SERVER}, ?MODULE, [], []). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%% subscribing process | |
-module(subscribe_madi). | |
-export([test/0]). | |
test() -> | |
mnesia:subscribe({table, nick, simple}), | |
loop(). | |
loop() -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(migrate). | |
-compile(export_all). | |
-include("v.hrl"). | |
gah() -> | |
Transformer = fun({v, Name, Parent}) -> | |
#vm{name = Name, parent = Parent, group = undefined} | |
end, | |
mnesia:transform_table(v, Transformer, [name, parent, group]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(kicker). | |
-compile(export_all). | |
sleeper() -> | |
spawn(fun() -> loop() end). | |
loop() -> | |
receive | |
Any -> | |
io:format("Message ~p~n", [Any]), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
is_table_defn_updated() -> | |
mnesia:table_info(version1, attributes) =/= record_info(fields, version1). | |
upgrade_version_table() -> | |
case is_table_defn_updated() of | |
false -> ok; | |
true -> | |
NewAttrs = record_info(fields, version1), | |
{ atomic, ok } = mnesia:transform_table(version1, (fun transformer/1), NewAttrs) | |
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def x (ref 0) | |
(def agents (for [i (range 0 1000)] (agent x))) | |
(map #(send %1 (fn [x] (dosync (alter x inc)))) agents) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/hbase org.jruby.Main | |
# | |
# HBase status plugin | |
# === | |
# | |
# This plugin checks if any of the regionservers are down | |
# | |
# Copyright 2012 Runa Inc | |
# | |
# Released under the same terms as Sensu (the MIT license); see LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ironfan.cluster 'test0' do | |
cloud(:ec2) do | |
permanent false | |
availability_zones ['us-east-1d'] | |
flavor 't1.micro' | |
backing 'ebs' | |
image_name 'natty' | |
bootstrap_distro 'ubuntu10.04-ironfan' | |
chef_client_script 'client.rb' | |
mount_ephemerals |
OlderNewer