Skip to content

Instantly share code, notes, and snippets.

View Jaballadares's full-sized avatar

John Balladares Jaballadares

View GitHub Profile
@Jaballadares
Jaballadares / reduceExamples.js
Created June 17, 2021 15:41 — forked from quangnd/reduceExamples.js
Some examples about reduce() in Javascript
//Example 1 - Calculate average value of an array (transform array into a single number)
var scores = [89, 76, 47, 95]
var initialValue = 0
var reducer = function (accumulator, item) {
return accumulator + item
}
var total = scores.reduce(reducer, initialValue)
var average = total / scores.length
/*Explain about function
@Jaballadares
Jaballadares / cli.js
Created June 4, 2021 00:34 — forked from dpyro/cli.js
simple readline cli for node.js
const readline = require('readline')
/**
* Create an active bound readline interface using `stdin` and `stdout`.
*
* @param {function(string): void} callback handler for each inputed line
* @returns {readline.ReadLine} the active configured interface
*/
function createReadlineInterface(callback) {
const rl = readline.createInterface({
@Jaballadares
Jaballadares / js-observables-binding.md
Created May 30, 2021 22:47 — forked from austinhyde/js-observables-binding.md
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);

@Jaballadares
Jaballadares / index.html
Created May 25, 2021 21:29 — forked from nazarbek7/index.html
Rich Text Editor
<div id="toolbar">
<div id="title"> Rich-text Editor </div>
<button id="bold" onclick="makeBold()"> Bold </button>
<button id="italic" onclick="makeItalic()"> Italic </button>
<button id="underline" onclick="doUnderline()"> Underline </button>
<button onclick="justifyLeft()"> Justify Left </button>
<button onclick="justifyCenter()"> Justify Center </button>
<button onclick="justifyRight()"> Justify Right </button>
@Jaballadares
Jaballadares / collectionHelpers.js
Last active June 24, 2021 16:51
Official Personal Lib | JLIB
const renameKeys = (keysMap, obj) =>
Object.keys(obj).reduce(
(acc, key) => ({
...acc,
...{ [keysMap[key] || key]: obj[key]},
}), {}
)
const JSONtoCSV = (arr, columns, delimiter = ',') =>
[
@Jaballadares
Jaballadares / skylineMods.js
Created April 12, 2021 20:20
skyline mods
function getDriveFiles() {
const folderToUpdate = DriveApp.getFolderById('1L_AWb4RbnpTj2NS5G7kbxIRuxtProCvb');
const files = folderToUpdate.getFiles();
let arr = [];
while (files.hasNext()) {
file = files.next();
arr.push(({id: file.getId(), name: file.getName()}));
}
return arr;
}
<head><style>*{margin:0;padding:0;text-decoration:none;vertical-align:middle}p{font-family:Arial,sans-serif;font-size:14px;line-height:16px;text-decoration:none}.disclaimer{padding-left:2px;color:#000;font-family:Arial,sans-serif;font-size:10px;line-height:14px;letter-spacing:.02em;font-style:italic;width:450px;text-align:justify}.main{width:450px}img{align:top}a{color:#808285!important;font-size:11px;text-decoration:underline}</style></head><div class="main"><table><tr><span style="font-family:arial,sans-serif;color:#808285;font-size:11px">*****************<br>Texas law requires all license holders to provide the <a href="https://members.har.com/mhf/terms/dispBrokerInfo.cfm?sitetype=aws&cid=653927">Information About Brokerage Services</a> and <a href="https://www.trec.texas.gov/sites/default/files/pdf-forms/CN%201-3.pdf">Texas Real Estate Commission Consumer Protection Notice</a> <br>*****************</span></tr><tr><td><img src="https://res.cloudinary.com/john-reside/image/upload/v1608585093/EnergyRealtyLog
@Jaballadares
Jaballadares / dataMunging.js
Created March 24, 2021 23:27
Useful Examples of Reduce, Map, Filter
‎‎​
@Jaballadares
Jaballadares / _jsonPuller.md
Created February 28, 2021 20:30 — forked from jalcantarab/_jsonPuller.md
A Google apps script to pull json from a spreadsheet

JSON Puller - Google Apps Script

Transforms the data of a given Spreadsheet Sheet to JSON.

  • The frozen rows are taken as keys for the JSON.
  • The data taken for the values is only that after the frozen rows

Set up:

exportJSON(Spreadsheet) - transforms the data in the given sheet to JSON.

@Jaballadares
Jaballadares / to_util.js
Last active February 28, 2021 20:14 — forked from nicobrx/to_util
Will be Useful When Combining Different Tabs | Google Apps Script utility functions for working with 2D arrays in Sheets/tabs, plus a few other miscellanea. The 2D functions depend on the first row of a tab being column headers and each row below the first row having the same number of columns as the first row.
/*
updated 2018-04-28
source lives here: https://gist.github.com/nicobrx/2ecd6fc9ca733dcd883afebba5cf200e
standalone script ID for use as a library: 1gZ78JObyrYiH0njoZ86fQ2NgMwavUgiXVhRDrIFetPZL256e31PSNiHq
Functions included here:
Sheets data array and object functions
objectifySheet(sheet,propertyNames,newPropertyNames) - Takes a sheet with a header row and converts it into an array of objects
arrayFromSheet(sheet,propertyNames,newPropertyNames) - creates an array from a sheet, can specify column headers