Skip to content

Instantly share code, notes, and snippets.

View testGCDDeterminism.swift
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 Oct 10, 2018
testGCDDeterminism.swift
View 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 {
View NoReallyDontTranslateAutoResizingMaskIntoContstraints.swift
extension UIView {
convenience init(translateMasks: Bool, frame: CGRect = CGRectZero) {
self.init(frame: frame)
self.translatesAutoresizingMaskIntoConstraints = translateMasks
}
}
View AssociatedStruct.swift
/*
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 Apr 12, 2021
Helpers to assist using the ObjC runtime to associate both objects and structs in Swift
View AssociationHelpers.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 Oct 7, 2015
Modified (and hacky) homebrew recipe for rcs that supports --HEAD
View rcs.rb
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 Feb 11, 2015
Script to symbolicate output from Activity Monitor.app's sample dumps
View symbolicate_activity_monitor_sample.pl
#!/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 Nov 28, 2014
Make a Dash compatible docset from ChilKat's ObjC library html documentation
View make_chilkat_objc_docset.pl
#!/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
View 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 Feb 12, 2014
my Reveal lldb setup, based on @orj and @chrismiles efforts
View .lldbinit
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];