This file contains hidden or 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
| ;; Deze oplossing is geschreven in WebAssembly Text Format (WAT). | |
| ;; | |
| ;; Je kent WebAssembly misschien als een manier om andere programmeertalen dan | |
| ;; JavaScript te gebruiken in de browser. Je kunt er ook losstaande | |
| ;; programma's mee schrijven. Dan heb je wel een runtime nodig. | |
| ;; | |
| ;; Installeer de `wabt` package en assemble het programma: | |
| ;; | |
| ;; wat2wasm boompjes.wat -o boompjes.wasm | |
| ;; |
This file contains hidden or 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
| /* | |
| Deze oplossing implementeert een JIT compiler met Cranelift, een compiler backend | |
| oorspronkelijk gemaakt voor wasmtime. | |
| De input wordt naar machine code gecompiled en daarna uitgevoerd. In principe kan | |
| het ieder programma aan in de taal beschreven in de Infi opdracht, maar er worden | |
| speciale optimizations gebruikt om nog efficiënter met de echte input om te gaan. | |
| Op mijn PC worden alle blokjes berekend in 900µs, dus 33 nanoseconden per blokje. | |
| Daar gaat wel 450ms compile time aan vooraf. |
This file contains hidden or 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 python3 | |
| from __future__ import annotations | |
| import ast, itertools, math, operator, sys, dataclasses | |
| @dataclasses.dataclass(frozen=True) | |
| class Point: | |
| x: float = 0.0 | |
| y: float = 0.0 |
This file contains hidden or 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
| use std::cell::RefCell; | |
| use std::rc::Rc; | |
| struct TrackingIterator<T>(Rc<RefCell<(u64, T)>>); | |
| impl<T> TrackingIterator<T> { | |
| fn new(inner: T) -> Self { | |
| Self(Rc::new(RefCell::new((0, inner)))) | |
| } |
This file contains hidden or 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
| # Painlessly get all events from an EventStore stream. | |
| # Useful for exporting data, not very useful for real-time processing. | |
| import json | |
| import requests | |
| def get_stream(name, host='localhost', port=2113, start=0, step=2000): | |
| events = [] |