Skip to content

Instantly share code, notes, and snippets.

View shnhrrsn's full-sized avatar

Shaun Harrison shnhrrsn

View GitHub Profile
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"EGOTitledTableViewCell";
EGOTitledTableViewCell *cell = (EGOTitledTableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[EGOTitledTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell...
if(indexPath.row == 0) {
// Load an Image:
UIImage* image = [UIImage imageWithData:[[EGOCache currentCache] dataForKey:@"imageCacheKey"]];
// Store an Image:
[[EGOCache currentCache] setData:UIImagePNGRepresentation(image) forKey:@"imageCacheKey" withTimeoutInterval:604800];
- (void)viewDidLoad {
[super viewDidLoad];
float scaleBy = 0.80;
id<MKAnnotation> annotation; // Define to yours
self.mapView = [[[MKMapView alloc] initWithFrame:CGRectMake(20.0f, 20.0f, 64 / scaleBy, 64 / scaleBy)] autorelease];
[self.mapView addAnnotation:job];
CLLocationCoordinate2D coordinate = annotation.coordinate;
coordinate.longitude -= 0.0006;
@implementation ExampleCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
imageView = [[EGOImageView alloc] initWithPlaceholderImage:[UIImage imageNamed:@"placeholder.png"]];
imageView.frame = CGRectMake(4.0f, 4.0f, 36.0f, 36.0f);
[self.contentView addSubview:imageView];
}
return self;
protected void onDraw(Canvas canvas) {
Bitmap bitmap; // set to your bitmap
canvas.drawBitmap(bitmap, null, new Rect(0, 0, 50, 50), null);
}
protected void onDraw(Canvas canvas) {
Bitmap bitmap; // set to your bitmap
Rect src = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); // Fix for HA
canvas.drawBitmap(bitmap, src, new Rect(0, 0, 50, 50), null);
}
@shnhrrsn
shnhrrsn / gist:5723701
Last active December 18, 2015 04:09
Swap class selectors with a block
#import <objc/runtime.h>
#import <objc/message.h>
SEL SHNSwapSelectorWithBlock(Class class, SEL selector, BOOL isClassMethod, id block) {
Method method1 = isClassMethod ? class_getClassMethod(class, selector) : class_getInstanceMethod(class, selector);
// Generate new selector to inject
SEL newSelector = NSSelectorFromString([@"_swappedBlock_" stringByAppendingString:NSStringFromSelector(selector)]);
// Inject the block as method in the class
@shnhrrsn
shnhrrsn / SHNFakeStatusBar.m
Created December 3, 2013 18:53
Include in your code to create a fake and consistent status bar to take screenshots with.
//
// SHNFakeStatusBar
// Created by Shaun Harison on 12/3/13.
//
#import <objc/runtime.h>
#define CARRIER_STRING @"Apple"
#define TIME_STRING @"Timestamp"
extension CGRect: DebugPrintable {
var debugDescription: String {
return NSStringFromCGRect(self)
}
}
extension CGSize: DebugPrintable {
var debugDescription: String {
return NSStringFromCGSize(self)
}
@shnhrrsn
shnhrrsn / urlsession-mitmproxy.swift
Created March 12, 2017 20:02
URLSession + MITM Proxy
fileprivate class NetworkingDelegate: NSObject, URLSessionDelegate {
fileprivate func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
completionHandler(.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!))
}
}
private let proxySessionDelegate = NetworkingDelegate()