Skip to content

Instantly share code, notes, and snippets.

@jeffhung
Created April 21, 2012 06:31
Show Gist options
  • Select an option

  • Save jeffhung/2434806 to your computer and use it in GitHub Desktop.

Select an option

Save jeffhung/2434806 to your computer and use it in GitHub Desktop.
function fn_akamai() {};
fn_akamai.prototype.tmexpr = function() {
return "sid=`mist-session` && mist-source $sid -m calc.in | mist-decode -l";
};
function fn_count(s) { this.s = s; }
fn_count.prototype.tmexpr = function() {
return this.s.tmexpr() + " | " + " count-lines ";
};
function fn_filter(s, f, v) { this.s = s; this.f = f; this.v = v; }
fn_filter.prototype.tmexpr = function() {
return this.s.tmexpr() + " | grep '" + this.f + "=" + this.v + "' ";
};
var evaluate = function(formula, sheetname, cellcoord) {
var AKAMAI = function() {
console.log("AKAMAI");
return new fn_akamai();
};
var COUNT = function(source) {
console.log("COUNT");
return new fn_count(source);
};
var FILTER = function(source, field, value) {
console.log("FILTER");
return new fn_filter(source, field, value);
};
return eval(formula).tmexpr() + " | update-sheet " + URL_BASE + "/_/" + sheetname + " " + cellcoord;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment