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
<?php | |
class Logger { | |
static function debug($msg) { | |
$file = dirname(__FILE__) . "/debug.log"; | |
$output = strftime('%Y-%m-%d %T ') . ":" . $msg . "\n"; | |
file_put_contents($file, $output, FILE_APPEND); | |
} | |
} |
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 ArrayError : ErrorType{ | |
case OutOfBounds | |
} | |
class SomeClass { | |
var test: NSArray! = ["Test1", "Test2"] | |
func testCode() { |
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
<?php | |
// DATABASE-HOSTNAME-OR-IPADDRESS-GOES-HERE | |
// MYSQL-DBNAME-GOES-HERE | |
class LoginHandler { | |
public $dbHostname = 'DATABASE-HOSTNAME-OR-IPADDRESS-GOES-HERE'; | |
public $dbDatabaseName = 'MYSQL-DBNAME-GOES-HERE'; | |
public $user = 'DATABASE_USERNAME'; | |
public $password = 'DATABASE_PASSWORD'; | |
//public $port = 3307; | |
public $message; |
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
// Given the string "Fox is in the hole", how to get a substring up to the first space. | |
let myMessage = "Fox is in the hole" | |
var result: String? | |
if let index = myMessage.characters.indexOf(" ") { | |
result = myMessage.substringToIndex(index) | |
} | |
print(result) |
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
// Approach #1 | |
let fruit = ["012Apple", "03218Banana", "11 Orange"] | |
var stringsOnly: [String] = [] | |
for f in fruit { | |
stringsOnly.append(f.stringByTrimmingCharactersInSet(NSCharacterSet.letterCharacterSet().invertedSet)) | |
} | |
// Approach #2 | |
let fruits = ["012Apple", "03218Banana", "11 Orange"] | |
var stringOnly = [String]() |
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 LookAtMeNotification { | |
func createNotification(key: String) { | |
let notification = UILocalNotification() | |
notification.fireDate = NSDate(timeIntervalSinceNow: 5) | |
notification.repeatInterval = NSCalendarUnit.Minute | |
notification.alertBody = "Please Look at me" | |
notification.soundName = UILocalNotificationDefaultSoundName | |
notification.userInfo = ["ID": key] |
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
print("Day test = \(rangeOfPeriod(.Day, date: NSDate()))") | |
print("Week test = \(rangeOfPeriod(.WeekOfYear, date: NSDate()))") | |
print("month test = \(rangeOfPeriod(.Month, date: NSDate()))") | |
print("Year test = \(rangeOfPeriod(.Year, date: NSDate()))") |
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 settingsButtonPressed(sender:UIButton) { | |
let storyboard = UIStoryboard(name: "AccountLinking", bundle: nil) | |
let linkingVC = storyboard.instantiateViewControllerWithIdentifier("AccountLinkingTable") | |
self.navigationController?.pushViewController(linkingVC, animated: true) | |
} |
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 UIView { | |
public func addTopBorderWithColor(color: UIColor, width: CGFloat) { | |
let border = CALayer() | |
border.backgroundColor = color.CGColor | |
border.frame = CGRectMake(0, 0, self.frame.size.width, width) | |
self.layer.addSublayer(border) | |
} | |
public func addRightBorderWithColor(color: UIColor, width: CGFloat) { | |
let border = CALayer() |
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 Vector | |
{ | |
var x: Double = 0 | |
var y: Double = 0 | |
init(x: Double, y: Double) | |
{ | |
self.x = x | |
self.y = y | |
} |
OlderNewer