Skip to content

Instantly share code, notes, and snippets.

View gabrielelana's full-sized avatar
🎯
Focusing

Gabriele Lana gabrielelana

🎯
Focusing
View GitHub Profile
@gabrielelana
gabrielelana / stream_behaviour_test.ex
Last active August 29, 2015 14:20
Unexpected behaviour from Elixir streams
defmodule StreamBehaviourTest do
use ExUnit.Case, async: true
test "will not pull from upstream after halt" do
called = fn key, x -> Process.put(key, [x|Process.get(key, [])]) end
results = 1..10
|> Stream.each(&called.(:upstream, &1))
|> Stream.take(1)
|> Stream.each(&called.(:downstream, &1))
@gabrielelana
gabrielelana / output
Created January 20, 2015 15:50
Elixir GenServer stop
$elixir stop.exs
Asked to stop because :normal
1) test stop (Test)
stop.exs:28
** (exit) exited in: GenServer.call(#PID<0.68.0>, :stop, 5000)
** (EXIT) normal
stacktrace:
(elixir) lib/gen_server.ex:356: GenServer.call/3
@gabrielelana
gabrielelana / ERLANG.md
Created October 3, 2014 14:03
Github users and repo to keep an eye on for Erlang
@gabrielelana
gabrielelana / .vimrc
Created May 9, 2013 12:54
Local .vimrc for a php project, run/open current test
" autoload the local .vimrc file you need to have
" https://github.com/MarcWeber/vim-addon-local-vimrc
" plugin installed
map <Leader>t :call RunCurrentTest()<CR>
map <Leader>o :call OpenCurrentTest()<CR>
function! RunCurrentTest()
@gabrielelana
gabrielelana / dabblet.css
Created April 27, 2013 12:56
Big rounded form
body {
background-color: #eee;
}
.container {
margin-top: 50px;
width: 1400px;
text-align: center;
font-family: sans-serif;
height: 75px;
score(Rolls) ->
NumberOfFrames = 10,
{ Score, _ } = lists:foldl(fun(_, { Score, FramesRolls }) ->
{ ScoreInFrame, RemainingFramesRolls } = score_frame(FramesRolls),
{ Score + ScoreInFrame, RemainingFramesRolls }
end, { 0, Rolls }, lists:seq(1, NumberOfFrames)),
Score.
score_frame([ 10, FirstNextFrame, SecondNextFrame | Rolls ]) ->
{ 10 + FirstNextFrame + SecondNextFrame, [ FirstNextFrame, SecondNextFrame | Rolls ] };
score(Rolls) -> score(Rolls, 10).
score(_Rolls, 0) -> 0;
score(Rolls, NumberOfFrame) ->
case Rolls of
[ 10, FirstOfNextFrame, SecondOfNextFrame | NextRolls ] ->
10 + FirstOfNextFrame + SecondOfNextFrame +
score([ FirstOfNextFrame, SecondOfNextFrame | NextRolls ], NumberOfFrame - 1);
[ FirstOfCurrentFrame, SecondOfCurrentFrame, FirstOfNextFrame | NextRolls ]