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
"Your Password must be between 7 and 15 characters long. It must contain at least one upper case letter, one lower case letter, and one number. Your Password cannot contain spaces or special characters (like @, &, or _). It also cannot contain consecutively repeated characters (e.g. 11, 222, AAAA). Please select another 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
func emptyImage() -> UIImage { | |
UIGraphicsBeginImageContext(CGSize(width: 1, height: 1)) | |
let img = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return img | |
} | |
let img = emptyImage() | |
let dat = UIImagePNGRepresentation(img) |
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 node = nodeAtPoint(location) | |
assert(node.containsPoint(location)) // wtf? this assert does fail sometimes. |
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 FooSingleton { | |
private static let _sharedInstance = FooSingleton() | |
class var sharedInstance: FooSingleton { | |
return _sharedInstance | |
} | |
} |
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 | |
/* | |
// In Swift 1.2 this definition gave us what we wanted | |
func lerp(a: Float, b: Float, t: Float) -> Float { | |
return (b-a)*t+a | |
} | |
*/ | |
// now Swift 2.0 requires this | |
func lerp(a: Float, _ b: Float, _ t: Float) -> Float { |
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
enum Change { | |
case Insert(at: Int) | |
case Delete(at: Int) | |
case Move(from: Int, to: Int) | |
} | |
extension Change: Printable { | |
var description: String { | |
switch self { | |
case .Insert(let at): |
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
static const uint8_t image_cat[] PROGMEM = {0x55,0x8b,0x55,0x23,0x55,0x88,0x55,0x23,0x55,0xe8,0x55,0xa2,0x55,0x88,0x55,0x2,0x55,0xaf,0x77,0xff,0xdd,0xff,0x75,0xff,0xd5,0xef,0x77,0xff,0xdd,0xff,0x57,0xff,0xdf,0xff,0x77,0xff,0x5d,0xff,0x55,0xb8,0x55,0xa8,0x55,0x20,0x55,0x88,0x55,0xf2,0x55,0xe8,0x55,0xb,0x55,0xbe,0x55,0x2b,0x55,0xf,0x55,0xb,0x15,0xb,0x15,0x3,0x11,0x0,0x1,0x0,0x11,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x11,0x0,0x4,0x0,0x11,0x0,0x55,0x3b,0x55,0xff,0x55,0xff,0xd5,0xff,0x55,0xff,0xfd,0xff,0x77,0xff,0xdd,0xfe,0x75,0xfa,0xd5,0xff,0x55,0xfb,0xd5,0xea,0x55,0xba,0x55,0xaa,0x55,0x23,0x55,0x8a,0x55,0x22,0x55,0x88,0x55,0x2a,0x55,0xff,0x75,0xff,0x5d,0xfe,0x55,0x2e,0x55,0x8e,0x55,0x2b,0x55,0xff,0x57,0xff,0xdd,0xff,0x77,0xff,0xdd,0xff,0x77,0xff,0xdf,0xff,0x55,0xbf,0x5d,0xaf,0x55,0x3b,0x55,0xae,0x55,0xfa,0xd5,0xbe,0x55,0x1b,0x55,0x2,0x55,0x0,0x15,0x0,0x5,0x0,0x11,0x0,0x0,0x0,0x11,0x0,0x0,0x0,0x1,0x0,0x40,0x0,0x11,0x0,0x44,0x0,0x11,0x0,0x44,0x0,0x11,0x0,0x0 |
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
private let ValidCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n".utf8 | |
private func RandomString() -> String { | |
var str = "" | |
// 1-140 | |
let len = 1+(Int(rand())%140) | |
for _ in 0...len { | |
let offset = Int(rand())%Int(ValidCharacters.count) | |
let index = advance(ValidCharacters.startIndex, offset) |
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
// vertically expand label so hanging letters such as 'g' don't get clipped | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
if let textLabel = textLabel { | |
textLabel.frame = CGRectInset(textLabel.frame, 0, -10) | |
} | |
} |
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
// ... | |
tableView.reloadData() | |
// ... | |
CATransaction.begin() | |
tableView.tableFooterView?.layer.removeAllAnimations() | |
CATransaction.commit() |