Skip to content

Instantly share code, notes, and snippets.

@j0057
j0057 / useitorloseit@.service
Last active August 5, 2021 11:54
Use it or lose it with bpftrace
# vim: set ft=systemd:
# bpftrace script to monitor access to a file, and delete the file if it's not
# used by anyting. Helpful for files that contain credentials.
# To use, create a drop-in file with `systemctl edit useitorloseit@<name>`
# and define a [Service] block with Environment= lines for at last FILENAME
# and FILENAME_LEN.
# TODO: find better way to set filename length
#!/usr/bin/env python3
import socket
import threading
import time
STATUS = None
def prompt_for_status():
global STATUS
use std::collections::HashMap;
#[derive(Debug)]
struct Item {
name: String,
value: i64,
}
impl Item {
fn new(n: &str, v: i64) -> Self {
@j0057
j0057 / wardley-maps.py
Created March 9, 2019 10:30
Take a bunch of Medium URLs and hack them up into something more portable
#!/usr/bin/env python3.7
# take a bunch of Medium URLs, download them, remove the crap and bundle them up into something for your e-reader
import lxml
import lxml.etree
import lxml.builder
import requests
import io
@j0057
j0057 / pip-download
Last active April 28, 2018 11:40
pip-download
#!/bin/bash -x
${PY:-python3} -m pip download --no-binary :all: $*
${PY:-python3} -m pip download $*
${PY:-python3} -m pip wheel $*
@j0057
j0057 / airvpn
Created March 3, 2018 21:03
airvpn.org api tool
#!/bin/bash
...
@j0057
j0057 / .gitignore
Created October 19, 2017 16:55
pi camera
*.swp
@j0057
j0057 / .gitignore
Last active August 15, 2017 20:18
folds.py
*.swp
*.o
*.hi
*.txt
rwh??
@j0057
j0057 / menno-vs-joost.pgn
Created June 7, 2016 11:47
menno-vs-joost.pgn
[Event "Menno vs Joost"]
[Site "Cyberspace"]
[Date "2016"]
[White "Dokter, Menno"]
[Black "Molenaar, Joost"]
1.e4 d5 2.exd5 Qxd5 3.Nc3 Qa5 4.d4 e6 5.Bd3 Nf6 6.Nf3 Nd5 7.Bd2 Bb4 8.O-O Nxc3 9.bxc3 Bxc3 10.Rb1 Bxd2 11.Qxd2 Qd5 12.c4 Qd7 13.c5 b6 14.Qc3 Bb7 15.Ne5 Qd5
*
@j0057
j0057 / convert.py
Last active March 31, 2016 20:27
Convert .cap to .capx in Capella
import os, os.path
import sys
SOURCE_DIR = r'c:\users\joost\documents\capella\voorbeelden'
# a few useful functions
output = lambda s, t='': messageBox(t, str(s))
change_ext = lambda fn, ext: os.path.splitext(fn)[0] + ext
copy_mtime = lambda src, tgt: os.utime(tgt, os.stat(src)[7:9])