Skip to content

Instantly share code, notes, and snippets.

View ccgus's full-sized avatar

August "Gus" Mueller ccgus

View GitHub Profile
@ccgus
ccgus / gist:3429274
Created August 22, 2012 20:56
SFPasswordAssistantInspectorController
[[jstalk jsController] loadFrameworkWithName:@"SecurityInterface"];
var paic = [[SFPasswordAssistantInspectorController alloc] init]
[paic showPasswordAssistantPanel:nil]
var assistWindow = [paic valueForKey:@"passwordAssistantPanel"];
[assistWindow center];
@ccgus
ccgus / gist:3238464
Created August 2, 2012 16:37
FMDB custom functions
[db makeFunctionNamed:@"UTTypeConformsTo" maximumArguments:2 withBlock:^(sqlite3_context *context, int argc, sqlite3_value **argv) {
if (sqlite3_value_type(argv[0]) == SQLITE_TEXT) {
const unsigned char *a = sqlite3_value_text(argv[0]);
const unsigned char *b = sqlite3_value_text(argv[1]);
CFStringRef as = CFStringCreateWithCString(0x00, (const char*)a, kCFStringEncodingUTF8);
CFStringRef bs = CFStringCreateWithCString(0x00, (const char*)b, kCFStringEncodingUTF8);
sqlite3_result_int(context, UTTypeConformsTo(as, bs));
@ccgus
ccgus / FMDrawContext
Created July 16, 2012 18:57
Sketching up a little drawable context guy.
@interface FMDrawContext : NSObject {
CGContextRef _cgContext;
}
+ (id)drawContextWithSize:(NSSize)s;
- (CGImageRef)CGImage __attribute__((cf_returns_retained));
- (NSImage*)NSImage;
- (NSData*)dataOfType:(NSString*)uti;
- (void)drawInContextWithBlock:(void (^)())r;
10.6:
typedef signed __int32 cl_int2[2];
10.7:
typedef union
{
cl_int CL_ALIGNED(8) s[2];
#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
__extension__ struct{ cl_int x, y; };
__extension__ struct{ cl_int s0, s1; };
#0 0x00007fff901296b6 in semaphore_wait_trap ()
#1 0x00007fff8d85820a in _dispatch_semaphore_wait_slow ()
#2 0x00007fff8d94efb9 in -[NSXPCConnection sendMessage:waitForAck:] ()
#3 0x00007fff8d91a202 in _CFXNotificationPost ()
#4 0x00007fff8d92b758 in CFNotificationCenterPostNotification ()
#5 0x00007fff8aee2086 in HIS_XPC_CFNotificationCenterPostNotification ()
#6 0x00007fff8ec88e4b in BroadcastToolboxMessage ()
#7 0x00007fff8ebf82c7 in SendMenuOpening ()
#8 0x00007fff8ebfb8cd in DrawTheMenu ()
#9 0x00007fff8ebfbdd7 in MenuChanged ()
@ccgus
ccgus / gist:2840343
Created May 31, 2012 01:50
Threads r hard
Thread 1, Queue : com.apple.main-thread
#0 0x00007fff901296b6 in semaphore_wait_trap ()
#1 0x00007fff8d85820a in _dispatch_semaphore_wait_slow ()
#2 0x00007fff966027e8 in -[NSDocument _performFileAccessOnMainThread:usingBlock:] ()
#3 0x00007fff966026ae in -[NSDocument performSynchronousFileAccessUsingBlock:] ()
#4 0x00007fff96602eb2 in -[NSDocument _isLocatedByURL:becauseOfAutosavedContentsFile:] ()
#5 0x00007fff9649f30e in -[NSDocumentController _documentForURL:] ()
#6 0x00007fff9649f1e0 in -[NSDocumentController documentForURL:] ()
#7 0x0000000108d76b74 in -[DUDocument writeSafelyToURL:ofType:forSaveOperation:error:] at /Volumes/srv/Users/gus/Dropbox/Code/DocumentForURLBlock/DocumentForURLBlock/DUDocument.m:42
#8 0x00007fff96609a7b in __-[NSDocument saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_8 ()
@ccgus
ccgus / gist:2466760
Created April 22, 2012 20:43
custom margins.
function pageWasOpened(document, page) {
if ([page isRichText]) {
// custom insets per document!
var wc = [document mainWindowController];
var tv = [wc textView];
[tv setTextContainerInset:NSMakeSize(30, 0)];
}
}
@ccgus
ccgus / stackcrasher.m
Created February 26, 2012 01:20
CI Stack Crasher
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
/*
This example will create around 15k stack frames on 10.7, which ends up crashing the process.
clang stackcrasher.m -o stackcrasher -framework Cocoa -framework QuartzCore -fobjc-arc
*/
@ccgus
ccgus / gist:1838008
Created February 15, 2012 18:28
font stuff.
- (void)changeFont:(id)sender {
// by default, the bold menu is hooked up to NSFontManagers' - (void)addFontTrait:(id)sender; Start there to debug.
// isEditable , inputContext
for (TSGraphic *graphic in [[[self document] currentLayer] selectedGraphics]) {
if (![graphic isKindOfClass:[TSTextArea class]]) {
continue;
Process: VoodooPad [82471]
Path: /tmp/*/VoodooPad.app/Contents/MacOS/VoodooPad
Identifier: com.flyingmeat.VoodooPad
Version: 5b1+ (3559)
Code Type: X86-64 (Native)
Parent Process: bash [81641]
Date/Time: 2012-02-06 20:27:13.681 -0800
OS Version: Mac OS X 10.7.3 (11D50)
Report Version: 9