Skip to content

Instantly share code, notes, and snippets.

@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
@yeiichi
yeiichi / ren_n_utf8_bklog_csv.py
Last active December 29, 2024 01:03
Rename and re-encode Nulab Backlog CSV files in a directory.
#!/usr/bin/env python3
import re
from pathlib import Path
import pandas as pd
def glob_backlog_csvs(csv_dir):
csv_files = list(Path(csv_dir).glob('Backlog-Issues*.csv'))
if csv_files:
@yeiichi
yeiichi / det_nth_wk_of_month.py
Last active August 1, 2025 01:22
Determine the nth week of the month for a given date string.
#!/usr/bin/env python3
import calendar
from datetime import date
import numpy as np
def ordinal(n):
"""Converts an integer to its ordinal representation.
Reference:
@yeiichi
yeiichi / dates_in_week.py
Created December 15, 2024 00:22
Return the dates within the same week as the given date.
#!/usr/bin/env python3
from collections import namedtuple
from datetime import datetime
def get_week_dates(date_str):
"""Return the dates within the same week as the given date.
Args:
date_str (str): A date string in ISO format (e.g., '2021-01-01').
Returns: