Skip to content

Instantly share code, notes, and snippets.

View Pre1's full-sized avatar
Coffee(ing)

Abdullah Pre1

Coffee(ing)
View GitHub Profile
precedencegroup RangePattern {
associativity: left
lowerThan: RangeFormationPrecedence
}
infix operator .. : RangePattern
extension Float {
var samePrecision: Float {
return Float(description) ?? 0.0
}
}
@Pre1
Pre1 / Networking.swift
Created June 18, 2016 19:23
from Swift Talk 1st episode
// Check out the talk: https://talk.objc.io/episodes/S01E01-networking (Part 1)
// the talk uses swift 2 and I follow along by writing it in swift 3.
import Foundation
import PlaygroundSupport
//extension Sequence {
// public func failingFlatMap<T>(_ transform: @noescape(Self.Iterator.Element) throws -> T?) rethrows -> [T]? {
// var result: [T] = []
// for element in self {
@Pre1
Pre1 / 99bottles.swift
Last active April 14, 2016 13:24
99 bottles of beer in swift 2.2...3.0
/*
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
.
.
.
1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.
No more bottles of beer on the wall, no more bottles of beer.