Skip to content

Instantly share code, notes, and snippets.

View daydreamboy's full-sized avatar
🎯
Focusing

daydreamboy

🎯
Focusing
View GitHub Profile
@daydreamboy
daydreamboy / main.m
Created June 22, 2022 16:17 — forked from pudquick/main.m
Load Mach-O executable at runtime and execute its entry point
void callEntryPointOfImage(char *path, int argc, char **argv)
{
void *handle;
int (*binary_main)(int binary_argc, char **binary_argv);
char *error;
int err = 0;
printf("Loading %s…\n", path);
handle = dlopen (path, RTLD_LAZY);
@daydreamboy
daydreamboy / xcode-build-bump.sh
Created May 26, 2022 03:07 — forked from Valthoron/xcode-build-bump.sh
Set a timestamp as the build number when an Xcode project is compiled.
# xcode-build-timestamp.sh
# @desc Set a timestamp as the build number when the project is compiled.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Target dependencies"
buildNumber=$(date +%Y%m%d%H%M)

iOS Shared Cache Extraction

Having fallen off the iOS-exploration train due to completing my Masters and other commitments, I have finally climbed back aboard in pursuit of understanding the telephony stack.

Like most things in iOS that are used frequently, the vast majority of the frameworks and libraries used in the telephony stack reside in the DYLD shared cache located at /System/Library/Caches/com.apple.dyld/dyld_shared_cache_armv7.

In this post I am going to explain how to go about extracting this cache file so that you can then work with each library individually.

Get The Cache

The first step in all of this is to copy the cache over to your local machine. I did this using a program called iExplorer, but you can just as easily do it over SSH. As a side note, you can connect to your iDevice using SSH over USB if you install a tool called iProxy.

@daydreamboy
daydreamboy / toposort.swift
Created October 9, 2021 02:01 — forked from mrecachinas/toposort.swift
First topological sort written in Apple's new language Swift.
// First Topological Sort in Apple's new language Swift
// Updated on 10/30/2016 to account for the newest version of Swift (3.0)
// Michael Recachinas
enum TopologicalSortError : Error {
case CycleError(String)
}
/// Simple helper method to check if a graph is empty
/// - parameters:
/// - dependency_list: a `Dictionary<String, [String]>` containing the graph structure
@daydreamboy
daydreamboy / UIImageToDataTests.swift
Created August 30, 2020 09:36 — forked from benbahrenburg/UIImageToDataTests.swift
Swift Playground for testing memory associated with converting UIImage to Data
import UIKit
import ImageIO
import MobileCoreServices
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
func report_memory() -> UInt64 {
var taskInfo = mach_task_basic_info()
var count = mach_msg_type_number_t(MemoryLayout<mach_task_basic_info>.size)/4
@daydreamboy
daydreamboy / JavascriptCorePerfTest.swift
Created August 21, 2020 04:10 — forked from zwang/JavascriptCorePerfTest.swift
Test the performance of functions calls in JavaScriptCore in iOS 8+
class JSCContextTests: XCTestCase {
var jscContext: JSContext!
override func setUp() {
jscContext = JSContext()
let log_Binder: @convention(block) String -> Void = { input in
print(input)
@daydreamboy
daydreamboy / jscore.md
Created August 21, 2020 04:09 — forked from mheiber/jscore.md
Using JavaScriptCore in a Production iOS app

JavaScriptCore is a built-in iOS library that enables you to use JavaScript in apps alongside Objective-C and Swift. It lets developers read JavaScript from a string, execute it from Objective-C or Swift, and share data structures and functions across languages. We JavaScriptCore to share code between Web and iOS.

Sharing code helped us produce a high-quality, consistent experience across devices while iterating rapidly.

This post is about why we chose to use JavaScriptCore and what we learned. The biggest challenges to using JavaScriptCore in a production app were performance optimization for older devices and getting the build process right. Luckily, these problems have simple solutions that just weren't documented.

Why did we use JavaScriptCore?

A killer feature of one of our apps is search that is optimized for finding guests by name. Our goals included:

@daydreamboy
daydreamboy / ocmock-cheatsheet.m
Created February 19, 2019 07:11 — forked from kharmabum/ocmock-cheatsheet.m
OCMock cheatsheet
/*----------------------------------------------------*/
#pragma mark - XCTAsserts
/*----------------------------------------------------*/
XCTAssert(expression, format...);
XCTAssertTrue(expression, format...);
XCTAssertFalse(expression, format...);
XCTAssertEqual(expression1, expression2, format...);
XCTAssertNotEqual(expression1, expression2, format...);
XCTAssertNil(expression, format...);
@daydreamboy
daydreamboy / m3u8-to-mp4.md
Created December 1, 2018 07:49 — forked from tzmartin/m3u8-to-mp4.md
m3u8 stream to mp4 using ffmpeg

1. Copy m3u8 link

Alt text

2. Run command

echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4
@daydreamboy
daydreamboy / urlcharsets.txt
Created July 29, 2018 06:46 — forked from ericdke/urlcharsets.txt
URL encoding NSCharacterSet characters
URLQueryAllowedCharacterSet
!$&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~
URLHostAllowedCharacterSet
!$&'()*+,-.0123456789:;=ABCDEFGHIJKLMNOPQRSTUVWXYZ[]_abcdefghijklmnopqrstuvwxyz~
URLPathAllowedCharacterSet