This file contains hidden or 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 bash | |
| set -u | |
| usage() { | |
| cat <<EOF | |
| Usage: "${BASH_SOURCE[0]##*/}" [options] [extra_file ...] |
This file contains hidden or 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 bash | |
| JQWINS=' | |
| [recurse(.nodes[])] | | |
| [ | |
| .[] | | |
| select(has("app_id")) | | |
| (.id | tostring) + "\t" + .name + (" [" + if .app_id then .app_id else .shell end + "]") | |
| ] | |
This file contains hidden or 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/bash | |
| RMTE="${1:?"No host supplied!"}" | |
| RDIR="${2:?"No path supplied!"}" | |
| REPO="${3:-"refs/heads/sync"}" | |
| git push "${RMTE}:${RDIR}" "+@:${REPO}" && git diff HEAD | ssh "${RMTE}" \ | |
| "{ git -C '${RDIR}' reset --hard '${REPO}' && git -C '${RDIR}' apply --index - ; }" |
This file contains hidden or 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 bash | |
| # combiget: get appropriate elements from a combination of arrays given a flat index | |
| combiget() { | |
| ind="${1:?'No index.'}" | |
| arrs=("${@:2}") | |
| for (( i = 0 ; i < ${#arrs[@]} ; i++)); do | |
| n="$ind" | |
| for (( j = i + 1 ; j < ${#arrs[@]} ; j++ )); do |
This file contains hidden or 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 bash | |
| RETVAL=0 | |
| VENV="${1:?"No path to virtual environment supplied!"}" | |
| shift | |
| exec 3>"${VENV}.lock" | |
| if flock --exclusive --wait 180 3; then | |
| if ! [ -d "$VENV" ]; then |
This file contains hidden or 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 h5py | |
| import click | |
| @click.command() | |
| @click.argument('sources', nargs=-1, type=click.Path(exists=True, dir_okay=False)) | |
| @click.argument('destination', type=click.Path(dir_okay=False, writable=True)) | |
| def main(sources, destination): | |
| outfd = h5py.File(destination, 'a') |
This file contains hidden or 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 python3 | |
| import xml.etree.ElementTree as ET | |
| import logging | |
| import os | |
| import click | |
| import yaml | |
| logger = logging.getLogger(__name__) |
This file contains hidden or 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
| """LazyProxy and LazyDict for lazily evaluated objects""" | |
| class LazyProxy: | |
| """Lazily apply a chain of functions on a single object""" | |
| def __init__(self, parent=None): | |
| """Lazily apply a chain of functions on a single object | |
| Parameters | |
| ---------- | |
| parent : LazyProxy or None |
This file contains hidden or 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 h5py | |
| def h5tree(base, key='/', depth=1): | |
| if isinstance(base, h5py.Group): | |
| return key + '\n' + '\n'.join(' ' * depth + h5tree(obj, key, depth + 1) for key, obj in base.items()) | |
| else: | |
| blist = str(base[()]).split('\n', maxsplit=1) | |
| return '{}: {}'.format(key, blist.pop(0) + (' (...)' if blist else '')) |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <pulse/simple.h> | |
| #include <pulse/error.h> | |
| #define BUFSIZE 1024 | |
| void square(short *data, unsigned int length, unsigned int period, short magnitude) { | |
| unsigned int i; |