Skip to content

Instantly share code, notes, and snippets.

View obfusk's full-sized avatar
🏳️‍🌈
hacking ⇒ ¬sleeping 😸

FC (Fay) Stegerman obfusk

🏳️‍🌈
hacking ⇒ ¬sleeping 😸
View GitHub Profile
@obfusk
obfusk / x.java
Last active August 27, 2023 16:48
java stuff
public class DisplayOption {
String item;
boolean checked;
Consumer<Boolean> callback;
public DisplayOption(String item, boolean checked, Consumer<Boolean> callback) {
this.item = item;
this.checked = checked;
this.callback = callback;
}
}
@obfusk
obfusk / weird.py
Last active August 24, 2023 23:49
weird python thing
>>> try:
... raise Exception("oops")
... except Exception as e:
... print("A", e)
... try:
... pass # raise Exception("uh-oh")
... except Exception as e:
... print("B", e)
... print("C", e)
...
@obfusk
obfusk / example.js
Last active August 12, 2023 23:30
jsonata last-modified
const jsonata = require("jsonata");
const axios = require("axios");
const jsonPath = "$toMillis(`last-modified`, '[FNn,-3], [D] [MNn,-3] [Y] [H]:[m]:[s] GMT') > $millis() - 1000 * 60 * 60 * 24 * 7";
const expectedValue = "true";
let res = await axios.request({url: "https://f-droid.org/repo/index-v1.jar", method: "HEAD"});
headers = res.headers;
let expression = jsonata(jsonPath);

mirrors in README

https://f-droid.org/repo
rsync://mirror.f-droid.org/
https://mirror.albony.xyz/fdroid/repo
https://cloudflare.f-droid.org/repo
https://fdroid.tetaneutral.net/fdroid/repo
https://mirror.cyberbits.eu/fdroid/repo
https://bubu1.eu/fdroid/repo
@obfusk
obfusk / yaml2json
Created August 6, 2023 20:07
yaml -> json
#!/usr/bin/python3
import json, sys
from ruamel.yaml import YAML
json.dump(YAML(typ="safe").load(sys.stdin), sys.stdout)
@obfusk
obfusk / test.md
Created July 29, 2023 17:06
weird github bug
First Header Second Header
✔️ ✔️
✔️ ✔️
✔️ ✔️
✔️ ✔️
✔️ ✔️
✔️ ✔️
✔️ ✔️
✔️ ✔️
@obfusk
obfusk / stocard-dump-msgpack.py
Last active July 24, 2023 16:01
dump stocard msgpack
#!/usr/bin/python3
import csv
import json
import msgpack
MSGPACK = "bootstrapdata.msgpack"
OUTFILE = "stocard_stores.csv"

Dummy MTA so APT won't recommend/install exim4/postfix/whatever

$ equivs-build mail-transport-agent.control
$ sudo dpkg -i dummy-mail-transport-agent_1.0_all.deb
@obfusk
obfusk / avx.c
Created July 4, 2023 23:06
avx detection
#include <stdio.h>
// https://en.wikipedia.org/wiki/CPUID
static void cpuid(int cpu_info[4], int info_type) {
__asm__ volatile("cpuid \n\t"
: "=a"(cpu_info[0]),
"=b"(cpu_info[1]),
"=c"(cpu_info[3]),
"=d"(cpu_info[2])
: "a"(info_type), "c"(0));
@obfusk
obfusk / sort-version-codes.sh
Last active June 19, 2023 12:41
python one-liner to sort version codes
python3 -c $'import sys\nfor line in sorted(sys.stdin, key=lambda x: [int(n) for n in x[1:].split("-")[0].split(".")]): print(line, end="")'