Skip to content

Instantly share code, notes, and snippets.

@isaac-ped
isaac-ped / snapshot_query_definition.py
Last active April 15, 2025 18:14
scheduled snapshot query creation
def _snapshot_query(
snapshot_dataset: str,
source_dataset: str,
source_table: str,
retention_days: int | None,
) -> str:
"""Contsruct the query for snapshotting a table.
Taken from: https://cloud.google.com/bigquery/docs/table-snapshots-scheduled#schedule_the_monthly_query
See the docstring for _create_scheduled_snapshot for details on parameters.
@isaac-ped
isaac-ped / git-trash
Created August 7, 2023 00:16
git-trash
#!/usr/bin/env bash
REALPATH="$(nix-shell -p coreutils -p which --pure --run 'which realpath')"
#echo $REALPATH
usage() {
echo "Usage: $0 files..."
echo "Move files into a datestamped .trash/ directory at the root of the git repo"
}
@isaac-ped
isaac-ped / .envrc
Created June 27, 2023 18:43
Minimal nix setup
#!/usr/bin/env bash
## This is copied directly from `lorri init`
# the shebang is ignored, but nice for editors
if type -P lorri &>/dev/null; then
eval "$(lorri direnv)"
else
echo 'while direnv evaluated .envrc, could not find the command "lorri" [https://github.com/nix-community/lorri]'
use nix
@isaac-ped
isaac-ped / enable-touchbar-sudo.sh
Last active June 22, 2023 17:05
Enable touch-id authentication for sudo privileges on mac OS
#!/usr/bin/env bash
# From: https://it.digitaino.com/use-touchid-to-authenticate-sudo-on-macos/
# Check if it's already done
if grep 'auth[[:space:]]*sufficient[[:space:]]*pam_tid.so' /etc/pam.d/sudo; then
echo "Already done"
else
# One-liner to do it
sudo sed -i.backup 's/\(auth[[:space:]]*sufficient[[:space:]]*pam_smartcard.so\)/\1\nauth sufficient pam_tid.so/' /etc/pam.d/sudo
fi
@isaac-ped
isaac-ped / ResourceGroup.py
Last active May 8, 2023 21:30
Automatic instantiation of single-use component resources
"""
Automatically define singleton resource groups
The structure of the python pulumi library is such that many properties
of resources are not easily modifyable after initialization.
This module functions by delaying the creation of resource attributes
within the ResourceGroup class until the class has been fully instantiated.
"""
from typing import Any, ClassVar, Iterable, TypeVar, Generic
@isaac-ped
isaac-ped / index.html
Created April 29, 2023 21:15
gibbering attempts
This file has been truncated, but you can view the full file.
<html>
<head><meta charset="utf-8" /></head>
<body>
<div> <script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
<script type="text/javascript">/**
* plotly.js v2.20.0
* Copyright 2012-2023, Plotly, Inc.
* All rights reserved.
* Licensed under the MIT license
*/
@isaac-ped
isaac-ped / local.nix
Last active February 25, 2025 20:15
Nix file defining additional packages to import to darwin-configuration.nix
{ pkgs, ... } :
{
environment.systemPackages = [
pkgs.jq # Query json output from the CLI
pkgs.tree # Prettier directory output listings
pkgs.rename # Mass-rename files
pkgs.k8s # K9s is a super useful CLI utility for interacting with kubernetes
pkgs.gh # The github command-line tool
pkgs.unixtools.watch # The 'watch' command
];
@isaac-ped
isaac-ped / wifi-qrcode.sh
Created April 13, 2023 20:05
Create WIFI QRCode
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p qrencode
usage() {
echo "Usage: $0 <SSID> <PASSWORD> [-e ENCODING] [-o OUTPUT] -- Passthrough to qrencode"
echo "ENCODING defaults to WPA, but can also be WEP"
echo "OUTPUT defaults to <SSID>.png"
}
ssid=""
def log_exception(msg: str, e: Exception) -> None:
"""Log detailed exception info.
Only the exception stack logs to logging.critical
Local variales are also appended to logging.debug
:param msg: A message to prefix the exception output
:param e: An exception object to inspect for local variables
"""
@isaac-ped
isaac-ped / trash
Last active January 14, 2021 20:14
Trash, don't remove!
#!/bin/bash -e
usage() {
echo "Move to trash directory without deleting"
echo "Usage: $(basename $0) [-v] thing-to-trash1 [thing-to-trash2 ...]"
}
VERBOSE=0
POSITIONAL=""
while (( "$#" )); do # While there are arguments left