Skip to content

Instantly share code, notes, and snippets.

View pietrovismara's full-sized avatar
🎯
Focusing

Pietro Paolo Vismara pietrovismara

🎯
Focusing
View GitHub Profile
@pietrovismara
pietrovismara / google-ranking.js
Created January 5, 2017 21:39
Get google ranking for given keywords
const scavenger = require('scavenger');
module.exports = googleRanking;
/**
* @async
* @param {String} keywords
* @param {String} compareUrl
* @param {Number} pagesAmount
* @return {Number}
@pietrovismara
pietrovismara / sliceFile.js
Created July 8, 2016 11:38
Slice a File/Blob instance in the desired amount of chunks
/**
* @param {File|Blob} - file to slice
* @param {Number} - chunksAmount
* @return {Array} - an array of Blobs
**/
function sliceFile(file, chunksAmount) {
var byteIndex = 0;
var chunks = [];
for (var i = 0; i < chunksAmount; i += 1) {
var byteEnd = Math.ceil((file.size / chunksAmount) * (i + 1));