Skip to content

Instantly share code, notes, and snippets.

{-# language OverloadedLists #-}
{-# OPTIONS_GHC -Wall #-}
module Overlays where
import Prelude hiding ((.))
import GHC.Stack
import Debug.Trace
@hwayne
hwayne / allen.md
Created June 30, 2021 20:10
Frances Allen

A while back I complained on Twitter about how Ada Lovelace is used as an example of "an important woman in CS", because she's a pretty terrible example (thread in comments), and listed some better choices. In response, somebody said that public people get why Lovelace is interesting, whereas it's hard to explain why, like, Barbara Liskov matters so much. That got me interested in explaining the contributions to CS in ways that are understandable to people with no tech background. Here's my attempt to explain Frances E Allen, who did foundational work in optimizing compilers:


Without Frances Allen, our videogames would be stuck in the SNES era.

So at a fundamental level, a computer is just a bag of buckets of data (memory addresses), and a program is just instructions ot move data between the buckets. Like mov edx, [ebp + 8] means "take the data in the 8th bucket after the ebp bucket and move it to the edx bucket." All programs eventually become this "assembly" language that the computer execut

@hwayne
hwayne / pubsub.als
Created June 25, 2021 00:36
Pub-Sub for Alloy
open util/ordering[Time]
let unchanged[x, t, t'] {x.t = x.t'}
sig Time {}
sig Msg {}
sig Pub {
-- really a topic, but then we're double-using T as a letter
, msgs: Msg -> Time
@matthewjberger
matthewjberger / Cargo.toml
Last active April 17, 2022 15:33
An example of creating and serializing an ecs world with legion ecs in rust
[dependencies]
legion = "0.4.0"
serde = "1.0.125"
serde_json = "1.0.64"
@sdiehl
sdiehl / church.py
Created February 15, 2021 14:07
Pathological Python Programs
TRUE = lambda x: lambda y: x
FALSE = lambda x: lambda y: y
Product = lambda x: lambda y: lambda z: (z)(x)(y)
And = lambda x: lambda y: (x)(y)(x)
Not = lambda x: lambda y: lambda z: (x)(z)(y)
Boolean = (Product)(True)(False)
Succ = lambda x: lambda y: lambda z: (y)((x)(y)(z))
Pred = lambda x: lambda y: lambda z: x(lambda i: lambda j: j(i(y))) (lambda k: z) (lambda k: k)
Y = lambda g: (lambda z:z(z)) (lambda f: g(lambda arg: f(f)(arg)))
Nth = Y(lambda f: lambda n: Succ(f(n-1)) if n else Zero)
@sjoerdvisscher
sjoerdvisscher / LinearStateMonad.hs
Last active August 12, 2025 12:56
Alternative ways to write the linear quicksort from https://www.tweag.io/blog/2021-02-10-linear-base/
{-# LANGUAGE LinearTypes #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE QualifiedDo #-}
import Prelude.Linear hiding (partition)
import qualified Control.Functor.Linear as Linear
import Control.Functor.Linear (State, state, execState, pure)
import qualified Data.Array.Mutable.Linear as Array
@domenkozar
domenkozar / cachix.org.spec.purs
Created January 28, 2021 11:13
Automated testing for 404/500 errors
module Spec where
import Quickstrom
import Data.Foldable (any)
import Data.Maybe (maybe)
import Data.Tuple (Tuple(..))
import Data.String.CodeUnits (contains)
import Data.String.Pattern (Pattern(..))
readyWhen = "body"
@borkdude
borkdude / api_diff.clj
Last active September 30, 2021 19:37
Print API breakage warnings
#!/usr/bin/env bash
#_" -*- mode: clojure; -*-"
#_(
"exec" "clojure" "-Sdeps" "{:deps {clj-kondo/clj-kondo {:mvn/version \"2020.12.12\"} org.clojure/tools.deps.alpha {:mvn/version \"0.9.857\"} org.slf4j/slf4j-nop {:mvn/version \"1.7.30\"} lambdaisland/deep-diff2 {:mvn/version \"2.0.108\"} juji/editscript {:mvn/version \"0.5.4\"}}}" "-M" "$0" "$@"
)
;; Example usage:
;; api_diff.clj org.clojure/clojure "1.8.0" "1.10.1" > /tmp/diff.txt
(require '[clj-kondo.core :as clj-kondo])
@Gabriella439
Gabriella439 / concurrent-map.hs
Created December 3, 2020 23:27
Low-tech concurrent hashmap
module ConcurrentMap where
import Control.Concurrent.STM.TVar (TVar)
import Control.Concurrent.STM (STM)
import Data.Hashable (Hashable)
import Data.HashMap.Strict (HashMap)
import Data.Vector (Vector)
import qualified Control.Concurrent.STM.TVar as TVar
import qualified Data.Hashable as Hashable
@Gabriella439
Gabriella439 / livestream-nixos-vm.nix
Last active December 4, 2020 18:30
Code used for Kafka livestream example
let
nixpkgs = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/f3fc2f3326a23797b2c95297e68ed8e8de2a95e6.tar.gz";
sha256 = "0wsplccl8bv522zh3y8affacw9pmzsxm18i5hdgz78gxh8m7k933";
};
nixos = import "${nixpkgs}/nixos" {
system = "x86_64-linux";
configuration = { pkgs, ... }: