Skip to content

Instantly share code, notes, and snippets.

View MarkVillacampa's full-sized avatar
:octocat:
just setting up my gthb

Mark Villacampa MarkVillacampa

:octocat:
just setting up my gthb
View GitHub Profile
@import Darwin;
@import ObjectiveC;
@import CloudKit;
extern bool GEOConfigGetBOOL(int feature, void* something);
// Hooks feature flags in a resigned Maps.app to return true.
// Usage:
// clang -shared -fmodules -o libmaps_inject.dylib maps_inject.m \
// "$(xcrun
@nicklockwood
nicklockwood / CodableVersioning.swift
Last active January 29, 2024 11:31
Example demonstrating how to use versioning for Codable structs
// This gist demonstrates how you can implement versioning for a Codable struct to support loading
// old serialized data after changing the structure. Notable features of this solution:
//
// * No need to make new properties optional, or to perform post-processing on the struct after
// loading in ordeer to populate missing values
// * No need to change the call site - from the outside this struct behaves just the same
// as if we had implemented codable directly in the normal way.
// * Versioning can be applied individually to parents or leaves in a larger tree of
// structs without affecting the other elements
// * This approach will work even if the original struct was not designed with versioning in mind
@krzyzanowskim
krzyzanowskim / class_Equatable.swift
Created January 14, 2021 19:24
Swift class Equatable need check parent class
class A: Equatable {
let name: String
init(name: String) {
self.name = name
}
static func ==(lhs: A, rhs: A) -> Bool {
return lhs.name == rhs.name
}
// Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e
// by @levelsio
// HOW TO
// 1) Make a Google Sheet, we'll pull the first cell e.g. A1
// 2) Publish your Google Sheet, File -> Publish To Web
// 3) Copy the SHEET_ID in the URL, put it in here below:
const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"
// 4) Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188
// 5) Copy this entire script in to Scriptable (tip: you can send it to your iPhone via Whatsapp/Messenger/Telegram etc)
@zhuowei
zhuowei / WDBSetWebSecurityEnabled.m
Created September 1, 2020 04:47
Disable same-origin policy on iOS WKWebView with private API.
// Allows disabling Same-Origin Policy on iOS WKWebView.
// Tested on iOS 12.4.
// Uses private API; obviously can't be used on app store.
@import WebKit;
@import ObjectiveC;
void WKPreferencesSetWebSecurityEnabled(id, bool);
@interface WDBFakeWebKitPointer: NSObject
@steipete
steipete / OSLogStream.swift
Last active December 21, 2024 15:11
Access streaming OSLogStore at runtime with SPI. (FB8519418) https://steipete.com/posts/logging-in-swift/
//
// OSLogStream.swift
// LoggingTest
//
// Created by Peter Steinberger on 24.08.20.
//
// Requires importing https://github.com/apple/llvm-project/blob/apple/master/lldb/tools/debugserver/source/MacOSX/DarwinLog/ActivityStreamSPI.h via bridging header
import Foundation
import Combine
import Foundation
let c = Publishers
.CombineLatest(
Just(true)
.delay(for: .seconds(0.5), scheduler: DispatchQueue(label: "A"))
.prepend(false),
Just(true)
.delay(for: .seconds(1), scheduler: DispatchQueue(label: "B"))
@b3ll
b3ll / simrecord.fish
Last active February 6, 2022 15:02
Record iOS Simulator Fish Function
function simrecord
if count $argv > /dev/null
set save_dir $argv
else
set save_dir ~/Downloads
end
pushd $save_dir
xcrun simctl io booted recordVideo --mask black --codec "h264" SimulatorRecording-(date +%F)-(date +%H.%M.%S).mov
popd
@xspyhack
xspyhack / LazyVGrid.swift
Last active June 18, 2021 18:04
FB7812486: LazyVGrid poor performance
import SwiftUI
// https://developer.apple.com/documentation/swiftui/lazyvgrid
struct ContentView: View {
var columns: [GridItem] =
Array(repeating: .init(.flexible()), count: 4)
var body: some View {
ScrollView {
@douglashill
douglashill / FourColumns.swift
Created June 23, 2020 21:05
A sample UIKit app that sets up a four column layout with new iOS 14 API on UISplitViewController.
import UIKit
class FourColumnsContainerViewController: UIViewController {
let outerSplitViewController = UISplitViewController(style: .tripleColumn)
let innerSplitViewController = UISplitViewController(style: .doubleColumn)
let primary = makeContentViewController("App")
let secondary = makeContentViewController("Files")
let mainContent = makeContentViewController("File Content")
let inspector = makeContentViewController("Inspector")