Skip to content

Instantly share code, notes, and snippets.

View scarf005's full-sized avatar

scarf scarf005

View GitHub Profile
# reset author and email while keeping date correct
# https://stackoverflow.com/questions/750172/how-do-i-change-the-author-and-committer-name-email-for-multiple-commits/1320317#1320317
# https://stackoverflow.com/a/72930891/13503626
GIT_EDITOR=: git -c rebase.instructionFormat='%s%nexec GIT_AUTHOR_DATE="%ci" GIT_COMMITTER_DATE="%ci" git commit --amend --no-edit --allow-empty --allow-empty-message --reset-author' rebase -i --root
#!/bin/bash
INPUT=${1:-input.mp4}
OUTPUT=${2:-output.gif}
ffmpeg -i "$INPUT" -vf "fps=10,palettegen=max_colors=20:reserve_transparent=0" palette.png
ffmpeg -i "$INPUT" -i palette.png -filter_complex "fps=4,paletteuse" "$OUTPUT" -y
rm palette.png
@main def main() =
val blockQuotes = '"'.toString * 3
val text = """@main def main() =
val blockQuotes = '"'.toString * 3
val text = %s
println(text.formatted(blockQuotes + text + blockQuotes))"""
println(text.formatted(blockQuotes + text + blockQuotes))
@scarf005
scarf005 / 한글.txt
Created August 26, 2024 12:23
한글 테스트
asfd
@scarf005
scarf005 / result.md
Created July 25, 2024 06:15
O(1) vs O(N)
$  deno bench set_bench.ts
Check file:///Users/nemo/repo/deno-playground/set_bench.ts
cpu: Apple M1 Pro
runtime: deno 1.45.2 (aarch64-apple-darwin)

file:///Users/nemo/repo/deno-playground/set_bench.ts
benchmark             time (avg)        iter/s             (min … max)       p75       p99      p995
---------------------------------------------------------------------- -----------------------------
for (const N of [10_000, 100_000, 1_000_000]) {
Deno.bench("Array.fill()", { group: `${N}`, baseline: true }, () => {
new Array(N).fill(0)
})
Deno.bench("Array.from()", { group: `${N}` }, () => {
Array.from({ length: N }, () => 0)
})
}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NoFieldSelectors #-}
import Data.List (intercalate)
mergeSort :: Ord a => [a] -> [a]
mergeSort [] = []
mergeSort [x] = [x]
mergeSort xs = merge (mergeSort left) (mergeSort right)
@scarf005
scarf005 / index.html
Created May 28, 2024 00:53
Simplest preact app without any build step
<!DOCTYPE html>
<html>
<head>
<title>Look ma, no build step</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.js"></script>
/**
* Sync PR/revert인 경우 merge commit, 그 외에는 squash merge
*
* 의존성: [github cli](https://cli.github.com)
* 설치: gh alias set pr-merge '! deno run -A /스크립트가/있는/경로/gh-pr-merge.ts $@'
*
* @module
*/
import $ from "jsr:@david/dax@^0.41.0"
@scarf005
scarf005 / closure_bench.ts
Last active January 8, 2024 02:08
Inline your callbacks
const f = (g: (x: number) => number) => (x: number) => g(x)
Deno.bench("closure directly", { baseline: true }, () => {
const foo = [...Array(1000).keys()].map(f((x) => x + 1))
})
Deno.bench("closure indirectly", () => {
const g = f((x) => x + 1)
const foo = [...Array(1000).keys()].map(g)
})