Skip to content

Instantly share code, notes, and snippets.

@alastori
alastori / .migrate_venvs.sh
Created November 11, 2025 20:21
Script to relocate venvs from ~/Sandbox into ~/.venvs and leave symlinks
#!/usr/bin/env bash
set -euo pipefail
VENV_ROOT="${VENV_ROOT:-$HOME/.venvs}"
mkdir -p "$VENV_ROOT"
echo "Scanning $HOME/Sandbox for virtualenv activate scripts..."
processed=0
migrated=0
skipped=0
@alastori
alastori / .bootstrap_venv.sh
Created November 11, 2025 20:03
Minimal script to bootstrap project venvs under ~/.venvs
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'USAGE'
Usage: bootstrap_venv.sh /path/to/project [requirements-file]
Environment variables:
PYTHON_BIN Path to the Python executable to use (default: /opt/homebrew/bin/python3.12)
VENV_ROOT Directory where virtualenvs are stored (default: $HOME/.venvs)
@alastori
alastori / setup_jupyter.sh
Last active August 29, 2025 11:55
setup_jupyter.sh — builds on [setup_venv.sh](https://gist.github.com/alastori/ed46fba72be8398e171c401761d0be9e) to install Jupyter in .venv and register a per-project kernel
#!/usr/bin/env bash
set -euo pipefail
# Ensure the base venv script exists in your home
if [ ! -x "$HOME/setup_venv.sh" ]; then
echo "Error: $HOME/setup_venv.sh not found or not executable."
echo "Download it or make it executable: chmod +x ~/setup_venv.sh"
exit 1
fi
@alastori
alastori / setup_venv.sh
Created August 29, 2025 11:46
setup_venv.sh — create a project-local Python .venv using uv and add .venv/ to .gitignore
#!/usr/bin/env bash
set -euo pipefail
VENV_DIR=".venv"
if ! command -v uv >/dev/null 2>&1; then
echo "Error: uv is not installed. Install with: brew install uv"
exit 1
fi
@alastori
alastori / nintendo_switch_sd_migration.md
Last active May 11, 2025 07:48
How to transfer Nintendo Switch SD Card data using macOS

How to Transfer Nintendo Switch SD Card Data (macOS Guide)

This guide explains how to migrate a Nintendo Switch SD card to a larger SD card on macOS, ensuring data integrity while avoiding hidden macOS metadata files.

Summary of Steps

Step Action
1 Create a read-only .dmg backup of the old SD card using Disk Utility.
2 Format the new SD card in the Nintendo Switch.
@alastori
alastori / org-obsidian-screenshots.py
Created July 30, 2024 18:54
This Python script processes referenced screenshots in Obsidian Markdown files, renaming them to include the Markdown file's name and a unique timestamp. It updates the Markdown files with the new filenames and generates a processing report. Create a config.ini file with your notes directory and maximum filename length, then run the script.
# org-obsidian-screenshots.py
"""
Script to Organize and Rename Screenshot Files in Obsidian Markdown Notes
Purpose:
This script processes referenced screenshots in Obsidian Markdown (`.md`) files. It renames the screenshot files to include the name of the Markdown file and a unique timestamp. Additionally, it updates the Markdown files to reference the new screenshot filenames and generates a processing report.
Usage:
1. Create a `config.ini` file in the same directory as the script with the following content:
#!/bin/bash
# Display the directory structure
cat <<EOL
This script will create the following directory structure:
project_name/
├── notebooks/ # Jupyter notebooks for analysis, exploration, etc.
│ ├── exploratory/ # Initial explorations, drafts, experiments.
{
"character_sets": [
{
"name": "armscii8",
"description": "ARMSCII-8 Armenian",
"default_collation": "armscii8_general_ci",
"collations": [
"armscii8_general_ci",
"armscii8_bin"
]
@alastori
alastori / mysql-charsets.js
Created June 10, 2022 05:35
MySQL Shell script to create a nested JSON with character sets and collations
// MySQL Shell script to create a nested JSON with character sets and collations
session.setCurrentSchema('information_schema');
var query = 'SELECT cs.CHARACTER_SET_NAME, cs.DESCRIPTION, cs.DEFAULT_COLLATE_NAME, co.COLLATION_NAME, co.IS_DEFAULT FROM CHARACTER_SETS as cs, COLLATIONS as co WHERE cs.CHARACTER_SET_NAME = co.CHARACTER_SET_NAME ORDER BY cs.CHARACTER_SET_NAME, co.IS_DEFAULT DESC, co.COLLATION_NAME';
var res = session.sql(query).execute();
var myJson = {['character_sets']:[]};
var row = res.fetchOne();
while(row) {
var character_set = {'name': {}, 'description': {}, 'default_collation': {}, 'collations': []};
character_set.name = row[0];
@alastori
alastori / python3-venv.md
Last active May 26, 2022 17:44
Python 3 virtual environment

Create a new Python Virtual Environment

Pre-requistes

Define the directory

$ export VENVDIR=~/test-python

Check if Python 3 is installed