Skip to content

Instantly share code, notes, and snippets.

#!/bin/python3
from argparse import ArgumentParser, ArgumentError
from contextlib import contextmanager
@contextmanager
def scoped_setattr(obj, name, value):
dne = object()
try:
#!/bin/python3
import argparse
class OverloadAction(argparse.Action):
class OverloadParser(argparse.ArgumentParser):
def exit(self, status = 0, message = None):
raise argparse.ArgumentError(None, message)
def _print_message(self, message, file = None):
@tsibley
tsibley / Snakefile
Last active November 12, 2024 18:29
"""
For Cécile, re: <https://bedfordlab.slack.com/archives/C0K3GS3J8/p1731108015913239>.
The rule-of-thumb is: if you need to read from a file output by rule A in order
to determine what rule B will declare as input, then rule A needs to be a
checkpoint and rule B needs to use an input function that reads from the file.
In this example, the intermediate rule is naive to the checkpoint and input
function: it's a basic rule that uses two wildcards. The final rule uses an
input function to declare input files that "pass thru" the global {scenario}
#!/usr/bin/env python3
import xml.etree.ElementTree as ET
from sys import argv, stdin, stdout
layer = argv[1]
doc = ET.parse(stdin)
root = doc.getroot()
for g in root.findall(".//{http://www.w3.org/2000/svg}g[@id]"):
id = g.get("id")
@tsibley
tsibley / clockins
Last active November 9, 2024 03:53
#!/bin/bash
# usage: clockins [<since>]
#
# <since> defaults to "yesterday".
set -euo pipefail
since="${1:-yesterday}${1:+ ago}"
{
journalctl \
@tsibley
tsibley / plx
Created November 3, 2024 17:06
#!/bin/bash
# usage: plx install <module> [args…]
# plx link <module>
# plx ls [<module>]
# plx --help
#
# Install Perl programs into isolated environments.
set -euo pipefail
PREFIX="$(realpath "${PREFIX:-$HOME/.local}")"
diff --git a/ingest/defaults/config.yaml b/ingest/defaults/config.yaml
index 7bd0362..dfddd22 100644
--- a/ingest/defaults/config.yaml
+++ b/ingest/defaults/config.yaml
@@ -39,9 +39,11 @@ curate:
# For the Nextstrain team, this is currently
# "https://raw.githubusercontent.com/nextstrain/ncov-ingest/master/source-data/gisaid_geoLocationRules.tsv"
geolocation_rules_url: "https://raw.githubusercontent.com/nextstrain/ncov-ingest/master/source-data/gisaid_geoLocationRules.tsv"
- # The path to the local geolocation rules within the pathogen repo
+ # General global defaults are sourced from the geolocation_rules_url URL above.
#!/bin/bash
set -euo pipefail
REPO="$(basename $PWD)"
mkdir -p .github
cat > .github/dependabot.yml <<~~
# Dependabot configuration file
# <https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file>
/* Color values from RTD's Doc Diff addon's CSS */
.doc-diff-added { --bgcolor: rgb(171, 242, 188) }
.doc-diff-removed { --bgcolor: rgba(255, 129, 130, 0.4) }
/* Doesn't work in Firefox 131… not sure why… *//*
.doc-diff-removed {
--bgcolor: color(
from rgba(255, 129, 130, 0.4)
srgb
calc(((1 - alpha) * 255) + (alpha * r))
defaults:
a:
x: 1
y: 2
b:
z: 3
builds:
global:
a: