Skip to content

Instantly share code, notes, and snippets.


Will Rouesnel wrouesnel

View GitHub Profile
wrouesnel /
Created Aug 2, 2022
Firefox enterprise CA certs
wrouesnel /
Created Jul 23, 2022
Github Clone All

Script for bulk cloning of Github repositories.

wrouesnel /
Created Jun 8, 2022
128 bit ID in b32 lowercase with no special characters
# Generate a 128-bit identifier, encoded entirely in b32 lowercase. No special characters.
function safeid() {
python3 -c 'import uuid, base64 ; print(base64.b32encode(uuid.uuid4().bytes).lower().rstrip(b"=").decode())'
wrouesnel /
Created Mar 19, 2022
An action implementing key=<json> parsing
import argparse
import json
class KeyValueJsonAction(argparse.Action):
Argparse action for generating dictionaries from key-value args with JSON support
def __call__(self, parser, namespace, values, option_string=None):
result = {}
for entry in values:
wrouesnel /
Created Mar 13, 2022
# See:
# Note: you can't refactor this out: its at the top of every script so the scripts can find their includes.
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
wrouesnel /
Created Mar 4, 2022
launch a properly passed through shell command in python
cmd = []
env = os.environ.copy()
p = subprocess.Popen(
cmd, env=env, cwd=os.path.realpath(os.curdir), stdin=sys.stdin, stderr=sys.stderr, stdout=sys.stdout
# Attach all signals and forward them to the subprocess
def sighandler(signum, stack):
def boto_results(key, fn, *args, **kwargs):
result = []
next_token = None
while True:
r = fn(*args, **kwargs)
next_token = r.get("NextToken")
value = r[key]
if isinstance(value, (str, bytes)):
elif isinstance(value, Mapping):
wrouesnel /
Last active Feb 2, 2022 — forked from liuw/
Nasty hack to raise exception for other threads
#!/usr/bin/env python
# liuw
# Nasty hack to raise exception for other threads
import ctypes # Calm down, this has become standard library since 2.5
import threading
import time
NULL = 0
View gist:74df5ce0622fbc7addcee5f6be82ed7f
from dataclasses import dataclass, field
from typing import List, Optional, ClassVar, Type, Union
import marshmallow_dataclass
import marshmallow_union
from marshmallow import fields
from marshmallow.validate import Equal
from marshmallow_polyfield import PolyField
from marshmallow_toplevel import TopLevelSchema
wrouesnel /
Last active Nov 3, 2021
Simple function for recursively iterating JSON-like data in Python
from import Mapping
from typing import Any, Callable, Iterable, MutableMapping, MutableSequence
def recurse_object(o: Any,
fn: Callable[[Any,Any,Any],Any]=None,