Skip to content

Instantly share code, notes, and snippets.

View lpil's full-sized avatar
🦦
Ahoy! Have a fab time!

Louis Pilfold lpil

🦦
Ahoy! Have a fab time!
View GitHub Profile
@lpil
lpil / lustre-dev-tools.log
Created October 9, 2024 22:14
Gleam v1.5 vs v1.6 compile perf
louis ~/src/gleam/lustre-dev-tools (main *) $ gleam clean
louis ~/src/gleam/lustre-dev-tools (main *) $ asdf local gleam 1.5.1
louis ~/src/gleam/lustre-dev-tools (main *?) $ time gleam build --no-print-progress
________________________________________________________
Executed in 14.25 secs fish external
usr time 13.52 secs 0.07 millis 13.52 secs
sys time 7.78 secs 1.14 millis 7.78 secs
louis ~/src/gleam/lustre-dev-tools (main *?) $ time gleam build --no-print-progress^C
@lpil
lpil / uploader.js
Last active March 2, 2023 23:45
A file uploader + tagger written in under 20 lines and under 30 minutes.
import { serve } from "https://deno.land/std@0.114.0/http/server.ts";
import { multiParser } from "https://deno.land/x/multiparser@0.114.0/mod.ts";
import * as uuid from "https://deno.land/std@0.175.0/uuid/mod.ts";
import NodeID3 from "npm:node-id3";
serve(async (req) => {
if (req.method == "POST") {
const { files, fields } = await multiParser(req);
const path = "uploads/" + uuid.v1.generate() + ".mp3";
await Deno.writeFile(path, files.track.content);
@lpil
lpil / TrailingLambda.elm
Last active November 25, 2022 14:33
An example of the trailing lambda pattern in Elm
import Html exposing (text)
main =
let result =
bind readNumber <| \x ->
bind readNumber <| \y ->
bind readNumber <| \z ->
Ok (x + y + z)
in
text (Debug.toString result)
import gleam/bitwise
import gleam/int
import gleam/list
import gleam/string
import chip8/helpers
import chip8/instruction
import chip8/keyboard
import chip8/memory
import chip8/registers
import chip8/screen
pub fn make_birthday(x: aged, get_age: fn(aged) -> Int) {
get_age(x) + 1
}
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))
}
@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/
{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 / 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}.
## 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