Skip to content

Instantly share code, notes, and snippets.

View zats's full-sized avatar

Sash Zats zats

View GitHub Profile
@zats
zats / values_scaling.md
Last active October 22, 2023 22:41
Scaling values proportional to font in SwiftUI

Context

In UIKit we have access to a bunch of useful methods on UIFont such as UIFontMetrics.scaledValue(…) it allows to convert value to proportional one when user adjusts the dynamic size settings This is currently not support in SwiftUI, following extensions should help

TL;DR this method only works for system text styles which is more than I need for my app

public extension UIFont {
    convenience init(_ font: Font) {
@zats
zats / square_image.md
Last active May 15, 2025 08:23
Square image container

Image in a square container

It took me way too long to figure out how to achieve following:

image

Key points to call out:

I wanted API to look something like

@zats
zats / ContentView.swift
Last active January 24, 2026 23:59
Internal SF Symbols
struct ContentView: View {
var body: some View {
let names = [
["appstore.app.dashed", "buildings.3d", "emoji.chicken.face"],
["person.text.rectangle.and.nfc", "secure.element", "laugh.bubble.tapback.2.he"],
["apple.news", "apple.podcasts.square.stack", "apple.slice"],
]
VStack(spacing: 20) {
Grid(horizontalSpacing: 20, verticalSpacing: 20) {
ForEach(names, id: \.self) { nameRow in
@zats
zats / readme.md
Created October 12, 2023 03:08
Private SF Symbols

List of all the images in /Library/Developer/CoreSimulator/Volumes/iOS_21A328/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/SFSymbols.framework/CoreGlyphsPrivate.bundle/Assets.car

NSBundle *const sfSymbolsBundle = [SFSCoreGlyphsBundle private];
_UIAssetManager *const assetManager = [_UIAssetManager assetManagerForBundle:sfSymbolsBundle];
UIImage *const image = [assetManager imageNamed:@"apple.breathe"];
@zats
zats / EnableVoiceOver.m
Last active September 24, 2023 16:46
Set voice over enabled with private API - not for AppStore
static void _setVoiceOver(BOOL enabled) {
NSString* const accessibilityUtilitiesPath = [[NSBundle bundleForClass:UIApplication.class]
.bundleURL
.URLByDeletingLastPathComponent
.URLByDeletingLastPathComponent
URLByAppendingPathComponent:@"PrivateFrameworks/AccessibilityUtilities.framework/AccessibilityUtilities"]
.relativePath;
void* handler = dlopen([accessibilityUtilitiesPath cStringUsingEncoding:NSUTF8StringEncoding], RTLD_NOW);
if (!handler) {
return;
@zats
zats / REMAP_M1_KEYS.MD
Last active July 15, 2025 05:54
Apple M1 MacBook Do Not Disturb Key remapping

Following is a sample of LaungAgent that remaps do not disturb key to Siri (I am using Type to Siri)

This is a lightweight solution not relying on external apps.

Setting up

  1. Create ~/Library/LaunchAgents/com.local.KeyRemapping.plist
  2. Edit it to have following content
@zats
zats / EmojiTokensLoader.m
Last active November 22, 2023 15:52
[WIP] Emoji tokens - word matching with emojis as of macOS 12.1. So far only found a list of tokens, gotta find a mapping to the emojis
[[NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/EmojiFoundation.framework"] load];
EMFDefaultAutocompleteCandidateProvider *provider = [[EMFDefaultAutocompleteCandidateProvider alloc] initWithBundle:bundle];
[provider tokens]; // returns all the tokens recognized as emojis
@zats
zats / ApplePodcastToOMPL.js
Last active March 11, 2026 17:17
Export OPML from Apple Podcasts app on macOS
#!/usr/bin/env node
const { exit } = require('process');
const PREDEFINED_PATH = "~/Library/Group Containers/243LU875E5.groups.com.apple.podcasts/Documents/MTLibrary.sqlite";
const XML_TEMPLATE = `<?xml version="1.0"?>
<!-- example OPML file -->
<opml version="1.0">
<head>
<title>Overcast Podcast Subscriptions</title>
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, DBGInterfaceStyleOverride) {
DBGInterfaceStyleOverrideNone = 0,
DBGInterfaceStyleOverrideLight,
DBGInterfaceStyleOverrideDark,
};
#ifdef __cplusplus
extern "C" {
@zats
zats / presenting.md
Last active July 6, 2018 13:02
Takeaways from "Presenting Design Work" - WWDC sessions 2018 https://developer.apple.com/videos/play/wwdc2018/811/

The presenter

Clarify your objectives

  • Establish your goals
  • Identify the questions you need answered
  • Understand the objective of your audiences
  • Don't dive into details before clarifying bigger picture

Embrace feedback

  • Take all feedback seriously even if disagree
  • Clarify the problems identified by the audience - separate problems highlighted from (potentially) invalid solutions suggested
  • Be willing to change your position