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 Foundation | |
let randomInt = Int.random(in: 0...3) | |
let spelledOut: String = { | |
switch randomInt { | |
case 0: | |
return "Zero" | |
case 1: | |
return "One" |
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
<!-- | |
Related: https://twitter.com/natanrolnik/status/1055756310023716865 | |
The following snippet should be copied to: | |
~/Library/Developer/Xcode/UserData/CodeSnippets | |
as, for example, guardweak.codesnippet. | |
When you type `guardweakself` inside a function scope, it will generate the following code snippet: | |
guard let <#self#> = <#self#> else { |
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 UIKit | |
extension UICollectionViewFlowLayout { | |
func equalizeSpacing(with minimumSpacing: CGFloat, aItemSize: CGSize? = nil, sectionInsetTop: CGFloat = 0, sectionInsetBottom: CGFloat = 0) { | |
guard let collectionView = collectionView else { return } | |
let totalWidth = collectionView.frame.width | |
let itemSizeToUse = aItemSize ?? itemSize | |
itemSize = itemSizeToUse |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
import PlaygroundSupport | |
extension UIView { | |
func addAndFitSubview(_ subview: UIView, insets: UIEdgeInsets = .zero) { | |
addSubview(subview) | |
subview.fitInSuperview(with: insets) | |
} |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
import PlaygroundSupport | |
extension NSLayoutConstraint { | |
func applyInset(_ insets: UIEdgeInsets) -> NSLayoutConstraint { | |
guard firstAttribute == secondAttribute else { | |
return 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
source 'https://rubygems.org' | |
gem 'cocoapods', '~> 1.5.3' | |
gem 'fastlane', '~> 2.100.1' |
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
def push_notify(lane_name, success) | |
require 'uri' | |
uri = URI.parse("https://api.parse.com/") | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
request = Net::HTTP::Post.new("/1/classes/LaneResult") | |
request.add_field('Content-Type', 'application/json') | |
request.add_field('X-Parse-Application-Id', 'my_parse_id') | |
request.add_field('X-Parse-Master-Key', 'my_parse_key') |
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
after_all do |lane| | |
notify "Fastlane succeeded '#{lane}'" unless Helper.is_ci? #if I'm running it locally, show a terminal OS X notification | |
push_notify(lane, "Succeeded") #check the bonus part! | |
end | |
error do |lane, exception| | |
notify "Fastlane failed '#{lane}'" unless Helper.is_ci? #if I'm running it locally, show a terminal OS X notification | |
push_notify(lane, "Failed") #check the bonus part! | |
end |
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
Parse.Cloud.afterSave("LaneResult", function(request) { | |
var query = new Parse.Query(Parse.Installation); | |
var text = "New event from " + request.object.get("App") + ": " + request.object.get("EventType"); | |
Parse.Push.send({ | |
where: query, // Set our Installation query | |
data: { | |
alert: text, | |
sound: "register.aiff" |
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
def import_certificates | |
return unless Helper.is_ci? # As in my local machine I don't need to import the certificates, only run if it's in the CI | |
create_keychain( | |
name: ENV["KEYCHAIN_NAME"], | |
default_keychain: true, | |
unlock: true, | |
timeout: 3600, | |
lock_when_sleeps: true, | |
password: ENV["KEYCHAIN_PASSWORD"] |