This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from urllib.parse import urlparse, urlunparse, ParseResult | |
# Constants | |
ROOT_PATH = '/' | |
def extract_parent_path(path: str) -> str: | |
""" | |
Extracts the parent directory path from the given file path. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse | |
from collections import namedtuple | |
from datetime import date | |
Week = namedtuple("Week", ["week_number", "start_date", "end_date"]) | |
def list_iso_week_dates(year): | |
""" |
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 9 columns, instead of 2 in line 9.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
country_region_code,short_name_wdi,short_name_mofa,region_wdi,region_mofa,remarks,wdi_asof,mofa_asof,mofa_url_ja | |
ABW,Aruba,not_defined,Latin America & Caribbean,not_defined,blank,2022-08-01,not_defined,not_defined | |
AFE,Africa Eastern and Southern,not_defined,not_defined,not_defined,blank,2022-08-01,not_defined,not_defined | |
AFG,Afghanistan,アフガニスタン,South Asia,中東,blank,2022-08-01,2022-08-06,https://www.mofa.go.jp/mofaj/area/afghanistan/index.html | |
AFW,Africa Western and Central,not_defined,not_defined,not_defined,blank,2022-08-01,not_defined,not_defined | |
AGO,Angola,アンゴラ,Sub-Saharan Africa,アフリカ,blank,2022-08-01,2022-08-06,https://www.mofa.go.jp/mofaj/area/angola/index.html | |
ALB,Albania,アルバニア,Europe & Central Asia,欧州,blank,2022-08-01,2022-08-06,https://www.mofa.go.jp/mofaj/area/albania/index.html | |
AND,Andorra,アンドラ,Europe & Central Asia,欧州,blank,2022-08-01,2022-08-06,https://www.mofa.go.jp/mofaj/area/andorra/index.html | |
ARB,Arab World,not_defined,not_defined,not_defined,blank,2022-08-01,not_defined,not_defined | |
ARE,United |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from datetime import date | |
def get_max_iso_week(year: int) -> int: | |
""" | |
Calculates the maximum ISO week number for a given year. | |
ISO weeks run from Monday to Sunday. Week 1 is the week | |
with the year's first Thursday. The week containing December 28 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import re | |
import unicodedata | |
from typing import List | |
# Constants | |
KANJI_DIGITS = '〇零一壱二弐三参四五伍六七八九' | |
ARABIC_DIGITS = '001122334556789' | |
KANJI_TO_ARABIC_MAPPING = str.maketrans(KANJI_DIGITS, ARABIC_DIGITS) | |
UNICODE_NORMALIZATION_FORM = 'NFKC' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
set -e | |
# Constants | |
DEFAULT_GROUP="www-data" | |
CWD="$(pwd)" # Get current working directory immediately | |
VENV_DIR="${CWD}/.venv" # Define VENV_DIR relative to CWD | |
BACKUP_FILE="backup_$(basename "${CWD}")_$(date +%Y%m%d%H%M%S).tar.gz" # Backup file name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# Traverse the directory tree upwards to the marked directory. | |
MARKER_DIR=".git" # Arbitrary directory like '.git', '.env', etc. | |
display_help() { | |
cat <<EOF | |
Usage: $(basename "$0") [OPTIONS] | |
Options: | |
--help Display this help message and exit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Byte-compiled / optimized / DLL files | |
__pycache__/ | |
*.py[cod] | |
*$py.class | |
# C extensions | |
*.so | |
# Distribution / packaging | |
.Python |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# === 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import csv | |
import logging | |
from collections import Counter | |
from pathlib import Path | |
logging.basicConfig(level=logging.INFO) | |
class CSVSquarer: |
NewerOlder