Skip to content

Instantly share code, notes, and snippets.

@ahgraber
ahgraber / README.md
Created December 30, 2023 16:50
Editing Customize TimeMachine Exclusions

Customize TimeMachine Exclusions

Add exclusions by dirname

find $(pwd) -type d -name <NAME> -maxdepth 3 -exec tmutil addexclusion {} \;

Automate exclusions

@ahgraber
ahgraber / loc.sh
Created March 1, 2023 14:17
Get lines of code across multiple repos
#!/bin/bash
## assumes "multiple repos" are all in the same parent directory, which is also the current working directory
# set up git
for dir in ./*/; do
dir=${dir%*/} # remove the trailing "/"
cd "$dir"
echo "$dir"
git fetch -p && git pull
@ahgraber
ahgraber / README.md
Last active January 16, 2023 14:11
Clean up GitHub Actions workflow runs

Cleanup legacy GitHub Actions workflow runs

Python utility to delete GitHub Actions runs for a repository, based on parameters. The GitHub UI currently allows removal of individual workflow runs, but this becomes tedious with a bulk of previous runs. Credit: https://gist.github.com/magnetikonline/2242eb18bf8890e9fc72b3c3ef41bd93

Usage

  1. Create a Personal access token allowing the workflow scope:
  2. Execute the script against a target GitHub repository (with optional parameters).
@ahgraber
ahgraber / latest.md
Last active May 19, 2022 13:17
Latest github release
@ahgraber
ahgraber / open-in-vscode.md
Last active February 25, 2022 14:43
Open folder in VSCode

Steps

  1. Launch Automator
  2. Create New Document
  3. Create a new Quick Action (Select "Quick Action")
  4. Add the Action Workflow receives current files or folders in Finder
  5. If desired, add custom image/icon (see comment below)
  6. Add a new Run Shell Script action to the workflow.
  7. Configure the Workflow
@ahgraber
ahgraber / ! Managing conda envs.md
Last active August 24, 2023 22:10
Sensible SOP for managing conda envs on MacOS

Creating / Managing conda envs

Rules / SOPs:

  1. Don't work in base environment
  2. Use mamba as a solver
  3. Create default environments with pinned packages, and clone / update the default envs as needed
@ahgraber
ahgraber / Apple Silicon + emulation.md
Last active August 2, 2023 10:04
Apple arm64 and x86 emulation

Working with Apple arm64 architecture

For most applications, native vs. emulated modes do not need to be user-managed. However, for development purposes, managing the entire stack's architecture may become necessary.

Emulated terminal environment

For an x86 (Rosetta-emulated) environment, create an emulated Terminal.app:

  1. Open Finder
@ahgraber
ahgraber / repo_root.py
Last active September 8, 2023 18:55
Get path of repository folder
import os
def isdrive(path):
"""Return `True` if path is the drive root
Parameters
----------
path : path-like
"""
path = os.path.abspath(path)
@ahgraber
ahgraber / logging.md
Last active September 15, 2021 21:37
logging with Python

Logging with Python

Standards

  • Prefer logs to print statements
  • Logging objects should be named logger
  • Refer to boilerplate(s) below for add'l details

Basic logging setup