Skip to content

Instantly share code, notes, and snippets.

View yoonbae81's full-sized avatar

Yoonbae Cho yoonbae81

View GitHub Profile
@yoonbae81
yoonbae81 / nyt.py
Last active March 28, 2020 15:22
Send the first page of New York Times to Kindle
#!/usr/bin/env python3
import urllib.request
import smtplib
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from datetime import datetime, timedelta
KINDLE_ID = '__________@kindle.com'
GMAIL_ID = '__________@gmail.com'
@yoonbae81
yoonbae81 / rename_movies_using_pictures.py
Created April 4, 2020 05:47
ํŒŒ์ผ๋ช…์ด ์œ ์‚ฌํ•œ ์‚ฌ์ง„ํŒŒ์ผ์„ ํ™œ์šฉํ•ด ๋™์˜์ƒ ์ดฌ์˜์ผ์‹œ๋ฅผ ์ถ”๋ก ํ•˜๊ณ  ํŒŒ์ผ๋ช… ๋ฐ”๊พธ๊ธฐ
from datetime import datetime
from os import rename, walk
from os.path import join, splitext, basename
import exiftool
def get_files(dir):
files = []
for d, _, fs in walk(dir):
@yoonbae81
yoonbae81 / MButton.ahk
Created April 19, 2020 04:22
๋งˆ์šฐ์Šค ํœ ๋ฒ„ํŠผ ํ™œ์šฉํ•˜๊ธฐ (๋ธŒ๋ผ์šฐ์ € ๋’ค๋กœ๊ฐ€๊ธฐ, ํƒญ ๋‹ซ๊ธฐ)
MButton::
if (A_ThisHotkey = A_PriorHotkey and A_TimeSincePriorHotkey < 200)
Send, ^w
else
Send, {Browser_Back}
Return
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}
@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
@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 / 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 / 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 / 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 / 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