Skip to content

Instantly share code, notes, and snippets.

View yoonbae81's full-sized avatar

Yoonbae Cho yoonbae81

View GitHub Profile
@yoonbae81
yoonbae81 / price-day.clj
Created August 25, 2019 09:13
๋„ค์ด๋ฒ„์—์„œ ์ „์ข…๋ชฉ ์ผ๋ณ„ OHLC ๊ฐ€์ ธ์˜ค๊ธฐ
(ns price-day
(:require [clj-http.client :as client]
[clojure.string :as s]
[clojure.core.async :as a :refer [>!! >! <! <!!]]
[environ.core :refer [env]]
[taoensso.timbre :as log]
[taoensso.carmine :as r]
[clojure.string :as str]))
(def redis-uri (or (env :redis-uri) "redis://localhost:6379"))
@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 = '[email protected]'
GMAIL_ID = '[email protected]'
@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