Skip to content

Instantly share code, notes, and snippets.

Avatar

Timothy J. Wood tjw

View GitHub Profile
View void-specialize.swift
func f(code:Void -> Void) {
print("no throw version called")
code()
}
func f<Result>(code:Void throws -> Result) rethrows -> Result {
print("rethrow version called")
return try code()
}
@tjw
tjw / generic-ivar.swift
Last active Dec 2, 2015
Corruption when assigning to stored properties in classes using generics
View generic-ivar.swift
import Cocoa
class A<T> : NSViewController {
var x:T? = nil
override init?(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
}
class B : A<NSString> {
override init?(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
@tjw
tjw / generic-link-error.swift
Last active Dec 2, 2015
Swift generics link error
View generic-link-error.swift
@tjw
tjw / conflicts-ios.txt
Created Nov 6, 2015
system method signature conflicts
View conflicts-ios.txt
2015-11-06 11:34:23.731 OmniFocus-Debug[1518:936775] *** Starting OBPerformRuntimeChecks
2015-11-06 11:34:23.795 OmniFocus-Debug[1518:936775] Method context has conflicting type signatures between class and its superclass:
signature ^{GraphicsContext3D=Iii{RetainPtr<WebGLLayer>=^v}@{HashMap<unsigned int, WebCore::GraphicsContext3D::ShaderSourceEntry, WTF::IntHash<unsigned int>, WTF::HashTraits<unsigned int>, WTF::HashTraits<WebCore::GraphicsContext3D::ShaderSourceEntry> >={HashTable<unsigned int, WTF::KeyValuePair<unsigned int, WebCore::GraphicsContext3D::ShaderSourceEntry>, WTF::KeyValuePairKeyExtractor<WTF::KeyValuePair<unsigned int, WebCore::GraphicsContext3D::ShaderSourceEntry> >, WTF::IntHash<unsigned int>, WTF::HashMap<unsigned int, WebCore::GraphicsContext3D::ShaderSourceEntry, WTF::IntHash<unsigned int>, WTF::HashTraits<unsigned int>, WTF::HashTraits<WebCore::GraphicsContext3D::ShaderSourceEntry> >::KeyValuePairTraits, WTF::HashTraits<unsigned int> >=^{KeyValuePair<unsigned int, WebCore::GraphicsCont
@tjw
tjw / gist:67da25b39f6a18197f4d
Created Oct 29, 2015
Build failure w/ObjC modules
View gist:67da25b39f6a18197f4d
CompileC /Users/bungi/Library/Developer/Xcode/DerivedData/OmniFocus-awuidrenlcqzqucuyvzjajjoqbeo/Build/Intermediates/XMLData.build/Debug/XMLDataTestTool.build/Objects-normal/x86_64/XMLDataTestTool_main.o Tests/XMLDataTestTool_main.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/bungi/Source/Omni/clean/OmniGroup/Applications/OmniFocus/XMLData
export LANG=en_US.US-ASCII
/Applications/Xcode-7.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch x86_64 -fmessage-length=251 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fcolor-diagnostics -std=gnu99 -fmodules -gmodules -fmodules-cache-path=/Users/bungi/Library/Developer/Xcode/DerivedData/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/bungi/Library/Developer/Xcode/DerivedData/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-m
View XcodeMindWipe.zsh
XcodeMindWipe () {
rm -rf ~/Library/Developer/Xcode/DerivedData
find . -name $USER.xcuserdatad -o \( -name xcuserdata -o -name "*.xccheckout" \) -print0 | xargs -0 rm -rf
}
@tjw
tjw / ticket-scanner.py
Last active Aug 29, 2015 — forked from swizzlevixen/ticket-scanner.py
Python OpenCV program to extract ticket stub images from photographs, via automatic perspective correction for quadrilateral objects.
View ticket-scanner.py
#!/usr/local/bin/python
# coding: utf-8
import cv2
import sys
import numpy
from matplotlib import pyplot as plt
from scipy.spatial import distance
"""
@tjw
tjw / init-cannot-assign-to-let.swift
Last active Aug 29, 2015
init-cannot-assign-to-let.swift
View init-cannot-assign-to-let.swift
public class Measurement {
public let value: Double
public required init(_ value:Double) {
self.value = value
}
}
public struct Size {
public let width:Measurement
@tjw
tjw / instantiate-from-class.swift
Created Jul 20, 2015
instantiate-from-class.swift
View instantiate-from-class.swift
protocol P {
static var name: String { get }
init(i:Int)
}
class A: P {
static var name: String {
get { return "A" }
}
required init(i:Int) {}
@tjw
tjw / CGGStack
Created Jun 3, 2015
CGGStack dtrace wrapper script
View CGGStack
#!/bin/zsh -euf
# NOTE: In order for the -c flag to work, 'main' must not be stripped from the executable.
# If it has been, you'll get the cryptic
#
# dtrace: failed to control pid 82297: process exited with status 0
#
if [ $# -ne 1 ]; then
echo "usage: $0 [executable-name|app-path|app-identifier]" 1>&2