Skip to content

Instantly share code, notes, and snippets.

View tjw's full-sized avatar

Timothy J. Wood tjw

View GitHub Profile
@tjw
tjw / instantiate-from-class.swift
Created November 16, 2014 21:30
Radar 18996669: Swift: Attempting to instantiate instance via class pointer crashes
/*
Radar 18996669: Swift: Attempting to instantiate instance via class pointer crashes
% xcrun -sdk macosx swiftc instantiate-from-class.swift
0 swift 0x0000000107668b68 llvm::sys::PrintStackTrace(__sFILE*) + 40
1 swift 0x0000000107669054 SignalHandler(int) + 452
2 libsystem_platform.dylib 0x00007fff95c74f1a _sigtramp + 26
3 libsystem_platform.dylib 0x0000000108bd3e00 _sigtramp + 1928720128
4 swift 0x0000000107a675fc collectFullName(swift::ArchetypeType const*, llvm::SmallVectorImpl<char>&) + 92
5 swift 0x0000000107a675c8 collectFullName(swift::ArchetypeType const*, llvm::SmallVectorImpl<char>&) + 40
@tjw
tjw / preview-from-url.m
Created January 9, 2015 00:43
NSURLThumbnailDictionaryKey test
#import <Cocoa/Cocoa.h>
/*
clang -fobjc-arc -Wall preview-from-url.m -o /tmp/preview-from-url -framework Cocoa
When run on a file in my iCloud Drive:
2015-01-08 16:39:54.008 preview-from-url[23221:261259] NSURLThumbnailDictionaryKey = {
NSThumbnail1024x1024SizeKey = "<NSImage 0x7fd6b34228f0 Size={790, 1024} Reps=(\n \"<NSCGImageSnapshotRep:0x7fd6b34249e0 cgImage=<CGImage 0x7fd6b3423de0>>\"\n)>";
}
@tjw
tjw / readonly-property-analyzer.m
Created March 12, 2015 18:56
20140181: Regression: clang static analyzer emits spurious warning when releasing strong ivar in -dealloc
#import <Foundation/Foundation.h>
/*
clang --analyze readonly-property-analyzer.m
readonly-property-analyzer.m:20:2: warning: Incorrect decrement of the reference count of an object that is not owned at this point by the caller
[_string release];
^~~~~~~~~~~~~~~~~
1 warning generated.
@tjw
tjw / CGGStack
Created June 3, 2015 04:08
CGGStack dtrace wrapper script
#!/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
@tjw
tjw / instantiate-from-class.swift
Created July 20, 2015 03:29
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 / init-cannot-assign-to-let.swift
Last active August 29, 2015 14:25
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 / ticket-scanner.py
Last active June 30, 2023 08:15 — forked from swizzlevixen/ticket-scanner.py
Python OpenCV program to extract ticket stub images from photographs, via automatic perspective correction for quadrilateral objects.
#!/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 / XcodeMindWipe.zsh
Created October 29, 2015 15:43
XcodeMindWipe
XcodeMindWipe () {
rm -rf ~/Library/Developer/Xcode/DerivedData
find . -name $USER.xcuserdatad -o \( -name xcuserdata -o -name "*.xccheckout" \) -print0 | xargs -0 rm -rf
}
@tjw
tjw / gist:67da25b39f6a18197f4d
Created October 29, 2015 16:12
Build failure w/ObjC modules
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
@tjw
tjw / conflicts-ios.txt
Created November 6, 2015 19:41
system method signature conflicts
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