Skip to content

Instantly share code, notes, and snippets.

@DmitrySkiba
DmitrySkiba / keybench.cpp
Last active August 29, 2015 14:24
Key benchmark
******************** O2 ********************
$ clang++ -DDUMB_KEY -Wall -stdlib=libstdc++ -std=c++11 -O2 keybench.cpp && ./a.out
sizeof(Key) = 16
5 iterations:
elapsed: 17635698 nsec
elapsed: 16047390 nsec
elapsed: 15367448 nsec
elapsed: 15024112 nsec
@DmitrySkiba
DmitrySkiba / gist:6774995
Created October 1, 2013 07:32
Proof that CFGetTypeID() doesn't call [_cfTypeID]
#include <CoreFoundation/CoreFoundation.h>
#include <objc/runtime.h>
typedef struct __CFRuntimeClass {
CFIndex version;
const char *className;
void (*init)(CFTypeRef cf);
CFTypeRef (*copy)(CFAllocatorRef allocator, CFTypeRef cf);
void (*finalize)(CFTypeRef cf);
Boolean (*equal)(CFTypeRef cf1, CFTypeRef cf2);
@DmitrySkiba
DmitrySkiba / gist:1634076
Created January 18, 2012 17:04
Example of app that Itoa supports
#import <Foundation/Foundation.h>
#import <CoreFoundation/CoreFoundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
/////////////////////////////////////////////////////////////////////
@interface ApplicationDelegate: NSObject<UIApplicationDelegate> {
@DmitrySkiba
DmitrySkiba / gist:1614967
Created January 15, 2012 07:54
Simple iOS app (from Itoa tutorial)
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
/*
* ApplicationDelegate
*/
@interface ApplicationDelegate: NSObject<UIApplicationDelegate> {
UIWindow* m_window;
}
@DmitrySkiba
DmitrySkiba / gist:1017293
Created June 9, 2011 17:52
JNIpp: getting IMEI from native code on Android
/* There is no native way to get IMEI, so we have to call
* Java classes through JNI.
*
* But fear not: JNIpp (github.com/DmitrySkiba/itoa-jnipp) makes
* this task much easier.
*
* To get IMEI we need to perform the following calls:
*
* TelephonyManager telephony=(TelephonyManager)
* context.getSystemService(Context.TELEPHONY_SERVICE);