Skip to content

Instantly share code, notes, and snippets.

@yeiichi
yeiichi / disable_ms_mau_steps.txt
Created June 7, 2025 07:35
Disable Microsoft AutoUpdate (MAU) + OneDrive auto-update
# === Disable Microsoft AutoUpdate (MAU) + OneDrive auto-update ===
# === macOS cheat sheet ===
# My profile: Mac only / Office 365 (Word, Excel, PPT, OneDrive) / Teams in browser
# STEP 1: Add blocklist to /etc/hosts
sudo vi /etc/hosts
# Add this block:
127.0.0.1 officecdn.microsoft.com
127.0.0.1 officecdn.microsoft.com.edgesuite.net
@yeiichi
yeiichi / csv_squarer.py
Created June 2, 2025 02:08
Make a CSV file to be square by removing irregular rows
#!/usr/bin/env python3
import csv
import logging
from collections import Counter
from pathlib import Path
logging.basicConfig(level=logging.INFO)
class CSVSquarer:
@yeiichi
yeiichi / bom-killer.sh
Last active June 1, 2025 06:20
Remove BOM (Byte Order Mark) sequence from a file.
#!/usr/bin/env sh
HELP_MESSAGE="Usage: $(basename "$0") <file>
Remove BOM (Byte Order Mark) sequence from a file.
Arguments:
<file> Input file to process
Options:
-h, --help Show this help message"
@yeiichi
yeiichi / project_paths.py
Created June 1, 2025 00:27
Initialize and provide reusable constants and paths for various project subdirectories.
#!/usr/bin/env python3
# noinspection PyUnresolvedReferences
"""
This script initializes and provides reusable constants and paths
for various project subdirectories such as `src`, `config`, `data`,
`tests`, and `logs`. It uses the `pathlib` library to construct
platform-independent paths relative to the directory where this file resides
(assumed to be the project root).
Module Constants:
@yeiichi
yeiichi / csvbookconv.py
Created May 22, 2025 08:59
Combine multiple CSV files into a single Excel workbook.
#!/usr/bin/env python3
# Combine multiple CSV files into a single Excel workbook.
import re
from dataclasses import dataclass
from pathlib import Path
import pandas as pd
from openpyxl import Workbook
from openpyxl.workbook.views import BookView
@yeiichi
yeiichi / days-since.sh
Last active May 19, 2025 00:32
Echo how many calendar days have passed between the REFERENCE_DATE and today.
#!/usr/bin/env sh
# Echo how many calendar days have passed between the REFERENCE_DATE and today.
readonly REFERENCE_DATE='2025-01-01'
readonly SECONDS_PER_DAY=86400
error_exit() {
echo "$1" >&2
exit "${2:-1}"
}
@yeiichi
yeiichi / gpg_json_reader.py
Last active May 5, 2025 02:27
Read, decrypt, and parse JSON data from a GPG-encrypted JSON file.
#!/usr/bin/env python3
import json
import os
import shutil
import subprocess
from pathlib import Path
class GPGJSONReaderError(Exception):
@yeiichi
yeiichi / gnupg_wrapper.py
Created May 2, 2025 00:27
A class that provides a simplified interface for common GPG operations.
#!/usr/bin/env python3
"""
A class that provides a simplified interface for common GPG operations
like encryption, decryption, signing, and key management. `GPGWrapper`
"""
from functools import wraps
from pathlib import Path
from typing import Optional, List, Dict, Any, Callable
import gnupg
@yeiichi
yeiichi / git_commit_helper.zsh
Last active May 1, 2025 05:35
Helps the user construct a Git commit message interactively.
gitmsg () {
read -r "type?Type (feat/fix/refactor/docs/test/chore/style): "
read -r "desc?Description: "
read -r "file?File name: "
msg="${type}: ${desc} (${file})"
echo "git commit -m '${msg}'"
}
@yeiichi
yeiichi / add_fiscal_year_to_csv.py
Created April 24, 2025 06:48
Add a fiscal year column to a CSV file based on dates.
#!/usr/bin/env python3
"""
Add a fiscal year column to a CSV file based on dates,
supporting both US and Japanese fiscal calendar systems.
"""
import argparse
from datetime import datetime
from pathlib import Path
import pandas as pd