Skip to content

Instantly share code, notes, and snippets.

View pbk20191's full-sized avatar

Byeong Gwan pbk20191

View GitHub Profile
import Foundation
extension NSSortDescriptor {
// CFBinaryHeapCompareContext does not actullay retains the info field which looks like a bug
func makeBinaryHeap() -> CFBinaryHeap {
// let naturalOrder = NSSortDescriptor(key: "self", ascending: true)
var heapCb = kCFStringBinaryHeapCallBacks
var context = CFBinaryHeapCompareContext()
heapCb.retain = kCFTypeDictionaryKeyCallBacks.retain
@pbk20191
pbk20191 / CFRunLoopChain.swift
Last active December 24, 2025 07:42
CFRunLoop derived DispatchSerialQueue
import Foundation
import Dispatch
class Receiver: NSObject, NSMachPortDelegate {
weak var ref:DispatchQueue?
weak var runLoop:CFRunLoop?
let perform:@convention(c) (DispatchQueue) -> DarwinBoolean
func handleMachMessage(_ msg: UnsafeMutableRawPointer) {
guard let ref else { return }
import JavaScriptCore
@objc(JSModuleLoaderDelegate)
public protocol JSModuleLoaderDelegate: NSObjectProtocol {
@objc(context:fetchModuleForIdentifier:withResolveHandler:andRejectHandler:)
func context(_ context: JSContext, fetchModuleFor identifier: JSValue, withResolveHandler: JSValue, andRejectHandler: JSValue)
@objc(willEvaluateModule:)
optional func willEvaluateModule(_ key: URL)
//
// CSVParserSequence.swift
// MyTool
//
// Created by 박병관 on 8/25/25.
//
import Foundation
@pbk20191
pbk20191 / settings.json
Created June 7, 2025 13:47
VSCode settings data json
{
"workbench.colorTheme": "Default Dark Modern",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
@pbk20191
pbk20191 / AppleMessageSend.cs
Last active June 20, 2025 00:42
Post Notification using Apple NSNotificationCenter with Pure c# and CoreFoundation
#nullable enable
using System;
using System.Runtime.InteropServices;
using System.Text;
public static class AppleMessagesend
{
#if UNITY_IOS || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_TVOS
@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