Skip to content

Instantly share code, notes, and snippets.

🌙
BRB GOING TO THE MOON

Federico Zanetello zntfdr

🌙
BRB GOING TO THE MOON
Block or report user

Report or block zntfdr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zntfdr
zntfdr / firebase-iOS-breakdown
Last active Nov 6, 2019
Firebase iOS Version breakdown
View firebase-iOS-breakdown
// How to:
// 1. Go in the Firebase Analytics Dashboard
// 2. Filter iOS Platform only
// 3. Scroll down, select `Device` under the "What is your audience like?" widget
// 4. Export the CSV data (top right of the corner, there's a `...` menu with Download CSV option)
// 5. Open the file and select the iOS breakdown raw data
// 6. Replace your data with the sample data in this script
// 7. Run the script in a Xcode Playground
// 8. See the terminal output
View vibrant-materials.swift
//
// System Materials Playground
// fivestars.blog
//
// Created by Federico Zanetello on 9/6/19.
//
import UIKit
import PlaygroundSupport
@zntfdr
zntfdr / grayscaleSystemColors.swift
Last active Jun 18, 2019
A Playground showcasing the iOS 13 system colors grayscale
View grayscaleSystemColors.swift
//
// System Colors Playground
// fivestars.blog
//
// Created by Federico Zanetello on 9/6/19.
//
import UIKit
import PlaygroundSupport
@zntfdr
zntfdr / rainbowSystemColors.swift
Last active Jun 18, 2019
A Playground showcasing all the iOS 13 system colors
View rainbowSystemColors.swift
//
// System Colors Playground
// fivestars.blog
//
// Created by Federico Zanetello on 9/6/19.
//
import UIKit
import PlaygroundSupport
@zntfdr
zntfdr / clean_localizable.swift
Created Sep 21, 2018 — forked from ginowu7/clean_localizable.swift
Clean swift localizable script
View clean_localizable.swift
/// Throws error if ALL localizable files does not have matching keys
///
/// - Parameter files: list of localizable files to validate
func validateMatchKeys(_ files: [LocalizationStringsFile]) {
print("------------ Validating keys match in all localizable files ------------")
guard let base = files.first, files.count > 1 else { return }
let files = Array(files.dropFirst())
files.forEach {
guard let extraKey = Set(base.keys).symmetricDifference($0.keys).first else { return }
let incorrectFile = $0.keys.contains(extraKey) ? $0 : base
View resourceIsAvailableFail.swift
if (resourceIsAvailable) {
resourceIsAvailable = false
useResource()
resourceIsAvailable = true
} else {
// resource is not available, wait or do something else
}
View UIImageLoader.swift
extension UIImage {
func load(image imageName: String) -> UIImage {
// declare image location
let imagePath: String = "\(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0])/\(imageName).png"
let imageUrl: URL = URL(fileURLWithPath: imagePath)
// check if the image is stored already
if FileManager.default.fileExists(atPath: imagePath),
let imageData: Data = try? Data(contentsOf: imageUrl),
let image: UIImage = UIImage(data: imageData, scale: UIScreen.main.scale) {
View TheTwelveDaysOfChristmasSong.swift
let gifts = [ "partridge in a pear tree", "Two turtle doves", "Three French hens",
"Four calling birds", "Five golden rings", "Six geese a-laying",
"Seven swans a-swimming", "Eight maids a-milking", "Nine ladies dancing",
"Ten lords a-leaping", "Eleven pipers piping", "Twelve drummers drumming" ]
let nth = [ "first", "second", "third", "fourth", "fifth", "sixth",
"seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth" ]
func gifts(for day: Int) -> String {
var result = "On the \(nth[day-1]) day of Christmas, my true love sent to me:\n"
View Backward-Compatibility-example.swift
import UIKit
class MyView: UIView {
fileprivate var myPreviewInteraction: Any? = nil
init() {
super.init(frame: CGRect.zero)
if #available(iOS 10.0, *) {
myPreviewInteraction = UIPreviewInteraction(view: self)
View DijkstraShortestPath.swift
internal func shortestPath(source: Vertex, destination: Vertex) -> Path? {
var frontier: [Path] = [] {
didSet {
frontier.sortInPlace()
}
}
var finalPaths: [Path] = [] {
didSet {
finalPaths.sortInPlace()
You can’t perform that action at this time.