Skip to content

Instantly share code, notes, and snippets.

@thiagoperes
thiagoperes / gist:5887917
Created June 28, 2013 20:38
Helper functions to calculate the distance between two coordinates and to create a distance string
CLLocationDistance distanceBetweenCoordinates(CLLocationDegrees startLat, CLLocationDegrees startLng,
CLLocationDegrees endLat, CLLocationDegrees endLng)
{
CLLocation *locA = [[CLLocation alloc] initWithLatitude:startLat
longitude:startLng];
CLLocation *locB = [[CLLocation alloc] initWithLatitude:endLat
longitude:endLng];
return [locA distanceFromLocation:locB];
#include <stdio.h>
int mul (int a, int b) {
int p = 0;
while (b) {
if ((b&1) == 1)
p += a;
a <<= 1;
b >>= 1;
}
void uncaughtExceptionHandler(NSException *exception)
{
for (id obj in [exception callStackSymbols])
{
printf("%s\n", [obj UTF8String]);
}
}
+ (AVCaptureConnection *)connectionWithMediaType:(NSString *)mediaType fromConnections:(NSArray *)connections
{
for ( AVCaptureConnection *connection in connections ) {
for ( AVCaptureInputPort *port in [connection inputPorts] ) {
if ( [[port mediaType] isEqual:mediaType] ) {
return connection;
}
}
}
return nil;