Skip to content

Instantly share code, notes, and snippets.

View insidegui's full-sized avatar

Guilherme Rambo insidegui

View GitHub Profile
@insidegui
insidegui / lsremovearchives.sh
Created December 21, 2021 18:28
Remove Xcode app archives from macOS LaunchServices database
#!/bin/bash
# Recursivelly removes all apps from your Xcode archives from the LaunchServices database, preventing them from being used for widgets, launch at login, etc.
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -R -f -u $HOME/Library/Developer/Xcode/Archives
@insidegui
insidegui / ScrollViewOffsetModifier.swift
Created July 20, 2021 20:28
A SwiftUI ViewModifier that can be used to read a ScrollView's offset and store it into a @State property of the view
struct ScrollViewOffsetPreferenceKey: PreferenceKey {
static var defaultValue: CGPoint = .zero
static func reduce(value: inout CGPoint, nextValue: () -> CGPoint) {
value = nextValue()
print("value = \(value)")
}
typealias Value = CGPoint
@insidegui
insidegui / statusbarfix.sh
Created March 16, 2021 23:04
Alias called "statusbarfix" which will update the status bar on any iOS Simulator that's currently running to look better for marketing images
alias statusbarfix='xcrun simctl status_bar booted override --time 9:41 --cellularMode active --cellularBars 4 --batteryState charging --operatorName ""'
import UIKit
import Combine
import CoreData
import OSLog
public typealias CoreDataModelTransformer<T: NSManagedObject, M: Hashable> = (T) -> M?
public final class CoreDataAdapter<T: NSManagedObject, M: Hashable>: NSObject, NSFetchedResultsControllerDelegate {
private let logger = Logger(subsystem: "codes.rambo.CombineCoreData", category: "CoreDataAdapter")
@insidegui
insidegui / Data+Compression.swift
Created July 21, 2020 15:01
A wrapper for compression/decompression of Swift Data using Apple's Compression framework.
/// Created by Gui Rambo
/// This wraps Apple's Compression framework to compress/decompress Data objects.
/// It will use Compression's modern API for iOS 13+ and its old API for older versions.
/// For more information, check out Apple's documentation: https://developer.apple.com/documentation/compression
/*
Copyright 2020 Guilherme Rambo
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
import UIKit
import MobileCoreServices
/// Helps with the presentation and handling of the chibi picker from ChibiStudio.
final class ChibiPicker {
static let shared = ChibiPicker()
/// This is the URL ChibiStudio will open in your app after the user has picked a chibi,
/// make sure it is properly configured in your app's Info.plist and that you have added
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.is.workflow.my.workflows</string>
</array>
<key>get-task-allow</key>
This file has been truncated, but you can view the full file.
//
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#pragma mark Blocks
typedef void (^CDUnknownBlockType)(void); // return type and parameters are unknown
@insidegui
insidegui / gist:a18124c0c573a4eb656f5c485ea7dae4
Last active March 29, 2024 07:46
Unofficial documentation for the iCloud Apple device image URL format
https://statici.icloud.com/fmipmobile/deviceImages-9.0/iPhone/iPhone9,4-2-3-0/online-infobox__3x.png
A B C D E F G
A: deviceImages version seems to determine the format of the image specifier (C, D, E, F)
B: device marketing name
C: device model identifier
D: color cover glass (front color)
1 - Black
2 - White
E: device enclosure color (back color)
@insidegui
insidegui / iBridge2_1_devtree.txt
Created March 10, 2018 15:38
iBridge 2,1 device tree
dtre
Device Tree with 19 properties and 10 children
Properties:
device-tree:
| +--name 12 bytes: device-tree
| +--target-type 5 bytes: J137
| +--mlb-serial-number 29 bytes: syscfg/MLB#/0x20,zeroes/0x20
| +--compatible 27 bytes: J137AP
| +--secure-root-prefix 3 bytes: md
| +--AAPL,phandle 4 bytes: 1