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 CustomError extends Error { | |
//Extend the super class, in this case the standard Error object | |
constructor(message){ | |
super(message); | |
this.name = this.constructor.name; | |
} | |
} | |
module.exports = CustomError; |
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 UIImageView { | |
func resizeForProfilePic(){ | |
self.layer.borderWidth = 1 | |
self.layer.masksToBounds = false | |
self.layer.borderColor = UIColor.blackColor().CGColor | |
self.layer.cornerRadius = self.frame.height/2 | |
self.clipsToBounds = 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 UIImageView { | |
func downloadImageFrom(link link:String, contentMode: UIViewContentMode) { | |
NSURLSession.sharedSession().dataTaskWithURL( NSURL(string:link)!, completionHandler: { | |
(data, response, error) -> Void in | |
dispatch_async(dispatch_get_main_queue()) { | |
self.contentMode = contentMode | |
if let data = data { self.image = UIImage(data: data) } | |
} | |
}).resume() | |
} |
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
//Use as follows | |
//let dateHelper = Helpers() | |
//let dateString: String = row["dateString"] as! String | |
//label.text = dateHelper.getFormattedDate(dateString) | |
import Foundation | |
class Helpers: NSObject { | |
func getFormattedDate(date: String) -> 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
/** | |
Use this function to make calls to a JSON REST API see demo.js for useage | |
@param options | |
@param end (Callback) | |
**/ | |
exports.api = function(options, end) { | |
//This function makes calls to an Endpoint and then sends the data back via callback to the function that requested it. | |
//Alloy.CFG.conn_url is set in your config.json file and can be accessed depending on which environment you are using. | |
var method = options.method, |