Skip to content

Instantly share code, notes, and snippets.

View dhil's full-sized avatar

Daniel Hillerström dhil

View GitHub Profile
@dhil
dhil / diff
Created September 25, 2024 12:53
dhil/wasm-stack-switching branch `wasm-3.0` diff `WebAssembly/spec` branch `wasm-3.0`
$ git remote -vv
origin [email protected]:dhil/wasm-stack-switching.git (fetch)
origin [email protected]:dhil/wasm-stack-switching.git (push)
spec [email protected]:WebAssembly/spec.git (fetch)
spec [email protected]:WebAssembly/spec.git (push)
upstream [email protected]:WebAssembly/stack-switching.git (fetch)
upstream [email protected]:WebAssembly/stack-switching.git (push)
$ git diff spec/wasm-3.0
diff --git a/README.md b/README.md
index cbc17b46..fde9c1c7 100644
@dhil
dhil / seesaw.wast
Last active September 18, 2024 14:30
Seesaw in WasmFX / WebAssembly + stack-switching
(module $co2
(type $task (func (result i32))) ;; type alias task = [] -> []
(type $ct (cont $task)) ;; type alias ct = $task
(tag $pause (export "pause")) ;; pause : [] -> []
(tag $cancel (export "cancel")) ;; cancel : [] -> []
;; run : [(ref $task) (ref $task)] -> []
;; implements a 'seesaw' (c.f. Ganz et al. (ICFP@99))
(func $run (export "seesaw") (param $up (ref $ct)) (param $down (ref $ct)) (result i32)
(local $result i32)
;; run $up
@dhil
dhil / wasmfxtime
Created January 4, 2024 15:39
A thin wrapper around wasmtime's CLI to easily run WasmFX programs
#!/usr/bin/env bash
#
# A thin wrapper around wasmtime's CLI to easily run WasmFX programs.
#
DEBUG_BIN=~/projects/wasmfx/wasmtime/target/debug/wasmtime
RELEASE_BIN=~/projects/wasmfx/wasmtime/target/release/wasmtime
WASMTIME=$DEBUG_BIN
WFLAGS="exceptions,function-references,typed-continuations"
@dhil
dhil / y.rs
Created March 7, 2023 13:34
Typing the Y combinator in Rust
// Typing the Y combinator in Rust.
// $ rustc y.rs -o y
// $ .y
// 720
// Succ(Succ(Succ(Succ(Succ(Succ(Zero))))))
use std::fmt;
trait Apply<A, B> {
fn apply(&self, f: &dyn Apply<A, B>, x: A) -> B;
/* jshint globalstrict: true */
/* jshint esversion:6 */
'use strict';
/* First-order continuation module */
const _$K = (function() {
return Object.freeze({
'kind': 'Default_Continuation',
'apply': function(k, arg) {
return k(arg);
@dhil
dhil / saturate
Created April 11, 2022 23:51
Colour saturation script
#!/bin/bash
TOGGLE=/tmp/.saturate-toggle
if [ ! -e $TOGGLE ]; then
touch $TOGGLE
nvidia-settings -a DigitalVibrance=1000
else
rm $TOGGLE
nvidia-settings -a DigitalVibrance=0
@dhil
dhil / runlinks
Last active June 29, 2021 11:35
Links web application runner
@dhil
dhil / watermark
Created October 9, 2020 14:19
A script to watermark pictures
#!/usr/bin/env bash
# Acknowledgement: this idea is adapted from Raphaël Rigo (https://twitter.com/_trou_/status/1313951783182651393?s=20).
if [[ -z "${1+x}" || -z "${2+x}" || -z "${3+x}" ]]; then
echo "usage: $(basename $0) <source-file> <text> <output-file>"
exit 0
fi
convert -density 150 -fill "rgba(255,0,0,0.25)" -gravity Center -pointsize 80 -draw "rotate -45 text 0,0 \"$2\"" "$1" "$3"
@dhil
dhil / links_types_refactor.ml
Last active April 16, 2020 15:10
Links types refactor -- draft
@dhil
dhil / y.cs
Created September 13, 2019 03:00
Typing the Y combinator in C#.
// Typing the Y combinator in C#.
// $ mcs y.cs
// $ mono y.exe
// 720
// Succ(Succ(Succ(Succ(Succ(Succ(Zero))))))
using System;
class YCombinator {