Skip to content

Instantly share code, notes, and snippets.

View Adobels's full-sized avatar
🎯
Focusing

Blazej SLEBODA Adobels

🎯
Focusing
View GitHub Profile
@Adobels
Adobels / gist:2dea07c9f7e65a1127cde7211ce3394a
Created July 7, 2024 20:52
Draft: Swift @propertyWrapper to execute given selector on value did change. Can be helpfull with UIViewKit
@propertyWrapper
public struct InvalidateBody<T> {
private var value: T
weak var storage: UIViewController?
let selector: Selector
public var wrappedValue: T {
get { value }
set {
@Adobels
Adobels / Demangle Swift
Created July 6, 2024 10:45 — forked from krzyzanowskim/Demangle Swift
Hopper Disassembler Swift names demangle script
import subprocess
def looksLikeBeginning(doc,seg,adr):
if isinstance(seg.getNameAtAddress(adr), str):
label = seg.getNameAtAddress(adr)
pos = label.find("_T")
if pos != -1:
return label[pos:]
return None
@Adobels
Adobels / gist:e7682bce150efe56e033d4d82c3f5522
Created June 28, 2024 09:46
generateImageOfLetterInRectangleOfSize
public static func generateImageOfLetterInRectangleOfSize(
letter: Character,
backgroundColor: UIColor,
letterColor: UIColor,
width: CGFloat,
height: CGFloat
) -> UIImage {
let size = CGSize(width: width, height: height)
let renderer = UIGraphicsImageRenderer(size: size)
let image = renderer.image { context in
@Adobels
Adobels / gist:1d83193857192dd3bfa93cb5e64859bb
Created September 21, 2023 19:52
Tappable Trapezoids and Rectangle UIView
import UIKit
class ShapeView: UIView {
private var topTrapezoidPath: UIBezierPath!
private var bottomTrapezoidPath: UIBezierPath!
private var leftTrapezoidPath: UIBezierPath!
private var rightTrapezoidPath: UIBezierPath!
private var rectanglePath: UIBezierPath!
created_at: Sun, 11 Jun 2023 13:31:06 GMT, Xcode 15.0.0-beta
Swift-macros quick notes
Related videos:
- [WWDC23 What’s new in Swift](https://developer.apple.com/videos/play/wwdc2023/10164)
- [WWDC23 Write Swift macros](https://developer.apple.com/videos/play/wwdc2023/10166)
- [WWDC23 Expand on Swift macros](https://developer.apple.com/videos/play/wwdc2023/10167)
It looks like:
@Adobels
Adobels / UIKitBuilder.swift
Created May 31, 2023 05:54
UIKitView builder + constraints
//
// ViewController.swift
// pocUIViewBuilder
//
// Created by MaxAir on 26/05/2023.
//
import UIKit
@resultBuilder
struct SubviewBuilder {
import UIKit
@resultBuilder
struct SubviewBuilder {
static func buildEither(first component: UIView) -> UIView {
print(#function + "2")
return component
}
static func buildEither(second component: UIView) -> UIView {
print(#function + "1")
@Adobels
Adobels / gist:8e84091f16ef2c6f1706b30e58aa5f72
Created November 29, 2022 15:49
git: print commits which changed a given file
git log --full-history -1 -- '*IdentifierTextField.swift'
usage examples:
- Find out in which commit a given file was deleted from project
@Adobels
Adobels / gist:0ff6a4f8f5528cc2578591db09fca7f5
Created November 29, 2022 15:46
Terminal: find file names with xib extension and get only file name component
find . -type f -name '*.xib' | rev | cut -d '/' -f1 | rev | cut -d '.' -f1
@Adobels
Adobels / gist:409261b06c4238e38f23a0475401cecd
Last active November 29, 2022 15:40
Xcode regex: find line with commented code
[/]{2}\h*(lazy|private|let|var|func|struct|class|enum|case)