Skip to content

Instantly share code, notes, and snippets.

View asimmittal's full-sized avatar

Asim Mittal asimmittal

View GitHub Profile
@asimmittal
asimmittal / gist:e047901590325639fb1e
Last active February 12, 2018 17:25
Access values in a Google sheet
/********************************************************
* grab all the rows from the sheet and POST to the DB
********************************************************/
function grabRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
//these labels will be used to mark the fields in
@asimmittal
asimmittal / xlsToJson.js
Last active March 28, 2018 19:36
A gist to turn my excel template into JSON
var Excel = require("exceljs");
var fs = require("fs");
function churnString(valString, dataType){
let valNum = parseFloat(valString);
let percentageTypes = [
'natWageGrowth', 'natEmpGrowth', 'natTurnoverRate', 'wgJobHolders', 'wgJobSwitchers', 'wgEntrants',
'wgValue', 'wgHolders', 'wgSwitchers', 'wgEntrants','empGrowth','turnover'
];
@asimmittal
asimmittal / sequentialLoad.js
Created March 8, 2017 05:05
Sequentially load JS files
(function(){
//three JS files that need to be loaded one after the other
var libs = [
'https://code.jquery.com/jquery-3.1.1.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/underscore.string/3.3.4/underscore.string.js'
];
var injectLibFromStack = function(){
/*
* ajaxGET
* -- Custom wrapper around the Jquery GET method
* -- when the request is complete, it returns the response using
* the 'finish' callback
*/
var ajaxGET = function(url, finish){
$.get(url).done(function(data){
finish(data);
});
@asimmittal
asimmittal / scrapeUsingJQuery.js
Created October 4, 2017 16:01
JqueryScraper
console.log("---> Running");
const curl = require("curl");
const jsdom = require("jsdom");
const url = "http://www.imdb.com/list/ls004489992/";
curl.get(url, null, (err,resp,body)=>{
if(resp.statusCode == 200){
parseData(body);
}