Skip to content

Instantly share code, notes, and snippets.

View crabdancing's full-sized avatar

Ada crabdancing

  • Earth
View GitHub Profile
@crabdancing
crabdancing / quick-nix-repl-tutorial.md
Last active November 12, 2024 05:41
a quick nix repl tutorial

If you want to probe a nix flake and figure out what it exposes, I typically just load it into nix repl and then tab complete around until I find what I'm looking for. E.g.:

$ nix repl
Welcome to Nix 2.18.5. Type :? for help.

nix-repl> :lf github:wez/wezterm/main?dir=nix
Added 12 variables.
#!/bin/bash
# This entire script was written by the circa 2022 public demo ChatGPT AI with the following prompt:
# "Write me a Bash script with 'safe mode' enabled, that dumps clipboard contents to a directory under $HOME/Clipboard in a .txt file named according to the current time in `%Y-%m-%d_%H:%M:%S` format"
# This is both useful and terrifying
# Regardless, I'm going to take credit for it and say it's Copyleft (C) Alexandria P., under the GNU GPLv3
# Enable safe mode
set -euo pipefail
#!/usr/bin/env python3
from typing import List
from manim import *
import os
from manim.utils.file_ops import open_file as open_media_file
class SquareToCircle(Scene):
def construct(self):
[Unit]
Description=Xpra
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Service]
ExecStart=/usr/bin/xpra start :10 --start=xterm --daemon=no
Restart=always
Type=simple
User=pi
@crabdancing
crabdancing / 2021-spyjs-workaround-1.md
Last active December 21, 2021 05:25
Getting SpyJS to work on some systems is difficult. Here's how to do it.

I use Arch Linux, with KDE. I've spent the past TWO HOURS trying to get SpyJS -- a proxy-based JS debugging tool -- to work. It originally did not work, giving an incredibly vague 'No events captured' message, and no error. Because it's a proxy -- essentially a workaround for lack of proper integration -- it can't tell what's gone wrong, if it's on the browser's side.

So, modern browsers apparently try to 'intelligently' ignore proxy settings if you're accessing localhost. Did you know this? I sure didn't.

They do this silently with no warning anywhere -- even though they ostensibly do this for security reasons.

There's a workaround where you replace localhost with local, and add local to your /etc/hosts. This workaround works for both Chromium and Firefox, in my tests, but gives you a 404 when you try to access the local dev server -- because SpyJS is paranoid and will reject it if it's accessing via the wrong domain.

If you want to use Chromium/Chrome, with localhost proxying you can _suppose

@crabdancing
crabdancing / journey2xaero.py
Last active August 31, 2023 22:49
Converting JourneyMap waypoints to Xaero waypoints
#!/usr/bin/env python3
# IDK this is GNU GPLv3 or osmething, leave me alone
# --Alexandria 2021
from pathlib import Path
import json
import pydantic
from typing import List
import random
#!/usr/bin/env bash
# VERY IMPORTANT! Strict mode. See: http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
@crabdancing
crabdancing / backup-mainrouter.lan
Created October 5, 2021 10:33
Automatically backup your OpenWRT router configuration to a local tarball under ~/Backups
#!/usr/bin/env bash
# script based on instructions from:
# https://openwrt.org/docs/guide-user/troubleshooting/backup_restore
router_hostname=mainrouter.lan
# Generate/update backup
ssh "$router_hostname" 'umask go=; sysupgrade -b /tmp/backup-${HOSTNAME}-$(date +%F).tar.gz'
# TODO: replace with mechanism that rearranges existing
while read line; do
case "$line" in
''|\#*) continue ;; # skip blanks
esac # Stolen from: https://unix.stackexchange.com/questions/244465/how-to-make-bash-built-in-read-ignore-commented-or-empty-lines
# Expand tilda
line=${line/#\~/$HOME}
# If exists (as directory)
if [ -d "$line" ]; then
# If isn't in PATH
@crabdancing
crabdancing / zdani-build.sh
Created April 2, 2021 01:35
toolchain and comments for building a custom Ubuntu distro image
#!/bin/env bash
function init_rootfs() {
mkdir -p rootfs scratch image/live
sudo debootstrap focal rootfs/
}
# For how to initialize rootfs packages, see:
# https://bigdaddylinux.com/ubuntu-arch-style/
# I encountered this network-manager bug: