Skip to content

Instantly share code, notes, and snippets.

View mjy9088's full-sized avatar

Juyeong Maing mjy9088

  • 대한민국
  • 03:00 (UTC +09:00)
View GitHub Profile
@mjy9088
mjy9088 / XOR.ts
Last active April 9, 2025 08:46
TypeScript XOR with multiple operands
export type XOR<T extends any[]> = XORInternal1<
T,
XORInternal2<T, never>,
never
>;
type XORInternal2<T extends any[], R> = T["length"] extends 0
? R
: XORInternal2<RemoveFirst<T>, keyof T[0] | R>;
@mjy9088
mjy9088 / HKT.ts
Created April 8, 2025 10:08
TypeScript simple HKT? (not works)
type ArrayToPromise = <T>(_: Array<T>) => Promise<T>;
type TransformType<Transform extends (a: any) => any, Type> = Transform extends (_: Type) => infer I ? I : never;
type ArrayOfNumber = Array<number>;
type PromiseOfNumber = TransformType<ArrayToPromise, ArrayOfNumber>;
@mjy9088
mjy9088 / CMakeLists.txt
Created June 16, 2024 13:58
serialize bmp
cmake_minimum_required(VERSION 3.10)
project(bmp)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR})
add_executable(dummy_bmp main.c bmp.c)
@mjy9088
mjy9088 / github.css
Last active May 26, 2024 12:06
giscus github theme supports class-strategy dark mode
/* from https://giscus.app/themes/light.css and https://giscus.app/themes/dark.css for dark mode */html:not(.dark) main{--color-prettylights-syntax-comment:#6e7781;--color-prettylights-syntax-constant:#0550ae;--color-prettylights-syntax-entity:#8250df;--color-prettylights-syntax-storage-modifier-import:#24292f;--color-prettylights-syntax-entity-tag:#116329;--color-prettylights-syntax-keyword:#cf222e;--color-prettylights-syntax-string:#0a3069;--color-prettylights-syntax-variable:#953800;--color-prettylights-syntax-brackethighlighter-unmatched:#82071e;--color-prettylights-syntax-invalid-illegal-text:#f6f8fa;--color-prettylights-syntax-invalid-illegal-bg:#82071e;--color-prettylights-syntax-carriage-return-text:#f6f8fa;--color-prettylights-syntax-carriage-return-bg:#cf222e;--color-prettylights-syntax-string-regexp:#116329;--color-prettylights-syntax-markup-list:#3b2300;--color-prettylights-syntax-markup-heading:#0550ae;--color-prettylights-syntax-markup-italic:#24292f;--color-prettylights-syntax-markup-bold:#2429
@mjy9088
mjy9088 / criticalSection.ts
Last active January 24, 2024 09:46
Typescript CriticalSection
interface Pending {
resolve: (value: any) => void;
reject: (error: any) => void;
criticalSection: () => Promise<unknown>;
}
export function criticalSection(): <T>(
criticalSection: () => Promise<T>
) => Promise<T> {
const pending: Pending[] = [];
@mjy9088
mjy9088 / get_next_line.c
Last active June 14, 2024 21:22
get_next_line in 4 functions
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: Juyeong Maing <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/16 16:47:34 by Juyeong Maing #+# #+# */
/* Updated: 2023/04/22 19:26:51 by Juyeong Maing ### ########.fr */
/* */
@mjy9088
mjy9088 / README.md
Last active February 26, 2023 15:37
Setup raspberry pi home k3s cluster

Setup raspberry pi home k3s cluster

[TOC]

Installation

  1. Download Raspberry Pi Imager on laptop
  2. Setup network anyway...
  3. Setup each cluster nodes (raspberry pis)
  4. Write to Micro SD or USB drive using Raspberry Pi Imager, with SSH enabled
@mjy9088
mjy9088 / Makefile
Created March 31, 2022 17:18
config.mk generator
Q := $(if $(filter 1,$(V) $(VERBOSE)),,@)
NAME := config.mk
$(NAME): variable_cc.mk variable_diagnostics.mk
$Qrm -f tmp_$@
$Qcat variable_*.mk > tmp_$@
$Qmv tmp_$@ $@
$Qecho "Configure OK!"
$Qmake --no-print-directory clean
@mjy9088
mjy9088 / init.sh
Last active February 26, 2023 15:40
Development environment setup script for 42schools
#!/bin/bash
# link cache directories to goinfre
TARGET=(
"Caches"
"ApplicationSupport/Code/Cache"
"ApplicationSupport/Code/CachedData"
"ApplicationSupport/Code/CachedExtensions"
@mjy9088
mjy9088 / Dockerfile
Last active March 4, 2022 01:34
Janus test dockerfile - currently WIP
FROM ubuntu:18.04
# command: docker build -t janus-test:0.0.2 .
# install dependencies
RUN apt update && apt install -y \
libjansson-dev \
libconfig-dev \
libnice-dev \