Skip to content

Instantly share code, notes, and snippets.

View yoonbae81's full-sized avatar

Yoonbae Cho yoonbae81

View GitHub Profile
@yoonbae81
yoonbae81 / InverseGeotagging.md
Created May 16, 2022 10:18
Inverse Geotagging

Inverse Geotagging

Generate GPX tracking file

Make

exiftool -DateTimeOriginal-=4 -overwrite_original *.jpg
@yoonbae81
yoonbae81 / apply.py
Created March 5, 2022 04:56
A scriptlet for apply template to multiple files
from pathlib import Path
from datetime import datetime
files = [f for f in Path().iterdir() if f.suffix == '.md']
files
template = Path('template').read_text()
template
def apply(source, template):
@yoonbae81
yoonbae81 / timestamp-hhmm.py
Created December 2, 2021 12:05
Convert timestamp to hhmm format
#!/usr/bin/env python3
import argparse
from collections import namedtuple, defaultdict
from collections.abc import Generator
from datetime import datetime
from pathlib import Path
from zoneinfo import ZoneInfo # requires `pip install tzdata` on Windows
FIELDS = ['TICKER', 'PRICE', 'VOL', 'TIMESTAMP']
@yoonbae81
yoonbae81 / minute-us.py
Last active April 10, 2022 14:08
Convert ticker-based files from stooq.com into date-based files
#!/usr/bin/env python3
"""
Convert ticker-based files from https://stooq.com/db/h/ into date-based files
"""
import argparse
from collections import namedtuple, defaultdict
from collections.abc import Generator
from datetime import datetime, date
from pathlib import Path
@yoonbae81
yoonbae81 / 30.ahk
Created September 10, 2020 23:54
Stretch Alarm
#SingleInstance
; get filename
SplitPath, A_ScriptName, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
; convert text to number
minutes := OutNameNoExt, minutes += 0
; set minutes 30 if the conversion above failed
if minutes is space
@yoonbae81
yoonbae81 / monthly.sh
Last active July 1, 2020 00:43
Rename photo and movie files with created date from EXIF
exiftool "-FileName<CreateDate" -d "%Y%m%d %H%M%S.%%e" .
exiftool "-FileModifyDate<FileName" "-FileCreateDate<FileName" "-AllDates<FileName" -overwrite_original -P -r -ext jpg ./
exiftool "-FileModifyDate<FileName" "-FileCreateDate<FileName" "-AllDates<FileName" -overwrite_original -P -r -ext mov ./
exiftool "-FileModifyDate<FileName" "-FileCreateDate<FileName" "-AllDates<FileName" -overwrite_original -P -r -ext mp4 ./
# Regenerate broken movie files
# exiftool -time:all -a -G0:1 -s "20130607 190850.m4v"
# ffmpeg -i "20130607 190850.m4v" -acodec copy -vcodec copy -f mov "20130607 190850.mov"
@yoonbae81
yoonbae81 / preview_rst.py
Last active June 11, 2020 03:39
Preview rst (RestructuredText) files on Chrome when modified
from subprocess import call
from time import sleep
from selenium import webdriver
from pathlib import Path
DRIVER_PATH = 'C:/Users/y/AppData/Local/Google/Chrome/chromedriver.exe'
SOURCE_PATH = 'source'
BUILD_PATH = 'build'
INTERVAL = 1
@yoonbae81
yoonbae81 / diaro.py
Created June 9, 2020 03:00
Import Diaro journal entries and render to another format
"""
Output:
### 2020-06-08 12:00
Title and contents are here
### 2020-06-09 12:00
Another title and contents are here
"""
@yoonbae81
yoonbae81 / prototype.py
Last active April 25, 2020 12:06
Message passing prototype for backtest
import logging
from collections import defaultdict
from dataclasses import dataclass
from multiprocessing import Pipe, Process, Queue
from multiprocessing.connection import Connection, wait
from os import cpu_count
from random import randint
from threading import Thread
from time import sleep
from typing import Any, Callable, DefaultDict, Dict, List, Optional, Set, TypeVar
MButton::
if (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)
Send, ^w
else
Send, {MButton}
Return
RButton::
if (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200) {
Send, {Browser_Back}