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 | |
public class Team | |
{ | |
// Nombre del equipo | |
public var name: String | |
// Cuando se ha creado | |
public private(set) var createdAt: Date | |
public init(named name: String) |
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
<html> | |
<head> | |
<title>La prueba</title> | |
<style> | |
.btn-hide | |
{ | |
visibility: hidden; | |
} | |
.btn-show |
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 tweet: String = "Detectar etiquetas y usuario en un tuit con #Swift. También podemos recoger los usuario como @fitomad o @AppStore. #SwiftLang #iOSDev #macOSDev" | |
// Estos caracteres no nos interesan... | |
var skip_set: CharacterSet = CharacterSet.whitespacesAndNewlines | |
skip_set.formUnion(CharacterSet.punctuationCharacters) | |
// ...excepto estos, que son para usuarios y etiquetas y no debemos excluirlos. | |
skip_set.remove(charactersIn: "@#_") |
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
// Números del 0 al 10 pero con el **5** un poco *descolocaldo* | |
let numeros: [Int] = [ 0, 1, 2, 3, 4, 6, 7, 8, 9, 5, 10 ] | |
// Swift 3.1 | |
let menores = numeros.prefix(while: { $0 < 5 }) | |
let mayores = numeros.drop(while: { $0 < 5 }) | |
dump(menores) | |
/* |
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 | |
extension Array where Element: Comparable | |
{ | |
/** | |
Saludamos en orden a todos los integrantes del `Array`. | |
*/ | |
public func saluteAllElements() -> Void | |
{ | |
let sorted_elements: [Element] = self.sorted(by: { $0 < $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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Ejemplo LivePhotosKit JS</title> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<div id="livephotos-layer" style="width: 1024px; height: 720px;"></div> | |
</body> |
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
// Creamos el LivePhotos Player. | |
const player = LivePhotosKit.Player(document.getElementById('livephotos-layer')); | |
player.photoSrc = 'images/live/waves.jpg'; | |
player.videoSrc = 'images/live/waves.mov'; | |
// | |
// Eventos | |
// |
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 CoreMotion | |
import Foundation | |
let queue: OperationQueue = OperationQueue() | |
queue.qualityOfService = .utility | |
let motionManager: CMMotionManager = CMMotionManager() | |
motionManager.magnetometerUpdateInterval = 0.5 | |
motionManager.startMagnetometerUpdates(to: queue, withHandler: { (data: CMMagnetometerData?, error: Error?) -> Void in |
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
/* | |
An autoclosure is a closure that is automatically created to wrap an expression that’s being passed as an argument to a function. | |
It doesn’t take any arguments, and when it’s called, it returns the value of the expression that’s wrapped inside of it | |
*/ | |
let greeting: () -> (String) = { | |
print("You can do other things here...") | |
return "Hi everyone!" |
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 | |
// | |
// MARK: - Venue struct representation | |
// | |
/** | |
Different venue types. | |
*/ | |
public enum Kind: String, Codable |