Skip to content

Instantly share code, notes, and snippets.

View maptv's full-sized avatar
👨‍💻
Per aspera💪ad astra✨

Martin Laptev maptv

👨‍💻
Per aspera💪ad astra✨
View GitHub Profile
@maptv
maptv / tod_to_hms.py
Created June 30, 2025 08:02
Fractional day time-of-day (tod) to hour-minute-second (hms) triplet
def tod_to_hms(tod):
hour, remainder = divmod(tod * 86400, 3600)
return int(hour), *map(int, divmod(remainder, 60))
@maptv
maptv / is_balanced.py
Created June 10, 2025 18:52
Check if wrapping characters in a string is balanced
def is_balanced(s: str) -> bool:
stack = []
bracket_map = {')': '(', ']': '[', '}': '{'}
open_brackets = set(bracket_map.values())
for char in s:
if char in open_brackets:
stack.append(char)
elif char in bracket_map:
if not stack or stack[-1] != bracket_map[char]:
@maptv
maptv / deciday.py
Last active July 20, 2023 19:50
Display deciday time with deciday offset and 24-hour time with UTC offset, e.g. 5.50-2 and 13:00-05
# test by running the following in a UNIX shell:
# for tz in 'Pacific/Samoa' 'America/Los_Angeles' 'Etc/UTC' 'Asia/Shanghai' 'Pacific/Kiritimati'; do; echo \\n$tz; env TZ=$tz python deciday.py; done;
from datetime import datetime, timezone
import time
utc = datetime.now(timezone.utc)
mid = utc.replace(hour=0, minute=0, second=0, microsecond=0)
seconds_since_midnight = (utc - mid).total_seconds()
deciday = seconds_since_midnight / 8640
offset = round(time.timezone / 8640)
@maptv
maptv / deciday.js
Last active July 20, 2023 19:44
Display deciday time with deciday offset and 24-hour time with UTC offset, e.g. 5.50-2 and 13:00-05
// test by running the following in a UNIX shell:
// for tz in 'Pacific/Samoa' 'America/Los_Angeles' 'Etc/UTC' 'Asia/Shanghai' 'Pacific/Kiritimati'; do; echo \\n$tz; env TZ=$tz node deciday.js; done;
const now = new Date(),
year = now.getUTCFullYear(),
month = now.getUTCMonth(),
day = now.getUTCDate(),
hour = now.getUTCHours(),
minute = now.getUTCMinutes(),
second = now.getUTCSeconds(),
@maptv
maptv / doom-info.txt
Created June 21, 2023 15:03
Doom emacs info
generated Jun 21, 2023 11:02:04
system MacOS 12.6.6 Darwin 21.6.0 x86_64
emacs 28.2 ~/.config/emacs/
doom 3.0.0-pre PROFILE=_@0 grafted, HEAD -> master, origin/master,
origin/HEAD 07fca78 2023-05-30 19:39:04 -0400 ~/.config/doom/
shell /usr/local/bin/zsh
features ACL GMP GNUTLS JSON LIBXML2 MODULES NOTIFY KQUEUE PDUMPER THREADS
ZLIB
traits batch envvar-file
modules :config use-package :completion company vertico :ui doom