Skip to content

Instantly share code, notes, and snippets.

View nevyn's full-sized avatar

Nevyn Bengtsson nevyn

View GitHub Profile
@nevyn
nevyn / TollFreeBridgedCpp.mm
Created April 8, 2010 21:58
Transparent ObjC<>C++ bridge
/*
Say you have a largeish C++ class. You want to use it from ObjC. ObjC++ is painful;
C++ is painful. .mm files are bad. How about if we could just treat that C++
object as an ObjC object whenever it exits C++ land?
Apple already solved this problem once with toll free bridging. The tricky part is
vtables -- with a vtable, isa isn't at offset 0 of the memory layout of the object.
The code below is a work in progress to work around this.
*/
@nevyn
nevyn / README.md
Created January 4, 2011 08:37
SPMediaKeyTap is a global event tap for the play/pause, prev and next keys on the keyboard. http://overooped.com/post/2593597587/mediakeys
#include <Cartridge.h>
uint8_t smb2_overworld[] = {
0x56, 0x67, 0x6D, 0x20, 0x5B, 0x69, 0x00, 0x00, 0x61, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x68, 0x00, 0x00, 0x17, 0xD9, 0x21, 0x00, 0xDF, 0x12, 0x00, 0x00, 0x20, 0xCC, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x4F, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@nevyn
nevyn / GFClock.h
Created July 10, 2014 11:33
Don't use [NSDate timeIntervalFromReferenceDate] if you're working with deltas or timing or anything that isn't directly date related. Use absolute, monotonically increasing time instead. Using mach time is easy but slightly inconvenient; here's a very simple NSDate-like class you can use in your code.
#import <Foundation/Foundation.h>
@interface GFClock : NSObject
+ (instancetype)sharedClock;
// since device boot or something. Monotonically increasing, unaffected by date and time settings
- (NSTimeInterval)absoluteTime;
@end
@nevyn
nevyn / LICENSE.md
Last active December 23, 2017 08:43
A generic NSError presenter for iOS, like -[UIApp presentError::::]. Depends on some Lookback internals that should be easy to remove, but I need to sleep

The MIT License (MIT)

Copyright (c) 2015 Lookback

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@nevyn
nevyn / LBCompositionDebugger.h
Last active July 18, 2017 17:42
Debug AVVideoCompositions using Apple's sample code, without having to find space *in your app* for its debug UI. I'm not sure what the correct way to license this is, but you're free to use it as you see fit as long as it conforms to Apple's original license :)
//
// LBCompositionDebugger.h
// LBMergeVideo
//
// Created by nevyn Bengtsson on 2016-02-19.
// Copyright © 2016 Lookback. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreMedia/CoreMedia.h>
@nevyn
nevyn / GFASLProxy.m
Created November 30, 2015 23:41
Capturing ASL on Mac/iOS
// See also https://github.com/CocoaLumberjack/CocoaLumberjack/blob/master/Classes/DDASLLogCapture.m
#import "GFASLProxy.h"
#include <asl.h>
#include <notify.h>
#include <notify_keys.h>
#include <sys/time.h>
@implementation GFASLProxy
pod 'Lookback'
@nevyn
nevyn / LookbackParticipate.h
Created February 4, 2017 00:01
Participate 1.9.0.2
#import <UIKit/UIKit.h>
@protocol LookbackParticipateDelegate;
NS_ASSUME_NONNULL_BEGIN
/*! @header LookbackParticipate.h
@abstract
Public interface for Lookback Participate, the friendly UX for guiding test particioants
through a research session, be it live, self-guided or in person.
@nevyn
nevyn / LookbackParticipate.h
Created February 3, 2017 07:53
Lookback 1.8.0.1 SDK Beta
#import <UIKit/UIKit.h>
@protocol LookbackParticipateDelegate;
NS_ASSUME_NONNULL_BEGIN
/*! @header LookbackParticipate.h
@abstract
Public interface for Lookback Participate, the friendly UX for guiding test particioants
through a research session, be it live, self-guided or in person.