I always feel like state machines can quickly become a lot of pain. Although I have had my reservations about the Python case/match feature, it's a perfect fit for this.
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 urllib.request | |
| import urllib.parse | |
| import argparse | |
| import json | |
| import random | |
| import time | |
| import enum | |
| import logging | |
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
| { | |
| "nodes": { | |
| "nixpkgs": { | |
| "locked": { | |
| "lastModified": 1770841267, | |
| "narHash": "sha256-9xejG0KoqsoKEGp2kVbXRlEYtFFcDTHjidiuX8hGO44=", | |
| "owner": "nixos", | |
| "repo": "nixpkgs", | |
| "rev": "ec7c70d12ce2fc37cb92aff673dcdca89d187bae", | |
| "type": "github" |
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 yaml from "js-yaml"; | |
| import traverse from "traverse"; | |
| import { readFileSync } from "node:fs"; | |
| import { SCHEMA } from "./schema.mjs"; | |
| function extendConfig(base, derived) { | |
| const baseRef = traverse(base); | |
| const mergedConfig = traverse(derived).map(function (item) { | |
| if (item.klass === "ExtendingArray") { | |
| const other = baseRef.get(this.path); |
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 python | |
| import subprocess | |
| import json | |
| import argparse | |
| import math | |
| import sys | |
| NFS_TEMPLATE = """ | |
| jupyterhub-home-nfs: | |
| quotaEnforcer: |
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 -eu | |
| # We ensure that nothing has the wrong project by clearing project IDs | |
| # Clear the /export/staging project (it's not actually a project, but this works) | |
| xfs_quota -x -c "project -C -p /export/staging 0" /export -D /dev/null -P /dev/null | |
| # We ensure no quotas are set, so that the reconciliation loop happens | |
| # Clear all quotas | |
| cut -d: -f1 /etc/projid | tail -n+2 | xargs -I{} xfs_quota -x -c 'limit -p bhard=0 {}' -D /etc/projects -P /etc/projid /export |
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 retextSpell from "retext-spell"; | |
| async function loadDictionary(dictionary) { | |
| const baseUrl = new URL(`https://unpkg.com/dictionary-${dictionary}@latest/`); | |
| const [aff, dic] = await Promise.all([ | |
| fetch(new URL("index.aff", baseUrl)), | |
| fetch(new URL("index.dic", baseUrl)), | |
| ]); |
NewerOlder