Skip to content

Instantly share code, notes, and snippets.

@marnix
marnix / Zig async semantics.md
Last active Jan 30, 2021
Zig async semantics
View Zig async semantics.md

Zig async semantics

by Marnix Klooster (https://github.com/marnix); license: public domain (attribution appreciated); status: probably-incorrect draft

(TODO: Update with Protty's feedback on gist revision 33 or 38 on Discord, https://discord.com/channels/605571803288698900/605572581046747136/794993176779292693 and subsequent discussion.)

(TODO: After I have a version that I'm at least a bit happy with, consider g-w1's suggestion of a pull request to https://github.com/ziglang/zig-spec/blob/disorganized-spec-chunks/spec/disorganized_facts_about_zig.md .)

How does async (and the related suspend/resume and await) work? Here is my attempt to describe this in a language specification kind of way.

View MainForBCFIPSMixedApprovedOnlyIssue.java
/** This reproduction scenario by Marnix Klooster is public domain. */
package marnix.experiment.bcfips;
import java.net.URL;
import java.security.KeyStore;
import java.security.Security;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
@marnix
marnix / arcperfdiff.nim
Created Jun 13, 2020
Reproduction scenario for nim --gc:arc performance difference
View arcperfdiff.nim
import memfiles
import streams
proc mmapStream(mmFileName: string): Stream =
return newMemMapFileStream(mmFileName)
iterator tokens(mmfile: Stream): string =
var i,j = 0
while not mmfile.atEnd():
let c = mmfile.readChar()
@marnix
marnix / df-at-exp.mm
Created Sep 27, 2019
Attempt at a mechanism for expanding definitions in Metamath
View df-at-exp.mm
$[ set.mm $]
$( TO EXPAND THE FOLLOWING TWO AXIOMS ~ cat and ~ df-at WHICH TOGETHER MAKE UP ` HAtoms ` ...
@( Extend class notation with set of atoms on a Hilbert lattice. @)
cat @a class HAtoms @.
@{
@d x y @.
View a.rkt
#lang racket
(require racket/include
syntax/parse/define
(for-syntax racket/syntax
racket/port
syntax/modread))
(define-simple-macro (require/sweet-exp-racket path)
#:with modname (generate-temporary #'path)
View mm-calc.user.js
// ==UserScript==
// @name mm-calc
// @description Make `metamath /html' proofs look more like calculations. (License: public domain; initial author: Marnix Klooster <marnix.klooster@gmail.com>.)
// @version 3
// @grant none
// @include /^https?://.*\.metamath\.org(:\d+)?/[^/]*/[^/]*.html(#.*)?$/
// @require https://code.jquery.com/jquery-3.3.1.slim.min.js
// ==/UserScript==
// Mark all proof-like tables with class 'proof'
View try-pip-main-install-nested-package.py
#!/usr/bin/env python2
## !!! WARNING: THIS CODE COULD VERY WELL REMOVE YOUR SYSTEM-WIDE
## plaitpy AND bda.basen PACKAGES !!!
# verify that we start with a clean slate: no plaitpy, no bda.basen
import os
assert not os.path.isfile('/usr/local/lib/python2.7/dist-packages/plaitpy/__init__.py')
try:
import plaitpy # this fails, as expected
View HQio-11.hs
-- first let's get the type signatures out of the way
band :: Integer -> Integer -> Integer
bor :: Integer -> Integer -> Integer
bnot :: Integer -> Integer
-- now a special case, to terminate the recursion for 'band';
-- this follows directly from the general definition below
a `band` b | a == a `div` 2 && b == b `div` 2 = - ((a `mod` 2) * (b `mod` 2))
@marnix
marnix / calc-env.md
Last active Aug 6, 2017
MathJax \calc
View calc-env.md

$% \require{begingroup} \begingroup \newcommand{\calc}{\begin{align} \quad &} \newcommand{\op}[1]{\ #1 \quad & \quad \unicode{x201c}} \newcommand{\hints}[1]{\mbox{#1} \ \quad & \quad \phantom{\unicode{x201c}} } \newcommand{\hint}[1]{\mbox{#1} \unicode{x201d} \ \quad & } \newcommand{\endcalc}{\end{align}} \newcommand{\subcalch}[1]{\ \quad & \quad #1 \ \quad &} \newcommand{\subcalc}{\quad \begin{aligned} \quad & \ \bullet \quad & }

@marnix
marnix / Ghilbert expexp: structured calculational proof
Created May 1, 2014
Ghilbert expexp: structured calculational proof
View Ghilbert expexp: structured calculational proof
$
\newcommand{\calc}{\begin{align} \quad &}
\newcommand{\calcop}[2]{\notag \\ #1 \;\;\; & \;\;\; \langle\mbox{#2}\rangle \notag \\ \quad & }
\newcommand{\endcalc}{\notag \end{align}}
\newcommand{\subcalc}{\quad \begin{aligned} \\ \bullet \quad &}
\newcommand{\subcalcop}[2]{\calcop{#1}{#2} \subcalc}
\newcommand{\endsubcalc}{\notag \end{aligned} \\ \\ \cdot \quad &}
\newcommand{\nextsubcalc}{\notag \end{aligned} \\ \\ & \subcalc}
$_(Referenced in [Ghilbert Google group thread 'Step theorem display and HTML typesetting'](https://groups.google.com/d/topic/ghilbert/44niyKKts_8/discussion).)_