Skip to content

Instantly share code, notes, and snippets.

Swift + Machine Learning + Big Data

Adolfo fitomad

View GitHub Profile
View turicreate_web.config.xml
<!-- web.config ASP.NET // IIS -->
<directoryBrowse enabled="true" />
<clear />
<mimeMap fileExtension="*" mimeType="application/octet-stream" />
View generic-codable-decoder.swift
import Foundation
public struct Show: Codable
public var name: String
public var network: String
View ultimate_interview_code_review_never_and_ever.swift
import Foundation // Always import Foundation, no matter what you're developing
public struct Interview // Use structs, Apple loves structs, then me too. Why? Cause Apple love structs.
// ¡Oh fortuna! ¿por qué eres tan esquiva conmigo? (Yes, spanish too)
private var result: Bool
/// Human readable result.
public var resultMessage: String
View queue-playground.swift
import Foundation
public struct Queue<Element>
private var storage: [Element]
public init()
{ = [Element]()
fitomad / stack-playground.swift
Created May 17, 2018
Swift Stack Data Structure
View stack-playground.swift
import Foundation
public struct Stack<Element>
private var storage: [Element]
public init()
{ = [Element]()
fitomad / first-word-duplicated.swift
Created Apr 15, 2018
Obtain the first word duplicated in a phrase.
View first-word-duplicated.swift
let phrase: String = "If you know what you know if I..."
let words = phrase.split(separator: " ")
/// Check if a given word is includen in a string
/// before the own word.
func containsWord(_ word: String, offsetLimit limit: Int) -> Bool
return words.enumerated()
.filter({ $0.offset < limit })
.map({ String($0.element) })
fitomad / repeat_array.swift
Created Mar 14, 2018
Array extension that insert an element n-times in the array with a gap between each element's insertion.
View repeat_array.swift
extension Array
Insert an element n-times in the array
with a gap between each element's insertion.
var numbers: [String] = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ]
numbers.repeat("X", gap: 3, fromTheBeginning: false)
View array_swift41.swift
// New `joined` and `split` functions in Swift 4.1
// More info at Swift [Array Documentacion](
import Foundation
// The sample data...
let data: [String] = [ "Col1", "Col2", "Col3", "Col4", "Col5"]
View typeof.swift
// An array with Int, Double and String types inside
let items: [Any] = [ 32, 32.0, "32" ]
for item in items
switch type(of: item)
case is Int.Type:
print("Type Int: \(item)")
fitomad / background_sound.swift
Created Jan 30, 2018
Enable iOS app to play sound in background
View background_sound.swift
// MARK: - Step 1. Configuration
You need to enable one feature in order to allow our app play sounds in *background* mode.
Select the Capabilities tab of project's main target, go to Background Modes section and select:
**Audio, AirPlay and Picture in Picture
You can’t perform that action at this time.