Skip to content

Instantly share code, notes, and snippets.

View fenollp's full-sized avatar

Pierre Fenoll fenollp

View GitHub Profile
-module(thear).
-export([simplify/1]).
-spec simplify (E) -> E when E::term().
simplify (E) ->
S = fun
({add,E1,{num,0}}) ->
S(E1);
# For rπ only: -march=armv6zk -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard
git clone git@github.com: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(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) ->
@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
@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 / 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 / install_homebrew.rb
Created August 14, 2011 00:03 — forked from mxcl/install_homebrew.markdown
Installs Homebrew to /usr/local so you don't need sudo to `brew install`
#!/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/sceaga/homebrew/tarball/tiger anywhere you like.
module Tty extend self
def blue; bold 34; end
def white; bold 39; end
def red; underline 31; end
def reset; escape 0; end
def bold n; escape "1;#{n}" end
@fenollp
fenollp / _.xml
Created November 25, 2015 16:09
wh_util:get_xml_value/2
<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<soap:Body>
<SearchTelephoneNumbersResponse xmlns='http://www.bandwidth.com'>
<SearchTelephoneNumbersResult>
<a>
text out
<mytext ishere="text in"/>
</a>
<TelephoneNumber id="1">
@fenollp
fenollp / string_splitting.c
Last active December 15, 2015 01:59
A use case of strtok_r (instead of strtok) to split a string str wrt ifs characters.
char **ifs_split(const char *str, const char *ifs)
{
size_t index = 0;
size_t size = 1;
char *segment = NULL;
char *start = NULL;
char *rest = NULL;
char **tab = NULL; // Thou shall free thee.
start = dupstr(str);
-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}.