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 / ERLANG.md
Created October 3, 2014 14:03
Github users and repo to keep an eye on for Erlang
@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 / collector.ex
Last active August 29, 2015 14:21
Remove things in production
defmodule Paco.Collector do
@env String.to_atom(System.get_env("MIX_ENV") || "dev")
defmacro notify_loaded(text, state), do: call(@env, :do_notify_loaded, [text, state])
defmacro notify_started(parser, state), do: call(@env, :do_notify_started, [parser, state])
defmacro notify_ended(result, state), do: call(@env, :do_notify_ended, [result, state])
defp call(:prod, _, _), do: :ok
defp call(_, name, args) do
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 ]
@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;
@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()
Verifying that +gabrielelana is my blockchain ID. https://onename.com/gabrielelana

Keybase proof

I hereby claim:

  • I am gabrielelana on github.
  • I am gabrielelana (https://keybase.io/gabrielelana) on keybase.
  • I have a public key whose fingerprint is 181C 039B 8033 4010 66D3 C5E8 F3A4 6AB3 14CA E60E

To claim this, I am signing this object:

@gabrielelana
gabrielelana / virtual-keyboad.py
Created October 22, 2017 16:59
Virtual Keyboard POC
from evdev import UInput, InputDevice,categorize, ecodes
myKey = UInput.from_device('/dev/input/event7', name='MyKeyboard')
dev = InputDevice('/dev/input/event7')
print(dev)
for event in dev.read_loop():
if event.type == ecodes.EV_KEY:
print(event)