Skip to content

Instantly share code, notes, and snippets.

View lpil's full-sized avatar

Louis Pilfold lpil

View GitHub Profile
@lpil
lpil / one.rb
Last active April 22, 2017 11:14
Examples of Ruby Result monad in use
# Given methods that return Results...
get_params
.and_then(method(:validate_params))
.and_then(method(:save_record))
.and_then(method(:send_email))
.match(ok: method(:render_success),
error: method(:render_failure))
@lpil
lpil / bind.ex
Last active October 22, 2017 17:43
Ways of handling nil
id
|> get()
|> Maybe.and_then(& &1.size)
defmodule Web do
require Logger
@behaviour :elli_handler
def handle(r, _args) do
Router.handle(:elli_request.method(r), :elli_request.path(r), r)
rescue
exception ->
Logger.error(inspect(exception))
@lpil
lpil / elm.js
Last active September 2, 2018 19:34
var elm$core$Basics$never = function (_n0) {
never:
while (true) {
// Stuff here
}
};

Keybase proof

I hereby claim:

  • I am lpil on github.
  • I am lpil (https://keybase.io/lpil) on keybase.
  • I have a public key ASBlAwu7BPPtgNEVS1e2I12YMcjQpOSKHM1_Wz6Sd39YJQo

To claim this, I am signing this object:

## DecodeBench
benchmark name iterations average time
decode (small) (jiffy) 500000 117.63 µs/op
decode (small) (jsone) 200000 199.21 µs/op
decode (small) (tiny) 200000 216.86 µs/op
decode (small) (poison) 100000 225.53 µs/op
decode (small) (jason) 100000 228.00 µs/op
decode (small) (jsx) 100000 297.11 µs/op
decode (large) (jiffy) 50 612494.88 µs/op
@lpil
lpil / thing.erl
Last active May 28, 2020 18:42
Custom type helper for Erlang/Elixir.
-module(thing).
-export([makePerson/1]).
makePerson(#{name => Name, gender => Gender, age = Age}) ->
{person, Name, Gender, Age}.
personToMap({person, Name, Gender, Age}) ->
#{name => Name, gender => Gender, age => Age}.
{status,<0.51.0>,
{module,gen_server},
[[{'$initial_call',{inet_db,init,1}},
{'$ancestors',[kernel_sup,<0.46.0>]}],
running,<0.48.0>,[],
[{header,"Status for generic server inet_db"},
{data,[{"Status",running},
{"Parent",<0.48.0>},
{"Logged events",[]}]},
{data,[{"State",
@lpil
lpil / output.log
Created June 2, 2020 20:15
Gleam compiling Erlang without rebar3 for the first time
louis ~/src/gleam/gleam (build-tool *+) $ cargo run build test/build_with_gleam/
Compiling gleam v0.10.0-dev (/home/louis/src/gleam/gleam)
Finished dev [unoptimized + debuginfo] target(s) in 6.19s
Running `target/debug/gleam build test/build_with_gleam/`
[src/build.rs:88] &status = ExitStatus(
ExitStatus(
0,
),
)
louis ~/src/gleam/gleam (build-tool *+) $ tree test/build_with_gleam/
pub fn init(spec: Spec(Nil)) {
spec
|> add(
worker(start_child1)
|> with_state(fn(_state, pid) { pid }),
)
|> add(worker(start_child2))
|> add(worker(start_child3))
}