Skip to content

Instantly share code, notes, and snippets.

@macshome
macshome / EnvironmentVariables.swift
Created May 2, 2024 12:48
A playground to see different ways to get environment variables in Swift
import Foundation
// A playground to see different ways to get environment variables in Swift
// Foundation is the easiest way using the awesome ProcessInfo class.
// Get all of the environment variables for your running process in a Dictionary.
let foundationEnv = ProcessInfo().environment
print("********** ProcessInfo Environment **********")
@chockenberry
chockenberry / ContentView.swift
Created April 12, 2024 17:58
Optional Bindable
//
// ContentView.swift
// BindableOptional
//
// Created by Craig Hockenberry on 4/12/24.
//
import SwiftUI
@Observable
@thesamesam
thesamesam / xz-backdoor.md
Last active May 4, 2024 09:26
xz-utils backdoor situation (CVE-2024-3094)

FAQ on the xz-utils backdoor (CVE-2024-3094)

This is a living document. Everything in this document is made in good faith of being accurate, but like I just said; we don't yet know everything about what's going on.

Background

On March 29th, 2024, a backdoor was discovered in xz-utils, a suite of software that

@OrionReed
OrionReed / dom3d.js
Last active May 10, 2024 17:16
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@stephancasas
stephancasas / NSApplication+NSResponderDebug.swift
Created March 18, 2024 20:35
An extension on NSApplication providing a computed property that describes the current responder chain.
//
// NSApplication+NSResponderDebug.swift
//
// Created by Stephan Casas on 3/18/24.
//
import Cocoa;
extension NSApplication {
@dskuza
dskuza / SafariLink.swift
Created January 7, 2024 19:41
SFSafariViewController in SwiftUI
import SwiftUI
#if os(iOS)
import UIKit
struct BranchPickerButton: UIViewRepresentable {
public var title: String = ""
public let producer: () async throws -> [(String, String)]
@Binding public var value: String
@leogdion
leogdion / NSWindowAdaptorModifier.swift
Created August 17, 2023 21:49
Allow SwiftUI to modifier NSWindow
//
// NSWindowAdaptorModifier.swift
// Copyright (c) 2023 BrightDigit.
//
import AppKit
import Foundation
import SwiftUI
// swiftlint:disable strict_fileprivate
@nicolas17
nicolas17 / gist:559bec0d8e636f93f62cca844ee94ada
Last active December 13, 2023 11:08
Apple IDS payload keys
c: command
cc: commandContext
v: version
P: payload
N: bulkedPayload
fP: fanoutPayload
aP: additionalPayload
Pm: payloadMetadata
i: messageId
U: messageUUID
@marcoarment
marcoarment / Text+InlineSymbol.swift
Last active October 26, 2023 17:13
SwiftUI Text with inline SF Symbols
import SwiftUI
extension Text {
public struct InlineSymbol {
public let name: String
public let accessibilityLabel: String
public let color: Color?
public init(name: String, accessibilityLabel: String, color: Color? = nil) {
self.name = name