Skip to content

Instantly share code, notes, and snippets.

View jprochazk's full-sized avatar
💭
📦

Jan Procházka jprochazk

💭
📦
View GitHub Profile
{
"random": [
{
"_id": "5f308f89582bc3c72e48d1d5",
"index": 0,
"guid": "5492dc3c-2610-4cae-98b6-103eb0ede71a",
"isActive": true,
"balance": "$3,390.36",
"picture": "http://placehold.it/32x32",
"age": 35,
{
"random": [
{
"_id": "5f308f89582bc3c72e48d1d5",
"index": 0,
"guid": "5492dc3c-2610-4cae-98b6-103eb0ede71a",
"isActive": true,
"balance": "$3,390.36",
"picture": "http://placehold.it/32x32",
"age": 35,
(function () {
window.CBOR_DATA = {
"random": [
{
"_id": "5f308f89582bc3c72e48d1d5",
"index": 0,
"guid": "5492dc3c-2610-4cae-98b6-103eb0ede71a",
"isActive": true,
"balance": "$3,390.36",
"picture": "http://placehold.it/32x32",
diff --git include/boost/asio/impl/use_awaitable.hpp include/boost/asio/impl/use_awaitable.hpp
index d0da2a35..95d864f9 100644
--- include/boost/asio/impl/use_awaitable.hpp
+++ include/boost/asio/impl/use_awaitable.hpp
@@ -237,7 +237,7 @@ T dummy_return()
}
template <>
-void dummy_return()
+inline void dummy_return()
@jprochazk
jprochazk / game_of_life.js
Last active October 27, 2021 20:55
Game of life which runs in a browser console
const console_render = (state) => console.log(state.map(row => row.map(v => '☐◼'[v]).join("")).join("\n"));
function game_of_life(w, h, fps, render = console_render) {
const state = (w, h) => Array(w).fill(0).map(() => Array(h).fill(0));
const randomize = (state) => state.map(a => a.map(b => Math.round(Math.random())));
const neighbours = (state, x, y) => [
state[x-1]?.[y-1], state[x]?.[y-1], state[x+1]?.[y-1],
state[x-1]?.[y ], state[x+1]?.[y ],
state[x-1]?.[y+1], state[x]?.[y+1], state[x+1]?.[y+1]
].map(v => v ?? 0);
const step = (state) => state.map((r, x) => r.map((v, y) => {
@jprochazk
jprochazk / brainfuck.js
Created December 10, 2021 15:55
brainfuck interpreter
class Brainfuck {
memory = new Uint8Array(30000);
ptr = 0;
input = { read() { return 0 } };
output = { write(v) { console.log(String.fromCharCode(v)) } };
run(code) {
for (let i = 0, len = code.length; i < len; ++i) {
let c = code.charAt(i);
switch (c) {
// move pointer right
@jprochazk
jprochazk / random.js
Last active April 6, 2022 15:13
A simple seedable PRNG
// Constants from glibc (GCC), with a period of 2**31
const M = (2 ** 31);
const A = 1103515245;
const C = 12345;
const randomSeed = (max) => Math.floor((crypto.getRandomValues(new Uint8Array(1))[0] / 255) * (max - 1));
/** Linear congruential generator */
class PRNG {
constructor(seed = randomSeed(M)) {
this.state = seed;
}
@jprochazk
jprochazk / brainfuck.js
Created July 24, 2022 08:04
BF -> JS compiler
// @ts-check
/** @returns {(stdin: () => number, stdout: (c: number) => void) => void} */
function compile(/** @type {string} */ source) {
let func =
"const memory = new Uint8Array(30000);\n" +
"let ptr = 0;\n";
for (let i = 0, len = source.length; i < len; ++i) {
let c = source.charAt(i);
switch (c) {
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
@jprochazk
jprochazk / gc_resources.md
Created February 27, 2023 07:08 — forked from mrnugget/gc_resources.md
Resources I used so far (26 feb 2023) to build a GC for my toy compiler
[gchb]: https://gchandbook.org/
[clawing]: https://blog.mozilla.org/javascript/2013/07/18/clawing-our-way-back-to-precision/
[gsgc]: https://piumarta.com/software/gsgc/index.shtml
[migc]: https://github.com/playXE/migc
[yarpenruntime]: https://github.com/mdlugajczyk/yarpen/blob/master/runtime/yarpen_runtime.c
[bdwgc]: https://www.hboehm.info/gc/
[bdwgcslides]: https://www.hboehm.info/gc/04tutorial.pdf
[bdwdescr]: https://hboehm.info/gc/gcdescr.html
[writinginterpretersinrust]: https://rust-hosted-langs.github.io/book/introduction.html
[gcandrustpart0]: http://blog.pnkfx.org/blog/2015/10/27/gc-and-rust-part-0-how-does-gc-work/