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
// Import these Frameworks: | |
#import <MapKit/MapKit.h> | |
// Include this delegate | |
@interface ViewController () <MKMapViewDelegate> | |
- (void)viewDidLoad | |
{ | |
// Add this code to your preexisting viewDidLoad method |
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
// Put this in viewDidLoad where _webView is your targetted view | |
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; | |
[refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged]; | |
[_webView.scrollView addSubview:refreshControl]; | |
// Declare this method elsewhere in the implementation file | |
-(void)handleRefresh:(UIRefreshControl *)refresh { | |
// Code here | |
[refresh endRefreshing]; | |
} |
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
MKMapRect zoomRect = MKMapRectNull; | |
for (id <MKAnnotation> annotation in mapView.annotations) { | |
MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate); | |
MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0); | |
if (MKMapRectIsNull(zoomRect)) { | |
zoomRect = pointRect; | |
} else { | |
zoomRect = MKMapRectUnion(zoomRect, pointRect); | |
} | |
} |
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
- (IBAction)showToolbarButtonPressed:(id)sender { | |
// Set up conditional to setup toggle feature. | |
// This conditional checks if the toolbar is invisible, and if it is, it animates the opacity to 100%, otherwise, it assumes the toolbar is visible, and animates the opacity to 0%. Code can check any other conditionals, ie. self.toolbar.isHidden == YES, etc. | |
if (self.toolbar.alpha == 0.0f) { | |
// Disable button | |
[self.showToolbarButton setEnabled:NO]; | |
// Fade toolbar in w/ Animation | |
[UIView animateWithDuration:2.0f |
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
CLLocationCoordinate2D mapCoordinate = ...; //user location or annot coord | |
MKMapPoint mapPoint = MKMapPointForCoordinate(mapCoordinate); | |
MKPolygonView *polygonView = | |
(MKPolygonView *)[mapView viewForOverlay:polygonOverlay]; | |
CGPoint polygonViewPoint = [polygonView pointForMapPoint:mapPoint]; | |
BOOL mapCoordinateIsInPolygon = |
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
// Initialize location services. | |
locationManager = [[CLLocationManager alloc] init]; | |
[locationManager requestAlwaysAuthorization]; | |
locationManager.delegate = self; | |
// Accuracy constants here. These should be tested for battery optimization. | |
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; | |
locationManager.distanceFilter = kCLDistanceFilterNone; | |
[locationManager startUpdatingLocation]; |
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
// Set up the CV Video Camera object to bring in video to the program | |
videoCamera = [[CvVideoCamera alloc] initWithParentView:self.imageView]; | |
videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionBack; | |
videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPresetHigh; | |
videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait; | |
videoCamera.defaultFPS = 30; | |
videoCamera.grayscaleMode = NO; | |
videoCamera.delegate = self; |
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
# I'll refactor this later, but it's almost midnight and I just wanted to demonstrate how sick NEAT is at solving problems without defining any direction for the algoritm | |
from __future__ import print_function | |
import gym | |
import numpy as np | |
import itertools | |
import os | |
from neat import nn, population, statistics |
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
from __future__ import print_function | |
import gym | |
import numpy as np | |
import itertools | |
import os | |
from neat import nn, population, statistics | |
# another great example of how crazy effective NEAT can be even when it knows literally nothing about what's going on in the environment. |
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
#--- parameters for the XOR-2 experiment ---# | |
# The `Types` section specifies which classes should be used for various | |
# tasks in the NEAT algorithm. If you use a non-default class here, you | |
# must register it with your Config instance before loading the config file. | |
[Types] | |
stagnation_type = DefaultStagnation | |
reproduction_type = DefaultReproduction | |
[phenotype] |
OlderNewer