Skip to content

Instantly share code, notes, and snippets.

View 0xced's full-sized avatar

Cédric Luthi 0xced

View GitHub Profile

Keybase proof

I hereby claim:

  • I am 0xced on github.
  • I am 0xced (https://keybase.io/0xced) on keybase.
  • I have a public key whose fingerprint is D954 97B0 B156 169F 8008 678B D5E1 5DE9 6AF8 341E

To claim this, I am signing this object:

@0xced
0xced / uncruftapidiff.m
Created June 18, 2014 22:17
Uncruft iOS 8.0 and OS X 10.10 API diffs
//
// Copyright (c) 2014 Cédric Luthi “0xced”
//
// ./uncruftapidiff https://developer.apple.com/library/prerelease/ios/releasenotes/General/iOS80APIDiffs/index.html iOS8_0APIDiffs.html
// ./uncruftapidiff https://developer.apple.com/library/prerelease/mac/documentation/General/Reference/APIDiffsMacOSX10_10SeedDiff/index.html OSX10_10APIDiffs.html
//
#import <Foundation/Foundation.h>
#import <sysexits.h>
@0xced
0xced / CFPropertyList.patch
Created October 1, 2014 12:30
Fix for rdar://18512876
--- CF-855.17/CFPropertyList.c 2014-08-15 23:19:37.000000000 +0200
+++ CF-855.17/CFPropertyList.c 2014-10-01 13:58:11.000000000 +0200
@@ -27,6 +27,7 @@
*/
#include <CoreFoundation/CFPropertyList.h>
+#include <CoreFoundation/CFByteOrder.h>
#include <CoreFoundation/CFDate.h>
#include <CoreFoundation/CFNumber.h>
#include <CoreFoundation/CFSet.h>
@0xced
0xced / FixLookbackMPMoviePlayerControllerCrash.m
Last active August 29, 2015 14:09
Fix for Lookback (0.6.5) crash when recording is stopped while playing a movie with a MPMoviePlayerController
/**
* Add these options to `OTHER_LDFLAGS` if Lookback is not linked to the app.
* -Wl,-U,_GFGetVersion
* -Wl,-U,_OBJC_CLASS_$_GFThumbnailer2
* -Wl,-U,_OBJC_IVAR_$_GFThumbnailer2._jobs
* -Wl,-U,_OBJC_IVAR_$_GFThumbnailer2._currentJob
*/
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
#import <dlfcn.h>
@0xced
0xced / FixMPMoviePlayerControllerControlsAutohide.m
Created December 11, 2014 13:25
Restore MPMoviePlayerController controls autohide behavior after unlocking a device
/**
* Locking then unlocking a device while a movie is playing disables controls autohiding.
* `MPInlineVideoController` registers for the (private) UIApplicationResumedEventsOnlyNotification
* (which is sent between UIApplicationWillEnterForegroundNotification and UIApplicationDidBecomeActiveNotification).
* In its callback (-[MPInlineVideoController _applicationResumedEventsOnly:]) it calls `[self setDisableControlsAutohide:YES]`
* effectively disabling controls autohide. In order to restore the automatic hiding of controls, we call
* setDisableControlsAutohide:NO when UIApplicationDidBecomeActiveNotification is posted.
*/
#import <MediaPlayer/MediaPlayer.h>
@0xced
0xced / MoviePlayerControllerDoneButton.h
Created December 17, 2014 09:54
Access the "Done" button of a MPMoviePlayerController
#import <MediaPlayer/MediaPlayer.h>
/**
* Example usage:
* UIButton *doneButton = MoviePlayerControllerDoneButton(moviePlayerViewController.moviePlayer);
* [doneButton setTitle:@"✖" forState:UIControlStateNormal];
* doneButton.titleLabel.font = [UIFont systemFontOfSize:30];
*/
extern UIButton * MoviePlayerControllerDoneButton(MPMoviePlayerController *moviePlayerController);
@0xced
0xced / MPMoviePlayerViewController.m
Created July 22, 2015 10:33
Reverse engineered implementation of -[MPMoviePlayerViewController _moviePlayerViewController_playbackDidFinishNotification:]
@implementation MPMoviePlayerViewController
- (void) _moviePlayerViewController_playbackDidFinishNotification:(NSNotification *)notification
{
if (self.presentingViewController.presentedViewController == self)
{
UIViewController *presentingViewController = self.presentingViewController;
if (self->_internal->_wasDisplayedAnimated)
[presentingViewController dismissMoviePlayerViewControllerAnimated];
else
@0xced
0xced / screenNameForDisplay.m
Created August 7, 2009 14:44
Human readable string for a display name (as in the Displays preference pane)
#import <IOKit/graphics/IOGraphicsLib.h>
#import <IOKit/graphics/IOGraphicsTypes.h>
NSString* screenNameForDisplay(CGDirectDisplayID displayID)
{
NSString *screenName = nil;
NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName);
NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
@0xced
0xced / fixXQuery.m
Created August 9, 2009 17:13
Fix for NSXMLNode XPath/XQuery using regular expressions bug (10.5.8)
#import <Foundation/Foundation.h>
#import <dlfcn.h>
#import <mach/vm_map.h>
#import <mach-o/dyld.h>
#import <mach-o/nlist.h>
#if defined(__i386__) || defined(__x86_64__)
@0xced
0xced / absim.sh
Created March 11, 2010 21:25
Use your own Address Book in the iPhone Simulator
#!/bin/bash
cd ~/Library/Application\ Support/MobileSync/Backup
backup=`ls -t1 | sed -n '1p'` # most recent backup
for f in "$backup"/*.mdinfo; do
grep -q "Library/AddressBook/AddressBook.sqlitedb" $f
if [ $? -eq 0 ]; then
addressbook=`basename $f .mdinfo`
cp -v "`pwd`/$backup/$addressbook.mddata" ~/Library/Application\ Support/iPhone\ Simulator/User/Library/AddressBook/AddressBook.sqlitedb
exit $?