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
func Options(set int, options *[]int) { | |
var shift uint = 0 | |
for set >= (1 << shift) { | |
if (1 << (shift + 1)) > set { | |
enum := (1 << shift) | |
*options = append(*options, enum) | |
set = set - enum |
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 | |
private class Weak<T : AnyObject> { | |
private weak var pointer : T? | |
private init(pointer:T) { self.pointer = pointer } | |
} | |
prefix operator § {} | |
postfix operator § {} |
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
// Generated with Jenerator : github.com/romainmenke/Jenerator | |
import Foundation | |
/** | |
* Your Description For WFJenerator Goes Here | |
*/ | |
class WFJenerator { | |
var elements : [WFJeneratorElement] |
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
// Generated with Jenerator : github.com/romainmenke/Jenerator | |
import Foundation | |
/** | |
* Your Description For GFSRestaurants Goes Here | |
*/ | |
class GFSRestaurants { |
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
#!/bin/bash | |
# setup directories | |
mkdir swift-src | |
cd swift-src | |
# get swift | |
git clone https://github.com/apple/swift.git | |
# get utils |
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
var reservedWords = ["associatedtype", "class", "deinit", "enum", "extension", "func", "import", "init", "inout", "internal", "let", "operator", "private", "protocol", "public", "static", "struct", "subscript", "typealias", "var", "break", "case", "continue", "default", "defer", "do", "else", "fallthrough", "for", "guard", "if", "in", "repeat", "return", "switch", "where", "while", "as", "catch", "dynamicType", "false", "is", "nil", "rethrows", "super", "self", "Self", "throw", "throws", "true", "try", "#column", "#file", "#function", "#line", "_,#available", "#column", "#else#elseif", "#endif", "#file", "#function", "#if", "#line", "#selector", "associativity", "convenience", "dynamic", "didSet", "final", "get", "infix", "indirect", "lazy", "left", "mutating", "none", "nonmutating", "optional", "override", "postfix", "precedence", "prefix", "Protocol", "required", "right", "set", "Type", "unowned", "weak", "willSet"] |
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
FROM ubuntu:15.10 | |
RUN buildDeps='git cmake ninja-build uuid-dev icu-devtools libbsd-dev \ | |
libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev \ | |
libncurses5-dev pkg-config ca-certificates python rsync file'; \ | |
runDeps='libicu-dev clang'; \ | |
apt-get update \ | |
&& apt-get -y install $buildDeps $runDeps --no-install-recommends \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* \ |
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 KituraNet | |
// Replacement for NSData(contentsOfURL:NSURL) | |
extension NSData { | |
public static func contents(ofUrl urlString:String, completionHandler:((data:NSData?) -> Void)) { | |
let request = HTTP.request(urlString) { (response) in | |
guard let response = response else { |
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 UIKit | |
// Swift rewrite challenge | |
// Starting point: https://gist.github.com/jkereako/200342b66b5416fd715a#file-scale-and-crop-image-swift | |
extension CGSize { | |
func scale(toSize newSize: CGSize, fit: Bool) -> CGSize { | |
let test : (CGFloat,CGFloat) -> CGFloat = fit ? { max($0, $1) } : { min($0, $1) } | |
let scale : CGFloat = test(width / newSize.width, height / newSize.height) |
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
extension NSDate { | |
func yearsFrom(date:NSDate) -> Int{ | |
return NSCalendar.currentCalendar().components(.Year, fromDate: self, toDate: date, options: []).year | |
} | |
func monthsFrom(date:NSDate) -> Int{ | |
return NSCalendar.currentCalendar().components(.Month, fromDate: self, toDate: date, options: []).month | |
} | |
func weeksFrom(date:NSDate) -> Int{ | |
return NSCalendar.currentCalendar().components(.WeekOfYear, fromDate: self, toDate: date, options: []).weekOfYear | |
} |