Skip to content

Instantly share code, notes, and snippets.

View atomicbird's full-sized avatar

Tom Harrington atomicbird

View GitHub Profile
#include <stdlib.h>
#include <stdio.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#include <sys/types.h>
#include <unistd.h>
// Return 1 if being debugged, 0 if not (or if debug status can't be determined).
int beingDebugged()
{
// Define a debug-build-only NSLog wrapper. DLog printing will only happen in debug builds.
#ifdef DEBUG
#define DLog(...) NSLog(__VA_ARGS__)
#else
#define DLog(...)
#endif
(gdb) info sharedlibrary
The DYLD shared library state has been initialized from the executable's shared library information. All symbols should be present, but the addresses of some symbols may move when the program is executed, as DYLD may relocate library load addresses if necessary.
Requested State Current State
Num Basename Type Address Reason | | Source
| | | | | | | |
1 dyld - 0x8fe00000 dyld Y Y /usr/lib/dyld at 0x8fe00000 (offset 0x0) with prefix "__dyld_"
2 valgrind - 0x1000 exec Y Y /usr/local/bin/valgrind (offset 0x0)
3 libgcc_s.1.dylib - 0x96526000 dyld Y Y /usr/lib/libgcc_s.1.dylib at 0x96526000 (offset -0x69ada000)
4 libSystem.B.dylib - 0x9652e000 dyld Y Y /usr/lib/libSystem.B.dylib at 0x9652e000 (offset -0x69ad2000)
(commpage objfile is) /usr/lib/libSystem.B.dylib[LC_SEGMEN
// - (id)initWithContentsOfURL:(NSURL *)url error:(NSError **)outError;
NSError *error;
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:wavURL error:&error];
// Warning: passing argument 2 of 'initWithContentsOfURL:error:' from distinct Objective-C type
==35777== 18 bytes in 1 blocks are possibly lost in loss record 650 of 3,892
==35777== at 0x1075CA: malloc_zone_malloc (vg_replace_malloc.c:198)
==35777== by 0xA54BD4: _strdup_internal (in /usr/lib/libobjc.A.dylib)
==35777== by 0xA594BD: __sel_registerName (in /usr/lib/libobjc.A.dylib)
==35777== by 0x3F9319: NSKeyValueMethodForPattern (in /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation)
==35777== by 0x3FB0A0: +[NSObject(NSKeyValueCodingPrivate) _createMutableSetValueGetterWithContainerClassID:key:] (in /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation)
==35777== by 0x3FAE7F: _NSKeyValueMutableSetGetterForClassAndKey (in /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation)
==35777== by 0x3F881E: _NSKVONotifyingEnableForInfoAndKey (in /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation)
==35777== by 0x3F8407: -[NSKeyValueUnnestedProperty _isaForAutonotifying] (in /System/Library/Frameworks/Foundation.framework/
// Assuming NSString *username, NSString *password, NSURLRequest *request...
NSData *authRawData = [[NSString stringWithFormat:@"%@:%@", username, password] dataUsingEncoding:NSUTF8StringEncoding];
NSString *authEncoded = [authRawData asBase64EncodedString];
[request setValue:[NSString stringWithFormat:@"Basic %@", authEncoded] forHTTPHeaderField:@"Authorization"];
--- Color4.h ---
@interface Color4 : NSObject {
}
-(id) initWithRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha;
@end
--- Color4.m ---
kern.ostype = Darwin
kern.osrelease = 10.3.1
kern.osrevision = 199506
kern.version = Darwin Kernel Version 10.3.1: Mon Mar 15 23:15:33 PDT 2010; root:xnu-1504.2.27~18/RELEASE_ARM_S5L8930X
kern.maxvnodes = 750
kern.maxproc = 52
kern.maxfiles = 12288
kern.argmax = 262144
kern.securelevel = 0
kern.hostname = [redacted]
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
opQ = [[NSOperationQueue alloc] init];
[[NSNotificationCenter defaultCenter] addObserverForName:@"CustomOperationCompleted"
object:nil queue:opQ
usingBlock:^(NSNotification *notif) {
NSNumber *theNum = [notif.userInfo objectForKey:@"NumberOfItemsProcessed"];
NSLog(@"Number of items processed: %i", [theNum intValue]);
}];
}
Mach Virtual Memory Statistics: (page size of 4096 bytes, cache hits 0%)
free active spec inactive wire faults copy 0fill reactive pageins pageout
1682 264972 3588 128968 59267 99747167 3980863 48903497 1262518 893491 289592
4969 263635 3392 127918 58546 3895 293 2002 0 71 3
4412 263712 3614 127890 58697 4435 160 3120 0 164 0
3266 263908 4186 128109 58815 3674 32 2993 0 112 0
1939 264895 3584 128793 59268 6196 6 5325 1 669 7
1808 264984 1846 130528 59430 6365 9 4864 0 17 1
4212 265206 1908 128209 58805 7527 449 3450 0 15 0
4549 265236 1915 128180 58708 5558 81 4712 0 0 0