Skip to content

Instantly share code, notes, and snippets.

View lawrencelomax's full-sized avatar

Lawrence Lomax lawrencelomax

View GitHub Profile
@lawrencelomax
lawrencelomax / DYLD_INSERT_LIBRARIES Simulator Kernel Protection.md
Last active May 10, 2018 16:36
deny-mmap for DYLD_INSERT_LIBRARIES on Simulator Process

It looks like the Simulator.app binary is now signed as of Xcode 7 as the following occurs in instruments-without-delay when using the build script:

./build.sh test <SIMULATOR-UDID>

The message that we get from the kernel is: 7/23/15 12:22:52.000 PM kernel[0]: AMFI: Simulator(pid 72600) - [deny-mmap] mapped file has no team identifier and is not a platform binary: /Users/lawrencelomax/src/instruments-without-delay/build/SimShim.dylib

This causes a crash:

@lawrencelomax
lawrencelomax / gist:b7a357d1d35a305d531d
Created June 22, 2015 14:21
Fun with Interposing
#import <Foundation/Foundation.h>
#import <objc/objc.h>
#import <objc/runtime.h>
#import <objc/message.h>
// Can use class-dump to get this from XCTest.framework
#import "XCTestConfiguration.h"
static void swizzleSetActiveTestConfiguration(void) {
Method method = class_getClassMethod(XCTestConfiguration.class, @selector(setActiveTestConfiguration:));
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
@lawrencelomax
lawrencelomax / gist:00ea2c00c9b6ca5bb4ab
Created September 5, 2014 11:30
Return Early vs Nested Imperative Parsing in Swift
static func decodeImperative<X: XMLParsableType>(xml: X) -> Result<Animal> {
if let type = XMLParser.parseChildText("type")(xml: xml).toOptional() {
if let name = XMLParser.parseChildText("name")(xml: xml).toOptional() {
if let urlString = XMLParser.parseChildText("url")(xml: xml).toOptional() {
return Result.value(self(type: type, name: name, url: NSURL.URLWithString(urlString)) )
}
return Result.Error(decodeError("Could not parse 'urlString' as a String"))
}
return Result.Error(decodeError("Could not parse 'name' as a String"))
}
@lawrencelomax
lawrencelomax / scanner.swift
Created July 10, 2014 16:47
Word Scanner in Swift
// Playground - noun: a place where people can play
import Cocoa
let str = "Foo Bar bannana' basa fist ada-2@🚅 afa2-ff 👍🎭-asd👍 adsa😃da\ndas🎉d"
let whitespaceSet = NSCharacterSet.whitespaceAndNewlineCharacterSet()
enum ScanResult<T> {
case Append(T)
@lawrencelomax
lawrencelomax / rac_testing.md
Created April 30, 2014 15:38
RAC Testing abortive blogpost

layout: post title: "ReactiveCocoa Unit Testing Tips" date: 2013-09-22 20:45 comments: true categories:

  • Testing
  • iOS
  • Patterns
  • Xcode
@lawrencelomax
lawrencelomax / cat_list.json
Last active December 24, 2015 11:28
JSON Sample data for Unit Test demo
[
{"name" : "grumpy", "image_url" : "http://i.imgur.com/llerBCQ.jpg"},
{"name" : "long", "image_url" : "http://i.imgur.com/SkSNqfB.jpg"},
{"name" : "bullet", "image_url" : "http://i.imgur.com/djCifni.jpg"},
{"name" : "ceiling", "image_url" : "http://i.imgur.com/W86UhUT.png"}
]
Pod::Spec.new do |s|
s.name = "ReactiveCocoa"
s.version = "2.0.0-RC3"
s.summary = "A framework for composing and transforming sequences of values."
s.homepage = "https://github.com/blog/1107-reactivecocoa-is-now-open-source"
s.author = { "Josh Abernathy" => "[email protected]" }
s.source = { :git => "https://github.com/ReactiveCocoa/ReactiveCocoa.git", :tag => 'v2.0-RC3' }
s.license = 'Simplified BSD License'
s.description = "ReactiveCocoa offers:\n" \
"1. The ability to compose operations on future data.\n" \
#define recursiveBlock(type_out__, name__, type_in__, block__) \
typedef type_out__ (^type_in_out__##name__)type_in__;\
__weak __block type_in_out__##name__ name__;\
type_in_out__##name__ temp__##name__;\
name__ = temp__##name__ = ^type_out__(type_in__) block__
@lawrencelomax
lawrencelomax / gist:4711119
Last active December 12, 2015 03:58
ARC Retain/Release overhead in tight loops
/**
An inline (read: no overhead) function that will perform the physics increment for a given particle
@return A boolean for whether the particle has expired and needs to be removed
*/
extern inline BOOL updateParticle(BILParticleAtomConventional * atom, BILParticleModel * model, NSTimeInterval deltaTime)
{
// Time to Live
atom->atom.timeToLive -= deltaTime;