Skip to content

Instantly share code, notes, and snippets.

@edwardean
edwardean / FCPrivateBatteryStatus.m
Created March 21, 2016 01:25
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);
@edwardean
edwardean / IPInsetLabel.h
Created March 21, 2016 01:42
IPInsetLabel: a simple UILabel subclass that adds padding insets and auto-height-resizing
//
// IPInsetLabel.h
// Instapaper
//
// Created by Marco Arment on 7/23/11.
// Copyright 2011 Instapaper LLC, released to the public domain.
//
#import <UIKit/UIKit.h>
if pgrep "iOS Simulator"; then
killall "iOS Simulator"
fi
if pgrep "Xcode"; then
killall "Xcode"
fi
xcrun simctl list | awk -F "[()]" '{ for (i=2; i<NF; i+=2) print $i }' | grep '^[-A-Z0-9]*$' | xargs -I uuid xcrun simctl erase uuid | true
echo $?
@edwardean
edwardean / gist:16d33e42fb484a7eb149
Created March 21, 2016 02:54 — forked from peterlee0127/gist:2843423
iOS getgetIPAddress
//This is xxx.h
/*
//#import <ifaddrs.h>
//#import <arpa/inet.h>
@interface TKUWiFiInformation : NSObject
- (NSString *)getIPAddress;
@end
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@edwardean
edwardean / Breakpoints_v2.xcbkptlist
Created March 27, 2016 13:41 — forked from Ashton-W/Breakpoints_v2.xcbkptlist
My User Breakpoints_v2.xcbkptlist
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<!-- All Exceptions -->
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
#!/usr/bin/env ruby
search_dir = ARGV[0] || "."
files = Dir.glob("#{search_dir}/**/*.{h,m,swift}")
if files.length > 0
puts "Found the following header or implementation files in '#{search_dir}':"
files.each do |filepath|
puts filepath
+ (UIImage *)decompressedImageWithImage:(UIImage *)image resizeTo:(CGSize)targetSize
{
CGImageRef imageRef = image.CGImage;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef);
BOOL sameSize = NO;
if (CGSizeEqualToSize(targetSize, CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)))) {
targetSize = CGSizeMake(1, 1);
sameSize = YES;
}
- (void)rotatePath:(UIBezierPath *)path degree:(CGFloat)degree {
CGRect bounds = CGPathGetBoundingBox(path.CGPath);
CGPoint center = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
CGFloat radians = (degree / 180.0f * M_PI);
CGAffineTransform transform = CGAffineTransformIdentity;
transform = CGAffineTransformTranslate(transform, center.x, center.y);
transform = CGAffineTransformRotate(transform, radians);
transform = CGAffineTransformTranslate(transform, -center.x, -center.y);
[path applyTransform:transform];
* As an optimization, dispatch_sync() invokes the block on the current
* thread when possible.
dispatch_sync(dispatch_get_global_queue(0, 0), ^{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
NSLog(@"First");
}];
[[NSOperationQueue currentQueue] addOperationWithBlock:^{