Skip to content

Instantly share code, notes, and snippets.

View antdking's full-sized avatar

Anthony King antdking

View GitHub Profile
#!/usr/bin/env python
from contextlib import contextmanager
import inspect
from tempfile import NamedTemporaryFile
import typing as t
import typing_extensions as te
import os
import pystemd
import pystemd.run
@antdking
antdking / pkg-dev-auth.sh
Last active October 6, 2022 08:41
Setup pkg.dev authentication
#!/usr/bin/env bash
# gcloud doesn't provide a mechanism to configure Artifact Registry auth helpers out the box.
# ref: https://cloud.google.com/artifact-registry/docs/docker/authentication?hl=en-GB#gcloud-helper
registries="$(gcloud artifacts locations list --format json | jq -r '. | map("\(.name)-docker.pkg.dev") | join(",") | @sh')"
# don't quote 'registries', it's already escaped by jq
gcloud auth configure-docker $registries
@antdking
antdking / README.md
Last active February 23, 2022 21:02
Building a tool

Title

Guiding Principles

To let you be Production Ready from Day 0

Using the tool should enable tightly securing and monitoring your services, with no extra work necessary. Your scratch code is now near Production Ready*.

No Compromising Maintainability

Simple design, both for you and us.

#!/usr/bin/env bash
set -Eeuo pipefail
video_file="${1}"
palette_file="$(mktemp --suffix=.png)"
output_file="${video_file%.*}.gif"
function cleanup() {
rm -f "${palette_file}"
@antdking
antdking / pse.py
Last active January 3, 2020 13:11
Manage loading in values from parameter store into the environment
import logging
import os
from collections import defaultdict
from typing import Dict
LOG = logging.getLogger(__name__)
class ParameterStoreEnvirontment:
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
@antdking
antdking / docker-compose.yml
Created February 22, 2019 14:21
an example of compose tasks
version: "3.7"
services:
app:
build: .
depends_on:
- db
x-tasks:
test:
depends_on: db launch

Python Types, why you should use stubs

TLDR;

Types are great, and so are stub files. However there's a major issue at the moment which means your implementation doesn't have to behave the same as what your stub file say. Don't use stub files yet.

The Background

a = ([]+![]) [+!![]]
c = ([]+ [][([]+![])[+[]] + ([]+![])[!![]+!![]] + ([]+![])[+!![]] + ([]+!![])[+[]]])[!![]+!![]+!![]] // []['flat'][3]
d = ([]+[][[]]) [!![]+!![]]
e = ([]+!![]) [!![]+!![]+!![]]
f = ([]+![]) [+[]]
i = ([]+[][[]]) [!![]+!![]+!![]+!![]+!![]]
l = ([]+![]) [!![]+!![]]
n = ([]+[][[]])[+!![]] // undefined[1]
o = ([] + [][([]+![])[+[]] + ([]+![])[!![]+!![]] + ([]+![])[+!![]] + ([]+!![])[+[]]])[!![]+!![]+!![]+!![]+!![]+!![]] // function[6]
r = ([]+!![]) [+!![]]
@antdking
antdking / spec.md
Last active June 22, 2018 08:21
DotMade spec

At MadeTech, we need to deal with hundreds of projects, across lots of workspaces, and potentially across hundreds of clients' workspaces too.

To keep a standard approach, we should split dotfiles, or config files in general, into 3 categories:

  • Project level, Source controlled
  • Project level, user controlled
  • Workspace level, user controlled

Project level, source controlled