Skip to content

Instantly share code, notes, and snippets.

View pythoninthegrass's full-sized avatar

pythoninthegrass

View GitHub Profile
@pythoninthegrass
pythoninthegrass / cleanup.sh
Last active November 13, 2024 19:16
Cleanup ubuntu servers (non)interactively (cf. no disk space left)
#!/usr/bin/env bash
set -euo pipefail
# $USER
[[ -n $(logname >/dev/null 2>&1) ]] && logged_in_user=$(logname) || logged_in_user=$(whoami)
# $UID
# logged_in_uid=$(id -u "${logged_in_user}")
@pythoninthegrass
pythoninthegrass / deploy.sh
Last active November 12, 2024 04:47
Spin up a kind cluster with jupyterhub
#!/usr/bin/env bash
set -e
# Clean up function
cleanup() {
echo "Cleaning up existing cluster..."
kind delete cluster
}
@pythoninthegrass
pythoninthegrass / Earthfile
Created November 11, 2024 02:32
Multiplatform rust build and containerization using earthly
VERSION 0.8
ARG --global APP_NAME="hello_rust"
ARG --global PROFILE=release
all:
BUILD \
--platform=linux/amd64 \
--platform=linux/arm64 \
+docker
#!/usr/bin/env bash
set -eo pipefail
# Default values
PACKAGE_NAME=""
USER_NAME=""
DRY_RUN=false
VERBOSE=false
@pythoninthegrass
pythoninthegrass / archive.sh
Last active November 8, 2024 20:23
Clean up git directories (.venv, .terraform, node_modules, and target). Then archive repos.
#!/usr/bin/env bash
# shellcheck disable=SC2155
# Environment variable overrides with defaults
OUTPUT_DIR="${OUTPUT_DIR:-${HOME}/Downloads}"
ARCHIVE_FORMAT="${FORMAT:-zip}"
MAX_DEPTH="${MAX_DEPTH:-2}"
# Create output directory if it doesn't exist
@pythoninthegrass
pythoninthegrass / hello_docker.py
Created October 23, 2024 22:09
Use the python docker sdk to run a container in detached mode
#!/usr/bin/env python
import docker
client = docker.from_env()
container = client.containers.run("ubuntu:latest",
command=["echo", "hello", "world!"],
detach=True,
remove=False,
@pythoninthegrass
pythoninthegrass / biome.jsonc
Created October 19, 2024 22:07
biome config (used primarily as json formatter in zed)
// https://biomejs.dev/formatter/#options
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"formatter": {
"enabled": true,
"useEditorconfig": true,
"formatWithErrors": true
},
"json": {
@pythoninthegrass
pythoninthegrass / 01-machines.json.j2
Last active October 15, 2024 20:34
Setup cockpit on multiple servers via ansible
{%- set excluded_ips = [
'^192\.168\.8\.',
'^192\.168\.25\.',
'^192\.168\.105\.'
] -%}
{
{% for host in groups['all'] %}
{%- set ip = hostvars[host]['ansible_host'] | default(host) -%}
{%- if ip is not match(excluded_ips | join('|')) and host != 'localhost' and host != 'lance@orb' %}
"{{ ip }}": {
@pythoninthegrass
pythoninthegrass / Dockerfile
Created October 7, 2024 23:01
wip docker compose setup of tauri based in part on https://www.the-great.dev/blog/2024-02-04-tauri-docker
# syntax=docker/dockerfile:1.7.0
FROM lukemathwalker/cargo-chef:latest-rust-slim-bookworm AS base
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
libwebkit2gtk-4.0-dev \
build-essential \
curl \
@pythoninthegrass
pythoninthegrass / gum_log.sh
Last active October 2, 2024 22:23
gum logging mvp
#!/usr/bin/env bash
# Function to log using gum
logger() {
local level msg OPTIND log_file log_dir log_path
level=""
msg=""
log_dir="/tmp"
log_file="gum.log"
log_path="${log_dir}/${log_file}"