Skip to content

Instantly share code, notes, and snippets.

@kconner
kconner / macOS Internals.md
Last active June 21, 2024 20:02
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@christianselig
christianselig / UIAlertController+Conversion.swift
Created September 3, 2021 18:14
Adding an image to a UIAlertController
extension UIAlertController {
/// Creates a view controller for notifying the user that a conversion is occurring. Accepts a block that is executed upon conversion completion.
static func createConvertingAlertController(onConversionCompletion: @escaping () -> Void) -> UIAlertController {
// The title font corresponds to Dynamic Type style "Headline"
let titleFont = UIFont.preferredFont(forTextStyle: .headline)
let calculatorImageView = UIImageView(image: UIImage(named: "calculator.fill", in: nil, with: UIImage.SymbolConfiguration(font: UIFont.systemFont(ofSize: titleFont.pointSize * 2.0, weight: .semibold))))
let measuringAttributedStringHeight = NSAttributedString(string: "Penguin", attributes: [.font: titleFont]).boundingRect(with: .zero, options: [.usesFontLeading, .usesLineFragmentOrigin], context: nil).height
let desiredOffset = 15.0 + calculatorImageView.bounds.height
let totalNewlinePrefixes = Int((desiredOffset / measuringAttributedStringHeight).
@jordansinger
jordansinger / iPod.swift
Created July 27, 2020 21:19
Swift Playgrounds iPod Classic
import SwiftUI
import PlaygroundSupport
struct iPod: View {
var body: some View {
VStack(spacing: 40) {
Screen()
ClickWheel()
Spacer()
}
@JohnSundell
JohnSundell / StarPlane.swift
Created July 8, 2020 22:41
A simple game written in SwiftUI. Note that this is just a fun little hack, the code is not meant to be taken seriously, and only works on iPhones in portrait mode.
// A fun little game written in SwiftUI
// Copyright (c) John Sundell 2020, MIT license.
// This is a hacky implementation written just for fun.
// It's only verified to work on iPhones in portrait mode.
import SwiftUI
final class GameController: ObservableObject {
@Published var plane = GameObject.plane()
@Published private(set) var clouds = [GameObject]()
@blessanm86
blessanm86 / german-driving-license.md
Last active June 3, 2024 04:41
Quick Ref Notes for German Driving License Test

This is unmaintained and was created for personal use. As I passed the exam I have no use to keep this up to date. Feel free to fork

What are the consequences for a person driving a motor vehicle under the influence of drugs (e.g. hashish, heroin, cocaine)?

[x] Confiscation of driving licence or driving ban
[x] Compulsory medical/psychological examination
[x] Fine and/or imprisonment

In which instances do you have to approach a pedestrian crossing with particular care?

@unnamedd
unnamedd / MacEditorTextView.swift
Last active May 26, 2024 17:49
[SwiftUI] MacEditorTextView - A simple and small NSTextView wrapped by SwiftUI.
/**
* MacEditorTextView
* Copyright (c) Thiago Holanda 2020-2021
* https://twitter.com/tholanda
*
* MIT license
*/
import Combine
import SwiftUI
@viniciussoares
viniciussoares / HtmlContentView.html
Last active June 28, 2019 13:57
A WebView that automatically resizes itself - iOS - Swift
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style>
@font-face {
font-family: 'Uni Neue';
src: local('Uni Neue'), url('UniNeueRegular.otf') format('opentype');
@jaisonv
jaisonv / Note.txt
Created November 25, 2017 02:17
Error running tests on framework when your framework has third party frameworks dependencies
When adding a third framework to yours you may face the following error if you try to run tests:
The bundle “[framework-name]Tests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
(dlopen_preflight([framework-path]): Library not loaded: @rpath/[third-framework-name].framework/[third-framework-name]
Referenced from: [derived-data-framework-path]
Reason: image not found)
Program ended with exit code: 82
This problem can be solved by adding "$(PROJECT_DIR)" to the "Runpath Search Paths" on the framework's Build Settings.
exec > /tmp/${PROJECT_NAME}_archive.log 2>&1
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"
@MoOx
MoOx / index.js
Last active February 9, 2024 22:44
Export/import github labels
// go on you labels pages
// eg https://github.com/cssnext/cssnext/labels
// paste this script in your console
// copy the output and now you can import it using https://github.com/popomore/github-labels !
var labels = [];
[].slice.call(document.querySelectorAll(".label-link"))
.forEach(function(element) {
labels.push({
name: element.textContent.trim(),