Skip to content

Instantly share code, notes, and snippets.

Avatar

Shawn Wall shawnwall

View GitHub Profile
View gist:cacf727679f3794eba5d
- (void)drawRect:(CGRect)rect {
//draw the base
UIBezierPath* baseArc = [UIBezierPath bezierPathWithArcCenter:CGPointMake(CGRectGetWidth(self.bounds) / 2, CGRectGetHeight(self.bounds) / 2)
radius:self.bounds.size.height/2-24
startAngle:DEGREES_TO_RADIANS(180)
endAngle:DEGREES_TO_RADIANS(360)
clockwise:YES];
[[UIColor grayColor] setStroke];
baseArc.lineWidth = 24;
[baseArc stroke];
View gist:3077588
new-host-3:~ swall$ ios devices:list --trace
/Users/swall/.rvm/gems/ruby-1.9.2-p290/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:70:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
from /Users/swall/.rvm/gems/ruby-1.9.2-p290/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:70:in `block in connect'
from /Users/swall/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
from /Users/swall/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
from /Users/swall/.rvm/gems/ruby-1.9.2-p290/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:70:in `connect'
from /Users/swall/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
from /Users/swall/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:632:in `start'
from /Users/swall/.rvm/gems/ruby-1.9.2-p290/gems/net-http-persistent-2.7/lib/net/http/persistent.rb:511:in `conne
@shawnwall
shawnwall / gist:2657436
Created May 11, 2012
Python twitter json sample
View gist:2657436
#!/usr/bin/env python
import urllib2
import json
result = json.load(urllib2.urlopen('http://api.twitter.com/1/trends/daily.json'))
for date,trends in result['trends'].iteritems():
print date
for trend in trends:
print trend['query']
@shawnwall
shawnwall / gist:2423595
Created Apr 19, 2012
UIViewController gradient border
View gist:2423595
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
size_t num_locations = 2;
CGFloat locations[2] = { 0.0, 1.0 };
CGFloat components[8] = { 1.0, 1.0, 1.0, 0.0, // Start color
1.0, 1.0, 1.0, 1.0 }; // End color
CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB();
CGGradientRef gradient = CGGradientCreateWithColorComponents(rgbColorspace, components, locations, num_locations);
@shawnwall
shawnwall / gist:2423583
Created Apr 19, 2012
UIView gradient inner border drawRect:
View gist:2423583
- (void)drawRect:(CGRect)rect
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
UIBezierPath *path = [UIBezierPath bezierPathWithRect:rect];
//To create a 1.0f borderWidth
CGRect innerRect = rect;
innerRect.origin.x += 1.0f;
innerRect.origin.y += 1.0f;
innerRect.size.width -= 2.0f;
@shawnwall
shawnwall / gist:2215212
Created Mar 27, 2012
Unit testing blocks with AFNetworking example
View gist:2215212
/*
* SenTestingKit does not wait for blocks to finish by default so your test would simply complete
* as successful. You need to use a semaphore and keep the run loop going in order for the test
* to properly run.
*/
- (void)testGetSpots {
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
CLLocation location = [[CLLocation alloc] initWithLatitude:70.0 longitude:50.0];
[Spot spotsWithURLString:@"/spots" near:location parameters:[NSDictionary dictionaryWithObject:@"128" forKey:@"per_page"] block:^(NSArray *records) {
//sample assert