This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from argparse import ArgumentParser | |
from os import fspath | |
from pathlib import Path | |
import re | |
import sys | |
from textwrap import dedent | |
from coverage import Coverage | |
from coverage.exceptions import NotPython |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python3 | |
import argparse | |
from contextlib import contextmanager | |
from datetime import datetime | |
from datetime import timedelta | |
from select import select | |
import termios | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prom-query () { | |
local tmp=$(mktemp -t prom-query.XXXXXX) | |
curl -Ggs cakepile.local:8001/api/v1/namespaces/monitoring/services/prometheus-k8s:web/proxy/api/v1/query --data-urlencode query="$1" >$tmp | |
if jq -e '.status=="error"' <$tmp >/dev/null; then | |
jq <$tmp >&2 -r .error | |
rm -f $tmp | |
return 1 | |
fi | |
jq <$tmp '.data.result[]' | |
rm -f $tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use POSIX qw(WNOHANG WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG); | |
use Time::HiRes qw(gettimeofday); | |
die "usage: $0 TIMEOUT COMMAND ...\n" if (@ARGV < 2); | |
$timeout = shift @ARGV; | |
$pid = fork(); | |
die "fork: $!" if not defined $pid; | |
if ($pid == 0) { | |
exec @ARGV or die "$ARGV[0]: $!"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dedent(block) { | |
// Find the common leading space in a block of text, then remove it. Tabs are NOT handled. | |
//let spaces = Math.min.apply(null, block.match(/^ +(?=[^ ])/gm).map((ws) => ws.length)); | |
//let spaces = block.match(/^ +(?=[^ ])/gm).map((ws) => ws.length).reduce(Math.min); | |
let spaces = block.match(/^ +(?=[^ ])/gm).reduce((a,b) => a<b?a:b).length; | |
return block.replace(new RegExp(`^ {1,${spaces}}`, 'gm'), ''); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import ast | |
import re | |
import sys | |
from astunparse import unparse as astunparse | |
from astunparse import dump as astdump | |
def main(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''This is my second attempt. It is much cleaner, except for the part that exposes the injector on bound classes and instances. | |
''' | |
from contextlib import suppress | |
from functools import wraps | |
from pprint import pprint | |
import jeni |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newpgrp() { | |
# Non-interactive shells don't have job control. Spawn an interactive shell | |
# to create a new process group. The inner non-interactive shell is there | |
# to avoid interactive side-effects later on. | |
$BASH --norc -ic '$BASH -c \"\$@\" -- "$@"' -- "$@" | |
} | |
# Notes on things that don't work: | |
# set -i | |
# You can't turn job control on this way |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf8 | |
import json | |
from collections import OrderedDict | |
import dfiance | |
from dfiance.graph import TypeGraphNode | |
from rubedo.document import ( | |
Document, | |
DocRef, | |
) |
NewerOlder