Skip to content

Instantly share code, notes, and snippets.

View ccgus's full-sized avatar

August "Gus" Mueller ccgus

View GitHub Profile
- (void) deleteTweetsOlderThan:(int)inMaxToKeep
{
NSArray* recent_ids = [RFTweet tweetIDsReversedForCollectionID:self.collectionID];
if ([recent_ids count] > inMaxToKeep) {
FMDatabaseQueue *queue = …
[queue inDatabase:^(FMDatabase *db) {
if (inMaxToKeep > 0) {
NSNumber* last_tweet_id = [recent_ids objectAtIndex:inMaxToKeep - 1];
@ccgus
ccgus / gist:1762511
Created February 7, 2012 22:14
Auto-gitify
function runGitWithArgsForDocument(document, args) {
task = NSTask.alloc().init().autorelease();
task.setCurrentDirectoryPath(document.fileURL().path());
task.setLaunchPath('/usr/bin/git');
task.setArguments(args);
task.launch();
task.waitUntilExit();
}
function documentWasOpened(document) {
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
@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;
@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: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 / 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 ()
#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 ()
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; };
@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;