Skip to content

Instantly share code, notes, and snippets.

View 2chanhaeng's full-sized avatar
๐Ÿ
Pythonic

ChanHaeng Lee 2chanhaeng

๐Ÿ
Pythonic
View GitHub Profile
@2chanhaeng
2chanhaeng / GifToMp4Converter.tsx
Created November 23, 2024 02:40
GIF to MP4 converter component
import { useState, useMemo } from "react";
import { FFmpeg } from "@ffmpeg/ffmpeg";
import { guarantee, method, pipe, tapAsync } from "utils"; // jsr:@chomu/utils
export default function GifToMp4Converter() {
const ffmpeg = useMemo(() => new FFmpeg(), []);
const [gifFile, setGifFile] = useState<File | null>(null);
const [videoUrl, setVideoUrl] = useState("");
const convertGifToVideo = async () => {
@2chanhaeng
2chanhaeng / main.py
Last active August 27, 2024 02:10
Convert excel files (*.xlsx) to DB data (sqlite) using pandas
# !pip install openpyxl pandas
# Note: This code is written under the assumption that
# the schema of all data in the Excel file and sheet is the same.
# ์•Œ๋ฆผ: ์ด ์ฝ”๋“œ๋Š” ์—‘์…€ ํŒŒ์ผ๊ณผ ์‹œํŠธ ๋‚ด ๋ชจ๋“  ๋ฐ์ดํ„ฐ์˜ ์Šคํ‚ค๋งˆ๊ฐ€ ๋™์ผํ•˜๋‹ค๋Š” ๊ฐ€์ •ํ•˜์— ์ž‘์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
import sqlite3
from pathlib import Path
import pandas as pd
@2chanhaeng
2chanhaeng / README.md
Created February 23, 2023 02:11
gist for dark reader attachments

gist for dark reader attachments

@2chanhaeng
2chanhaeng / README.md
Last active August 10, 2022 05:31
JS async

ํ•ด์„ค

sync.js๋ฅผ ์ œ์™ธํ•œ ์ฝ”๋“œ๋Š” ๋ชจ๋‘ ์‹คํ–‰ํ•˜๋ฉด 5์ดˆ ํ›„ โ€œ5secโ€์„ ์ถœ๋ ฅํ•˜๊ณ , ์ด์–ด์„œ 4์ดˆ ํ›„ โ€œ4secโ€์„ ์ถœ๋ ฅํ•˜๊ณ , โ€ฆ, ์ด์–ด์„œ 1์ดˆ ํ›„ โ€œ1secโ€์„ ์ถœ๋ ฅํ•˜๊ณ  ์ข…๋ฃŒํ•˜๋Š” ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค. ๋‹ค๋งŒ sync.js๋Š” ์‹คํ–‰ํ•ด๋ณด์‹œ๋ฉด ์•Œ๊ฒ ์ง€๋งŒ ์‹œ์ž‘ํ•˜๋ฉด 1์ดˆํ›„ โ€œ1secโ€ ์ถœ๋ ฅ, ์ด์–ด์„œ 1์ดˆ ํ›„ โ€œ2secโ€ ์ถœ๋ ฅ, โ€ฆ, ์ด์–ด์„œ 1์ดˆํ›„ โ€œ5secโ€์„ ์ถœ๋ ฅํ•˜๊ณ  ์ข…๋ฃŒํ•˜๋Š” ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค. ํ•ด๋‹น ๊ธ€ ์•„๋ž˜๋กœ ์ด์–ด์ง€๋Š” ์ˆœ์œผ๋กœ ์ฝ”๋“œ๋ฅผ ์ฝ์œผ์‹œ๋ฉด ์ดํ•ดํ•˜์‹œ๊ธฐ ํŽธํ•˜์‹ค ๊ฒ๋‹ˆ๋‹ค.

sync.js

sync.js ๋Š” ๋™๊ธฐ/๋น„๋™๊ธฐ์— ๋Œ€ํ•œ ์ดํ•ด๊ฐ€ ์ „ํ˜€ ์—†๋Š” ๊ฒฝ์šฐ ์ผ๋ฐ˜์ ์œผ๋กœ ์ž‘์„ฑํ•˜๊ฒŒ ๋˜๋Š” ๋ฐฉ์‹์˜ ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.

callback.js

Promise๊ฐ€ ์ƒ๊ธฐ๊ธฐ ์ „, CallBack์„ ์ด์šฉํ•ด ๋น„๋™๊ธฐ์ ์œผ๋กœ ์‹คํ–‰๋˜๋Š” ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค. CallBack์„ ์ด์šฉํ•˜๋‹ค๋ณด๋‹ˆ ์ด๋ฅธ๋ฐ” CallBack ์ง€์˜ฅ์— ๊ฐ–ํ˜€ 5์ค‘์œผ๋กœ ๋“ค์—ฌ ์“ด ๋ชจ์Šต์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

promise.js