Skip to content

Instantly share code, notes, and snippets.

View eaton's full-sized avatar

Eaton eaton

View GitHub Profile
@eaton
eaton / 11tycsv
Last active March 9, 2021 03:10
11ty CSVtoJSON
// full API options at https://github.com/Keyang/node-csvtojson
const csv = require('csvtojson');
// Commonly-tweaked defaults
const options = {
delimiter: ",",
trim: true,
ignoreEmpty: false,
flatKeys: false,
@eaton
eaton / File structure
Last active December 3, 2023 17:29
Basic recipe for using 11ty to spit out arbitrary data
Eleventy can process a bunch of markdown files into HTML for a blog, but it's also handy for turning big data files into individual HTML pages. https://www.11ty.dev/docs/data-global/ and https://www.11ty.dev/docs/pagination/ have the skinny.
project folder
├─ .eleventy.js <-- control/override plugins, templating, directory names, etc
├─ src <-- Your content, data files, templates, etc
│ ├─ _data <-- JSON files you put here become part of the 'global data'
│ │ └─ foo.json <-- any template can use this data as {{ data.foo }}
│ └─ foo-things.html <-- uses 'pagination' to output one page for each record in foo
@eaton
eaton / fractional-progress-bar.ts
Created November 3, 2024 00:25
Fractional ASCII progress bar
export const BarThemes = {
fractional: [' ', '▏', '▎', '▍', '▌', '▋', '▊', '▉', '█'],
shaded: [' ', '░', '▒', '▓', '█'],
simple: ['▒', '█'],
ascii: ['-', '#'],
};
// Renders a fixed-length ASCII progress bar that supports
// fractionally-filled characters using Unicode boxes and bars.