Skip to content

Instantly share code, notes, and snippets.

View appsandwich's full-sized avatar

Vinny Coyne appsandwich

View GitHub Profile
import UIKit
extension UIView {
func traverseResponderChainForUIViewController() -> UIViewController? {
guard let nextResponder = self.next else {
return nil
}
@appsandwich
appsandwich / FCPrivateBatteryStatus.m
Created March 22, 2016 09:30
How to get raw battery info (mAh remaining, etc.) from iOS using private APIs. For internal testing only, NOT APP STORE DISTRIBUTION!
#import <Foundation/Foundation.h>
#include <dlfcn.h>
NSDictionary *FCPrivateBatteryStatus()
{
static mach_port_t *s_kIOMasterPortDefault;
static kern_return_t (*s_IORegistryEntryCreateCFProperties)(mach_port_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, UInt32 options);
static mach_port_t (*s_IOServiceGetMatchingService)(mach_port_t masterPort, CFDictionaryRef matching CF_RELEASES_ARGUMENT);
static CFMutableDictionaryRef (*s_IOServiceMatching)(const char *name);

Keybase proof

I hereby claim:

  • I am appsandwich on github.
  • I am vinnycoyne (https://keybase.io/vinnycoyne) on keybase.
  • I have a public key whose fingerprint is 3C10 AD66 8CD9 5781 C5A6 3B64 F255 01C8 4DB6 07BA

To claim this, I am signing this object:

@appsandwich
appsandwich / appviz
Created January 16, 2014 11:02
AppViz 2.3.13 (2.3.13) crash log
Process: AppViz 2 [28267]
Path: /Applications/AppViz 2.app/Contents/MacOS/AppViz 2
Identifier: com.ideaswarm.AppViz2
Version: 2.3.13 (2.3.13)
Code Type: X86-64 (Native)
Parent Process: launchd [395]
Responsible: AppViz 2 [28267]
User ID: 501
Date/Time: 2014-01-16 11:01:32.785 +0000
@appsandwich
appsandwich / MKMapView+Extensions
Created January 10, 2014 15:04
Get & set the zoom level of a MKMapView
@interface MKMapView (Extensions)
-(double)as_zoomLevel;
-(void)as_setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(NSUInteger)zoomLevel animated:(BOOL)animated;
@end
static double mercadorRadius = 85445659.44705395;
static double mercadorOffset = 268435456;
@appsandwich
appsandwich / gist:6007702
Created July 16, 2013 10:50
iOS - Simulate on-device memory warnings using volume button press
#if DEBUG
#import <MediaPlayer/MediaPlayer.h>
#endif
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#if DEBUG
// Debug code that lets us simulate memory warnings by pressing the device's volume buttons.
@appsandwich
appsandwich / gist:4531447
Created January 14, 2013 16:48
Enable paste
javascript:var%20a=document.getElementsByTagName('input');for(var%20i=0;i%3Ca.length;i++)%7Ba%5Bi%5D.onpaste=null%7D