Skip to content

Instantly share code, notes, and snippets.

View naramdash's full-sized avatar
🚲
Keep Studying & Working

김주호 naramdash

🚲
Keep Studying & Working
View GitHub Profile
@naramdash
naramdash / CustomElementVueTemplateTypeSupport.ts
Created September 10, 2024 22:44
how to add custom element vue template type support
import type { ComponentOptionsMixin, DefineComponent, PropType } from "vue";
import type {
Component,
ComponentAttributes, // Record<string, unknown>
ComponentEventMap // Record<string, CustomEvent>
} from "./component";
type Attrs = {
[P in keyof ComponentAttributes]: {
type: PropType<NonNullable<ComponentAttributes[P]>>;
@naramdash
naramdash / JsonElementFormatter.fs
Last active September 4, 2024 01:53
my lovely msgpack-cs serializer from jsonelement
open System.Text.Json
open MessagePack
open MessagePack.Resolvers
open MessagePack.Formatters
open MessagePack.FSharp
type JsonElementFormatter() as self =
let jsonElementFormatter = (self :> IMessagePackFormatter<JsonElement>)
@naramdash
naramdash / PipeTo.fs
Created August 1, 2024 23:47
is this code right?
let continuationAction (t: Task<int>) =
if not t.IsFaulted then
logger.Info(
"succ {@fetched} {@remained}",
[| messages.Length :> obj; queue.Count |]
)
else
logger.Error(
"error {@error}",
[| t.Exception.InnerExceptions.Count :> obj |]
@naramdash
naramdash / .zshrc
Created September 5, 2023 02:09
my essential oh-my-zsh config
plugins=(
git
dotnet
docker
docker-compose
z
zsh-autosuggestions
zsh-syntax-highlighting
)
@naramdash
naramdash / docker-compose.yml
Last active July 10, 2023 01:46
kafka kraft + docker compose minimum setting
services:
kafka-node-1:
container_name: kafka-node-1
image: confluentinc/cp-kafka:7.4.0
environment:
CLUSTER_ID: 'MkU3OEVBNTcwNTJENDM2Qk'
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: 'broker,controller'
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT'
@naramdash
naramdash / hyper.ts
Created March 12, 2023 12:28
DOM creation
// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir
type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <
T
>() => T extends Y ? 1 : 2
? A
: B;
type WritableKeys<T> = {
[P in keyof T]-?: IfEquals<
@naramdash
naramdash / run.sh
Created June 21, 2022 07:18
run mosquitto with docker
docker run \
--name mosquitto-container \
--restart always \
--detach \
-p 9001:9001 \
-p 1883:1883 \
eclipse-mosquitto:1.6
@naramdash
naramdash / make_volume.sh
Last active June 21, 2022 06:34
run postgres with docker volume
# do before run.sh
docker volume create postgres-volume
@naramdash
naramdash / CallDifferenceByOS.cs
Last active April 25, 2022 10:15
C# Preprocessor with Operating System
#if Windows
Console.WriteLine("Windows!");
#elif Linux
Console.WriteLine("Linuxw!");
#elif OSX
Console.WriteLine("osx!");
#endif
@naramdash
naramdash / equal.ts
Last active April 19, 2022 05:29
array helper function
function equal<Type, Key extends keyof Type>(propertyName: Key, value: Type[Key]) {
return (item: Type) => item[propertyName] === value;
}
const arr = [
{ id: 1, name: "juho" },
{ id: 2, name: "kim" },
{ id: 3, name: "holy" },
{ id: 4, name: "jesus" },
{ id: 5, name: "fire" },