This file contains hidden or 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
/* | |
script for file extention verification | |
*/ | |
var path = 'path/to/file'; | |
var imageExt = ['jpeg','jpg','png','gif','tiff']; //specify allowed file extentions | |
var fileExt = path.split('.'); | |
var checkExist = imageExt.indexOf(fileExt[fileExt.length-1]); // -1 if the file extention does not exist in imageExt | |
if (checkExist === -1){ | |
console.log('File type not supported, please use '+ imageExt); |
This file contains hidden or 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
/* | |
code to out put console message in phantomjs page into node.js console. | |
*/ | |
page.set('onConsoleMessage', function (message) { | |
console.log('Phantom Console: ' + message); | |
}); |
This file contains hidden or 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
/* | |
allows to call function from inside of page.evaluate in phantomjs-node | |
*/ | |
page.set('onCallback', function (arg) { | |
//callback actions | |
}); | |
//To use callback, use following command in your page.evaluate | |
window.callPhantom(arg); |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<style type="text/css"> | |
path.overlay { | |
fill: orange; | |
} | |
path.base{ | |
fill: #f3f3f3; |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<style type="text/css"> | |
rect.overlay { | |
fill: #2279bd; | |
} | |
rect.base{ | |
fill: #f3f3f3; |
This file contains hidden or 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
_.mixin({ | |
sum : function(data){ | |
return _.reduce(data, function(memo, num){ return memo + num; }, 0); | |
}, | |
mean : function(data){ | |
return this.sum(data)/data.length | |
}, | |
median : function(data){ | |
return this.percentile(data,50); | |
}, |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
/* | |
What is the optimal way to print values of 2 arrays alternately? (every 5 sec) | |
* Items in both arrays could change at any given moment | |
* update to each array needs to be applied imminently | |
* if array is empty, it will not print any value (and move to the other array) | |
So if you start with following arrays | |
var arr0 = ['1','2','3'] | |
var arr1 = ['a','b','c'] | |
It would start printing |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
background: #222; | |
color:#fff; | |
font-family: "Helvetica Neue", Helvetica, sans-serif; |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
background: #222; | |
color:#fff; | |
font-family: "Helvetica Neue", Helvetica, sans-serif; |
OlderNewer