Skip to content

Instantly share code, notes, and snippets.

View lpil's full-sized avatar

Louis Pilfold lpil

View GitHub Profile
pub fn make_birthday(x: aged, get_age: fn(aged) -> Int) {
get_age(x) + 1
}
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
@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)
@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/[email protected]/http/server.ts";
import { multiParser } from "https://deno.land/x/[email protected]/mod.ts";
import * as uuid from "https://deno.land/[email protected]/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 / 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