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/sh | |
CMD=$(basename $0) | |
if [ $# != 3 ]; then | |
echo "usage $CMD <svn branch> <local name> <rev spec>" | |
exit 1 | |
fi | |
if [ ! -d .git ]; then |
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/sh | |
# Must be called with two command-line args. | |
# Example: git-svn-relocate.sh http://old.server https://new.server | |
if [ $# -ne 2 ] | |
then | |
echo "Invoke this script with two command-line arguments (old and new SVN URLs)." | |
exit $E_NO_ARGS | |
fi | |
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
// Run from the root path of your git-svn clone as | |
// node git-svn-externals.js | |
var exec = require('child_process').exec, | |
celeri = require('celeri'), | |
_ = require('underscore') | |
; | |
var spinner = celeri.loading('Finding svn externals. This will take a couple of minutes. '); |
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
class Person { | |
var age: Int | |
var name: String | |
init(age: Int, name: String) { | |
self.age = age | |
self.name = name | |
} |
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
class ViewController: UIViewController, UIWebViewDelegate { | |
@IBOutlet weak var webView: UIWebView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let request = NSURLRequest(URL: NSURL(string: "http://www.duckduckgo.com")) | |
// let request = NSURLRequest(URL: NSURL(string: "http://www.google.com")) | |
// let request = NSURLRequest(URL: NSURL(string: "http://www.apple.com")) |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
func primeFactors(of int: Int) -> [Int] { | |
var n = int | |
var factors: [Int] = [] | |
var divisor = 2 | |
while n > 1 { | |
while n % divisor == 0 { |
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
struct Configuration: BooleanType { | |
private let isActiveConfiguration: Bool | |
// Extend to your heart's content, e.g. size classes | |
init(idiom: UIUserInterfaceIdiom? = nil, os: NSOperatingSystemVersion? = nil) { | |
var configuration = true | |
if let idiom = idiom { | |
configuration = idiom == UIDevice.currentDevice().userInterfaceIdiom | |
} |
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
class Foo { | |
// Keep default values for optionals anyway since we can do shorter self.init calls | |
// when the call is unambiguous from the convenience init | |
private init(image: UIImage? = nil, images: [UIImage]? = nil, imageURL: NSURL? = nil, blurStyle: UIBlurEffectStyle = .Dark) { | |
// init | |
} | |
// By exposing convenience initialisers that take mutually exclusive parameters | |
// we remove the need to do any kind of assertion on them |
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
class PasswordGenerator { | |
private static let Lowercase = "abcdefghijklmnopqrstuvwxyz".split() | |
private static let Uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split() | |
private static let Symbols = "!@#$%^&*?".split() | |
private static let Numbers = "0123456789".split() | |
class func generate(length: Int = 10) -> String { | |
let allLetters = (Lowercase + Uppercase + Symbols + Numbers).shuffle() | |
var password = "" |
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
let opts : [Int?] = [1, nil, 2, nil, nil, 5, | |
nil, 3, 8, 11, 2, 6, nil, 9] | |
// "1 2 5 3 8 11 2 6 9 " | |
for case let x? in opts { | |
print("\(x) ", false) | |
} |
OlderNewer