Skip to content

Instantly share code, notes, and snippets.

View lukaskubanek's full-sized avatar

Lukas Kubanek lukaskubanek

View GitHub Profile
@hishnash
hishnash / ExampleWindowReaderApp.swift
Created December 21, 2020 05:59
Access to the underlying UIWindow & NSWindow in swiftUI gives access to window methods and attributes.
//
// ExampleWindowReaderApp.swift
// Shared
//
// Created by Matthaus Woolard on 21/12/2020.
//
import SwiftUI
@main
@krzyzanowskim
krzyzanowskim / myview.swift
Last active October 24, 2020 10:16
FB8820682: Since when NSView.setNeedsDisplayInRect does not affects drawRect rectangle
// macOS 11.0 (20A5395g)
// Xcode 12.2 beta 3 (12B5035g)
class MyView: NSView {
override init(frame frameRect: NSRect) {
super.init(frame: frameRect)
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) {
let rect = NSRect(x: 10, y: 10, width: 10, height: 10)
extension UIHostingController {
convenience public init(rootView: Content, ignoreSafeArea: Bool) {
self.init(rootView: rootView)
if ignoreSafeArea {
disableSafeArea()
}
}
func disableSafeArea() {
@frankschlegel
frankschlegel / Combine+SelfBindings.swift
Last active February 17, 2024 02:14
Convenience extensions for Combine adding memory-save bindings and Cancellable management
import Combine
/// Classes implementing this protocol can be target of convenience Publisher
/// bindings and assignments without causing accidental retain cycles.
/// Those bindings and assignments are also released together with the target.
///
/// For example:
///
/// aPublisher.bind(to: self) { me, object in
@ole
ole / !swiftui-reflection-dump.md
Last active November 24, 2024 03:26
A dump of the SwiftUI.framework binary for the iOS simulator (as of Xcode 12.0 beta 2) using the swift-reflection-dump tool.

A dump of the SwiftUI.framework binary for the iOS simulator (as of Xcode 12.0 beta 2) using the swift-reflection-dump tool.

Note: I used a Swift 5.3 compiler build from a few weeks ago that I had laying around. Because of ABI stability, I don't think the swift-reflection-dump version has to match the compiler version that was used to build the binary, but I'm not 100% sure.

@mluisbrown
mluisbrown / Rx2Ras-Cheatsheet.md
Last active May 19, 2024 10:47
An RxSwift to ReactiveSwift cheatsheet
@chriseidhof
chriseidhof / boilerplate.swift
Last active December 11, 2024 13:54
QuickMacApp
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
@IsaacXen
IsaacXen / README.md
Last active April 7, 2025 18:40
(Almost) Every WWDC videos download links for aria2c.
// Copyright (c) 2019–20 Adam Sharp and thoughtbot, inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@mattt
mattt / UIViewControllerPreview.swift
Last active December 3, 2024 07:42
Generic structures to host previews of UIView and UIViewController subclasses.
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}