Skip to content

Instantly share code, notes, and snippets.

View colejd's full-sized avatar
🆒
beans

Jonathan Cole colejd

🆒
beans
View GitHub Profile
@colejd
colejd / ModalView.swift
Last active August 9, 2023 03:05
NSView that closes itself when clicking outside
// MIT License - © 2017 Jonathan Cole.
import Cocoa
/**
A view with the ability to hide itself if the user clicks outside of it.
*/
class ModalView: NSView {
private var monitor: Any?
@colejd
colejd / UIColor+UnsafeSwizzlingRandomizer.swift
Last active August 10, 2018 00:30
Swizzles in a randomized color block in place of the cgColor getter on UIColor, randomizing every color throughout the app. This WILL get you rejected from the App Store.
public extension UIColor {
private struct StaticVars {
// Names of classes to swizzle. Derived from dumped private headers.
static let classesToSwizzle: [String] = [
"UIColor",
"UIDeviceRGBColor",
"NSColor",
"UIDisplayP3Color",
"UIPlaceholderColor",
@colejd
colejd / UIColor+SafeishSwizzlingRandomizer.swift
Last active August 10, 2018 00:28
Swizzles in a randomized color block in place of the cgColor getter on UIColor, randomizing most colors throughout the app.
public extension UIColor {
private static let rzl_swizzleImplementation: Void = {
let instance: UIColor = UIColor.red // This is a `UICachedDeviceRGBColor` instance. For some reason you have to use red.
let _class: AnyClass! = object_getClass(instance)
let originalMethod = class_getInstanceMethod(_class, #selector(getter: cgColor))
let swizzledMethod = class_getInstanceMethod(_class, #selector(rzl_randomCGColor))
@colejd
colejd / UIColor+InvasiveSwizzlingRandomizer.swift
Last active August 13, 2018 15:20
Swizzles in a randomized color block in place of the cgColor getter on UIColor, randomizing every color throughout the app.
import Foundation
/*
██████╗ █████╗ ███╗ ██╗ ██████╗ ███████╗██████╗ ███████╗ ██████╗ ███╗ ██╗███████╗
██╔══██╗██╔══██╗████╗ ██║██╔════╝ ██╔════╝██╔══██╗ ╚══███╔╝██╔═══██╗████╗ ██║██╔════╝
██║ ██║███████║██╔██╗ ██║██║ ███╗█████╗ ██████╔╝ ███╔╝ ██║ ██║██╔██╗ ██║█████╗
██║ ██║██╔══██║██║╚██╗██║██║ ██║██╔══╝ ██╔══██╗ ███╔╝ ██║ ██║██║╚██╗██║██╔══╝
██████╔╝██║ ██║██║ ╚████║╚██████╔╝███████╗██║ ██║ ███████╗╚██████╔╝██║ ╚████║███████╗
╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝
*/
@colejd
colejd / userChrome.css
Created February 12, 2019 20:54
UserChrome for hiding tab bar in conjunction with the Tree Tabs extension
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
/* Hide all tabs (but not tab bar) when windowed. Preserves area for window controls (tested on macOS). */
/*#TabsToolbar {
visibility: collapse !important;
}*/
/* Hide the whole tab bar in fullscreen */
#TabsToolbar[inFullscreen] {
visibility: collapse !important;
@colejd
colejd / San Francisco internal variant names.txt
Created September 16, 2019 15:40
San Francisco Internal Font Variants (dumped from Xcode 10)
.SFUI-Black
.SFUI-BlackItalic
.SFUI-Bold
.SFUI-BoldItalic
.SFUI-Heavy
.SFUI-HeavyItalic
.SFUI-Light
.SFUI-LightItalic
.SFUI-Medium
.SFUI-MediumItalic
əˈkɔrdɪŋ tu ɔl noʊn lɔz
ʌv ˌeɪviˈeɪʃən,
ðɛr ɪz noʊ weɪ ə bi
ʃʊd bi ˈeɪbəl tu flaɪ.
ɪts wɪŋz ɑr tu smɔl tu gɛt
ɪts fæt ˈlɪtəl ˈbɑdi ɔf ðə graʊnd.
echo "Building for iOS..."
xcodebuild archive \
-sdk iphoneos IPHONEOS_DEPLOYMENT_TARGET=9.0 \
-arch armv7 -arch arm64 \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
-scheme "ExampleLibrary" \
-archivePath "./build/iphoneos/ExampleLibrary.xcarchive" SKIP_INSTALL=NO
@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 {
@colejd
colejd / PinningToCorner.swift
Created January 28, 2022 18:20
SwiftUI View that fills space and pins its contents to a given corner
//
// PinningToCorner.swift
// No license, go wild.
//
import SwiftUI
struct PinningToCorner<Content: View>: View {
enum Corner {
case topLeading