Skip to content

Instantly share code, notes, and snippets.

View jormungand's full-sized avatar

Ilya Stroganov jormungand

View GitHub Profile
import SwiftUI
struct AccessibleView: View {
@ScaledMetricCustom(relativeTo: .title) var someSize: CGFloat = 100
@ScaledFont(customFontName: "TimesNewRomanPS-BoldMT", size: 18, relativeTo: .body) var bodyFont
var body: some View {
VStack {
Rectangle()
.frame(width: someSize, height: someSize)
@ddunbar
ddunbar / deployable-artifacts.md
Last active June 27, 2021 07:46
Deployable Artifacts thoughts

My hopes for deployable artifacts:

  1. Packages would be able to just describe how the things they build should get laid out in a tarball.
  2. We would implement this as part of the build, it should be super fast (we might want to consider actually generating the tar directly for portability & control purposes).
  3. Packages could have control over the permissions inside the tar file (ideally without having to manipulate the permissions in the filesystem, problematic sometimes if root permission in the tar is desired).
  4. The mechanism would support knowing how to handle RPATH issues.
  5. The mechanism would know how to handle libswift* portability issues.
  6. The mechanism would know how to handle cross-Linux distro issues.
  7. Unlike below, I wouldn't expect the mechanism to handle the GIT REVISION stuff, that belongs in a separate proposal.
  8. The mechanism would support typical Unix-y things, like bin, lib, libexec, share.
  9. The mechanism could support vendored assets like other DSOs or frameworks that can't l
@mattt
mattt / UIViewControllerPreview.swift
Last active January 8, 2024 23:09
Generic structures to host previews of UIView and UIViewController subclasses.
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
@norio-nomura
norio-nomura / building-yams-using-xcodebuild-without-xcodeproj.sh-session
Last active August 3, 2023 10:56
[Xcode 11] Building Yams using `xcodebuild` without `.xcodeproj` with `-destination "name=iPhone 8"`
➜ 15:27:26 git clone https://github.com/jpsim/Yams.git
Cloning into 'Yams'...
remote: Enumerating objects: 111, done.
remote: Counting objects: 100% (111/111), done.
remote: Compressing objects: 100% (80/80), done.
remote: Total 3987 (delta 58), reused 71 (delta 31), pack-reused 3876
Receiving objects: 100% (3987/3987), 4.24 MiB | 1.85 MiB/s, done.
Resolving deltas: 100% (2313/2313), done.
➜ 15:27:43 cd Yams
➜ 15:27:46 git:(master) rm -rf Yams.xcodeproj
@NachoMan
NachoMan / architectures
Last active May 9, 2020 13:55
Multi-Architecture helper scripts
#!/bin/sh
function architectures() {
if $(lipo -info $1 | grep -q 'not a fat file'); then
lipo -info $1 | awk -F ': ' '/Non-fat file/ { print $3 }'
else
lipo -detailed_info $1 | awk '/^architecture / { print $2 }'
fi
}
@gabonator
gabonator / WebSocketServer.cpp
Created March 31, 2018 19:31
ESP8266 based Wifi CNC controller: http server, websocket server, embedded html resources
//#define DEBUGGING
#include "WebSocketServer.h"
#include "crypto.h"
bool WebSocketServer::handshake(Client &client) {
socket_client = &client;
// If there is a connected client->
if (socket_client->connected()) {
// Check request and look for websocket handshake
#ifdef DEBUGGING
@onevcat
onevcat / Delegate.swift
Last active December 23, 2022 07:21
An auto-weak delegate for handle modern delegate pattern.
import Foundation
/// A class that keeps a weakly reference for `self` when implementing `onXXX` behaviors.
/// Instead of remembering to keep `self` as weak in a stored closure:
///
/// ```swift
/// // MyClass.swift
/// var onDone: (() -> Void)?
/// func done() {
/// onDone?()
As of iOS 11/macOS High Sierra, and only including ones in Foundation and CoreFoundation
Strings:
_NSCFString - a CFStringRef or CFMutableStringRef. This is the most common type of string object currently.
- May have 8 bit (ASCII) or 16 bit (UTF-16) backing store
_NSCFConstantString - a compile time constant CFStringRef, like you'd get with @"foo"
- May also be generated by dynamic string creation if matches a string in a pre-baked table of common strings called the StringROM
NSBigMutableString - an NSString backed by a CFStorage (https://github.com/opensource-apple/CF/blob/master/CFStorage.h) for faster handling of very large strings
NSCheapMutableString - a very limited NSMutableString that allows for zero-copy initialization. Used in NSFileManager for temporarily wrapping stack buffers.
@gravitylow
gravitylow / codesign_gdb.md
Last active April 16, 2024 02:18 — forked from hlissner/codesign_gdb.md
Codesign gdb on macOS

If you are getting this in gdb on macOS while trying to run a program:

Unable to find Mach task port for process-id 57573: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
  1. Open Keychain Access
  2. In menu, open Keychain Access > Certificate Assistant > Create a certificate
  3. Give it a name (e.g. gdbc)
@maciekish
maciekish / resetXcode.sh
Created August 10, 2016 10:13
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches. You can thank me later.
#!/bin/bash
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
open /Applications/Xcode.app