Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby
=begin
#### DIRECTIONS ####
Run `/usr/bin/ruby savings.rb <path to executable>`, and it will report the estimated savings for that executable.
*However*, the executable cannot have been downloaded from the app store (or else it will already be the encrypted version, and we can't unencrypt it to calculate the savings)
Also, it should be a binary for a specific architecture, and not a fat binary. I'd assume arm64 would be way to go.
How to get an arm64 binary that is not encrypted?
Run Product -> Archive in Xcode, then export the app Ad Hoc, and for the device to thin for, select a device with arm64 (an iPhone 5s or above)
Unzip the .ipa file that was exported, and Payload/<app name>.app/<app name> should be the executable that you want
@cemolcay
cemolcay / machAbsoluteToSeconds.swift
Last active March 4, 2020 08:10
mach_absolute_time to seconds in Swift
var timebaseInfo = mach_timebase_info_data_t()
init() {
mach_timebase_info(&timebaseInfo)
}
func machAbsoluteToSeconds(machAbsolute: UInt64 = mach_absolute_time()) -> Double {
let nanos = Double(machAbsolute * UInt64(timebaseInfo.numer)) / Double(timebaseInfo.denom)
return nanos / 1.0e9;
}
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// Choose either "stable" for receiving highly polished,
// or "canary" for less polished but more frequent updates
updateChannel: 'stable',
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.
@tijme
tijme / UITextViewPlaceholder.swift
Last active January 7, 2024 03:06
The correct way to implement a placeholder in a UITextView (Swift)
//
// UITextViewPlaceholder.swift
// TextViewPlaceholder
//
// Copyright (c) 2017 Tijme Gommers <tijme@finnwea.com>
//
// 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
@mcgaffin
mcgaffin / gist:3873928
Created October 11, 2012 17:03
iOS: how to get the ip address of a remote host.
// adapted from: http://blog.zachwaugh.com/post/309927273/programmatically-retrieving-ip-address-of-iphone
- (NSString *)getIPAddress {
Boolean result;
CFHostRef hostRef;
CFArrayRef addresses;
NSString *hostname = @"domain.myhost.com";
NSString *ipAddress = @"";
hostRef = CFHostCreateWithName(kCFAllocatorDefault, (CFStringRef)hostname);
if (hostRef) {
@cppforlife
cppforlife / gist:1269501
Created October 7, 2011 05:09
objective-c debugging env variables
[schwa@ungoliant] ~$ export OBJC_HELP=1
[schwa@ungoliant] ~$ /Applications/Safari.app/Contents/MacOS/Safari
objc[10559]: Objective-C runtime debugging. Set variable=YES to enable.
objc[10559]: OBJC_HELP: describe available environment variables
objc[10559]: OBJC_PRINT_OPTIONS: list which options are set
objc[10559]: OBJC_PRINT_IMAGES: log image and library names as they are loaded
objc[10559]: OBJC_PRINT_LOAD_METHODS: log calls to class and category +load methods
objc[10559]: OBJC_PRINT_INITIALIZE_METHODS: log calls to class +initialize methods
objc[10559]: OBJC_PRINT_RESOLVED_METHODS: log methods created by +resolveClassMethod: and +resolveInstanceMethod:
objc[10559]: OBJC_PRINT_CLASS_SETUP: log progress of class and category setup