Skip to content

Instantly share code, notes, and snippets.

View AstraLuma's full-sized avatar
🐍
snek snek snek snek

Jamie Bliss AstraLuma

🐍
snek snek snek snek
View GitHub Profile
def mutate_url(url, *,
username=None, password=None, hostname=None, port=None, **kwargs
):
import urllib.parse
bits = urllib.parse.urlparse(url)
assert not ( (username or password or hostname or port) and 'netloc' in kwargs ) # noqa
if username or password or hostname or port:
# FIXME: url encoding
u = username or bits.username
w = password or bits.password
@AstraLuma
AstraLuma / README.md
Created March 3, 2021 17:00
git boop

Creates & pushes empty commits without disturbing your index or workspace

  1. Copy git-boop.sh to git-boop on your $PATH
  2. Run git boop
#!/usr/bin/env python3
"""
Launches and manages uMTP-Responder with better cleanup.
"""
import contextlib
import os
from pathlib import Path
import subprocess
import tempfile
import time
@AstraLuma
AstraLuma / proto.md
Created February 8, 2020 06:36
Untitled RPC Protocol

(Unnamed RPC Protocol)

  • Pulls a bunch of ideals from varlink
  • Encoded as two msgpack streams, one in each direction
  • The stream is broken up into channels, where there is a single call and potentially many responses.
  • Method names are forward-dotted paths (eg com.foobar.service.Method)
  • Parameters and returns are both maps; at the application level, methods only take keyword arguments and return named return values
  • Methods may return 0 or more returns or errors
@AstraLuma
AstraLuma / server-build.py
Last active January 26, 2020 03:42
buildahscript proof of concept
#!/usr/bin/env buildahscript
#| pip: requests
#| arg: eula: bool
#| arg: version: str = "latest"
#| arg: type: str = "vanilla"
with TemporaryDirectory() as td:
bin = td / 'bin'
bin.mkdir()
with workspace('rust:buster') as build:
@AstraLuma
AstraLuma / test.py
Created January 8, 2020 04:36
Podman Varlink Networking Tests
import contextlib
import json
import os.path
import subprocess
import tempfile
import time
from varlink import Client
IMG = "quay.io/libpod/alpine_nginx:latest"
#!/usr/bin/python3
import enum
import dataclasses
import struct
import asyncio
import weakref
class InvalidPacket(Exception):
"""
@AstraLuma
AstraLuma / README.md
Last active August 28, 2019 19:14
Importable GraphQL

The basic idea: Define GraphQL queries as importable modules.

For example:

# queries.gql
#!starwars

query HeroForEpisode($ep: Episode!) {
 hero(episode: $ep) {
@AstraLuma
AstraLuma / README.md
Last active August 5, 2019 02:55
How to make a chrome "app"
@AstraLuma
AstraLuma / 99-phonebackup.rules
Created March 16, 2019 18:25
Automatic Phone Backup (via udev and systemd)
ACTION=="add", ENV{ID_SERIAL}=="*?", RUN+="/home/astraluma/udev-handler"