Skip to content

Instantly share code, notes, and snippets.

View marcpalmer's full-sized avatar
💭
Busy working on Concepts app, Shareshot and Captionista

Marc Palmer marcpalmer

💭
Busy working on Concepts app, Shareshot and Captionista
View GitHub Profile
@marcpalmer
marcpalmer / OnboardingUISpec.swift
Created January 18, 2018 11:27
UISpec post example #1
public class OnboardingUISpec: AppUISpec {
public enum Card {
public static let cornerRadius = Dimensions.smallRadius
public static let backgroundColor = Colors.cardBackground
public static let padding = Dimensions.standardCardPadding
public static let headingFont = Fonts.massiveMarketingHeading
public static let bodyFont = Fonts.body
}
-static void DisableGDB() {
- void *handle = dlopen(0, RTLD_GLOBAL | RTLD_NOW);
- ptrace_ptr_t ptrace_ptr = dlsym(handle, "ptrace");
- ptrace_ptr(PT_DENY_ATTACH, 0, 0, 0);
- dlclose(handle);
-}
Crashed Thread: 0 main thread Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGSEGV)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: debugserver [35527]
Oct 1 15:47:27 Marcs-iPhone-7 debugserver[387] <Notice>: Connecting to com.apple.debugserver service...
Oct 1 15:47:27 Marcs-iPhone-7 trustd[125] <Notice>: cert[0]: AnchorTrusted =(leaf)[force]> 0
Oct 1 15:47:27 Marcs-iPhone-7 trustd[125] <Notice>: cert[0]: NonEmptySubject =(path)[]> 0
Oct 1 15:47:27 Marcs-iPhone-7 debugserver[387] <Notice>: Got a connection, waiting for process information for launching or attaching.
Oct 1 15:47:27 Marcs-iPhone-7 locationd[70] <Notice>: @WifiFlow, scanusage, aps, 4, type, Stage1, lastscan, 0, use, 0, bystander+, 1, spectator+, 1, reqtype, clientupdate
Oct 1 15:47:27 Marcs-iPhone-7 locationd[70] <Notice>: @WifiFlow, scannotify, aps, 4, Stage1, clients, 1, doCalc, 0, ls, 1
Oct 1 15:47:27 Marcs-iPhone-7 locationd[70] <Notice>: {"msg":"computed wifi position", "numberOfInputAps":0, "validLocationHint":1, "computedValidLocation":0, "numberOfApsActuallyUsed":0}
Oct 1 15:47:27 Marcs-iPhone-7 locationd[70] <Notice>: @WifiFlow, compute, 0, hacc, -1.0, conf, 63, reason, scan
O
Command list is [
GraphicsCommand.moveTo(50.0, 50.0),
GraphicsCommand.lineTo(100.0, 100.0),
GraphicsCommand.lineTo(0.0, 100.0),
GraphicsCommand.lineTo(50.0, 50.0),
GraphicsCommand.setColour(16711935)
]
@marcpalmer
marcpalmer / dsltest.swift
Last active September 1, 2016 09:48
Example of using Swift property change observation to bind models to arguments passed to DSL closures
//: Playground - show possible simple DSL mechanism using mutable local vars
import UIKit
typealias MoveToFunction = (x: Float, y: Float) -> ()
typealias LineToFunction = (x: Float, y: Float) -> ()
typealias DSLClosure = (inout colour: UInt32, moveTo: MoveToFunction, lineTo: LineToFunction) -> ()
enum GraphicsCommand {
case setColour(colour: UInt32)
@marcpalmer
marcpalmer / gist:e1c1b7166e6cce7c8759
Created July 15, 2015 11:20
Demo of a possible approach to memoization of arbitrary function return values
//: # Memoization demo
import UIKit
/*:
These are infrastructure classes for storing the cached function return values based on object instance, function name and input arguments.
There is still work to do here. It is not thread safe.
*/
typealias MemoKey = String
@marcpalmer
marcpalmer / gist:283333cd3ce9032e7637
Created January 5, 2015 11:36
Puzzling compiler error with Xcode 6.2 (6C101)
// Works
class Testing {
func something() {
dispatch_async(dispatch_get_main_queue()) {
[weak self] in
if let blockSelf = self {
blockSelf.somethingElse()
}
}
}
@marcpalmer
marcpalmer / gist:6e30d394f8c2e92fe0a3
Created November 28, 2014 12:12
Seriously? XSS fun
window.alert('Pwnd!');
@marcpalmer
marcpalmer / gist:11423d0d589f13a0e947
Created October 29, 2014 14:59
Conditional variadic argument list evaluation
let debugEnabled = true
// This makes it all a bit easier to read
typealias LazyVarArgClosure = @autoclosure () -> CVarArgType
func conditionallyLogSomething(messageFormat:@autoclosure () -> String, args:LazyVarArgClosure...) {
// If this is false, we do nothing
if debugEnabled {
// Go through the list of closures and invoke them all, to get an array of arguments
// compatibvle with va_list