This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
operator infix ⏰ {} | |
@infix func ⏰(time: NSTimeInterval, block: (() -> Void)) { | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(time * Double(NSEC_PER_SEC))), dispatch_get_current_queue(), block) | |
} | |
5.0 ⏰ { | |
println("HI!") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation | |
{ | |
// Zoom to user location | |
MKMapCamera *camera = [mapView.camera copy]; | |
camera.altitude = 1; // Zoom in | |
camera.centerCoordinate = userLocation.coordinate; | |
mapView.camera = camera; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation | |
{ | |
if ([annotation isKindOfClass: [MKUserLocation class]]) | |
return nil; | |
MKPinAnnotationView *pinAnnotationView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier: @"pinAnnotation"]; | |
[pinAnnotationView setAnnotation: annotation]; | |
if (!pinAnnotationView) | |
{ | |
pinAnnotationView = [[MKPinAnnotationView alloc] initWithAnnotation: annotation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
[SIOSocket socketWithHost: @"http://yourHost:3000" response: ^(SIOSocket *socket) | |
{ | |
self.socket = socket; | |
}]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
[SIOSocket socketWithHost: @"http://yourHost:3000" response: ^(SIOSocket *socket) | |
{ | |
self.socket = socket; | |
__weak typeof(self) weakSelf = self; | |
self.socket.onConnect = ^() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[self.socket on: @"update" callback: ^(SIOParameterArray *args) | |
{ | |
// pinData == @"pinID:lat,long" | |
// self.pins == @{@"pinID": <WPAnnotation @ (lat, long)>} | |
NSString *pinData = [args firstObject]; | |
NSArray *dataPieces = [pinData componentsSeparatedByString: @":"]; | |
NSString *pinID = [dataPieces firstObject]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "WorldPinServer", | |
"version": "0.0.0", | |
"description": "Server to distributed phone locations to other phones", | |
"main": "app.js", | |
"author": "myself", | |
"dependencies": { | |
"socket.io":"1.0.4" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var io = require('socket.io')(3000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
io.on('connection', function (socket) { | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
io.on('connection', function (socket) { | |
socket.broadcast.emit('join', socket['id']); | |
console.log(socket['id'] + ' has connected!'); | |
}); |
OlderNewer