Skip to content

Instantly share code, notes, and snippets.

View yuwash's full-sized avatar

Yushin Washio yuwash

View GitHub Profile
@yuwash
yuwash / plan_recurrent_charge.py
Created January 30, 2020 21:49
Calculate optimal standing order for prepaid account
#!/usr/bin/env python
import datetime
current_balance = 450
desired_buffer_days = 30
planned_charge_period_days = 365.25/6
past_charges = [
(datetime.date(2019, 6, 30), 525),
(datetime.date(2019, 7, 22), 1250),
(datetime.date(2019, 12, 1), 500),
@yuwash
yuwash / paperformat.py
Created August 2, 2020 16:24
Find best-fit of tessarating two paper formats on each others
from itertools import product
dumplings = (352, 175) # Kartoffel Knödel 4000400130570
a5 = (210, 148)
def min_mod(x1, x2, n1_max):
def mod_for_n1(n1):
return (x1*n1) % x2
return min((mod_for_n1(n1), n1) for n1 in range(1, n1_max))
@yuwash
yuwash / benchmark.py
Created January 5, 2021 10:34
Benchmark for empty lists
import argparse
def create_data(amount=50):
return [
{"content": "abcdefghijkl"} for __ in range(amount)
]
def create_data_empty_list(amount=50):
@yuwash
yuwash / pulsate.sh
Created January 27, 2021 12:41
Pulsate following a pattern
#! /usr/bin/env bash
pulsate_once () {
export delay="$1"
echo -n O
sleep "$delay"
}
pulsate_word () {
word="$1"
@yuwash
yuwash / armv
Created August 6, 2023 21:41
Archive Move
# Armv "Archive Move"
# A command to write a "moved.txt" file in the source directory with a
# list of files moved and the destination.
# The command also moves all the files to the destination.
# Usage: armv source/path dest/path
FROM_PATH="$1"
TO_PATH="$2"
MOVED_FILE_HEADER="TO: $(realpath "$TO_PATH")"