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 | |
| # make CTRL-C kill background jobs | |
| # https://stackoverflow.com/a/2173421 | |
| trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM INT EXIT | |
| # wait if too many background jobs | |
| wait_max_concurrent() { | |
| local n="$1" | |
| if [[ "$n" -le 0 ]]; 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
| #! /usr/bin/env nix-shell | |
| #! nix-shell -i bash -p bash gh | |
| set -eu | |
| # See <https://gist.github.com/lorenzleutgeb/239214f1d60b1cf8c79e7b0dc0483deb>. | |
| # Will exit non-zero if not authenticated. | |
| gh auth status | |
| if [ $# -ge 1 ] |
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 nix-shell | |
| #!/nix-shell --pure -i bash -p git git-wait nix gum | |
| set -euo pipefail | |
| export GIT_WAIT_TIMEOUT_MS=5000 | |
| trace() ( set -x; "$@"; ) | |
| die() { echo >&2 "ERROR:" "$@"; exit 1; } | |
| git diff HEAD --quiet --exit-code || die "Your worktree is dirty, please commit your changes first." | |
| # Fetch upstream branch chosen by user |
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
| ssh idun-login1.hpc.ntnu.no sinfo -N -o %all --json | jq ' | |
| [.sinfo[]|select(.partition.name == "CPUQ")] as $CPUQ_nodes | | |
| [.sinfo[]|select(.partition.name == "GPUQ")] as $GPUQ_nodes | | |
| def gpus_maximum: | |
| .gres.total | |
| | match("gpu:[^:]*:([0-9]+)").captures[0].string | |
| | tonumber; | |
| def gpus_used: | |
| .gres.used |
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
| porcelain2jsonl() { | |
| uniq | ( | |
| printf "[" | |
| while read key data; do | |
| if test -z "$key"; then | |
| printf "]\n[" | |
| else | |
| printf '{"%s": "%s"}, ' "$key" "$data" | |
| fi | |
| done |
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
| NIX_CONFIG="extra-experimental-features = nix-command flakes" use flake |
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 requests | |
| from requests.utils import parse_url | |
| from functools import lru_cache | |
| from pathlib import Path | |
| import shlex | |
| from tqdm.auto import tqdm | |
| import re | |
| import typer | |
| import os |
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 numpy as n,pygame as p | |
| q=(999,)*2 | |
| b=n.random.rand(*q)>.3 | |
| t=p.display | |
| r=n.roll | |
| o=p.surfarray.pixels2d(t.set_mode(q)) | |
| while 1: | |
| w=sum(r(r(b,a,0),c,1)for a in[-1,0,1]for c in[-1,0,1]) | |
| b=b&((w==3)|(w==4))|((~b)*(w==3)) | |
| o[:,:]=0-b |
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 re | |
| import os | |
| import sys | |
| from pathlib import Path | |
| import subprocess | |
| import shutil | |
| import concurrent.futures as futures | |
| import requests | |
| import json |
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
| $fn = 100; | |
| rotate([0, 0, 180]) { | |
| color("brown"){ | |
| translate([-2.5, -2.5, 0]) cube([5, 5, 70]); | |
| translate([0, 2.5, 50]) cube([40, 5, 5], center=true); | |
| } | |
| translate([0, 5, 50]) |
NewerOlder