Skip to content

Instantly share code, notes, and snippets.

@hughsw
hughsw / CollectCurrencyPairs.txt
Last active May 25, 2019 13:45
Javascript data wrangling
Real-world, little Javascript problem
Input is an array of strings.
Each string encodes a pair of 3-letter symbols, separated by an underscore '_'.
We talk about the left-hand and right-hand symbols that are encoded into the string.
E.g.
['AED_AFN', 'ALL_AMD', 'AMD_AFN', 'ALL_GBP']
'AED' is the left-hand symbol of the first pair; 'AFN' is the right-hand symbol of the first pair. Etc.
We want this data rearranged into an object.
@hughsw
hughsw / collectSymbols.js
Last active June 10, 2019 01:16
Versions of collectSymbols
const input = ['AED_AFN', 'ALL_AMD', 'AMD_AFN', 'ALL_GBP'];
console.log('input:', JSON.stringify(input));
// somewhat functional, somewhat imperative
const collectSymbols0 = pairs => {
co
@hughsw
hughsw / excelgist.js
Created June 23, 2019 01:15
Basic basic bootstrapping example for exceljs
// See: https://gist.github.com/nealrs/4bdcb6316665338d9a1f7c2b690d6a19
const Excel = require('exceljs');
// create workbook & add worksheet
const workbook = new Excel.Workbook();
const worksheet = workbook.addWorksheet('Discography');
// add column headers
worksheet.columns = [