{{ message }}

Instantly share code, notes, and snippets.

# Marnix Klooster marnix

Created Oct 27, 2021
Generators in Zig: complete, simple, and no allocator needed.
View gen.zig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 const std = @import("std"); const assert = std.debug.assert; pub fn IterOf(comptime Result: type) type { return struct { // Invariant: self._yield_frame != null or self._value == null _value: ?Result = null, _yield_frame: ?anyframe = undefined, const _the_result_type = Result;
Last active Nov 1, 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.

Last active Aug 10, 2020
View MainForBCFIPSMixedApprovedOnlyIssue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 /** 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;
Created Jun 13, 2020
Reproduction scenario for nim --gc:arc performance difference
View arcperfdiff.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 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()
Created Sep 27, 2019
Attempt at a mechanism for expanding definitions in Metamath
View df-at-exp.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 $[ 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 @. Created May 23, 2019 View a.rkt This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters  #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) Last active Jan 15, 2021 View mm-calc.user.js This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters  // ==UserScript== // @name mm-calc // @description Make metamath /html' proofs look more like calculations. (License: public domain; initial author: Marnix Klooster .) // @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'
Last active Jan 5, 2018
View try-pip-main-install-nested-package.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #!/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
Created Apr 20, 2017
null created by marnix - https://repl.it/HQio/11
View HQio-11.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 -- 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))
Last active Aug 6, 2017
MathJax \calc
View calc-env.md