Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am guedes on github.
  • I am guedes (https://keybase.io/guedes) on keybase.
  • I have a public key whose fingerprint is D2B9 F3C5 CB65 0447 9990 7B1E C4C4 9A9A 9FA5 0500

To claim this, I am signing this object:

@guedes
guedes / gist:6717736
Created September 26, 2013 17:38 — forked from alco/gist:6715876
# 3 runs
iex(19)> :timer.tc fn -> <<x :: size(128) >> = :crypto.md5("lol"); hd(:io_lib.format("~32.16.0b", [x])) |> iolist_to_binary end
{127, "9cdfb439c7876e703e307864c9167a15"}
iex(20)> :timer.tc fn -> <<x :: size(128) >> = :crypto.md5("lol"); hd(:io_lib.format("~32.16.0b", [x])) |> iolist_to_binary end
{128, "9cdfb439c7876e703e307864c9167a15"}
iex(21)> :timer.tc fn -> <<x :: size(128) >> = :crypto.md5("lol"); hd(:io_lib.format("~32.16.0b", [x])) |> iolist_to_binary end
{98, "9cdfb439c7876e703e307864c9167a15"}
# 3 runs
iex(22)> :timer.tc fn -> bc << char >> inbits :crypto.md5("lol"), do: << integer_to_binary(char, 16) :: binary >> end
@guedes
guedes / .ctags
Last active December 17, 2015 18:28
My little `$HOME/.ctags` file to extend `ctags` to support Elixir language
# My little `$HOME/.ctags` file to extend `ctags` to support Elixir language
--langdef=elixir
--langmap=elixir:.ex.exs
--regex-elixir=/^[ \t]*defmodule[ \t]* ((\w(\.)?)+)/\1/m,module/
--regex-elixir=/^[ \t]*defrecord[ \t]* (\w+)/\1/r,record/
--regex-elixir=/^[ \t]*defmacro[ \t]* (\w+[!\?]?)/\1/d,macro/
--regex-elixir=/^[ \t]*def[p]?[ \t]* (\w+[!\?]?)/\1/f,function/
# You can remove some of the following lines
--exclude=*.as
--exclude=*.bat
guedes@betelgeuse:/disco/guedes/guedes/programas/Erlang/dynamo_demo
(master)$ elixir --no-halt -S mix run "DynamoDemo.start"
Running DynamoDemo.App on port 3000 with Cowboy
=ERROR REPORT==== 26-Aug-2012::12:03:13 ===
** Handler 'Elixir-Dynamo-Cowboy-Handler' terminating in init/3
for the reason error:undef
** Options were 'Elixir-DynamoDemo-App'
** Request was [{socket,#Port<0.3099>},
{transport,cowboy_tcp_transport},
1) test_array_object_minimal (JSON.Parser.ParseTest)
** (ExUnit.AssertionError) Expected [[{"a","b"},{"c","d"}],[{"a1","b1"},{"c1","d1"}],[{"a2","b2"},{"c2","d2"}]] to be equal to (==) [[{"a","b"},{"c","d"}],[[{"a1","b1"},{"c1","d1"}],[{"a2","b2"},{"c2","d2"}]]]
stacktrace:
/disco/guedes/guedes/programas/Erlang/exjson.bkp/test/json_parser_test.exs:78: JSON.Parser.ParseTest.test_array_object_minimal/0
/disco/guedes/guedes/programas/Erlang/elixir/lib/ex_unit/lib/ex_unit/runner.ex:84: ExUnit.Runner.run_test/3
lists.erl:1262: :lists.foreach/2
/disco/guedes/guedes/programas/Erlang/elixir/lib/elixir/lib/enum.ex:237: Enum.each/2
/disco/guedes/guedes/programas/Erlang/elixir/lib/ex_unit/lib/ex_unit/runner.ex:72: ExUnit.Runner.run_tests/2
@guedes
guedes / gist:2701936
Created May 15, 2012 13:51
Elixir test ERROR
Running tests ...
time elixir -pa ebin -r "test/**/*_test.exs"
......F....
1) test_date_to_timestamp_with_chars (DateTest)
** (ExUnit.AssertionError) Expected "2000-01-01 23:59:59" to be equal to (==) "200045014501322358595859"
stacktrace:
/disco/programas/exdate/test/date_test.exs:107: DateTest.test_date_to_timestamp_with_chars/0
/disco/programas/elixir/lib/ex_unit/runner.ex:78: ExUnit.Runner.run_test/3
/disco/programas/elixir/lib/enum.ex:619: Enum.do_each/3
@guedes
guedes / ERROR
Created May 11, 2012 17:18
Error testing some scenarios...
guedes@dba01:/disco/programas/exdate$ make clean test
rm -rf ebin
Compiling Elixir code ...
elixirc lib/*/*/*.ex lib/*/*.ex lib/*.ex -o ebin --docs
Compiled lib/date.ex
Running tests ...
time elixir -pa ebin -r "test/**/*_test.exs"
F.F...
import Elixir.Builtin, except: ["+": 2]
defmodule DateUtils do
def :+.(left, right) when is_tuple(left) do
seconds = Erlang.calendar.datetime_to_gregorian_seconds(left)
result = seconds + right
Erlang.calendar.gregorian_seconds_to_datetime(result)
end
# is this correct ?
guedes@betelgeuse:/media/fdc918b8-8a3f-4a63-bfc1-e4155da45514/guedes/guedes/programas/Erlang/exjson$ ../exdoc/bin/exdoc -pa exbin
** (UndefinedFunctionError) undefined function: JSON.__info__/1
JSON.__info__(:moduledoc)
/media/fdc918b8-8a3f-4a63-bfc1-e4155da45514/guedes/guedes/programas/Erlang/exdoc/lib/exdoc/retriever.ex:12: ExDoc.Retriever.get_docs_from_file/2
/media/fdc918b8-8a3f-4a63-bfc1-e4155da45514/guedes/guedes/programas/Erlang/elixir/lib/enum.ex:374: Enum."-map/2-lc$^0/1-0-"/2
/media/fdc918b8-8a3f-4a63-bfc1-e4155da45514/guedes/guedes/programas/Erlang/exdoc/lib/exdoc.ex:5: ExDoc.generate_docs/3
src/elixir_compiler.erl:76: :elixir_compiler."-code_loading_compilation/5-fun-0-"/4
src/elixir_compiler.erl:75: :elixir_compiler.code_loading_compilation/5
src/elixir_compiler.erl:29: :elixir_compiler.string/2
/media/fdc918b8-8a3f-4a63-bfc1-e4155da45514/guedes/guedes/programas/Erlang/elixir/lib/code.ex:94: Code.require_file/2
[... cut ...]
==> elixir (exunit)
..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................F...
1) test_pwd (SystemTest)
** (ExUnit.AssertionError) Expected '/media/fdc918b8-8a3f-4a63-bfc1-e4155da45514/guedes/guedes/programas/Erlang/elixir' to be equal to '/home/guedes/guedes/programas/Erlang/elixir'
stacktrace:
/media/fdc918b8-8a3f-4a63-bfc1-e4155da45514/guedes/guedes/programas/Erlang/elixir/test/elixir/system_test.exs:36: SystemTest.test_pwd/0
/media/fdc918b8-8a3f-4a63-bfc1-e4155da45514/guedes/guedes/programas/Erlang/elixir/lib/ex_unit/runner.ex:78: ExUnit.Runner.run_test/3
/media/fdc918b8