Great series of short articles introducing Apple's Metal framework.
- 2022-04-01: Day 1: Devices
- 2022-04-02: Day 2: Buffers
- 2022-04-03: Day 3: Commands
- 2022-04-04: Day 4: MTKView
- 2022-04-05: Day 5: Shaders
- 2022-04-06: Day 6: Pipelines
// Some Swift code for different ways to find the current username on macOS. | |
// | |
// You can run this in a Playground, or compile it with `swiftc`. Compiling | |
// it will let you experiment with different ways of running the command. | |
print("********** Foundation Usernames **********") | |
// If you are only importing Foundation you have a few options to get the current user. | |
// Note that if run from the CLI they will report the CLI user running them. | |
import Foundation |
#!/usr/local/bin/bash | |
export BORG_REPO="ssh://user@server/borg-repo" | |
if [[ ! "${USER}" == "root" ]]; then | |
echo Start this script as root | |
exit 1 | |
fi | |
echo === Present snapshots === |
Great series of short articles introducing Apple's Metal framework.
#!/usr/bin/env osascript -l JavaScript | |
function run(_) { | |
const pid = $.NSRunningApplication.runningApplicationsWithBundleIdentifier( | |
'com.microsoft.VSCode', | |
).firstObject.processIdentifier; | |
// Bring all VSCode windows to the current Mission Control view. | |
$.CGSProcessAssignToAllSpaces($.CGSMainConnectionID(), pid); |
#!/usr/bin/env osascript -l JavaScript | |
/** | |
* ----------------------------------------------------------------------------- | |
* Activate Sidecar/Screen Mirroring from Control Center | |
* ----------------------------------------------------------------------------- | |
* | |
* Created on February 17, 2023 by Stephan Casas | |
* Updated on May 18, 2023 by Stephan Casas | |
* |
From Jonathan Dietz, Jr.:
Almost all new displays employ VESA Coordinated Video Timings using Reduced Blanking Timing Version 2 (CVT-RBv2) which adds a small amount of overhead to the video signal. This overhead includes 80 additional horizontal pixels and enough additional lines to meet the 460 µs minimum vertical blanking interval requirement. You can download an Excel spreadsheet from VESA that will do all the calculations for you, but the math is pretty simple:
460 / ((1000000 / [refresh rate in Hz] - 460) / [vertical resolution])
To get an integer number of lines, you round this result down and add 1. So for Pro Display XDR resolution at 120 Hz that would work out to:
460 / (1000000 / 120 - 460) / 3384) = 197.710 = 198 additional lines
<!-- | |
When an input element gets focused, iOS Safari tries to put it in the center by scrolling (and zooming.) | |
Zooming can be easily disabled using a meta tag, but the scrolling hasn't been quite easy. | |
The main quirk (I think) is that iOS Safari changes viewport when scrolling; i.e., toolbars shrink. | |
Since the viewport _should_ change, it thinks the input _will_ move, so it _should_ scroll, always. | |
Even times when it doesn't need to scroll—the input is fixed, all we need is the keyboard— | |
the window always scrolls _up and down_ resulting in some janky animation. | |
However, iOS Safari doesn't scroll when the input **has opacity of 0 or is completely clipped.** |
import UIKit | |
import MobileCoreServices.UTCoreTypes | |
if #available(iOS 14.1, *) { | |
let input = Bundle.main.url(forResource: "IMG_0037", withExtension: "HEIC")! | |
let output = FileManager().temporaryDirectory.appendingPathComponent("IMG_0037.GAIN_MAP.BMP") | |
let source = CGImageSourceCreateWithURL(input as CFURL, nil)! | |
// urn:com:apple:photo:2020:aux:hdrgainmap | |
let dataInfo = CGImageSourceCopyAuxiliaryDataInfoAtIndex(source, 0, kCGImageAuxiliaryDataTypeHDRGainMap)! as Dictionary |
ℹ️ Enable iCloud end-to-end encryption:
System settings
→ Apple ID
→ iCloud
→ Set Advanced Data Protection
to On
.System settings
→ Apple ID
→ iCloud
→ Disable Access iCloud Data on the Web
.