Skip to content

Instantly share code, notes, and snippets.

@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

@alastori
alastori / Tutorial - Connecting to a MySQL Database Service DB System with a public IP address using a Network Load Balancer.md
Last active December 10, 2021 22:53
How to configure an Oracle Cloud Infrastructure Network Load Balancer with a MySQL Database Service DB System backend. You can use this to create a Public Endpoint to a single read-write MySQL DB System or multiple read-only MySQL DB Systems.

Tutorial - Connecting to a MySQL Database Service DB System with a public IP address using a Network Load Balancer

This tutorial will teach you how to configure an Oracle Cloud Infrastructure Network Load Balancer with a MySQL Database Service DB System backend. You can use this to create a public endpoint to a single MySQL DB System backend.

Note: It is a high security risk to expose your database to be accessible by hosts from the internet. Consider using the Bastion Service or a VPN. In cases where access via public IP address is the only alternative, ensure you restrict the authorized external IP addresses to the minimum and use in-transit encryption. Check the [OCI Networking best practices](https://docs.cloud.o

@alastori
alastori / ODBC TLS and MDS.md
Last active October 6, 2021 04:30
MySQL Connector/ODBC SSL connections with MySQL Database Service

ODBC TLS and MDS

Testing encrypted connections using MySQL Connector/ODBC with MySQL Database Service.

Install MySQL Connector/ODBC 8.0.26 on Oracle Linux 7.8

$ sudo cat /etc/os-release | grep NAME
NAME="Oracle Linux Server"
PRETTY_NAME="Oracle Linux Server 7.8"
CPE_NAME="cpe:/o:oracle:linux:7:8:server"