Skip to content

Instantly share code, notes, and snippets.

View flupe's full-sized avatar
👋
moving to sourcehut

Lucas Escot flupe

👋
moving to sourcehut
View GitHub Profile
@Trebor-Huang
Trebor-Huang / lc.typ
Last active December 31, 2024 05:11
Evaluator for lambda calculus in Typst
// *** Jump to the bottom for example usage ***
#set page(paper: "a5")
#let Lam(var, body) = ("Lam", var, body)
#let App(fun, arg) = ("App", fun, arg)
// An elaborate pretty printer because I'm bored
#let print-var(str) = if str.starts-with("@") {
$x_#str.slice(1)$ // generated variable name
{-# language
BlockArguments
, ConstraintKinds
, ImplicitParams
, LambdaCase
, OverloadedStrings
, PatternSynonyms
, Strict
, UnicodeSyntax
#-}
--{-# OPTIONS -v any-auto:10 #-}
open import Data.List
open import Data.List.Membership.Propositional using (_∈_)
open import Data.List.Relation.Unary.Any using (Any; here; there)
open import Data.List.Relation.Unary.Any.Properties using
(singleton⁺; map⁺; mapMaybe⁺; ++⁺ˡ; ++⁺ʳ; concat⁺)
open import Data.Maybe using (Maybe; nothing; just)
open import Data.Maybe.Relation.Unary.Any using (just) renaming (Any to MAny)
open import Data.Nat using (ℕ; zero; suc; _+_)
@quangdinh
quangdinh / gammastep.sh
Last active November 6, 2025 23:56
Sway / Waybar / Wofi / Swaylock config & styles
#!/usr/bin/env bash
pid=$(pgrep gammastep)
if [[ $1 = "toggle" ]]; then
if pgrep -x "gammastep" > /dev/null; then
kill -9 $(pgrep -x "gammastep");
else
gammastep -O ${GAMMASTEP_NIGHT:-3500} &
fi
@nicowilliams
nicowilliams / fork-is-evil-vfork-is-good-afork-would-be-better.md
Last active December 2, 2025 05:20
fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid

I recently happened upon a very interesting implementation of popen() (different API, same idea) called popen-noshell using clone(2), and so I opened an issue requesting use of vfork(2) or posix_spawn() for portability. It turns out that on Linux there's an important advantage to using clone(2). I think I should capture the things I wrote there in a better place. A gist, a blog, whatever.

This is not a paper. I assume reader familiarity with fork() in particular and Unix in general, though, of course, I link to relevant wiki pages, so if the unfamiliar reader is willing to go down the rabbit hole, they should be able to come ou

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@kometbomb
kometbomb / tweetjam.md
Last active May 29, 2025 16:41
PICO-8 tweetjam stuff

PICO-8 size optimization stuff for tweetcarts

Here are some simple ways to make your PICO-8 code fit in 140 280 characters (as in the #tweetjam #tweetcart craze). I did not invent these, I merely observed and collected them from the tweetjam thread.

LUA syntax stuff

  • Use single character variable names
  • Use x=.1 and x=.023, not x=0.1 or x=0.023
  • x=1/3 is shorter than x=.3333
  • You don't need to separate everything with spaces or write them on their own lines, e.g. circ(x,y,1)pset(z,q,7) works just as well
@davidmatas
davidmatas / mou.html
Last active March 1, 2023 16:42
highlight syntax for Mou.app
<!-- Highlight syntax for Mou.app, insert at the bottom of the markdown document -->
<script src="http://yandex.st/highlightjs/7.3/highlight.min.js"></script>
<link rel="stylesheet" href="http://yandex.st/highlightjs/7.3/styles/github.min.css">
<script>
hljs.initHighlightingOnLoad();
</script>
@23Skidoo
23Skidoo / remove_duplicates.ml
Created January 23, 2012 16:15
Ocaml exercise: remove duplicates from a list
let remove_elt e l =
let rec go l acc = match l with
| [] -> List.rev acc
| x::xs when e = x -> go xs acc
| x::xs -> go xs (x::acc)
in go l []
let remove_duplicates l =
let rec go l acc = match l with
| [] -> List.rev acc