Skip to content

Instantly share code, notes, and snippets.

View pythoninthegrass's full-sized avatar

pythoninthegrass

View GitHub Profile
@pythoninthegrass
pythoninthegrass / devbox
Last active July 12, 2024 17:11
Shim for devbox to automatically append --env-file to services argument
#!/usr/bin/env bash
# shellcheck disable=SC1091,SC2317
# shift shim behind real binary
export PATH="/usr/local/bin/:${PATH}"
# env vars
git_root="$(git rev-parse --show-toplevel 2>/dev/null)"
script_dir=$(dirname "$(readlink -f "$0")")
@pythoninthegrass
pythoninthegrass / Dockerfile.deadsnakes
Last active July 11, 2024 18:59 — forked from BillRaymond/gist:b39ae5d862aa81a250b70b812bd5d1cc
Dockerfile to build a specific version of Python and set it as the default using Deadsnakes
# syntax=docker/dockerfile:1.7
FROM ubuntu:20.04
ARG PYTHON_VERSION="3.11"
ENV TZ=US/Chicago
ARG DEBIAN_FRONTEND=noninteractive
RUN <<EOF
#!/usr/bin/env bash
@pythoninthegrass
pythoninthegrass / input_timeout.py
Created July 8, 2024 21:04
Use python signals to enforce a user input timeout
#!/usr/bin/env python
import sys
import signal
timeout = 5 # Timeout in seconds
def handle_timeout(signum, frame):
raise TimeoutError("Input timed out!")
@pythoninthegrass
pythoninthegrass / get_secrets.py
Last active June 24, 2024 22:31
Snippet from an env role to generate programmatic .env files via the `get_secrets.py` script
...
@log_call
def file_exists(filename):
"""Check if a file exists."""
fn = Path.cwd() / filename
if fn.exists():
overwrite = input(f"File '{filename}' already exists. Do you want to overwrite it? (y/n): ")
match overwrite.lower():
case "y" | "yes":
fn.touch(exist_ok=True)
@pythoninthegrass
pythoninthegrass / main.py
Last active June 23, 2024 00:01
geopy test file
#!/usr/bin/env python
import os
from geopy.geocoders import Nominatim
from pprint import pprint
app = Nominatim(user_agent="tutorial")
if len(os.sys.argv) > 1:
your_loc = os.sys.argv[1]
# https://learn.microsoft.com/en-us/windows/wsl/wsl-config#example-wslconf-file
# Per-distro settings go in /etc/wsl.conf
# $env:userprofile\.wslconfig
# WSL2-specific options
[wsl2]
processors = 4 # Makes the WSL 2 VM use two virtual processors
memory = 8GB # Limits VM memory in WSL 2
swap = 0 # Do not use swap file
localhostforwarding=true # bind WSL 2 localhost to Windows localhost
# kind create cluster --config kind-config.yaml
---
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
# Set the API server address to be accessible from the LAN
apiServerAddress: "192.168.25.196"
apiServerPort: 6443
disableDefaultCNI: true
nodes:
@pythoninthegrass
pythoninthegrass / send_email.py
Last active June 8, 2024 17:52
Resend boilerplate template
#!/usr/bin/env python
import markdown
import resend
from decouple import config
# from pathlib import Path
# env vars
resend_api_key = config("RESEND_API_KEY")
resend_from = config("RESEND_FROM", default="Acme <onboarding@resend.dev>")
[General]
sIntroSequence=
fChancesToPlayAlternateIntro=0
uMainMenuDelayBeforeAllowSkip=0
bAllowConsole=1
bPlayMainmenuMusic=1
uGridsToLoad=5
uExterior Cell Buffer=36
bForceUpdateDiffuseOnly=1
iTextureDegradeDistance0=800
@pythoninthegrass
pythoninthegrass / README.md
Last active June 21, 2024 19:02
Bespoke askpass script for macOS

ask_pass

Bespoke askpass script for macOS.

NOTE

Moved to a proper repo as gists are pretty limited for organization.

Installation