Skip to content

Instantly share code, notes, and snippets.

View scarf005's full-sized avatar

scarf scarf005

View GitHub Profile

how to only commit successfully fixed files:

  1. run checks
parallel clang-tidy --enable-check-profile --store-check-profile=clang-tidy-trace -fix '--checks=-\*,modernize-use-ranges' {} ::: src/*.{cpp,h}
  1. collect failing build error messages
@scarf005
scarf005 / lib.rs
Created April 19, 2025 12:09
order preserving javascript JSON serde via giving and passing Map
use serde_json::Value;
use serde_wasm_bindgen;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn parse_json(string: JsValue) -> Result<JsValue, JsValue> {
let string: String = string
.as_string()
.ok_or_else(|| JsValue::from_str("Expected a string"))?;
@scarf005
scarf005 / bap.user.js
Created April 6, 2025 03:17
Replace thumbs-down with baps
// ==UserScript==
// @name GitHub Custom Thumbs Down
// @namespace https://github.com/scarf005
// @version 1.0.0
// @description Replaces the default GitHub thumbs down emoji with a custom image
// @author scarf
// @match https://github.com/*
// @grant none
// @run-at document-idle
// ==/UserScript==
import scala.annotation.tailrec
sealed abstract class SnocList[+A]:
inline def :<[B >: A](a: B): SnocList[B] = new :<(this, a)
final def toList: List[A] =
@tailrec def go(xs: SnocList[A], acc: List[A]): List[A] = xs match
case Lin => acc
case xs :< x => go(xs, x :: acc)
go(this, Nil)
override def toString: String = toList.mkString("SnocList(", ", ", ")")
// https://xebia.com/blog/how-to-derive-type-class-instances-with-shapeless-3/
//> using dep org.typelevel::shapeless3-deriving::3.5.0
package deriving
import shapeless3.deriving.*
trait Show[A]:
def show(a: A): String
# 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
---------------------------------------------------------------------- -----------------------------