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
//: Playground - noun: a place where people can play | |
import Cocoa | |
/* | |
I've been using an object like ObjectWrapper in Swift 2.x without any problems | |
to store a Swift struct as a property an Objective-C object, and then later | |
access and use that struct from other Swift code. |
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
Date/Time: 2014-10-23 21:09:32 +0000 | |
OS Version: Mac OS X 10.10.0 (14A389) | |
Report Version: 104 | |
Exception Type: SIGSEGV | |
Exception Codes: SEGV_ACCERR at 0x7fff5f3ffff8 | |
Crashed Thread: 0 | |
Thread 0 Crashed: | |
0 CoreFoundation 0x00007fff924ac084 CFRetain + 4 |
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
NSDateComponents* oneYear = [NSDateComponents new]; | |
oneYear.year = 1; | |
dave.age = [[NSCalendar currentCalendar] dateByAddingComponents:oneYear toDate:dave.age options:0]; |
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
BOOL BWProcessIsBeingTraced() | |
{ | |
int mib[4]; | |
size_t bufSize = 0; | |
struct kinfo_proc kp; | |
mib[0] = CTL_KERN; | |
mib[1] = KERN_PROC; | |
mib[2] = KERN_PROC_PID; | |
mib[3] = getpid(); |
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
tell application "System Events" | |
if exists application process "Tweetbot" then | |
tell application process "Tweetbot" | |
if frontmost then | |
set visible to false | |
else | |
set frontmost to true | |
end if | |
end tell | |
end if |
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
This is some LLDB output from my app in a hung state somewhere deep in the image rendering frameworks. It looks like it's hung on dispatch_sync_f(), and from what I can tell from the disassembly, it looks like it's dispatching it on the current queue (see the call to dispatch_get_current_queue() just a few instructions prior), which the docs say will always hang. | |
(lldb) bt | |
* thread #1: tid = 0x2203, 0x00007fff88b4f6c2 libsystem_kernel.dylib`semaphore_wait_trap + 10, stop reason = signal SIGSTOP | |
frame #0: 0x00007fff88b4f6c2 libsystem_kernel.dylib`semaphore_wait_trap + 10 | |
frame #1: 0x00007fff88924c6e libdispatch.dylib`_dispatch_thread_semaphore_wait + 16 | |
frame #2: 0x00007fff88924ace libdispatch.dylib`_dispatch_barrier_sync_f_slow + 188 | |
frame #3: 0x00007fff89387efb OpenCL`clFinish + 120 | |
frame #4: 0x00007fff8e5d5d3d CoreImage`-[FEOpenCLContext _quad:] + 3743 | |
frame #5: 0x00007fff8e6ce18e CoreImage`-[FEContext(Drawing) quad:kernel:] + 107 |
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/ruby | |
#Just run this script in a terminal window, leaving the window open in the | |
#background so it can continue to process messages. | |
IO.popen("syslog -F \'$(Sender): $Message\' -w -k Sender com.apple.backupd") { |syslogIO| | |
while (inputString = syslogIO.gets) do | |
escapedString = inputString.gsub("'", "\\'") | |
`/usr/local/bin/growlnotify -a 'Time Machine' -m '#{escapedString}'` | |
end | |
} |
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
- (oneway void)release | |
{ | |
int retainCount = [self retainCount]; | |
[super release]; | |
if(retainCount == 2) | |
[resourceFiles removeObjectForKey: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
// | |
// NSObject+BlockObservation.h | |
// Version 1.0 | |
// | |
// Andy Matuschak | |
// [email protected] | |
// Public domain because I love you. Let me know how you use it. | |
// | |
/* |
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
// | |
// NSObject+BlockObservation.h | |
// Version 1.0 | |
// | |
// Andy Matuschak | |
// [email protected] | |
// Public domain because I love you. Let me know how you use it. | |
// | |
#import <Cocoa/Cocoa.h> |
NewerOlder