Skip to content

Instantly share code, notes, and snippets.

View kjsman's full-sized avatar

Jinseo Kim kjsman

View GitHub Profile
@kjsman
kjsman / pqdm.py
Created February 12, 2025 13:44
pqdm: Portable tqdm that fits in your clipboard
# Licensed under the Zero-Clause BSD License (0BSD)
# See: https://opensource.org/licenses/0BSD
import sys
import time
def format_time(seconds):
m, s = divmod(int(seconds), 60)
return f"{m:02d}:{s:02d}"
class tqdm:
@kjsman
kjsman / chacha20poly1305.js
Last active February 12, 2024 17:55
ChaCha20-Poly1305 in 779 bytes
encrypt=async(P,Q,K,N)=>{I=-64;do{T=U=Uint32Array,J=0;O=await(A=async(...V)=>W(await(new Blob(V)).arrayBuffer()))("expand 32-byte k",K,(W=x=>new U(x))([I/64+1]),N),R=O.slice(),(D=b=>(S=[7,8,12,L=16],J<80&&(B=(W,Z,Y,X)=>(s=S.pop())&&(w=O[W]^=O[X]+=O[Y],O[W]<<=s,O[W]|=w>>>-s,B(Y,X,W,Z)))((M=i=>i*4+((J/4&1&&i)+J)%4)(3),M(2),M(1),J++%4)+D()))();for(i=L;i;O[--i]+=R[i]);U=Uint8Array;O=await A(O);P=I?P:W(P);Y=I<0?O:Y;for(i=0;i<64;i++)P[I++]^=O[i]}while(P[I]+1);r=(F=(a,i,j)=>(j??=L)?BigInt(a[i])+F(a,i+1,--j)*(Z=256n):0n)(Y,0)&0xffffffc0ffffffc0ffffffc0fffffffn;a=0n;p=P[l='length'],q=Q[l],k=(1<<30)*4,Q=await A(Q,(X=x=>W(x%L&&L-x%L))(q),P,X(p),new T([q,q/k,p,p/k]));for(I=0;Q[I]+1;I+=L)a=(a+F(Q,I)+(1n<<128n))*r%((1n<<130n)-5n);a+=F(Y,L);return[P,W(L).map(t=>(r=a%Z,a/=Z,`${r}`))]}
@kjsman
kjsman / definitions.units
Created August 1, 2021 00:00
GNU Units database
#
# This file is the units database for use with GNU units, a units conversion
# program by Adrian Mariano [email protected]
#
# September 2020 Version 3.09
#
# Copyright (C) 1996-2002, 2004-2020
# Free Software Foundation, Inc
#
# This program is free software; you can redistribute it and/or modify
@kjsman
kjsman / birds.py
Created March 5, 2021 18:30
새떼 시뮬레이션 by Boids algorithm
# 2021, By Jinseo Kim
# CC BY 4.0으로 배포됩니다.
import random
import math
import time
import os
# Screen size
X = 200
@kjsman
kjsman / imagenet_classes.txt
Created December 7, 2020 09:20
ImageNet에 포함되는 사진 데이터의 클래스 목록.
tench, Tinca tinca
goldfish, Carassius auratus
great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias
tiger shark, Galeocerdo cuvieri
hammerhead, hammerhead shark
electric ray, crampfish, numbfish, torpedo
stingray
cock
hen
ostrich, Struthio camelus
@kjsman
kjsman / README.md
Last active June 21, 2021 04:56
Autograd

Autograd

Warning

  • 어디선가 오류 날 가능성 100%
  • 변수명 다 쌩까고 단일 변수로 취급함. 따라서 편미분 못함 ㅎㅎ

Update Log

파희

아희로 구현한 원주율 계산기입니다. Spigot 알고리즘을 이용하여 원주율의 (정수부 포함) 15000자리를 계산하여 출력합니다. reference.c를 바탕으로 만들었습니다.

알파희로 그냥 실행하면 Segmentation fault (core dumped)가 뜹니다. -O0으로 최적화를 꺼주면 잘 실행됩니다.

총 계산에 대략 8초 소요됩니다.

$ time ./rpaheui-c pi.aheui
@kjsman
kjsman / web.aheui
Last active April 17, 2020 04:58
아희로 만든 웹서버
밚반따숙처숚밗뚜밤뚜까머구ㅇ삳붅뜌
빠바줘ㅇ오봞봻봹봟슉커쏨ㅇ삼무발봊
토번세벟뚜벓데볝데삮쏜볘ㅇ뭏삳불뚜
붏톄냬뷧벗따볻따봇쏜아초ㅇ오뚜번빼
빠뙤밵뒈벫볾밝뿌뗘산토어ㅇ뚀빠뚜뱄
뿌되붣뾔퇴뷬뿨떠볷뷇섣ㅇ거봟붆뻐뒤
밧퇴뱑뱛번따따뷑뵔봦떼떼뽸봁빠두뾔
북떄뗴뷧뷚뵑솯뱨샘태봾뼤대봜뿨더볫
빠뺘뺘뻐따때뛔뛔뾔봽뙤뷎뷈떼투붉너
뚜봭뷜쀄때볧뵜뚸붮데뱉붩튀뵍뻐퉤살
@kjsman
kjsman / YouTube-Error-Monkey.html
Created October 27, 2018 14:11
YouTube Error Monkey
<svg viewBox="0 0 490 525" style="width:250;float:right"><path fill="#6A1B9A" d="M325 85c1 12-1 25-5 38-8 29-31 52-60 61-26 8-54 14-81 18-37 6-26-37-38-72l-4-4c0-17-9-33 4-37l33-4c9-2 9-21 11-30 1-7 3-14 5-21 8-28 40-42 68-29 18 9 36 19 50 32 13 11 16 31 17 48z"/><path fill="none" stroke="#6A1B9A" stroke-width="24" stroke-linecap="round" stroke-miterlimit="10" d="M431 232c3 15 21 19 34 11 15-9 14-30 5-43-12-17-38-25-59-10-23 18-27 53-21 97s1 92-63 108"/><path fill="#6A1B9A" d="M284 158c35 40 63 85 86 133 24 52-6 113-62 123-2 0-4 1-6 1-53 9-101-33-101-87V188l83-30z"/><path fill="#F7CB4D" d="M95 152c-3-24 13-57 46-64l27-5c9-2 16-19 17-28l3-15 20-3c44 14 42 55 18 69 22 0 39 26 32 53-5 18-20 32-39 36-13 3-26 5-40 8-50 8-80-14-84-51z"/><path fill="#6A1B9A" d="M367 392c-21 18-77 70-25 119h-61c-27-29-32-69 1-111l85-8z"/><path fill="#6A1B9A" d="M289 399c-21 18-84 62-32 111h-61c-37-34-5-104 43-134l50 23z"/><path fill="#EDB526" d="M185 56l3-15 20-3c25 8 35 25 35 41-12-18-49-29-58-23z"/><path fill="#E62117" d="M190 34c8