Skip to content

Instantly share code, notes, and snippets.

View pythoninthegrass's full-sized avatar

pythoninthegrass

View GitHub Profile
@pythoninthegrass
pythoninthegrass / proxy.py
Created February 12, 2025 01:32
Proxy requests from a free list at https://api.proxyscrape.com
#!/usr/bin/env python
import json
import requests
from pathlib import Path
from requests.exceptions import RequestException
from urllib.parse import urlencode
def get_my_ip():
@pythoninthegrass
pythoninthegrass / config
Last active January 7, 2025 01:52
Ghosty config (i.e., $HOME/.config/ghostty/config )
title = " "
macos-titlebar-proxy-icon = "hidden"
macos-icon ="custom-style"
macos-icon-frame = "beige"
macos-icon-screen-color = 1f1d45
font-size = 14
font-family = "Hack Nerd Font Mono"
theme = "AdventureTime"
shell-integration = "bash"
working-directory = "home"
[env]
TERM = "xterm-256color"
[terminal.shell]
program = "/usr/bin/bash"
args = ["-l", "-c", "zellij"]
[window]
dimensions.columns = 100
dimensions.lines = 34
@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
@pythoninthegrass
pythoninthegrass / archive.sh
Last active January 16, 2025 19:51
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/git_archive}"
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 / 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 / simple_server.py
Created September 25, 2024 22:06
http.server implementation of serving unencrypted directory content (e.g., kickstart files) over port 8000
#!/usr/bin/env python
import http.server
import os
import socketserver
from pathlib import Path
PORT = 8000
if os.getenv("WORK_DIR") is not None: