Skip to content

Instantly share code, notes, and snippets.

@lipka
lipka / FCPrivateBatteryStatus.m
Created February 5, 2016 17:32
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);
//
// Copyright (c) 2013-2015 Frank A. Krueger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
### Keybase proof
I hereby claim:
* I am lipka on github.
* I am lipka (https://keybase.io/lipka) on keybase.
* I have a public key whose fingerprint is 2C91 1727 8671 72B4 AB89 9A77 B8B1 4F9F 21BD 0CDC
To claim this, I am signing this object:
@lipka
lipka / gist:a01a8937bf945b573148
Created August 7, 2014 23:00
Enable slow iOS animations
p [(CALayer *)[[[[UIApplication sharedApplication] windows] objectAtIndex:0] layer] setSpeed:.1f]
@lipka
lipka / gist:9429277
Last active August 29, 2015 13:57
LinkAttributes on MonoTouch.TTTAttributedLabel
TTTAttributedLabel _notesLabel = new TTTAttributedLabel ();
NSMutableParagraphStyle paragraphStyle = new NSMutableParagraphStyle ();
paragraphStyle.Alignment = UITextAlignment.Center;
_notesLabel.LinkAttributes = new NSMutableDictionary () {
{ UIStringAttributeKey.ParagraphStyle, paragraphStyle },
{ UIStringAttributeKey.ForegroundColor, UIColor.Blue },
};