Skip to content

Instantly share code, notes, and snippets.

Avatar

Stefano Vettor freedom27

View GitHub Profile
View Neuron.swift
//: Playground - noun: a place where people can play
import Foundation
protocol Neuron {
var weights: [Double] {get}
func feedforward(input: [Double]) -> Double
func activation(input: Double) -> Double
}
View UIBarButtonItem+Badge.swift
//
// UIBarButtonItem+Badge.swift
// PiGuardMobile
//
// Created by Stefano Vettor on 12/04/16.
// Copyright © 2016 Stefano Vettor. All rights reserved.
//
import UIKit
View Observable.swift
protocol Disposable {
func dispose()
func addToDisposablesBag(bag: DisposablesBag)
}
extension Disposable {
func addToDisposablesBag(bag: DisposablesBag) {
bag.add(self)
}
}
View Promises_futures_experiments.swift
//
// Promise.swift
// PiGuardMobile
//
// Created by Stefano Vettor on 06/04/16.
// Copyright © 2016 Stefano Vettor. All rights reserved.
//
import Foundation
@freedom27
freedom27 / String+Enhancement.swift
Last active Feb 9, 2016
Working with swift's Strings made easy
View String+Enhancement.swift
import Foundation
extension String {
func substringWithRange(r: Range<Int>) -> String {
return substringWithRange(Range(start: startIndex.advancedBy(r.startIndex), end: startIndex.advancedBy(r.endIndex)))
}
func substringToIndex(i: Int) -> String {
return substringToIndex(startIndex.advancedBy(i))
@freedom27
freedom27 / Protocols_and_trees.swift
Last active Dec 16, 2015
Experimenting with Swift's protocols and trees
View Protocols_and_trees.swift
protocol HasName {
var name: String { get }
}
protocol HasSubNodes: HasName {
var subNodes: [HasName] { get }
}
protocol HasData: HasName {
You can’t perform that action at this time.