Skip to content

Instantly share code, notes, and snippets.

@alastori
alastori / nintendo_switch_sd_migration.md
Last active March 29, 2025 16:28
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"

OCI Usage Analysis with MySQL

Manual download of OCI usage data

Using the OCI web console, go to the Menu > Account Management > Usage Report.

Example:

reports/usage-csv/0001000000072041.csv.gz
reports/usage-csv/0001000000071666.csv.gz
reports/usage-csv/0001000000071275.csv.gz
# Get latest MySQL image available at Docker Hub
# https://hub.docker.com/_/mysql/ (not Oracle MySQL)
docker pull mysql:latest
docker images
# Create and run a container with MySQL named as 'mysql8'
docker run --name mysql8 -e MYSQL_ROOT_PASSWORD=Root123! -d mysql:latest
# Check if the constainer 'mysql8' is running
docker ps