Skip to content

Instantly share code, notes, and snippets.

@ahgraber
ahgraber / git.md
Last active December 14, 2022 16:15
Git Cheats

Git cheatsheet & reminders

Add existing repo to local file structure

# at destination folder:
git init
git remote add origin <git repo https url>
@ahgraber
ahgraber / conda.md
Last active September 16, 2021 20:01
conda cheatsheet

Conda cheatsheet and reminders

Installation

Install miniconda

mamba is a faster, drop-in replacement for conda. You can swap almost all commands between conda & mamba...

@ahgraber
ahgraber / SSH.md
Last active March 14, 2021 19:04
SSH keys
@ahgraber
ahgraber / docker-secrets.md
Last active June 12, 2024 12:37
Docker-secrets

GOAL: Keep secrets out of plaintext (esp when syncing dockerfile and docker-compose.yaml to repo)

  1. Each secret needs to be a single text file with a clear name
  2. Edit docker-entrypoint.sh to run per environmental variable
  3. (Re)Build docker image with docker-entrypoint.sh as entrypoint
  4. Create secrets in docker-compose
  5. Call secrets with "_FILE" appended to the name when specifying environmental variable

secret-init.sh:

@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

@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 / 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 / ! 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