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 loadImage(url, callback) { | |
var img = document.createElement("img"); | |
img.src = url; | |
if (callback) { | |
img.onreadystatechange = callback; | |
img.onload = callback; | |
} | |
} |
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
$(document).ready(function() { | |
getActivities('992572', gotCategory); | |
}); | |
function gotCategory(data) { | |
console.log(data); | |
var tbody = document.getElementById('tb_activity'); |
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() { | |
/** | |
* | |
* CSVJSON.sql2json(sql) | |
* | |
* Converts SQL to JSON. Returns an object. Detects CREATE TABLE and INSERT INTO | |
* statements to extract table header and rows. Use JSON.stringify to conver to a string. | |
* | |
* Dependencies: | |
* - underscore (http://underscorejs.org/) |
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 /path/to/files -type f -print0 | \ | |
perl -n0e '$new = $_; if($new =~ s/[^[:ascii:]]/_/g) { | |
print("Renaming $_ to $new\n"); rename($_, $new); | |
}' |
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
// Subclass the Backbone model to keep the model and its state (errors) | |
// sent back by the server. Creates a new errorModel property holding | |
// a Backbone model with errors, mapped to the model attributes. | |
Backbone.ModelWithState = Backbone.Model.extend({ | |
errorModel: undefined, | |
constructor: function(attributes, options) { | |
Backbone.Model.apply(this, arguments); | |
options || (options = {}); | |
this.errorModel = options.errorModel || new Backbone.Model(); | |
}, |
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
// Subclass Backgrid Filter to pass an extra 'pick' filter | |
Backgrid.ClientSideFilterWithPickFilter = Backgrid.Extension.ClientSideFilter.extend({ | |
pickFilter: null, | |
setPickFilter: function (attrs) { | |
this.pickFilter = attrs; | |
this.search(); | |
return this; | |
}, | |
makeMatcher: function (query) { |
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
/* | |
* Patches Telerik Tooltip control in IE10 which fails with this Javascript error: | |
* | |
* SCRIPT5007: Unable to get property 'documentElement' of undefined or null reference | |
* Telerik.Web.UI.WebResource.axd, line 151 character 2 | |
* | |
* Solution is to redefine the bugged function and replace a.document.documentElement | |
* with (a.document || a.ownerDocument).documentElement, thus avoiding a paid upgrade. | |
* | |
* To use, include this script after Telerik's. |
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
// Cache user inputs into HTML5 local storage. Restore them upon next page load. | |
// Usage: | |
// $('body').CacheInputs(); | |
// | |
// Will store stringified JSON in local storage, against the key you specify | |
// or 'cache-inputs' if you omit it. See settings below. | |
// | |
// Author: Martin Drapeau | |
// | |
// Greatly inspired from Johnathan Schnittger |
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
$.post('https://www.planbox.com/api/get_products', function(data) { | |
var products = data.content; | |
var product_ids = []; | |
var product_id2name = {}; | |
for (var i=0; i<products.length; i++) { | |
var product = products[i]; | |
product_id2name[product.id] = product.name; | |
product_ids.push(product.id); | |
} | |
$.post('https://www.planbox.com/api/get_stories', |
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
$.post('https://www.planbox.com/api/get_iterations', | |
{product_id:1234, timeframe:"current"}, | |
function(object) { | |
var iterations = object.content; | |
var iteration = iterations[0]; | |
console.log('Your velocity for iteration '+iteration.name+' averaged on the past '+iteration.velocity.iteration_ids.length+' iterations:'); | |
var record = iteration.velocity.data[0]; | |
console.log(' Estimate-hours Velocity = '+Math.round(record.estimate_done)); | |
console.log(' Points Velocity = '+Math.round(record.points_done)); | |
console.log(' Business Value Velocity = '+Math.round(record.value_done)); |