Skip to content

Instantly share code, notes, and snippets.

View nevyn's full-sized avatar

Nevyn Bengtsson nevyn

View GitHub Profile
0.0370 enter Lookback Recording
0.0760 enter Status Bar Notification
0.0820 exit App Settings
0.7280 enter HostVC
0.7280 enter
0.7280 enter Data V C
0.7280 enter
0.7290 enter Data V C
0.7290 enter
0.7290 enter Data V C
@nevyn
nevyn / UIApplication+GFInterceptEvents.m
Created March 23, 2014 19:57
Intercepting shake events
@implementation UIApplication (GFInterceptEvents)
+ (void)lookback_swizzleSendEvent
{
Method orig = class_getInstanceMethod([UIApplication class], @selector(sendEvent:));
Method repl = class_getInstanceMethod([UIApplication class], @selector(lookback_sendEvent:));
method_exchangeImplementations(orig, repl);
}
- (void)lookback_sendEvent:(UIEvent*)event
{
#include <IOKit/IOTypes.h>
#include <IOKit/IOKitLib.h>
#include <CoreSurface/CoreSurface.h>
#include <stdio.h> // For mprotect
#include <sys/mman.h>
#ifdef __cplusplus
extern "C" {
#endif
#import <CoreGraphics/CGGeometry.h>
static inline CGVector TCVectorMultiply(CGVector vector, CGFloat m);
static inline CGVector TCVectorMinus(CGPoint p1, CGPoint p2)
{
return CGVectorMake(
p1.x - p2.x,
p1.y - p2.y
);
@nevyn
nevyn / oops.c
Last active August 29, 2015 13:56 — forked from davepeck/oops.c
static OSStatus
SSLVerifySignedServerKeyExchange(SSLContext *ctx, bool isRsa, SSLBuffer signedParams,
uint8_t *signature, UInt16 signatureLen)
{
SSLBuffer hashCtx;
OSStatus err = _SSLVerifySignedServerKeyExchangeWithHashCtx(ctx, isRsa, signedParams,
signature, signatureLen, &hashCtx);
SSLFreeBuffer(hashCtx);
return err;
}
@nevyn
nevyn / async.m
Last active August 29, 2015 13:56
Why would you want a common abstraction for asynchrony? Well, compare these two. Might've gone a bit overboard, but the code was so easy with tasks I didn't realize what I was heading into when I was writing the callback hell version... Note: This would've been just as succinct using MAFuture or ReactiveCocoa or whatever. The important part is h…
// callback hell
- (void)fetch:(NSURL*)url saveWithCompletion:(void(^)())myCompletion errorHandler:(void(^)(NSError*))errorHandler
{
[downloader fetchURL:url completion:^(NSData *data) {
[parser parse:data completion:^(NSDictionary *parsed, NSError *err) {
if(parsed) {
[database save:completion^{
if(myCompletion)
myCompletion();
}];
foo(function(value) {
bar(value, function(value2) {
console.log("hey we're done", value2);
});
});
// becomes
var value = foo().wait();
var value2 = bar(value).wait();
_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, mysocket, 0, dispatch_get_main_queue());
dispatch_source_set_event_handler(_source, ^{
// do something with mysocket, because it has changed (has read, write or error)
};
dispatch_source_set_cancel_handler(source, ^{
close(mysocket);
});
dispatch_resume(_source);
// sen för att stänga socket:
@nevyn
nevyn / LookbackActivator.plist
Last active January 4, 2016 16:59
Both "about to register" and "registered" are printed, and shortly after Springboard crashes :( This is the entirety of the source in this dylib.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Filter</key>
<dict>
<key>Bundles</key>
<array>
<string>com.apple.springboard</string>
</array>
// Buttom of the stack. and it just keeps going like this until stack runs out of memory.
frame #11034: 0x00201c7b CoinPurse`std::__1::function<void (std::__1::error_code const&, std::__1::array<unsigned char, 16ul> const&)>::function<std::__1::__bind<std::__1::function<void (std::__1::error_code const&)>&, std::__1::placeholders::__ph<1>&> >(std::__1::__bind<std::__1::function<void (std::__1::error_code const&)>&, std::__1::placeholders::__ph<1>&>, std::__1::enable_if<__callable<std::__1::__bind<std::__1::function<void (std::__1::error_code const&)>&, std::__1::placeholders::__ph<1>&> >::value, void>::type*) [inlined] std::__1::__function::__func<std::__1::__bind<std::__1::function<void (this=0x0981a5a0, __f=0xbfffc738, __a=0xbfffc170)>&, std::__1::placeholders::__ph<1>&>, std::__1::allocator<std::__1::__bind<std::__1::function<void (std::__1::error_code const&)>&, std::__1::placeholders::__ph<1>&> >, void (std::__1::error_code const&, std::__1::array<unsigned char, 16ul> const&)>::__func(std::__1::__bin