Skip to content

Instantly share code, notes, and snippets.

View eaton's full-sized avatar

Eaton eaton

View GitHub Profile
@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.
@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 / 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 / reading-list.md
Created July 29, 2020 03:03
In progress collection of reading list about the current bullshit.
@eaton
eaton / d8-fieldapi-tricks.txt
Last active September 3, 2019 09:43
Drupal 8 field wrangling
// Check whether a node's bundle has a particular field
if ($node->hasField('field_might_be_missing')) { ... }
// Check field-type-specific empty/not empty logic
if ($node->field_name->isEmpty()) { ... }
// Iterate over individual instances in a field. field_name isn't an actual
// array, but a special iteratable class, so it won't die if the field is empty.
foreach ($node->field_name as $delta => $field_instance) { ... }
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Component\Utility\Html;
use \Drupal\node\Entity\Node;
function relater_node_presave(EntityInterface $node) {
if ($node->bundle() == 'my_custom_node') {
$embeds = _relater_get_embeds($node);
$node->field_my_entityref->setValue($embeds);
@eaton
eaton / Craft CMS
Created July 16, 2014 20:19
CMS test run vagrantfiles
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Setting up Craft CMS:
# 0. vagrant-up
# 1. Download the latest from http://buildwithcraft.com
# 2. Uncompress the Craft zip.
# 3. Copy its 'public' and 'craft' directories into the 'www' folder.
# 4. Rename www/public/htaccess to www/public/.htaccess
#!/bin/bash
# Assignment
text=$@
letters=("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z")
blackletters=("𝔞" "𝔟" "𝔠" "𝔡" "𝔢" "𝔣" "𝔤" "𝔥" "𝔦" "𝔧" "𝔨" "𝔩" "𝔪" "𝔫" "𝔬" "𝔭" "𝔮" "𝔯" "𝔰" "𝔱" "𝔲" "𝔳" "𝔴" "𝔵" "𝔶" "𝔷" "𝔄" "𝔅" "ℭ" "𝔇" "𝔈" "𝔉" "𝔊" "ℌ" "ℑ" "𝔍" "𝔎" "𝔏" "𝔐" "𝔑" "𝔒" "𝔓" "𝔔" "ℜ" "𝔖" "𝔗" "𝔘" "𝔙" "𝔚" "𝔛" "𝔜" "ℨ")
for i in {1..52}; do
text=${text//${letters[$i]}/${blackletters[$i]}}
@eaton
eaton / gist:7255146
Created October 31, 2013 19:12
dnsmasq setup for local craziness
brew install dnsmasq
mkdir /usr/local/etc
touch /usr/local/etc/dnsmasq.conf
echo "address=/dev/127.0.0.1\n" >> /usr/local/etc/dnsmasq.conf
echo "address=/vm/10.0.0.10\n" >> /usr/local/etc/dnsmasq.conf
sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons
mkdir /etc/resolver
@eaton
eaton / gist:6976743
Created October 14, 2013 14:40
A brainstorming list of the various ways digital devices can vary in capabilities, interface, etc. Responsive design (today) is primarily concerned with the physical size of the screen, and tentatively exploring the resolution of the screen.
New generations of computing devices are changing the way we interact with digital content. These shifts are usually lumped under the "mobile" banner, but that's just one facet of the new world. Forward-thinking designers, developers, and strategists need to consider all of the following (and more!) when they plan for their users.
Screen (This depends on the physical device, or how it's being used)
- Physical size
- Perceived size
- Resolution
- Responsiveness
- Fidelity
Alternative outputs