Skip to content

Instantly share code, notes, and snippets.

@adregan
adregan / rides.json
Last active December 30, 2020 13:06
{"count": 20, "fitness_disciplines": [{"id": "walking", "name": "Walking"}, {"id": "strength", "name": "Strength"}, {"id": "cycling", "name": "Cycling"}, {"id": "stretching", "name": "Stretching"}, {"id": "running", "name": "Running"}, {"id": "beyond_the_ride", "name": "Floor"}, {"id": "circuit", "name": "Bootcamp"}, {"id": "yoga", "name": "Yoga"}, {"id": "meditation", "name": "Meditation"}, {"id": "cardio", "name": "Cardio"}], "rides": [{"scheduled_start_time": 1565883000, "rating": 0, "difficulty_rating_avg": 0.0, "equipment_tags": [], "difficulty_rating_count": 0, "captions": [], "title": "30 min Power Zone Ride", "is_explicit": false, "live_stream_id": "e571d20a9efc4e34a75a8bb3924acfd7-live", "origin_locale": "en-US", "difficulty_estimate": null, "content_format": "video", "location": "nyc", "original_air_time": 1565882340, "has_closed_captions": false, "pedaling_duration": 1800, "sample_vod_stream_url": null, "extra_images": [], "series_id": "9fde039566054ea499130bed1c289eb3", "studio_peloton_id": "7812b
@mildocjr
mildocjr / access1.swift
Created August 11, 2018 01:56
access-1
public class myClass {
}
// the public keyword defines the access control for this class
@mildocjr
mildocjr / iflet5.swift
Created August 11, 2018 01:56
if-let-5
if let actualInteger = possibleInteger,
let actualDouble = actualInteger as? Double {
// do stuff with actualInteger
// or actualDouble
}
@mildocjr
mildocjr / iflet4.swift
Created August 11, 2018 01:55
if-let-4
if let acutualInteger = possibleInteger,
var actualString = possibleString {
// do stuff
}
@mildocjr
mildocjr / iflet3.swift
Created August 11, 2018 01:54
if-let-3
func add(firstPossibleInteger: Int?, secondPossibleInteger: Int?) -> Int? {
guard let firstNumber = firstPossibleInteger,
let secondNumber = secondPossibleNumber
else { return nil } // or 0 if you want to return a
// non-optional value
return (firstNumber + secondNumber)
}
@mildocjr
mildocjr / iflet2.swift
Created August 11, 2018 01:53
if-let-2
if let actualDouble = possibleDouble {
// do stuff with actualDouble
}
@mildocjr
mildocjr / iflet1.swift
Created August 11, 2018 01:53
if-let-1
if let actualInteger = possibleInteger as? Int {
// do stuff with actual integer
print(actualInteger) // prints 3
print(possibleInteger) // prints Optional(3)
// actualInteger's scope ends here
}
@mildocjr
mildocjr / typecast5.swift
Created August 11, 2018 01:52
type-cast-5
class CustomTableViewCell: UITableViewCell {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var title: UILabel!
@IBOutlet weak var subtitle: UILabel!
}
class TableView: UITableView {
func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(with: identifier)
@mildocjr
mildocjr / typecast4.swift
Created August 11, 2018 01:51
type-cast-4
var integerValue = 42
var stringValue = String(describing: 42)
var doubleValue = integerValue as! Double
var floatValue = Int(stringValue) as? Float
var array: [String] = ["eggs", "bacon", "ham", "cheese"]
let arrayCount = Double(array.count as? String)
var numArray: [Int] = [1, 2, 3, 4, 5]
@mildocjr
mildocjr / typecast3.swift
Created August 11, 2018 01:50
type-cast-3
var integerValue = 42
var stringValue = integerValue as? String