Skip to content

Instantly share code, notes, and snippets.

View tewha's full-sized avatar

Steven Fisher tewha

  • 21:51 (UTC -07:00)
View GitHub Profile
@tewha
tewha / gist:3065339
Created July 7, 2012 07:58 — forked from JimRoepcke/gist:3065296
@synchronized doesn't retain monitored object under MRC
__block id foo = [MyObject new];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSLog(@"block entering synchronized");
@synchronized(foo) {
NSLog(@"running in synchronized");
sleep(10);
// what does @synchronized do the now-zombie foo as part of its closure?
}
NSLog(@"block exited synchronized");
});
@tewha
tewha / complex-mapping-example.php
Created May 3, 2012 22:13
Example output mapping function for Presto
<?php
// NOTE that responses are automatically generated by Presto (this example simulates the call as a demonstration)
// 1. Create new Response (faking $ctx)
$r = new Response((object) array( 'res' => 'htm' ) ); // htm intentional, tests type matching
// 2. Add a new type handler, with a custom mapping (anon fn)