Skip to content

Instantly share code, notes, and snippets.

View rfletcher's full-sized avatar

Rick Fletcher rfletcher

View GitHub Profile
@rfletcher
rfletcher / FCPrivateBatteryStatus.m
Created January 30, 2016 01:31
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);
@rfletcher
rfletcher / to_hash.rb
Created February 3, 2011 00:15 — forked from wmw/to_hash.rb
class Balls
def initialize()
@name = 'blah'
@caption = 'blah'
end
def to_hash
self.instance_variables.inject({}) do |a, e|
a[e[1..-1].to_sym] = self.instance_variable_get(e)