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
// Inspiration source: https://www.maketecheasier.com/google-scripts-to-automate-gmail/ | |
function auto_mark_as_read_old_mails() { | |
var labels = ["Builds/Firebase", "Builds/TestFlight", "AppStore Connect"]; | |
for (var i = 0; i < labels.length; i++) { | |
var label = GmailApp.getUserLabelByName(labels[i]); | |
if(label != null) { | |
processThreads_(label.getThreads(), labels[i]); | |
} else { | |
console.log("wrong label: ", labels[i]); | |
} |
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 UIKit | |
import PlaygroundSupport | |
public class CircleProgressView: UIView { | |
private var radius: CGFloat { (bounds.height - lineWidth) / 2 } | |
private let baseLayer = CAShapeLayer() | |
private let progressLayer = CAShapeLayer() | |
private let progress: CGFloat | |
private let lineWidth: CGFloat = 10.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
func addAnimation(duration: TimeInterval, delay: TimeInterval) { | |
let animation = CABasicAnimation(keyPath: "strokeEnd") | |
animation.beginTime = CACurrentMediaTime() + delay | |
animation.duration = duration | |
animation.fromValue = 0 | |
animation.toValue = 1 | |
animation.timingFunction = CAMediaTimingFunction(name: .easeIn) | |
animation.fillMode = .forwards | |
animation.isRemovedOnCompletion = false | |
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
private extension CGFloat { | |
static var initialAngle: CGFloat = -(.pi / 2) | |
static func endAngle(progress: CGFloat) -> CGFloat { | |
.pi * 2 * progress + .initialAngle | |
} | |
} | |
let path = UIBezierPath( | |
arcCenter: CGPoint(x: bounds.width / 2, y: bounds.height / 2), |
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 layer = CAShapeLayer() | |
layer.lineWidth = 8 | |
layer.fillColor = UIColor.clear.cgColor | |
layer.lineWidth = lineWidth | |
layer.strokeColor = UIColor.orange.cgColor | |
let path = UIBezierPath( | |
arcCenter: CGPoint(x: bounds.width / 2, y: bounds.height / 2), | |
radius: (bounds.height - lineWidth) / 2, | |
startAngle: 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
xcrun simctl openurl booted https://www.example.com/faq | |
// https://objectivetidbits.com/2017/06/08/working-with-universal-links-on-ios-simulator/ |
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
// Idea obtained from https://medium.com/@dushyant_db/swift-4-recipe-self-sizing-table-view-2635ac3df8ab | |
// it can be useful if you want to center it in the screen (let's say in an iPad for example), or take up all the available | |
// height. Also it could be used to be placed inside a UIStackView | |
class IntrinsicContentSizeTableView: UITableView { | |
var maxHeight: CGFloat = UIScreen.main.bounds.size.height | |
override var intrinsicContentSize: CGSize { | |
let height = min(contentSize.height, maxHeight) | |
return CGSize(width: contentSize.width, height: height) | |
} |
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
Total time: 2.64654844999313 | |
TotalTimeOptimized: 2.50773054361343 | |
Total time difference: 0.1388179063797 | |
Average: 0.0001388179063797 |
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 String { | |
static func randomStringOptimized(size: UInt) -> String { | |
let stringSet = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ" | |
return (0..<size).reduce(into: "", stringSet.randomCharacterOptimized) | |
} | |
private func randomCharacterOptimized(partialResult: inout String, iterationIndex: UInt) { | |
let randomIndex = arc4random_uniform(UInt32(count)) | |
let charIndex = index(startIndex, offsetBy: String.IndexDistance(randomIndex)) |
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 String { | |
static func randomString(size: UInt) -> String { | |
let stringSet = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ" | |
return (0..<size).reduce("", stringSet.randomCharacter) | |
} | |
private func randomCharacter(partialResult: String, iterationIndex: UInt) -> String { | |
let randomIndex = arc4random_uniform(UInt32(count)) | |
let charIndex = index(startIndex, offsetBy: String.IndexDistance(randomIndex)) | |
return partialResult.appending(String(self[charIndex])) |
NewerOlder