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
if (typeof String.prototype.supplant !== 'function') { | |
String.prototype.supplant = function (o) { | |
return this.replace(/{([^{}]*)}/g, | |
function (a, b) { | |
var r = o[b]; | |
return typeof r === 'string' ? r : a; | |
}); | |
}; | |
} |
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
find . -regex '.*.svn' -exec rm -rf "{}" \; |
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
+ (CGRect) aspectFittedRect:(CGRect)inRect max:(CGRect)maxRect | |
{ | |
float originalAspectRatio = inRect.size.width / inRect.size.height; | |
float maxAspectRatio = maxRect.size.width / maxRect.size.height; | |
CGRect newRect = maxRect; | |
if (originalAspectRatio > maxAspectRatio) { // scale by width | |
newRect.size.height = maxRect.size.height * inRect.size.height / inRect.size.width; | |
newRect.origin.y += (maxRect.size.height - newRect.size.height)/2.0; | |
} 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
// A generic User object | |
user = { | |
id : 1, | |
firstName : "John", | |
lastName : "Doe", | |
email : "john.doe@fooey.com" | |
} | |
// REST api endpoint |
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
/*! | |
* Javascript Pattern for Rest Service API’s | |
* http://www.chriscouchoud.com/ | |
* | |
* Dual licensed under the MIT and GPL licenses. | |
*/ | |
service = { | |
baseURL : "http://www.yourrestapi.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
serviceDefinitions = { | |
"getUser" : { | |
"url" : "/users/{id}" | |
"type" : "GET", | |
"dataType" : "json", | |
"contentType" : "" | |
}, | |
"updateUser" : { |
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 call to update a user could look a little like this: | |
service.create(serviceDefinitions["updateUser"], user, {data:{first_name:"Jane", last_name:"Doe"}, success: someGlobalSuccessMethod}) | |
// Your call to get a recipe could look like this: | |
service.create(serviceDefinitions["getRecipe"], recipe, {success: someGlobalSuccessMethod}); | |
// Some other call that involves some processing | |
var resource = $.extend({},user); | |
resource["fullName"] = function() {return this.firstName + this.lastName}; | |
service.create(serviceDefinitions["getUserByFullName"], resource, {success: someGlobalSuccessMethod}); |
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
function recordingsByDate(recording_list) { | |
// collapse data into a dictionary of Array's | |
var dict = {}, | |
date = null; | |
$(recording_list).each(function(i, val){ | |
date = this.YOUR_DATE_NORMALIZATION_FUNCTION(); // returns something like 'May 1, 2002' | |
if(!dict[date]){ |
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
// recording and series list updates | |
var device = RemoteScheduling.user.getSelectedDevice(); | |
RemoteScheduling.bindTo(device, RemoteScheduling.Device.events.RECORDINGS_LIST_UPDATED, YOUR_CALLBACK_FUNCTION); | |
RemoteScheduling.bindTo(device, RemoteScheduling.Device.events.SERIES_LIST_UPDATED, YOUR_CALLBACK_FUNCTION); | |
// NOTE - anytime the series list is updated we do a refresh on the recordings list as well. |
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
// modify recording | |
{"error": | |
{ | |
"message":"Internal error Transformation error: org.xml.sax.SAXParseException: Element type "com:modifyScheduledRecording" must be followed by either attribute specifications, ">" or "/>".; nested exception is javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Element type "com:modifyScheduledRecording" must be followed by either attribute specifications, ">" or "/>". in net.comcast.cim.remotescheduling.utils.RemoteSchedulingUtils", | |
"code":"RemoteScheduling:008" | |
} | |
} | |
// series | |
{"error": |
OlderNewer