Skip to content

Instantly share code, notes, and snippets.

View frozendevil's full-sized avatar

Izzy frozendevil

View GitHub Profile
@marcpalmer
marcpalmer / Floating.swift
Created January 14, 2024 19:48
Modifiers for animating views from one place to another in the view hierarchy, even if the clipping changes
//
// Floating.swift
// Captionista
//
// Created by Marc Palmer on 24/02/2023.
//
import SwiftUI
/// Set to true for debug prints.
private var debug = false
@colejd
colejd / Davider.swift
Last active January 27, 2022 19:07
Horizontal SwiftUI divider with content embedded in center
/// Embeds its content between two horizontal dividers.
struct Davider<Content: View>: View {
let content: Content
init(@ViewBuilder content: () -> Content) {
self.content = content()
}
var body: some View {
HStack {
@byte-sourcerer
byte-sourcerer / MacEditorTextView.swift
Created October 31, 2021 10:46
An NSTextView wrapped by SwiftUI with TextKit 2
/**
* MacEditorTextView
* Copyright (c) Thiago Holanda 2020-2021
* https://twitter.com/tholanda
*
* MIT license
* Modified by https://github.com/cjwcommuny for TextKit 2
*/
import Combine
@kylehughes
kylehughes / TornRectangle.swift
Last active May 7, 2024 07:17
A rectangle shape for SwiftUI that can render any edge like a torn piece of paper.
// Copyright 2021 Kyle Hughes
//
// 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 all copies or substantial portions of the
// Software.
//
@jklausa
jklausa / xcode-curl.sh
Last active April 20, 2022 14:24
curl Xcode
#!/bin/bash
# Useful for downloading Xcode on machines where you don't want to log-in with your Apple ID (e.g. CI
# machines, or other low-trust environemnts).
# Requires you to manually log-in to the Apple Dev Portal, and extract contents of the ADCDownloadAuth cookie
# (easiest way to do it is using Web Inspector, going to the "Storage" Pane, selecting "Cookies" in the left sidebar,
# and copying the appropriate value.
#
# Usage:
# curl https://gist.githubusercontent.com/jklausa/5780d5126d97f73b70a91aeab58f7f4a/raw/ | bash -s -- XCODE-URL COOKIE_VALUE
@mmozeiko
mmozeiko / shader.hlsl
Last active November 7, 2024 20:23
compute shader for rendering monospaced glyphs in grid
//
struct TerminalCell
{
// cell index into GlyphTexture, should be two 16-bit (x,y) values packed: "x | (y << 16)"
uint GlyphIndex;
// 0xAABBGGRR encoded colors, nonzero alpha for Foreground indicates to render colored-glyph
// which means use RGB values from GlyphTexture directly as output, not as ClearType blending weights
uint Foreground;
@IanKeen
IanKeen / Example_Complex.swift
Last active September 10, 2024 11:53
PropertyWrapper: @transaction binding for SwiftUI to make changes to data supporting commit/rollback
struct User: Equatable {
var firstName: String
var lastName: String
}
@main
struct MyApp: App {
@State var value = User(firstName: "", lastName: "")
@State var showEdit = false
@shaps80
shaps80 / AVPlayer+Scrubbing.swift
Last active October 22, 2024 07:48
Enables smooth frame-by-frame scrubbing (in both directions) – similar to Apple's applications.
public enum Direction {
case forward
case backward
}
internal var player: AVPlayer?
private var isSeekInProgress = false
private var chaseTime = kCMTimeZero
private var preferredFrameRate: Float = 23.98

in /Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/XCLanguageSupport.xcplugin/Contents/Resources/Swift.xcspec find the dictionary with identifier com.apple.xcode.tools.swift.compiler and under options add this:

{
	Name = "SWIFT_DEBUG_TIME_FUNCTION_BODIES";
	Type = Boolean;
	DefaultValue = YES;
	CommandLineArgs = {
		YES = (
			"-Xfrontend", "-debug-time-function-bodies",

);