Skip to content

Instantly share code, notes, and snippets.

View composite's full-sized avatar
🤡
This is the face. 이것은 면상이다.

Ukjin Yang composite

🤡
This is the face. 이것은 면상이다.
View GitHub Profile
@composite
composite / docker-pull-and-restart.sh
Created July 3, 2025 07:35
Docker update and restart (currently not work I'll find why.)
#!/bin/bash
#set -ex
day=$(date '+%Y%m%d')
now=$(date '+%Y-%m-%d %H:%M:%S')
dir=$(dirname "$0")
out=$(sudo docker compose --project-directory "$dir" -f "$dir/docker-compose.yml" pull)
log="$dir/log/pull-$day.log"
mkdir -p $(dirname "$log")
@composite
composite / README.md
Last active July 1, 2025 07:09
A Vite plugin that directory and flat based router for React Router (Next.js style)

Vite Data Route plugin for ReactRouter v7

A powerful file-based routing plugin for React Router v7 that enables automatic route generation based on your file system structure, with full support for layouts, loaders, actions, and error boundaries.

Requirements

  • react-router 7.0.0 or higher
  • vite 6.0.0 or higher
  • glob package (dev dependency)
@composite
composite / backup-indexedb.js
Created May 8, 2025 01:59
Save whole code to snippet in devtools and run it. learn more about snippets in devtools: https://developer.chrome.com/docs/devtools/javascript/snippets
void (async () => {
const dbName = prompt("What's the name of the database to export?");
if (!dbName) return;
try {
const dbExists = await new Promise(resolve => {
const request = window.indexedDB.open(dbName);
request.onupgradeneeded = e => {
e.target.transaction.abort();
resolve(false);
};
@composite
composite / wsl2-network.ps1
Last active April 11, 2025 15:33 — forked from daehahn/wsl2-network.ps1
WSL 2 TCP NETWORK FORWARDING, IMPROVED FOR TASK SCHEDULER! ALSO WORKS ON WINDOWS SERVER 2022!
# WSL2 network port forwarding script v1
# for enable script, 'Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser' in Powershell,
# for delete exist rules and ports use 'delete' as parameter, for show ports use 'list' as parameter.
# written by Daehyuk Ahn, Aug-1-2020
# edited by Ukjin Yang, Jun-7-2022 (Windows Server 2022 also works!)
# Improved features: more detailed logs for Task Scheduler, saved IP check, etc.
If ($Args[0] -eq "list") {
netsh interface portproxy show v4tov4;
exit;
@composite
composite / SpelLoggerEvaluator.java
Created February 13, 2020 09:29
Logback Appender filter with Spring EL based evaluator. If you are using Spring, no other dependency required.
package your.logging.util;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.boolex.EventEvaluatorBase;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.ParseException;
import org.springframework.expression.spel.standard.SpelExpressionParser;
@composite
composite / grok3.sh
Created February 27, 2025 13:44
Grok3 API request with curl - UNOFFICIAL! Use at your own risk.
curl --location --request POST 'https://grok.com/rest/app-chat/conversations/new' \
--header 'accept: */*' \
--header 'accept-language: en-GB,en;q=0.9' \
--header 'content-type: application/json' \
--header 'origin: https://grok.com' \
--header 'priority: u=1, i' \
--header 'referer: https://grok.com/' \
--header 'sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Brave";v="126"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
@composite
composite / use-data-array.ts
Last active March 27, 2025 02:30
AI Generated react hooks
'use client';
import { useState, useCallback, useMemo, Dispatch, SetStateAction } from 'react';
export interface DataArray<R> {
data: R[] & { added: R[]; updated: R[]; removed: R[]; initial: R[] };
length: number;
isMutated: boolean;
isInsert: boolean;
isUpdate: boolean;
@composite
composite / example.ts
Last active March 18, 2025 05:41
zod Utility: Between FormData and plain object!
import { z } from 'zod';
import { formDataToObject, createFormDataPaths } from './zod-util';
const schema = z.object({
username: z.string(),
location: z.object({
latitude: z.number(),
longitude: z.number(),
}),
strings: z.array(z.object({ value: z.string() })),
@composite
composite / plotly-lazy.ts
Created March 5, 2025 05:21
Plotly.js for React: Modern style instead of react-plotly.js, typescript and SSR friendly.
import { lazy, forwardRef, useEffect } from 'react';
export interface PlotlyProps extends HTMLAttributes<HTMLDivElement> {
data: Partial<Data>[];
layout?: Partial<Layout>;
config?: Partial<Config>;
}
export const Plotly = lazy(
() =>
@composite
composite / request-single-frame.ts
Created March 4, 2025 08:09
AI Generated utility functions - Typescript friendly, tested.
/**
* Definition of the animation frame callback function type
*/
type AnimationFrameCallback = (time: number) => void;
/**
* Definition of the cancel function type
*/
type CancelFunction = () => void;