Skip to content

Instantly share code, notes, and snippets.

View pbk20191's full-sized avatar

Byeong Gwan pbk20191

View GitHub Profile
@pbk20191
pbk20191 / SwiftNSProxyObject.swift
Last active April 30, 2025 01:10
Objective-c proxy pattern using Pure Swift!
import Foundation
import ObjectiveC
final class SwiftNSProxyObject<T:NSObjectProtocol>: NSProxy {
@nonobjc
var baseObject:T!
typealias MethodLookup = @convention(c) (AnyObject, Selector, Selector) -> (Unmanaged<NSObject>?)
@pbk20191
pbk20191 / CompatKeyboardLayoutGuide.swift
Created April 28, 2025 03:10
CompatKeyboardLayoutGuide
//
// CompatKeyboardLayoutGuide.swift
//
import UIKit
import Combine
// Backport LayoutGuide for UIKeyboardLayout (This only works for Docked Keyboard)
@MainActor
public class CompatDockedKeyboardLayoutGuide: UILayoutGuide {
@pbk20191
pbk20191 / AnimatingBitmapView.swift
Last active April 6, 2025 15:42
Apple Swift Animated Bitmap View
import SwiftUI
import UniformTypeIdentifiers
import MobileCoreServices
struct AnimatingBitmapView: View, Equatable {
static func == (lhs: Self, rhs: Self) -> Bool {
lhs.param == rhs.param && lhs.label == rhs.label && lhs.paused == rhs.paused && lhs.resizingMode == rhs.resizingMode && lhs.capInsets == rhs.capInsets
@pbk20191
pbk20191 / _BTree++.swift
Created March 9, 2025 14:59
Apple BTree Collection extended
//
// customization.swift
// BTree
//
// Created by 박병관 on 3/9/25.
//
import Foundation
@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
/**