Skip to content

Instantly share code, notes, and snippets.

View m1guelpf's full-sized avatar

Miguel Piedrafita m1guelpf

View GitHub Profile
@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 February 13, 2026 12:02
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
@samhenrigold
samhenrigold / q&a.md
Created June 11, 2025 02:07
WWDC25 Camera/Photos Group Lab Q&A

What’s the first class way to use PhotoKit to reimplement a high performance photo grid? We’ve been using a LazyVGrid and the photos caching manager, but are never able to hit the holy trinity (60hz, efficient memory footprint, minimal flashes of placeholder/empty cells)

A few things. It sounds like you're using the PHCachingImageManager already, which is definitely recommended.

One kind of specific note there—you want to use that to get media content delivered before you need to display it. So, for example, let's say you're showing a large grid of photos. You can be prefetching before and after, in expectation that the user's going to scroll. Or, if you're in a one-up situation, prefetching left and right so that you know the user is likely going to swipe, and you can quickly deliver those images to the screen and cache them.

Another thing you should really make sure you're doing is specifying the size you need for the grid size. For example, if your app supports showing a smaller grid

import UIKit
import CoreImage
public extension UIImage {
/// Draws a rounded, solid‐color outline around this image’s alpha shape,
/// then composites the full-color image back in the center.
///
/// - Parameters:
/// - strokeColor: the color of the ring
/// - strokeWidth: the thickness of the ring (in points)