Skip to content

Instantly share code, notes, and snippets.

dmaclach dmaclach

Block or report user

Report or block dmaclach

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Instrument.xml
<?xml version="1.0" encoding="UTF-8" ?>
<package>
<id>com.google.ImageMapper</id>
<title>ImageMapper</title>
<owner>
<name>Dave MacLachlan</name>
</owner>
<import-schema>kdebug-strings</import-schema>
<ktrace-interval-schema>
<id>com-google-dyld-map-image-schema</id>
View dyld details.txt
total time: 635.49 milliseconds (100.0%)
total images loaded: 457 (451 from dyld shared cache)
total segments mapped: 15, into 3756 pages with 408 pages pre-fetched
total images loading time: 376.31 milliseconds (59.2%)
total load time in ObjC: 64.57 milliseconds (10.1%)
total debugger pause time: 0.00 milliseconds (0.0%)
total dtrace DOF registration time: 0.11 milliseconds (0.0%)
total rebase fixups: 1,164,368
total rebase fixups time: 76.51 milliseconds (12.0%)
total binding fixups: 83,028
View AppLaunchTime.c
#include <sys/sysctl.h>
struct timeval AppLaunchTimeRelativeTo1970(void) {
id_t pid = getpid();
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, (int)pid };
const size_t mibSize = sizeof(mib) / sizeof(mib[0]);
size_t infoSize = 0;
// Get initial size of KERN_PROC data structure.
if (sysctl(mib, mibSize, NULL, &infoSize, NULL, 0) != 0) {
@dmaclach
dmaclach / property_encoding.csv
Last active Dec 10, 2018
Objective C property encodings
View property_encoding.csv
code meaning
R read-only
C by-copy
& by-reference
D dynamic
G getter (followed by selector name)
S setter (followed by selector name)
V instance variable (followed by variable name)
T type encoding (followed by old-style type encoding)
W weak
View objc_metadata_hider.h
/**
* Wraps C++ classes so that they can be passed around in Objective C++ programs without
* generating a lot of useless Objective C runtime metadata.
* Example use:
* class Foo {
* public:
* ....
* };
* \@interface Bar
* \@property objc_metadata_hider_ptr<Foo> foo;
@dmaclach
dmaclach / main.mm
Last active Nov 29, 2018
ObjectiveC wrapping C++
View main.mm
#import <Foundation/Foundation.h>
#include <map>
#include <string>
struct CppType {
std::map<std::string, std::string> myMap;
};
@interface ObjCType : NSObject {
CppType map;
@dmaclach
dmaclach / main.m
Last active Nov 29, 2018
Create an Objective C Class at runtime
View main.m
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
Class myClass = objc_allocateClassPair([NSObject class], "MyClass", 0);
IMP methodIMP = imp_implementationWithBlock(^(id self) {
return @"Hello";
});
if (!class_addMethod(myClass, @selector(description), methodIMP, "@@:")) {
View main.m
//
// main.m
// signaltest
//
// Created by Dave MacLachlan on 11/12/18.
// Copyright © 2018 Dave MacLachlan. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <pthread.h>
You can’t perform that action at this time.