Skip to content

Instantly share code, notes, and snippets.

View kwylez's full-sized avatar

Cory D. Wiles kwylez

View GitHub Profile
@kwylez
kwylez / gist:1348851
Created November 8, 2011 19:30
Loading Local UIWebView with GCD
UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
webView.delegate = self;
webView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
NSURL *htmlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"]isDirectory:NO];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(queue, ^{
@kwylez
kwylez / gist:1355329
Created November 10, 2011 16:37
Main Thread Loading of Local UIWebView
// loadRequest
UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
NSURL *htmlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"about"
ofType:@"html"] isDirectory:NO];
NSURLRequest *request = [NSURLRequest requestWithURL:htmlPath];
[webView loadRequest:request];
[self.view addSubview:webView];
[webView release];
@kwylez
kwylez / gist:1355354
Created November 10, 2011 16:45
GCD Loading of Local UIWebView
// loadRequest
UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
NSURL *htmlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"] isDirectory:NO];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(queue, ^{
NSURLRequest *request = [NSURLRequest requestWithURL:htmlPath];
x = ''; (1..1000000).each { |c| x << c.to_s }
def method6():
return ''.join([`num` for num in xrange(loop_count)])
@kwylez
kwylez / sg_layer_export.py
Created January 18, 2012 12:45
Export SimpleGeo Storage Data to CSV
#!/usr/bin/env python
# Written by Cory D. Wiles (http://twitter.com/kwylez) and Bob Waycott (http://twitter.com/bobwaycott)
# Inspired by original work of Javier de la Torre ([email protected] @jatorre)
# Ruby script: https://gist.github.com/1610866
import csv
import time
from simplegeo import Client
@kwylez
kwylez / gist:1952410
Created March 1, 2012 19:13
Forward geocoding support for ios4 and ios5
// Block param typedef
typedef void (^ForwardGeoCompletionBlock)(CLLocationCoordinate2D coords);
// Fetch Records Method
- (void)fetchForwardGeocodeAddress:(NSString *)address withCompletionHanlder:(ForwardGeoCompletionBlock)completion {
if (NSClassFromString(@"CLGeocoder")) {
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
@kwylez
kwylez / CWCLocationManager.h
Created April 19, 2012 15:51
Shared core location manager
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@interface CWCLocationManager : NSObject <CLLocationManagerDelegate> {
CLLocationManager *locationManager;
CLLocation *currentLocation;
NSDate *locationManagerStartDate;
NSTimer *locationTimer;
@kwylez
kwylez / gist:2421928
Created April 19, 2012 15:53
Sample VC implementing shared location manager using KVO
- (void)dealloc {
[super dealloc];
[[CWCLocationManager sharedInstance] removeObserver:self
forKeyPath:@"currentLocation"];
}
- (id)init {
@kwylez
kwylez / gist:3762103
Created September 21, 2012 15:15
Method Swizzling
// json file
{
"Accounts":[{
"AccountNumber":"String content",
"Address":{
"Address1":"String content",
"Address2":"String content",
"City":"String content",
"State":"String content",
"ZipCode":"String content"