This file contains hidden or 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
let string = "This is a string with an \u{2014} unicode character &mdash" |
This file contains hidden or 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
// Load video | |
// Note: Needs to be a supported AVPlayer format, in this case MP4 (could also be M4V etc.) | |
if let filePath = Bundle.main.path(forResource: "video", ofType: "mp4") { | |
// url | |
let fileUrl = URL(fileURLWithPath: filePath) | |
// Player | |
let player = AVPlayer(url: fileUrl) |
This file contains hidden or 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
extension UIImage { | |
class func imageWithLayer(layer: CALayer) -> UIImage? { | |
UIGraphicsBeginImageContextWithOptions(layer.bounds.size, layer.isOpaque, 0.0) | |
layer.render(in: UIGraphicsGetCurrentContext()!) | |
guard let img = UIGraphicsGetImageFromCurrentImageContext() else { | |
return nil | |
} | |
UIGraphicsEndImageContext() |
This file contains hidden or 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
// Helper function for showing UIAlert prompts | |
func showMessagePrompt(_ title: String, message: String) { | |
let alert = UIAlertController.init(title: title, message: message, preferredStyle: .alert) | |
alert.addAction(UIAlertAction.init(title: "OK", style: .default, handler: nil)) | |
self.present(alert, animated: true, completion: nil) | |
} | |
/********************/ |
This file contains hidden or 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
@IBDesignable | |
class RoundedView: UIView { | |
@IBInspectable var roundedValue: CGFloat = 0.0 { | |
didSet { | |
layer.cornerRadius = roundedValue | |
} | |
} | |
@IBInspectable var strokeWidth: CGFloat = 0.0 { |
This file contains hidden or 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
// Charger locations array of touples (Double, Double) | |
let chargeLocations = stations.map { ($0.location.latitude, $0.location.longitude) } | |
// Returns an array of touples exctracted from the location value of each array element. |
This file contains hidden or 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 AVKit | |
import AVFoundation | |
class ViewController: UIViewController { | |
@IBOutlet weak var videoOverlayView: UIView! | |
@IBOutlet weak var videoView: UIView! | |
var player: AVPlayer? |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> | |
<CORSRule> | |
<AllowedOrigin>michaelevensen.com</AllowedOrigin> | |
<AllowedMethod>GET</AllowedMethod> | |
<AllowedMethod>HEAD</AllowedMethod> | |
<MaxAgeSeconds>3000</MaxAgeSeconds> | |
<AllowedHeader>*</AllowedHeader> | |
</CORSRule> | |
</CORSConfiguration> |
This file contains hidden or 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:(GMSMapView*)mapView idleAtCameraPosition:(GMSCameraPosition*)position | |
{ | |
CLLocationCoordinate2D topLeft = mapView.projection.visibleRegion.farLeft; | |
CLLocationCoordinate2D bottomLeft = mapView.projection.visibleRegion.nearLeft; | |
double lat = fabs(topLeft.latitude - bottomLeft.latitude); | |
double mpp = cos(lat * M_PI / 180) * 2 * M_PI * 6378137 / (256 * pow(2, mapView.camera.zoom)); | |
double distance = mpp * mapView.frame.size.width; | |
[[SearchManager shareInstance] distance: distance]; | |
} |
This file contains hidden or 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
// Conform to Hashable | |
extension ChargeConnector: Hashable { | |
var hashValue: Int { | |
return id.hashValue ^ id.hashValue | |
} | |
static func == (lhs: ChargeConnector, rhs: ChargeConnector) -> Bool { | |
return lhs.id == rhs.id | |
} |