Skip to content

Instantly share code, notes, and snippets.

View m1guelpf's full-sized avatar

Miguel Piedrafita m1guelpf

View GitHub Profile
@vistar941
vistar941 / ViewController.swift
Last active July 25, 2026 11:45
Work around UIButton limitations using only public APIs.
import UIKit
final class MenuControl: UIControl {
private let label: UILabel = {
let label = UILabel()
label.text = "Public API-Only Menu"
label.font = .boldSystemFont(ofSize: 15)
label.textAlignment = .center
label.textColor = .white
@Kyle-Ye
Kyle-Ye / CAHostingLayer.md
Last active July 15, 2026 10:08
Using CAHostingLayer in SwiftUI — access SwiftUI's SPI CALayer without Apple internal SDK

Using CAHostingLayer in SwiftUI

Background

SwiftUI provides more than just UIHostingController / _UIHostingView (iOS) and NSHostingController / NSHostingView (macOS) for embedding SwiftUI views into UIKit/AppKit.

Starting from iOS 18.0 / macOS 15.0, SwiftUI also offers CAHostingLayer<Content: View> — a CALayer subclass that can host SwiftUI content directly at the layer level. This API is currently marked as SPI (@_spi(ForUIKitOnly) / @_spi(ForAppKitOnly)) and is used internally by UIKit, AppKit, and WebKit.

Accessing CAHostingLayer without Apple Internal SDK

@stephancasas
stephancasas / NSAlert+NSTextField.swift
Last active March 3, 2026 10:25
An extension on `NSAlert` for `NSTextField` drawing/management
//
// NSAlert+NSTextField.swift
//
// Created by Stephan Casas for OpenAI on 2/26/26.
//
import Foundation
import AppKit
extension NSAlert {
@sebjvidal
sebjvidal / UIImage+BarButtonImage.swift
Created February 19, 2026 10:42
UIBarButtonItem Image and Title
import UIKit
extension UIImage {
static func barButtonImage(title titleText: String, showsBadge: Bool) -> UIImage {
let badgeView = UIImageView()
badgeView.image = .badge
badgeView.isHidden = showsBadge == false
badgeView.preferredSymbolConfiguration = UIImage.SymbolConfiguration(textStyle: .footnote)
let titleTextLabel = UILabel()
@maple3142
maple3142 / CVE-2025-55182.http
Last active July 17, 2026 03:58
CVE-2025-55182 React Server Components RCE POC
POST / HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Next-Action: x
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Length: 459
------WebKitFormBoundaryx8jO2oVc6SWP3Sad
Content-Disposition: form-data; name="0"
@Archetapp
Archetapp / SplitView.swift
Last active November 2, 2025 21:32
A split view similar to Abode. (Added keyboard avoidance logic.)
import SwiftUI
// MARK: - Component
fileprivate struct SplitViewConfig {
let topDetentRatio: CGFloat
let bottomDetentRatio: CGFloat
let elasticThreshold: CGFloat
let elasticResistance: CGFloat
let snapThreshold: CGFloat
#include <metal_stdlib>
#include <SwiftUI/SwiftUI.h>
using namespace metal;
float2 distort(float2 uv, float strength) {
float2 dist = 0.5 - uv;
uv.x = (uv.x - dist.y * dist.y * dist.x * strength);
uv.y = (uv.y - dist.x * dist.x * dist.y * strength);
return uv;
@jsmmth
jsmmth / ContentView.swift
Last active July 26, 2025 18:59
SwiftUI Animated Dashed Border
import SwiftUI
struct AnimatedBorder: View {
@State private var phase: CGFloat = 0
let cornerRadius: CGFloat = 25
let dashPattern: [CGFloat] = [15, 15]
let lineWidth: CGFloat = 4
var body: some View {
ZStack {
@jsmmth
jsmmth / Swift UI StarField Experiment
Created July 13, 2025 15:46
Pretty messy, probably quite un-optimised fun SwiftUI star field experiment.
import SwiftUI
import MetalKit
import simd
// MARK: - Metal View
struct MetalStarfieldView: UIViewRepresentable {
@Binding var speed: Double
@Binding var cameraShake: CGSize
let hyperdriveCallback: () -> Void
@ariankordi
ariankordi / FFLTestingThumbProvider.cpp
Created July 13, 2025 01:29
Mii thumbnailer for Windows PoC using the FFL-Testing Mii renderer server
/**
* \file FFLTestingThumbProvider.cpp
* \author Arian Kordi (https://github.com/ariankordi)
* \date 2025/07/12
*
* \brief Windows thumbnail provider for Mii data files using
* the FFL-Testing Mii renderer server: https://github.com/ariankordi/FFL-Testing
* \details Requires setting up and running on default port of 12346.
* Not ideal for real use. Should be considered a proof-of-concept/toy.
* https://github.com/ariankordi