Skip to content

Instantly share code, notes, and snippets.

View Zeta611's full-sized avatar
🎯
Focusing

Jay Lee Zeta611

🎯
Focusing
View GitHub Profile
@Zeta611
Zeta611 / adt.py
Last active March 1, 2022 02:44
[ADT in Python] Algebraic data type (sum type) in Python #demo
from dataclasses import dataclass
@dataclass(frozen=True)
class Var:
name: str
@dataclass(frozen=True)
class Int:
@Zeta611
Zeta611 / downloader.py
Last active February 24, 2022 07:54
[Async downloader] Async file downloader #automation
import aiohttp
import asyncio
async def download(session, url, file):
async with session.get(url) as res:
with open(file, "wb") as f:
f.write(await res.read())
@Zeta611
Zeta611 / FileIO.swift
Created August 16, 2021 14:51 — forked from JCSooHwanCho/FileIO.swift
ps할 때 입력을 한꺼번에 받기 위한 유틸리티 클래스. fread의 swift 버전.
import Foundation
final class FileIO {
private let buffer:[UInt8]
private var index: Int = 0
init(fileHandle: FileHandle = FileHandle.standardInput) {
buffer = Array(try! fileHandle.readToEnd()!)+[UInt8(0)] // 인덱스 범위 넘어가는 것 방지
@Zeta611
Zeta611 / CGPoint+offsetBy.swift
Last active January 18, 2021 13:36
[CGPoint+offsetBy] Extends `offsetBy` method to `CGPoint`. #extension #iOS
//
// CGPoint+offsetBy.swift
//
// Created by Jay Lee on 29/01/2019.
// Copyright © 2019 Jay Lee <jaeho.lee@snu.ac.kr>
// This work is free. You can redistribute it and/or modify it under the
// terms of the Do What The Fuck You Want To Public License, Version 2,
// as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
//
@Zeta611
Zeta611 / drawShifted.asy
Last active May 31, 2020 08:06
[drawShifted] Shift a path by an absolute value in Asymptote
void drawShifted(
path g,
pair trueshift,
picture pic=currentpicture,
Label label="",
pen pen=currentpen,
arrowbar arrow=None,
arrowbar bar=None,
margin margin=NoMargin,
marker marker=nomarker
@Zeta611
Zeta611 / pathLabel.asy
Last active May 31, 2020 08:04
[pathLabel] Add a label to a path
void pathLabel(
picture pic=currentpicture,
Label l,
path g,
real position=0.5,
align align=NoAlign,
bool sloped=false,
pen p=currentpen,
filltype filltype=NoFill
) {
@Zeta611
Zeta611 / sample.lua
Last active May 31, 2020 08:02
[Lua sample] Simple demo of a Lua code #demo
-- Use a builder to safely make objects
function build_complex(r, i)
return {real = r, img = i}
end
-- Accessing a value with a key
complex = build_complex(3, 4)
assert(complex["real"] == complex.real)
print(complex.real)
@Zeta611
Zeta611 / capture.lua
Last active May 31, 2020 08:02
[Lua capture] Shows a full lexical scoping of Lua
function enable_counting()
local count = 0
local old_print = print
print = function(...)
count = count + 1
old_print(...)
end
return function() return count end
end
@Zeta611
Zeta611 / work.sh
Last active March 13, 2020 14:27
[ffmpeg script] #ffmpeg #automation
ffmpeg -i ~/lecture-videos/week1_edit.mov -ss 00:00:00 -t 00:13:00 ~/lecture-videos/week1_edit_part1.mp4
ffmpeg -ss 00:10:00 -i ~/lecture-videos/week1_edit.mov -t 00:13:00 ~/lecture-videos/week1_edit_part2.mp4
ffmpeg -ss 00:20:00 -i ~/lecture-videos/week1_edit.mov -t 00:13:00 ~/lecture-videos/week1_edit_part3.mp4
ffmpeg -ss 00:27:00 -i ~/lecture-videos/week1_edit.mov -t 00:13:44 ~/lecture-videos/week1_edit_part4.mp4
ffmpeg -ss 00:00:00 -i ~/lecture-videos/week2_edit.mov -t 00:13:00 ~/lecture-videos/week2_edit_part1.mp4
ffmpeg -ss 00:10:00 -i ~/lecture-videos/week2_edit.mov -t 00:13:00 ~/lecture-videos/week2_edit_part2.mp4
ffmpeg -ss 00:20:00 -i ~/lecture-videos/week2_edit.mov -t 00:13:00 ~/lecture-videos/week2_edit_part3.mp4
ffmpeg -ss 00:25:00 -i ~/lecture-videos/week2_edit.mov -t 00:13:26 ~/lecture-videos/week2_edit_part4.mp4
@Zeta611
Zeta611 / setup.sh
Last active March 13, 2020 14:27
[setup.sh] #automation
#!/bin/bash
# tput variables
highlight=$(tput setaf 3; tput bold)
alert=$(tput setaf 1)
reset=$(tput sgr0)
# Install Xcode Command Line Tools
echo "${highlight}Installing Xcode Command Line Tools...${reset}"
xcode-select -p > /dev/null