Skip to content

Instantly share code, notes, and snippets.

View fenollp's full-sized avatar

Pierre Fenoll fenollp

View GitHub Profile
@fenollp
fenollp / Dialyzer false positive?
Created September 2, 2015 18:33
I don't get this warning
scanning "applications/omnipresence/ebin/omnip_sup.beam"
warn_behaviour omnip_sup.erl:58: The return type {'ok',{_,[{_,{atom() | tuple(),atom(),'undefined' | [any()]},'permanent' | 'temporary' | 'transient','brutal_kill' | 'infinity' | non_neg_integer(),'supervisor' | 'worker','dynamic' | [atom() | tuple()]}]}} in the specification of init/1 is not a subtype of 'ignore' | {'ok',{{'one_for_all',non_neg_integer(),non_neg_integer()} | {'one_for_one',non_neg_integer(),non_neg_integer()} | {'rest_for_one',non_neg_integer(),non_neg_integer()} | {'simple_one_for_one',non_neg_integer(),non_neg_integer()},[{_,{atom() | tuple(),atom(),'undefined' | [any()]},'permanent' | 'temporary' | 'transient','brutal_kill' | 'infinity' | non_neg_integer(),'supervisor' | 'worker','dynamic' | [atom() | tuple()]}]}}, which is the expected return type for the callback of supervisor behaviour
1 Dialyzer warnings
Somewhat easier to read:
{ok,{'_',[{'_',{atom,'|',tuple,atom,undefined,'|',[any]},
permanent
@fenollp
fenollp / grp.py
Last active August 29, 2015 14:27
list un-terminated logs by callid
#!/usr/bin/env python2
import re
import sys
fn = sys.argv[1]
lines = [line.rstrip('\n') for line in open(fn)]
def get_callid(line):
@fenollp
fenollp / wat_clauses
Created April 1, 2015 17:48
Erlang not good with strings
%% -*- coding: utf-8 -*-
-module(wat_clauses).
%% wat_clauses:
%% a warning should be emitted as 2nd clause will never match (given 1st clause)
-export([authenticate_nouns/1]).
%% API
-module(propfolding).
-export([get/1]).
get (Doc) ->
{Stars, AreaID, CheckinDate, HotelID, Rooms} =
lists:foldl(
fun
({<<"stars">>, Stars}, Acc) -> setelement(1, Acc, Stars);
({<<"areaID">>, AreaID}, Acc) -> setelement(2, Acc, AreaID);
({<<"checkinDate">>, <<Year:4, $-, Month:2, $-, Day:2>>}, Acc) ->
# For rπ only: -march=armv6zk -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard
git clone [email protected]:ckolivas/cgminer.git cgminer.git
cd cgminer.git/
git checkout v4.2.3 # The latest
./autogen.sh
CFLAGS="-O2 -Wall -march=armv6zk -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard" ./configure --enable-bflsc
CXXFLAGS="-O2 -Wall -march=armv6zk -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard" make
sudo ./cgminer -o stratum+tcp://eu-stratum.btcguild.com:3333 -u radioxid_monolith -p 123b
-module(thear).
-export([simplify/1]).
-spec simplify (E) -> E when E::term().
simplify (E) ->
S = fun
({add,E1,{num,0}}) ->
S(E1);
%% Copyright © 2013 Pierre Fenoll ‹[email protected]
%% See LICENSE for licensing information.
%% -*- coding: utf-8 -*-
-module(ifdef_in_fun).
%% 12:40 < stobix>| Grr... It would seem that I can't use ifdef directives inside function bodies. Any reason why, or is it just a design flaw?
%% 1> c(ifdef_in_fun).
%% ifdef_in_fun.erl:16: syntax error before: '-'
%% ifdef_in_fun.erl:18: syntax error before: '-'
@fenollp
fenollp / keyfold.erl
Created November 12, 2013 16:10
%% keyfold: extension to stdlib's lists module. %% Intersection of lists:fold{l,r}/3 and lists:keymap/3.
%% Copyright © 2013 Pierre Fenoll ‹[email protected]
%% See LICENSE for licensing information.
%% -*- coding: utf-8 -*-
-module(keyfold).
%% keyfold: extension to stdlib's lists module.
%% Intersection of lists:fold{l,r}/3 and lists:keymap/3.
-include_lib("eunit/include/eunit.hrl").
@fenollp
fenollp / otp_vsn.erl
Created October 24, 2013 13:55
Get an easily comparable version number of Erlang/OTP at runtime.
otp_vsn () ->
R = fun (D, U) -> 10 * (D - $0) + U - $0 end,
case erlang:system_info(otp_release) of
[$R, D,U ] -> R(D,U) + 0.00;
[$R, D,U, $A ] -> R(D,U) + 0.01;
[$R, D,U, $B ] -> R(D,U) + 0.02;
[$R, D,U, $B, DD,UU] -> R(D,U) + R(DD,UU) / 10 + 0.00
end.
%% On R16B02: otp_vsn() = 16.2
-module(my_tests).
-include_lib("eunit/include/eunit.hrl").
e_test () ->
{setup, fun () -> ok end,
fun () -> ok end,
fun () -> {inorder, [
?_assertMatch(fail, hard) %% Does not fail!
]} end}.