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
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
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
#!/usr/bin/env python | |
import optparse | |
import urllib | |
import urllib2 | |
import urlparse | |
import xml.etree.ElementTree as ET |
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
# encoding: utf8 | |
import json | |
from collections import OrderedDict | |
import dfiance | |
from dfiance.graph import TypeGraphNode | |
from rubedo.document import ( | |
Document, | |
DocRef, | |
) |
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 os.path | |
import yaml | |
class Loader(yaml.SafeLoader): | |
pass | |
def construct_include(loader, node): | |
'''Evaluate contents of another yaml file, optionally selecting part of it. |
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
class Tuple(Dictifier): | |
def __init__(self, ordered_field_types): | |
super(Tuple, self).__init__() | |
self.ordered_field_types = tuple(ordered_field_types) | |
def dictify(self, value, **kw): | |
if value is None: | |
return None | |
try: |
NewerOlder