Skip to content

Instantly share code, notes, and snippets.

@sloonz
sloonz / sandbox.py
Last active February 17, 2024 14:29
Sandboxing wrapper script for bubblewrap ; see https://sloonz.github.io/posts/sandboxing-3/
#!/usr/bin/python
import argparse
import os
import shlex
import sys
import tempfile
import yaml
config = yaml.full_load(open(os.path.expanduser("~/.config/sandbox.yml")))
@sloonz
sloonz / mdn_test.py
Created September 1, 2023 12:47
mixture density network with tensorflow
import math
import numpy as np
import tensorflow as tf
data = np.zeros((1000, 500))
def get_mdn_loss(n_kernels, n_dims):
def mdn_loss(y_true, y_pred):
logit_alpha, log_scale, mu = tf.split(y_pred, axis=1, num_or_size_splits=[n_kernels, n_kernels, n_dims*n_kernels])
#!/usr/bin/python
"""
MDB_page_header:
pgno: size_t
keysize: uint16_t // for LEAF2 pages, unused otherwise
flags: uint16_t // 1 = BRANCH, 2 = LEAF, 4 = OVERFLOW, 8 = META, 16 = DIRTY, 32 = LEAF2, 64 = SUBP, 0x4000 = LOOSE, 0x8000 = KEEP
union {
{ lower, upper: uint16_t }
pages: uint32_t // overflow pages
@sloonz
sloonz / mkebook.js
Last active June 10, 2021 19:33
Create epub from a list of URLs, using mozilla/readability to extract just the text
#!/usr/bin/node
// Install dependencies: npm install @mozilla/readability jsdom got argparse
// Usage: node mkebook.js --title Test url1 url2 > test.epub
const fs = require('fs').promises;
const { spawn } = require('child_process');
const { JSDOM } = require('jsdom');
const { Readability } = require('@mozilla/readability');