This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Associated wrapper by WeZZard : https://wezzard.com/2015/10/09/associated-object-and-swift-struct/ | |
// Type safe helpers inspired by Tikitu de Jager : https://medium.com/@ttikitu/swift-extensions-can-add-stored-properties-92db66bce6cd#.mx6ekrw16 | |
public final class AssociatedStruct<T>: NSObject, NSCopying { | |
public typealias Type = T | |
public let value: Type | |
public init(_ value: Type) { self.value = value } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use warnings; | |
# The human has to determine the UUID from the binary images section for now. Sue me. | |
my ($uuid, $sample_file_path) = @ARGV; | |
die "Usage:\n $0 'main bundle uuid' 'path to sample.txt'" | |
unless $uuid && -f $sample_file_path; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
import Foundation | |
class GCDTestTests: XCTestCase { | |
func testGCDDeterminism() { | |
// Just for sanity, confirming *everything* is happening on the serial main thread. | |
assert(Thread.isMainThread) | |
var seen = [Int]() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
class GCDTestTests: XCTestCase { | |
func testGCDDeterminism() { | |
// Just for sanity, confirming *everything* is happening on the serial main thread. | |
assert(Thread.isMainThread) | |
for _ in 0..<1_000 { | |
let expectations = (0..<1_000).map { self.expectation(description: "Expect \($0)") } | |
for i in 0..<1_000 { | |
DispatchQueue.main.async { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# You can use this script in a pipe. It's input will become an emacs buffer | |
# via emacsclient (so you need server-start etc.) | |
# See http://mark.aufflick.com/o/886457 for more information | |
# Copyright (C) 2011 by Mark Aufflick <mark@aufflick.com> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/NSObject.h> | |
@interface Fraction: NSObject { | |
int numerator; | |
int denominator; | |
} | |
-(void) print; | |
-(void) setNumerator: (int) n; | |
-(void) setDenominator: (int) d; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
=head1 NAME | |
make_chilkat_objc_docset - Make a Dash compatible docset from ChilKat's ObjC library html documentation | |
=head1 SYNOPSIS | |
./make_chilkat_objc_docset.pl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
convenience init(translateMasks: Bool, frame: CGRect = CGRectZero) { | |
self.init(frame: frame) | |
self.translatesAutoresizingMaskIntoConstraints = translateMasks | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
get { | |
return (objc_getAssociatedObject(self, &ourObserverItemKey) | |
as? AssociatedStruct<SomeStructType>) | |
.map {$0.value} | |
} | |
set { | |
objc_setAssociatedObject(self, | |
&ourObserverItemKey, | |
newValue.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" File: reveal.py | |
Add to ~/.lldbinit: | |
command script import ~/.lldb-scripts/reveal.py | |
Q: Want to automatically load the Reveal lib on launch while debugging from Xcode? | |
A: In Xcode: | |
Add a Symbolic Breakpoint | |
Symbol: "UIApplicationMain" | |
Action: Debugger Command with value "reveal" |
NewerOlder