Skip to content

Instantly share code, notes, and snippets.

@yeiichi
yeiichi / create_blank_png.py
Created February 16, 2025 04:25
Create a blank PNG image with a test string—A code written by ChatGPT o3-mini-high.
#!/usr/bin/env python3
from PIL import Image, ImageDraw, ImageFont
"""
Create a blank PNG image with a test string—A code written by ChatGPT o3-mini-high.
This script is created by ChatGPT o3-mini-high with the following prompt:
Objective: Write a Python code that creates a PNG file.
Specification:
- Ask the user for the dimension of the image.
@yeiichi
yeiichi / find_dup_files.py
Last active February 12, 2025 06:16
Class for detecting duplicate files based on their hash values.
#!/usr/bin/env python3
import csv
from collections import Counter
from datetime import datetime
from pathlib import Path
from list_files_sha256 import hash_by_256, list_fpaths_in_dir
class FindDupFile:
@yeiichi
yeiichi / list_files_sha256.py
Last active February 13, 2025 05:59
Create a filename / sha256 checksum list and save as a CSV file.
#!/usr/bin/env python3
import csv
from hashlib import sha256
from pathlib import Path
def hash_by_256(fpath):
"""
Computes a SHA-256 hash of a file using variable chunk sizes based on file size.
@yeiichi
yeiichi / pdf_scraper.py
Created January 22, 2025 08:18
Extract strings directly from a PDF file URL.
#!/usr/bin/env python3
from io import BytesIO
import requests
from pdfminer.high_level import extract_text
def extract_str_fm_pdf_url(url_pdf):
"""Extract strings directly from a PDF file URL.
Args:
@yeiichi
yeiichi / duplicate_tmpl_dir.zsh
Created January 16, 2025 04:06
Duplicate a template directory and rename.
#!/usr/bin/env zsh
my_name=$(basename "$0")
display_help() {
cat <<EOF
${my_name}:
Duplicate a template directory and rename.
EOF
@yeiichi
yeiichi / find_next_monday.py
Created January 14, 2025 06:41
Return this or next Monday.
#!/usr/bin/env python3
from datetime import date, timedelta
def find_next_monday(yyyymmdd):
"""Return this or next Monday.
"""
date_iso = date.fromisoformat(yyyymmdd)
day_o_wk = date_iso.isocalendar().weekday # Mon: 1, ... Sun: 7
dy_delta = 8 - day_o_wk
@yeiichi
yeiichi / enumerate_files.zsh
Last active January 13, 2025 10:55
Display a numbered file list of a specified directory.
#!/usr/bin/env zsh
my_name=$(basename "$0")
display_help() {
cat <<EOF
${my_name}:
Display a numbered file list of a specified directory.
EOF
@yeiichi
yeiichi / asana_csv_items.csv
Last active December 31, 2024 01:58
Asana asana_csv_items for ex/import
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 5 columns, instead of 4 in line 5.
field_type,column_name,data_type,description,source
basic,Name,text,use this column for the names of the tasks in your project.,https://help.asana.com/s/article/preparing-data-for-csv-import
basic,Description,text,use this column to provide details and context within the task.,https://help.asana.com/s/article/preparing-data-for-csv-import
basic,Section,text,a new section will be created once you manually move tasks into the desired section or column.,https://help.asana.com/s/article/preparing-data-for-csv-import
basic,Assignee,email_addr,assign one owner to each task by adding the email address of an Asana user from your workspace or organization. Tasks created in Asana can only be assigned to one user.,https://help.asana.com/s/article/preparing-data-for-csv-import
basic,Collaborators,email_addr,you can add several of your colleagues as collaborators on a task by adding email addresses of valid Asana users from your workspace or organization on a separate column. Take care to separate them with a comma and do
@yeiichi
yeiichi / backlog_csv_items.csv
Created December 29, 2024 15:31
Nulab backlog_csv_items for ex/import
col ja en
0 ID ID
1 プロジェクトID Project ID
2 プロジェクト名 Project Name
3 キーID Key ID
4 キー Key
5 種別ID Issue Type ID
6 種別 Issue Type
7 カテゴリーID Category ID
8 カテゴリー名 Category Name
@yeiichi
yeiichi / vim_open_mtg_idx.zsh
Created December 26, 2024 04:45
Opens ./meetings/yyyymmddHHMM/index.rst with Vim.
#!/usr/bin/env zsh
my_name=$(basename "$0")
display_help() {
echo usage: "${my_name}"
}
main() {
printf "*** Opens ./meetings/yyyymmddHHMM/index.rst with Vim. ***\n"
printf "\033[93mMeeting Date?(yyyymmdd) >> \033[0m"
read -r mtg_date