Skip to content

Instantly share code, notes, and snippets.

@mathieulegrand
mathieulegrand / FCPrivateBatteryStatus.m
Created January 30, 2016 03:01
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);
@mathieulegrand
mathieulegrand / fsa.py
Last active August 29, 2015 14:11 — forked from danielpunkass/fsa.py
"""
Automate loading of F-Script Anywhere into any app.
By Daniel Jalkut - @danielpunkass - http://indiestack.com/
To set up:
0. Make sure you have FScript.framework installed in /Library/Frameworks (http://www.fscript.org)
1. Copy this script to ~/.lldb/fsa.py
2. Add the following to your ~/.lldbinit file:
@mathieulegrand
mathieulegrand / area_code.rb
Created July 3, 2011 13:55 — forked from mager/area_code.rb
Get area code from IP address using SimpleGeo Places & Ruby
SimpleGeo::Client.set_credentials(ENV['SIMPLEGEO_KEY'],ENV['SIMPLEGEO_SECRET'])
resp = SimpleGeo::Client.geocode_from_ip()
options = {:num=>1}
place = SimpleGeo::Client.get_places(resp[:query][:latitude], resp[:query][:longitude], options)
phone = place[:features][0][:properties][:phone]
@area_code = phone[3..-10] # Phone number format: "+1 XXX XXX-XXXX"