Skip to content

Instantly share code, notes, and snippets.

@aufflick
aufflick / testGCDDeterminism.swift
Created October 11, 2018 00:27
XCTest Expectation bug
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]()
@aufflick
aufflick / testGCDDeterminism.swift
Created October 10, 2018 18:01
testGCDDeterminism.swift
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 {
extension UIView {
convenience init(translateMasks: Bool, frame: CGRect = CGRectZero) {
self.init(frame: frame)
self.translatesAutoresizingMaskIntoConstraints = translateMasks
}
}
/*
get {
return (objc_getAssociatedObject(self, &ourObserverItemKey)
as? AssociatedStruct<SomeStructType>)
.map {$0.value}
}
set {
objc_setAssociatedObject(self,
&ourObserverItemKey,
newValue.map
@aufflick
aufflick / AssociationHelpers.swift
Last active November 6, 2021 06:55
Helpers to assist using the ObjC runtime to associate both objects and structs in Swift
// 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 }
@aufflick
aufflick / rcs.rb
Created October 7, 2015 07:01
Modified (and hacky) homebrew recipe for rcs that supports --HEAD
class Rcs < Formula
desc "GNU revision control system"
homepage "https://www.gnu.org/software/rcs/"
url "http://ftpmirror.gnu.org/rcs/rcs-5.9.4.tar.xz"
mirror "https://ftp.gnu.org/gnu/rcs/rcs-5.9.4.tar.xz"
sha256 "063d5a0d7da1821754b80c639cdae2c82b535c8ff4131f75dc7bbf0cd63a5dff"
bottle do
cellar :any
sha1 "c1b9165adefc09d0ec1ed38ba7d25a47d61617b6" => :yosemite
@aufflick
aufflick / symbolicate_activity_monitor_sample.pl
Created February 11, 2015 09:20
Script to symbolicate output from Activity Monitor.app's sample dumps
#!/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;
@aufflick
aufflick / make_chilkat_objc_docset.pl
Created November 28, 2014 03:19
Make a Dash compatible docset from ChilKat's ObjC library html documentation
#!/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
@aufflick
aufflick / keybase.md
Created July 16, 2014 05:02
keybase.md

Keybase proof

I hereby claim:

  • I am aufflick on github.
  • I am markaufflick (https://keybase.io/markaufflick) on keybase.
  • I have a public key whose fingerprint is 6EBB 627B B1E6 79A5 F8A9 2700 055F DC37 3648 DE8B

To claim this, I am signing this object:

@aufflick
aufflick / .lldbinit
Created February 12, 2014 00:03
my Reveal lldb setup, based on @orj and @chrismiles efforts
command script import /opt/lldb-scripts/reveal.py
command alias interface_inspector p (BOOL)[[NSBundle bundleWithPath:@"/Applications/Interface Inspector.app/Contents/Resources/InterfaceInspectorRemote.framework"] load]
command alias reveal_load_sim expr (void*)dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib", 0x2);
command alias reveal_load_dev expr (void*)dlopen([(NSString*)[(NSBundle*)[NSBundle mainBundle] pathForResource:@"libReveal" ofType:@"dylib"] cStringUsingEncoding:0x4], 0x2);
command alias reveal_start expr (void)[(NSNotificationCenter*)[NSNotificationCenter defaultCenter] postNotificationName:@"IBARevealRequestStart" object:nil];
command alias reveal_stop expr (void)[(NSNotificationCenter*)[NSNotificationCenter defaultCenter] postNotificationName:@"IBARevealRequestStop" object:nil];