Instantly share code, notes, and snippets.

View gist:eb758f55cb2898b670a5
(lldb) b NSLog
Breakpoint 2: 2 locations.
(lldb) breakpoint command add -s python -o "return (frame.GetThread().GetFrameAtIndex(1).GetModule().GetFileSpec().GetFilename() == 'UIKit')"
View gist:9712783
- On 10.6 and 10.7 System Preferences's 64-bit image requires GC. If the user opens a preference pane
that does not support GC System Preferences will restart as a 32-bit process, provided that the
preference pane has a 32-bit image.
- On 10.8+ System Preferences's 64-bit image supports GC but does not require it, and by default it
launches with GC disabled. If the user opens a preference pane that requires GC System Preferences
relaunches with GC enabled, but still as a 64-bit process.
So if your deployment target is <= 10.7 you'll get the best user experience by building with
GCC_ENABLE_OBJC_GC = supported, as the preference pane will run on all platforms without requiring a
View filter.cpp
#include <znc/Modules.h>
using namespace std;
static const char evil[] = { (char)0xd8, (char)0xb3, 0 };
class CFilterMod : public CModule {
View embedded_resource.m
#import <Foundation/Foundation.h>
#import <mach-o/dyld.h>
#import <mach-o/getsect.h>
#import <mach-o/ldsyms.h>
// Embed via other linker flags: -sectcreate __TEXT test $(PROJECT_DIR)/test.txt
// Names are limited to 16 characters.
NSData *MSEmbeddedResourceDataWithName(NSString *name) {
unsigned long size = 0;
uint8_t *data = getsectiondata(&_mh_execute_header, "__TEXT", [name UTF8String], &size);
View GoogleTests.h
#import <SenTestingKit/SenTestingKit.h>
@interface GoogleTests : SenTestCase
View gist:5623680
- (BOOL)fileHasCustomIcon:(NSString *)path {
struct FinderInfoAttrBuf {
u_int32_t length;
FileInfo fileInfo;
ExtendedFileInfo extendedFileInfo;
} __attribute__((aligned(4), packed));
struct attrlist attrList = {};
struct FinderInfoAttrBuf attrBuf = {};
attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
View gist:5608445
NSSharingService *service = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];
NSDictionary *parameters = @{
@"NSSharingServiceParametersDefaultSubjectKey": @"Lo, a subject!",
@"NSSharingServiceParametersDefaultRecipientsKey": @[@""]
[service setValue:parameters forKey:@"parameters"];
[service performWithItems:@[@"Woo, private API."]];
View gist:4948153
LSSharedFileListRef recentDocsList = LSSharedFileListCreate(NULL, kLSSharedFileListRecentDocumentItems, NULL);
View gist:4400775
NSImage *computerImage = [NSImage imageNamed:NSImageNameComputer];
NSInteger size = 256;
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc]
View gist:3540222
NSDate *now = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *nowComponents = [calendar components:NSSecondCalendarUnit fromDate:now];
NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
[offsetComponents setMinute:1];
[offsetComponents setSecond:-[nowComponents second]];
NSDate *nextMinute = [calendar dateByAddingComponents:offsetComponents toDate:now options:0];
NSTimeInterval interval = [nextMinute timeIntervalSinceDate:now];