I just spent some time enough to call a waste on this issue so I wanted the next generations to go out have some fun instead.
When you try to do 'grails app-engine deploy', it will ask you for your google appengine email and password. After asking your email, intuitively you will type in your email and press on enter. When you do so, you will see that a shockingly suprising thing happens; NOTHING! And as a curious human being you will click enter again, then you will be asked for you password but once you enter it the appengine plugin will fail.
Well, here is the trick.
When you are asked for your email, FIRST press on ENTER and then type your email in the new line. For the password you don't have to do this.
Hope that helps.
Later,
Bilsay
Monday, 4 April 2011
Thursday, 24 March 2011
jQuery table row accumulator(sum, average)
I needed some simple plugin just to add up and take the average of numeric columns and since I couldn't find a lightweight one I just wrote it myself. I'm sure it can be extended to work in a more general way but I just needed it to be simple. It can be a good start so you can play with it.
Here is the plugin:
Here are the helper methods, you can keep them under a namespace maybe, thats how I do:
Here is the usage, the jquery object is the table structured well with tbody:
Here is the plugin:
(function($) {
$.fn.accumulate = function(options) {
options = options || {};
function view(row) {
var t = [];
t.push('');
for (var i = 0; i < row.meta.columnCount; i++) { t.push('');
t.push('');
if (columnHasFixedDisplay(i)) {
t.push(options["col" + i].display);
}
else {
if (row.data[i]) {
var value = columnHasAverageValue(i) ? (row.data[i].total / (row.data[i].count)) : row.data[i].total;
t.push(columnHasFixedDisplayFunction(i) ? options["col" + i].displayFunction(value) : value);
}
}
t.push('');
t.push('');
}
t.push('');
return t.join('');
}
//defaults to sum
function columnHasAverageValue(i) {
return options["col" + i] && "average" == options["col" + i].type;
}
function columnHasFixedDisplay(i) {
return options["col" + i] && options["col" + i].display;
}
function columnHasFixedDisplayFunction(i) {
return options["col" + i] && options["col" + i].displayFunction;
}
function columnHasAccumulatorFunction(i) {
return options["col" + i] && options["col" + i].accumulatorFunction;
}
return this.each(function() {
var $this = $(this);
var rows = $("tbody tr", $this);
var accumulatedRow = {
meta: {
rowCount: rows.length,
columnCount: 0
},
data: {}
};
rows.each(function() {
var $columns = $('td', $(this));
accumulatedRow.meta.columnCount = $columns.length;
for (var i = 0; i < $columns.length; i++) { var value = $columns[i].innerHTML; if (columnHasAccumulatorFunction(i)) { accumulatedRow.data[i] = options["col" + i].accumulatorFunction(accumulatedRow.data[i], value) } else{ if (NG.isNumeric(value)) { if (!accumulatedRow.data[i]) { accumulatedRow.data[i] = { count: 0, total: (NG.isFloat(value) ? 0 : 0.0) }; } accumulatedRow.data[i].count++; accumulatedRow.data[i].total += NG.isFloat(value) ? parseFloat(value) : parseInt(value); } } } }); $("tbody", $this).append(view(accumulatedRow)); }); }; })(jQuery);
Here are the helper methods, you can keep them under a namespace maybe, thats how I do:
isNumeric: function(input) {
var RE = /^-{0,1}\d*\.{0,1}\d+$/;
return (RE.test(input));
}
isFloat: function(input) {
return /\./.test(input.toString());
}
Here is the usage, the jquery object is the table structured well with tbody:
$("#table-id").accumulate({
"col0": {
display: "Total",
style: "text-align: left;"
},
"col1": {
accumulatorFunction: function(accumulatedValue, value) {
if (!accumulatedValue) {
accumulatedValue = {
total: {
firstEleven: 0,
sub: 0
},
count: 0
}
}
var s = value.replace(' ', '').replace(')', '').split('(');
accumulatedValue.count++;
accumulatedValue.total.firstEleven += parseInt(s[0]);
accumulatedValue.total.sub += 1 <>
Default behaviour is to sum up every numeric value, you can specify a fix display for a column, to play with the display value, I added a display function and as I had values like 9 (10) in some columns and since they are not numeric I had to add a accumulator function. Anyway I ll update it if I ever need to add more functionality.
Later.
Subscribe to:
Posts (Atom)