Skip to content

Instantly share code, notes, and snippets.

@jad
jad / iPhone: Drawing a Drop Shadow
Created May 2, 2009 17:48
Simple example of drawing a drop shadow with Core Graphics.
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
rect = [self bounds];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
// use the same background color as the view, but with an alpha of 1.0
@property(retain) NSString *foo;
void setFoo:(NSString *)s {
[release foo];
foo = [s retain];
}
func performRequest<A: Decodable>(request: NSURLRequest, callback: (Result<A>) -> ()) {
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) { data, urlResponse, error in
let responseResult = Result(error, Response(data: data, urlResponse: urlResponse))
let result = responseResult >>> parseResponse
>>> decodeJSON
>>> A.decode
callback(result)
}
task.resume()
}
var gistPrefix = 'http://gist.github.com/',
// Cache document.write so that it can be restored once all Gists have been
// embedded.
cachedWrite = document.write,
body = $('body'),
// Map each p.gist to an object that contains the paragraph to be replaced
// and the Gist's identifier.
gists = $('p.gist').map(function(n, p) {
p = $(p);