Skip to content

Instantly share code, notes, and snippets.

View cstar's full-sized avatar

Eric Cestari cstar

  • Escape Velocity Operations
  • Paris, France
  • 00:36 (UTC -12:00)
  • LinkedIn in/ecestari
View GitHub Profile
@cstar
cstar / feature.erl
Last active December 18, 2015 14:11
feature toggle
-mod(feature).
-export([feature/3]).
-spec feature(atom(), fun(), fun()) -> any().
feature(Name, TrueFun, FalseFun)->
case application:get_env(?APPLICATION,toggles, []) of
List ->
case lists:member(Name,List) of
true ->
@cstar
cstar / boss_tracer.erl
Created May 28, 2013 10:40
Traces queries to mysql and pgsql
-module (boss_tracer).
-behaviour (gen_server).
-export([start/0]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
@cstar
cstar / gist:982592
Created May 20, 2011 08:59
Choix Android
ça dépend :
* le prix qu'il veut mettre
* s'il choisi un device indemnisé par son opérateur
* de ses préférences personnelles : taille, poids, tronche, feeling global
pour moi, éviter à tout prix les constructeurs qui n'upgradent pas l'OS
d'une manière générale, le Nexus One et le Nexus S sont bons
le HTC Desire (et son successeur HTC Desire S) a un bon succès "mais" possède la surcouche HTC Sense
le HTC Desire HD a un gros n'écran : ce sera 4 ou 4.3 la taille d'écran de ma prochaine acquisition (que je reste sur Android ou pas)
le HTC Desire Z a un zouli clavier, c'est un appareil classouille
les LG Optimus 2X et Samsung Galaxy S ont bonne presse en ce moment...
@cstar
cstar / gist:970445
Created May 13, 2011 12:33
Fake your webmachine requests for unit testing.
make_wrq(Method, RawPath, Headers) ->
{ok, Dispatch} = file:consult(filename:join(
[filename:dirname(code:which(?MODULE)),
"..", "priv", "dispatch.conf"])),
R0 = wrq:create(Method, {1,1}, RawPath, mochiweb_headers:from_list(Headers)),
R1 = wrq:set_peer("127.0.0.1", R0),
{_, _, HostTokens, Port, PathTokens, Bindings, AppRoot, StringPath} =
webmachine_dispatcher:dispatch("127.0.0.1", RawPath, Dispatch),
wrq:load_dispatch_data(Bindings,
HostTokens,
This is embedded from github
%% A faire
% - passer en configuration l'arborescence des facette (par type)
% {mod_search, [{facet, {type, "produit"}, [{"facet.limit",5}], [
% style,
% {price, [{query, "price:[*+TO+500]"},
% {query, "price:[500+TO+*]"}]}
% ]}
% {facet, {type, "session"}, [], [style, gangs]}
% ]
% }
-module(erldis_multiple).
-export([test/0, get_key/1, server/2]).
test() ->
{ok, Conn} = erldis:connect("localhost", 6379),
erldis:zadd(Conn, "erldis_fail", 4.0, "thing1"),
erldis:zadd(Conn, "erldis_fail", 4.0, "thing2"),
erldis:zadd(Conn, "erldis_fail", 3.5, "thing3"),
erldis:zadd(Conn, "erldis_fail", 2.0, "thing4"),
erldis:zadd(Conn, "erldis_fail", 6.3, "thing5"),
-module(erldis_multiple).
-export([test/0, get_key/1, server/2]).
test() ->
{ok, Conn} = erldis:connect("localhost", 6379),
erldis:zadd(Conn, "erldis_fail", 4.0, "thing1"),
erldis:zadd(Conn, "erldis_fail", 4.0, "thing2"),
erldis:zadd(Conn, "erldis_fail", 3.5, "thing3"),
erldis:zadd(Conn, "erldis_fail", 2.0, "thing4"),
erldis:zadd(Conn, "erldis_fail", 6.3, "thing5"),
%#!/usr/bin/env escript
%%! -sasl errlog_type info -boot start_sasl -noshell -sname ejabberd
% returns on stdout all nodes called NodeName on the EC2 security group.
main([NodeName])->
catch ec2nodefinder:start(),
Nodes = case catch ec2nodefinder:discover() of
{ok, N}-> N;
_ ->
[]
end,
%% Analysis results:
{ analysis_options,
[{callers, false},
{sort, acc},
{totals, true},
{details, false}]}.
% CNT ACC OWN
[{ totals, 3626, 50.613, 19.008}]. %%%