Skip to content

Instantly share code, notes, and snippets.

View pbk20191's full-sized avatar

Byeong Gwan pbk20191

View GitHub Profile
@pbk20191
pbk20191 / CFRedBlackTreeState.swift
Last active March 9, 2025 12:01
CoreFoundation CFTree Based Red-Black Tree
//
// CFRedBlackTreeState.swift
// BTree
//
// Created by 박병관 on 3/5/25.
//
internal struct CFRedBlackTreeState<Key:Comparable> {
@pbk20191
pbk20191 / KTExtensionSpineCompat.kt
Last active February 16, 2025 11:41
Spine Android Native Drawable
package com.esotericsoftware.spine.android;
import android.graphics.Canvas
import com.badlogic.gdx.utils.Array
import com.esotericsoftware.spine.android.SkeletonRenderer.RenderCommand
// this is the hack for accessing package-private while in ART & Kotlin
// ART does not have module.info.java so we can safely access it at runtime
// we can access java-package scope at compile time thanks to kotlin
@pbk20191
pbk20191 / unix.py
Last active October 20, 2024 13:48
python async console inputs
import asyncio
import os
import sys
from typing import AsyncGenerator
from contextlib import closing
async def console_input() -> AsyncGenerator[str, None]:
loop = asyncio.get_event_loop()
reader = asyncio.StreamReader(loop=loop)
with os.fdopen(os.dup(sys.stdin.fileno()), mode='rt+') as file_ref:
@pbk20191
pbk20191 / tkproactorloop.py
Last active October 11, 2024 10:47
tkinter+asyncio
"""
An event loop policy that integrates Windows message loop with IOCP-based async processing.
"""
# SPDX-License-Identifier: MIT
__all__ = (
'TkinterProactorEventLoopPolicy',
'TclIocpProactor',
@pbk20191
pbk20191 / ArrayDeque.swift
Last active August 23, 2024 11:23
collection implementation in Swift
struct ArrayDeque<Element> {
private var buffer: ContiguousArray<Element?>
private var start: Int
private var itemCount: Int
private var capacity: Int {
buffer.count
}
init() {
@pbk20191
pbk20191 / CalendarGrid.kt
Last active December 28, 2024 18:04
Calendar Grid style layout for Compose
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.SubcomposeLayout
import androidx.compose.ui.layout.SubcomposeLayoutState
import androidx.compose.ui.layout.SubcomposeSlotReusePolicy
import androidx.compose.ui.unit.*
import java.time.LocalDate
/**
@pbk20191
pbk20191 / LoomCoroutineDispatcher.kt
Created March 31, 2024 08:17
CoroutineDispatcher and ScheduledExecutorService which use Virtual Thread Scheduler back end.
import kotlinx.coroutines.*
import org.jetbrains.annotations.BlockingExecutor
import java.util.concurrent.*
import kotlin.coroutines.CoroutineContext
import kotlin.time.ComparableTimeMark
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.TimeSource
import kotlin.time.toJavaDuration
@BlockingExecutor
import androidx.compose.foundation.layout.RowScope
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavBackStackEntry
import androidx.navigation.compose.LocalOwnersProvider
@Composable
@pbk20191
pbk20191 / ComposeBridge.kt
Last active June 27, 2024 08:51
Composable to host fragment, its state is managed by Compose ( not by FragmentManager)
package androidx.fragment.app
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.activity.ComponentActivity
import androidx.compose.runtime.Composable