<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Donald L. Merand</title>
 <link href="https://donald.merand.org/atom.xml" rel="self"/>
 <link href="https://donald.merand.org"/>
 <updated>2026-06-17T21:29:03-04:00</updated>
 <id>https://donald.merand.org</id>
 <author>
   <name>Donald L. Merand</name>
   <email>donald@merand.org</email>
 </author>

 
 <entry>
   <title>Scale Visualizer Now Supports Mandolin and Banjo</title>
   <link href="https://donald.merand.org//projects/2026/05/25/scale-visualizer-new-instruments.html"/>
   <updated>2026-05-25T00:00:00-04:00</updated>
   <id>https://donald.merand.org/projects/2026/05/25/scale-visualizer-new-instruments</id>
   <content type="html">&lt;p&gt;I’ve updated the &lt;a href=&quot;/projects/2025/01/11/unified-guitar-scale-pattern-visualizer.html&quot;&gt;unified scale pattern visualizer&lt;/a&gt; with new instruments. Mandolin is tuned in fifths, so the patterns look quite different from guitar. I added a 12-string perfect-fifths tuning to visualize the full 7-string repeating pattern when using 4 note-per-string scales on mandolin. I also added open G and open C banjo because good resources for C-tuned banjo are surprisingly hard to find. The algorithm now picks the right octave automatically based on the tuning, so everything just works. &lt;a href=&quot;/projects/2025/01/11/unified-guitar-scale-pattern-visualizer.html&quot;&gt;Give it a try.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;/projects/2026/04/07/mini-banjo-chord-transposer.html&quot;&gt;chord finder&lt;/a&gt; has also been updated — it now supports inversions with slash chord notation (C/E, G/B), position-based voicing anchored to where the bass note sits on the neck, and guitar alongside banjo and mandolin. The voicing algorithm is the same search, just with more knobs to turn.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Stringed Instrument Chord Finder</title>
   <link href="https://donald.merand.org//projects/2026/04/07/mini-banjo-chord-transposer.html"/>
   <updated>2026-04-07T00:00:00-04:00</updated>
   <id>https://donald.merand.org/projects/2026/04/07/mini-banjo-chord-transposer</id>
   <content type="html">&lt;div class=&quot;text-sm&quot;&gt;
  &lt;p&gt;
    A chord finder for banjo, mandolin, and guitar. Pick a tuning, root, quality, and inversion, and it shows every distinct, playable voicing up the neck. Click any shape to add it to a collection you can export as a chord sheet.
  &lt;/p&gt;
  &lt;p&gt;
    &lt;strong&gt;Update:&lt;/strong&gt; This started as a mini banjo transposition tool, and has since grown into a general-purpose chord finder with support for inversions and multiple instruments. See &lt;a href=&quot;#background&quot;&gt;below&lt;/a&gt; for the full story.
  &lt;/p&gt;
&lt;/div&gt;

&lt;div id=&quot;banjo-tool&quot; class=&quot;bg-white rounded-lg shadow-lg p-6 mt-8&quot;&gt;

&lt;div id=&quot;controls&quot; class=&quot;mb-6 pt-4&quot;&gt;

&lt;div class=&quot;mb-4&quot;&gt;
&lt;label class=&quot;block text-sm font-medium mb-2&quot;&gt;Tuning:&lt;/label&gt;
&lt;div class=&quot;flex gap-2 flex-wrap&quot;&gt;
&lt;button data-tuning=&quot;mini&quot; class=&quot;toggle-btn toggle-active&quot;&gt;Mini Banjo (C)&lt;/button&gt;
&lt;button data-tuning=&quot;standard&quot; class=&quot;toggle-btn&quot;&gt;Standard Banjo (G)&lt;/button&gt;
&lt;button data-tuning=&quot;mandolin&quot; class=&quot;toggle-btn&quot;&gt;Mandolin (GDAE)&lt;/button&gt;
&lt;button data-tuning=&quot;guitar&quot; class=&quot;toggle-btn&quot;&gt;Guitar (EADGBE)&lt;/button&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div class=&quot;mb-4&quot;&gt;
&lt;label class=&quot;block text-sm font-medium mb-2&quot;&gt;Root:&lt;/label&gt;
&lt;div class=&quot;flex gap-2 flex-wrap&quot; id=&quot;root-buttons&quot;&gt;
&lt;button data-root=&quot;C&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;C&lt;/button&gt;
&lt;button data-root=&quot;C#&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;C#&lt;/button&gt;
&lt;button data-root=&quot;D&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;D&lt;/button&gt;
&lt;button data-root=&quot;D#&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;D#&lt;/button&gt;
&lt;button data-root=&quot;E&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;E&lt;/button&gt;
&lt;button data-root=&quot;F&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;F&lt;/button&gt;
&lt;button data-root=&quot;F#&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;F#&lt;/button&gt;
&lt;button data-root=&quot;G&quot; class=&quot;toggle-btn toggle-sm toggle-active&quot;&gt;G&lt;/button&gt;
&lt;button data-root=&quot;G#&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;G#&lt;/button&gt;
&lt;button data-root=&quot;A&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;A&lt;/button&gt;
&lt;button data-root=&quot;A#&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;A#&lt;/button&gt;
&lt;button data-root=&quot;B&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;B&lt;/button&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div class=&quot;mb-4&quot;&gt;
&lt;label class=&quot;block text-sm font-medium mb-2&quot;&gt;Quality:&lt;/label&gt;
&lt;div class=&quot;flex gap-2 flex-wrap&quot; id=&quot;quality-buttons&quot;&gt;
&lt;button data-quality=&quot;major&quot; class=&quot;toggle-btn toggle-sm toggle-active&quot;&gt;Major&lt;/button&gt;
&lt;button data-quality=&quot;minor&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;Minor&lt;/button&gt;
&lt;button data-quality=&quot;diminished&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;Dim&lt;/button&gt;
&lt;button data-quality=&quot;augmented&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;Aug&lt;/button&gt;
&lt;button data-quality=&quot;dominant7&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;7&lt;/button&gt;
&lt;button data-quality=&quot;major7&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;Maj7&lt;/button&gt;
&lt;button data-quality=&quot;minor7&quot; class=&quot;toggle-btn toggle-sm&quot;&gt;m7&lt;/button&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div class=&quot;mb-4&quot;&gt;
&lt;label class=&quot;block text-sm font-medium mb-2&quot;&gt;Inversion:&lt;/label&gt;
&lt;div class=&quot;flex gap-2 flex-wrap&quot; id=&quot;inversion-buttons&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;

&lt;div id=&quot;voicings-section&quot; class=&quot;mt-4 mb-4&quot;&gt;
&lt;div class=&quot;voicings-header&quot;&gt;
&lt;label class=&quot;block text-sm font-medium&quot;&gt;Playable voicings up the neck:&lt;/label&gt;
&lt;div id=&quot;jump-area&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;preview-area&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;collection-section&quot; class=&quot;mt-6 pt-4 border-t border-gray-200&quot;&gt;
&lt;div class=&quot;flex gap-4 items-center flex-wrap mb-3&quot;&gt;
&lt;label class=&quot;block text-sm font-medium&quot;&gt;Your collection:&lt;/label&gt;
&lt;div id=&quot;collection-actions&quot; class=&quot;flex gap-4 items-center&quot; style=&quot;display: none;&quot;&gt;
&lt;button id=&quot;clear-chords&quot; class=&quot;text-sm cursor-pointer hover:opacity-70 transition-opacity green-text-button&quot;&gt;Clear All&lt;/button&gt;
&lt;button id=&quot;export-svg&quot; class=&quot;text-sm cursor-pointer hover:opacity-70 transition-opacity green-text-button&quot;&gt;Save as SVG&lt;/button&gt;
&lt;button id=&quot;export-png&quot; class=&quot;text-sm cursor-pointer hover:opacity-70 transition-opacity green-text-button&quot;&gt;Save as PNG&lt;/button&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;chord-collection&quot; class=&quot;flex flex-wrap gap-4 items-start&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div class=&quot;text-center text-xs text-gray-400 mt-6 pt-4 border-t border-gray-200&quot;&gt;
&lt;p&gt;Version 1.0.0 &amp;bull; &lt;a href=&quot;https://github.com/dmerand/donald.merand.org&quot; class=&quot;text-gray-500 hover:text-gray-700 underline&quot;&gt;Source code&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;/div&gt;

&lt;!-- banjo-chord-script --&gt;
&lt;script&gt;
/*
 * Mini Banjo Chord Transposer
 * Version: 1.0.0
 * Built: 2026-06-18T01:27:34.926Z
 * Generated automatically - do not edit directly
 */
// === core/musical-theory.js ===
/**
 * Core musical theory utilities
 * Pure functions with no DOM dependencies
 */

class MusicalTheory {
  constructor() {
    this.noteNames = [&apos;C&apos;, &apos;C#&apos;, &apos;D&apos;, &apos;D#&apos;, &apos;E&apos;, &apos;F&apos;, &apos;F#&apos;, &apos;G&apos;, &apos;G#&apos;, &apos;A&apos;, &apos;A#&apos;, &apos;B&apos;];
  }

  noteToSemitone(noteName) {
    const idx = this.noteNames.indexOf(noteName);
    if (idx === -1) throw new Error(`Unknown note: ${noteName}`);
    return idx;
  }

  semitoneToNote(semitone) {
    return this.noteNames[((semitone % 12) + 12) % 12];
  }

  transpose(noteName, semitones) {
    return this.semitoneToNote(this.noteToSemitone(noteName) + semitones);
  }

  chordNotes(rootName, intervals) {
    const rootSemitone = this.noteToSemitone(rootName);
    return intervals.map(i =&gt; this.semitoneToNote(rootSemitone + i));
  }

  chordSemitones(rootName, intervals) {
    const rootSemitone = this.noteToSemitone(rootName);
    return intervals.map(i =&gt; ((rootSemitone + i) % 12 + 12) % 12);
  }

  /**
   * Build a semitone → note name map with correct enharmonic spelling.
   * Tertian chords stack in thirds: root(0), 3rd(2), 5th(4), 7th(6) letters up.
   */
  chordSpelling(rootName, intervals) {
    const letters = [&apos;C&apos;, &apos;D&apos;, &apos;E&apos;, &apos;F&apos;, &apos;G&apos;, &apos;A&apos;, &apos;B&apos;];
    const letterSemitones = [0, 2, 4, 5, 7, 9, 11];

    const rootLetter = rootName.charAt(0);
    const rootLetterIdx = letters.indexOf(rootLetter);
    const rootSemitone = this.noteToSemitone(rootName);

    const spelling = {};
    for (let i = 0; i &lt; intervals.length; i++) {
      const semitone = (rootSemitone + intervals[i]) % 12;
      const targetLetterIdx = (rootLetterIdx + i * 2) % 7;
      const targetLetter = letters[targetLetterIdx];
      const natural = letterSemitones[targetLetterIdx];
      const diff = ((semitone - natural) + 12) % 12;

      if (diff === 0) spelling[semitone] = targetLetter;
      else if (diff === 1) spelling[semitone] = targetLetter + &apos;#&apos;;
      else if (diff === 11) spelling[semitone] = targetLetter + &apos;b&apos;;
      else spelling[semitone] = this.semitoneToNote(semitone);
    }
    return spelling;
  }
}

// === core/chord-library.js ===
/**
 * Chord definitions and quality formulas
 * Pure data + lookup, no DOM dependencies
 */

class ChordLibrary {
  constructor() {
    this.qualities = {
      &apos;major&apos;:      { intervals: [0, 4, 7],     suffix: &apos;&apos;,     name: &apos;Major&apos; },
      &apos;minor&apos;:      { intervals: [0, 3, 7],     suffix: &apos;m&apos;,    name: &apos;Minor&apos; },
      &apos;diminished&apos;: { intervals: [0, 3, 6],     suffix: &apos;dim&apos;,  name: &apos;Diminished&apos; },
      &apos;augmented&apos;:  { intervals: [0, 4, 8],     suffix: &apos;aug&apos;,  name: &apos;Augmented&apos; },
      &apos;dominant7&apos;:  { intervals: [0, 4, 7, 10], suffix: &apos;7&apos;,    name: &apos;Dominant 7th&apos; },
      &apos;major7&apos;:     { intervals: [0, 4, 7, 11], suffix: &apos;maj7&apos;, name: &apos;Major 7th&apos; },
      &apos;minor7&apos;:     { intervals: [0, 3, 7, 10], suffix: &apos;m7&apos;,   name: &apos;Minor 7th&apos; },
    };
  }

  getChord(rootName, qualityKey) {
    const quality = this.qualities[qualityKey];
    if (!quality) throw new Error(`Unknown quality: ${qualityKey}`);
    return {
      root: rootName,
      quality: qualityKey,
      intervals: quality.intervals,
      displayName: rootName + quality.suffix,
      fullName: rootName + &apos; &apos; + quality.name,
    };
  }
}

// === core/banjo-tunings.js ===
/**
 * Banjo tuning definitions
 * Strings indexed 5(drone) -&gt; 4 -&gt; 3 -&gt; 2 -&gt; 1 (highest)
 */

class BanjoTunings {
  constructor(theory) {
    this.theory = theory;
    // maxStretch is the widest fretted span (highest − lowest fret) a hand can
    // comfortably grip. Shorter-scale instruments earn a little more than guitar
    // (closer frets), but only a little — past ~5 frets the limit is finger
    // independence, not reach, so the spread stays modest across instruments.
    this.tunings = {
      &apos;standard&apos;: {
        name: &apos;Standard Banjo (G)&apos;,
        shortName: &apos;G Tuning&apos;,
        openNotes: [&apos;G&apos;, &apos;D&apos;, &apos;G&apos;, &apos;B&apos;, &apos;D&apos;],
        openSemitones: [7, 2, 7, 11, 2],
        numStrings: 5,
        hasDrone: true,
        maxStretch: 4, // ~26&quot; scale
      },
      &apos;mini&apos;: {
        name: &apos;Mini Banjo (C)&apos;,
        shortName: &apos;C Tuning&apos;,
        openNotes: [&apos;C&apos;, &apos;G&apos;, &apos;C&apos;, &apos;E&apos;, &apos;G&apos;],
        openSemitones: [0, 7, 0, 4, 7],
        numStrings: 5,
        hasDrone: true,
        maxStretch: 5, // ~19&quot; short scale
      },
      &apos;mandolin&apos;: {
        name: &apos;Mandolin (GDAE)&apos;,
        shortName: &apos;GDAE&apos;,
        openNotes: [&apos;G&apos;, &apos;D&apos;, &apos;A&apos;, &apos;E&apos;],
        openSemitones: [7, 2, 9, 4],
        numStrings: 4,
        hasDrone: false,
        maxStretch: 5, // ~14&quot; scale
      },
      &apos;guitar&apos;: {
        name: &apos;Guitar (EADGBE)&apos;,
        shortName: &apos;EADGBE&apos;,
        openNotes: [&apos;E&apos;, &apos;A&apos;, &apos;D&apos;, &apos;G&apos;, &apos;B&apos;, &apos;E&apos;],
        openSemitones: [4, 9, 2, 7, 11, 4],
        numStrings: 6,
        hasDrone: false,
        maxStretch: 4, // ~25.5&quot; scale
      },
    };
  }

  get(tuningKey) {
    return this.tunings[tuningKey];
  }

  noteAtFret(tuningKey, stringIndex, fret) {
    const tuning = this.tunings[tuningKey];
    const semitone = (tuning.openSemitones[stringIndex] + fret) % 12;
    return this.theory.semitoneToNote(semitone);
  }

  semitoneAtFret(tuningKey, stringIndex, fret) {
    const tuning = this.tunings[tuningKey];
    return (tuning.openSemitones[stringIndex] + fret) % 12;
  }
}

// === core/banjo-voicer.js ===
/**
 * Banjo/stringed-instrument voicer.
 *
 * Enumerates every distinct, playable voicing of a chord up the neck for a
 * given tuning, root, quality and inversion. There is no scoring or &quot;best&quot;
 * pick — each shape that is complete (all chord tones, no others) and
 * physically playable is returned, organized up the neck.
 */
class BanjoVoicer {
  constructor(theory, tunings) {
    this.theory = theory;
    this.tunings = tunings;
    this.maxFret = 12;
    this.maxStretch = 4;
  }

  /**
   * Is a set of frets physically playable?
   * Hard constraints that replace the old scoring penalties:
   *  - fretted span within reach (&lt;= maxStretch); the reachable span depends on
   *    the instrument&apos;s scale length, so callers pass the tuning&apos;s value
   *  - at most four fingers, allowing one index barre across the lowest fret
   * Open (0) and muted (-1) strings cost no finger.
   */
  isPlayable(frets, maxStretch = this.maxStretch) {
    const fretted = frets.filter(f =&gt; f &gt; 0);
    if (fretted.length === 0) return true;

    const minFret = Math.min(...fretted);
    const maxFret = Math.max(...fretted);
    if (maxFret - minFret &gt; maxStretch) return false;

    const atLowest = fretted.filter(f =&gt; f === minFret).length;
    const barreSaving = atLowest &gt;= 2 ? atLowest - 1 : 0;
    const fingers = fretted.length - barreSaving;
    return fingers &lt;= 4;
  }

  /**
   * Every distinct playable voicing up the neck.
   *
   * @returns array of { frets, notes, muted } sorted from the nut upward.
   */
  enumerateVoicings(chordSemitones, rootSemitone, tuningKey, bassSemitone, spelling = null) {
    const tuning = this.tunings.get(tuningKey);
    const hasDrone = tuning.hasDrone !== false;
    const numFretted = hasDrone ? tuning.numStrings - 1 : tuning.numStrings;
    const frettedOffset = hasDrone ? 1 : 0;
    const maxStretch = tuning.maxStretch || this.maxStretch;

    // The drone (5th string) is fixed open; it only rings if it is a chord tone.
    let droneFret = -1;
    if (hasDrone) {
      const droneOpen = tuning.openSemitones[0];
      droneFret = chordSemitones.includes(droneOpen) ? 0 : -1;
    }

    // Per fretted string: every chord-tone fret across the neck, plus &quot;muted&quot;.
    const candidates = [];
    for (let s = 0; s &lt; numFretted; s++) {
      const openSemitone = tuning.openSemitones[s + frettedOffset];
      const stringCandidates = [{ fret: -1, semitone: -1, muted: true }];
      for (let f = 0; f &lt;= this.maxFret; f++) {
        const semitone = (openSemitone + f) % 12;
        if (chordSemitones.includes(semitone)) {
          stringCandidates.push({ fret: f, semitone, muted: false });
        }
      }
      candidates.push(stringCandidates);
    }

    const chordToneSet = new Set(chordSemitones);
    const results = [];
    const seen = new Set();

    const accept = (fretted) =&gt; {
      // Bass note (lowest-pitched non-muted fretted string) must match the inversion.
      const firstActive = fretted.find(c =&gt; !c.muted);
      if (!firstActive || firstActive.semitone !== bassSemitone) return;

      // Collect sounding pitch classes, including the drone when it rings.
      const sounding = new Set();
      for (const c of fretted) {
        if (!c.muted) sounding.add(c.semitone);
      }
      if (droneFret === 0) sounding.add(tuning.openSemitones[0]);

      // Complete: every chord tone present (no non-chord tones can occur — only
      // chord-tone frets are generated as candidates).
      if (sounding.size !== chordToneSet.size) return;

      const frets = hasDrone
        ? [droneFret, ...fretted.map(c =&gt; c.fret)]
        : fretted.map(c =&gt; c.fret);

      if (!this.isPlayable(frets, maxStretch)) return;

      const key = frets.join(&apos;,&apos;);
      if (seen.has(key)) return;
      seen.add(key);

      const noteName = (semitone) =&gt;
        (spelling &amp;&amp; spelling[semitone]) || this.theory.semitoneToNote(semitone);
      const notes = frets.map((f, i) =&gt; {
        if (f &lt; 0) return null;
        return noteName((tuning.openSemitones[i] + f) % 12);
      });

      results.push({ frets, notes, muted: frets.map(f =&gt; f === -1) });
    };

    const current = new Array(numFretted);
    const search = (stringIdx) =&gt; {
      if (stringIdx === numFretted) {
        accept(current);
        return;
      }
      for (const candidate of candidates[stringIdx]) {
        current[stringIdx] = candidate;
        search(stringIdx + 1);
      }
    };
    search(0);

    const frettedOf = (v) =&gt; v.frets.filter(f =&gt; f &gt; 0);
    const soundCount = (v) =&gt; v.frets.filter(f =&gt; f &gt;= 0).length;
    const lowFret = (v) =&gt; { const f = frettedOf(v); return f.length ? Math.min(...f) : 0; };
    const fretSpan = (v) =&gt; { const f = frettedOf(v); return f.length ? Math.max(...f) - Math.min(...f) : 0; };

    // Collapse muting variants: a player can always mute a string, so a voicing
    // that is just a more-muted version of another (same frets where it sounds,
    // fewer strings ringing) adds no information — provided filling in the muted
    // strings keeps the same grip (the fretted span barely grows; that guard
    // avoids collapsing an iconic open shape into a fuller, neck-shifted one).
    const isMutedSubsetOf = (a, b) =&gt; {
      for (let i = 0; i &lt; a.frets.length; i++) {
        if (a.frets[i] === -1) continue;        // `a` may mute where `b` rings
        if (a.frets[i] !== b.frets[i]) return false;
      }
      return soundCount(a) &lt; soundCount(b) &amp;&amp; fretSpan(b) &lt;= fretSpan(a) + 1;
    };
    // Fullest-first, so a compact shape is only dropped for a superset we keep —
    // never for one that is itself collapsed away later in the pass.
    results.sort((a, b) =&gt; soundCount(b) - soundCount(a));
    const kept = [];
    for (const a of results) {
      if (!kept.some(b =&gt; isMutedSubsetOf(a, b))) kept.push(a);
    }

    // Up the neck: lowest fretted note first, then tighter shapes first.
    kept.sort((a, b) =&gt; lowFret(a) - lowFret(b) || fretSpan(a) - fretSpan(b) || a.frets.join().localeCompare(b.frets.join()));

    return kept;
  }
}

// === core/storage-manager.js ===
/**
 * localStorage wrapper for persisting UI state
 */

class StorageManager {
  constructor(prefix) {
    this.prefix = prefix;
  }

  save(key, value) {
    try {
      localStorage.setItem(this.prefix + key, JSON.stringify(value));
    } catch (e) { /* quota exceeded or private mode */ }
  }

  load(key, defaultValue) {
    try {
      const raw = localStorage.getItem(this.prefix + key);
      return raw !== null ? JSON.parse(raw) : defaultValue;
    } catch (e) {
      return defaultValue;
    }
  }
}

// === chord-diagram-renderer.js ===
/**
 * SVG chord diagram renderer
 * Produces vertical fretboard diagrams for 5-string banjo
 */

class ChordDiagramRenderer {
  constructor() {
    this.config = {
      stringSpacing: 28,
      fretSpacing: 32,
      numFrets: 5,
      numStrings: 5,
      topMargin: 58,
      bottomMargin: 24,
      leftMargin: 36,
      rightMargin: 18,
      dotRadius: 10,
      indicatorRadius: 7,
      nutWidth: 5,
      titleFontSize: 20,
    };
  }

  getDiagramWidth(numStrings) {
    const c = this.config;
    const ns = numStrings || c.numStrings;
    return c.leftMargin + (ns - 1) * c.stringSpacing + c.rightMargin;
  }

  get diagramWidth() {
    return this.getDiagramWidth(this.config.numStrings);
  }

  getDiagramHeight(numFrets) {
    const c = this.config;
    const nf = numFrets || c.numFrets;
    return c.topMargin + nf * c.fretSpacing + c.bottomMargin;
  }

  get diagramHeight() {
    return this.getDiagramHeight(this.config.numFrets);
  }

  render(voicing, chordName, tuningNotes) {
    const c = this.config;
    const numStrings = voicing.frets.length;

    const frettedFrets = voicing.frets.filter(f =&gt; f &gt; 0);
    const minFret = frettedFrets.length &gt; 0 ? Math.min(...frettedFrets) : 0;
    const maxFret = frettedFrets.length &gt; 0 ? Math.max(...frettedFrets) : 0;
    const span = frettedFrets.length &gt; 0 ? maxFret - minFret : 0;
    const numFrets = Math.max(c.numFrets, span + 1);

    const w = this.getDiagramWidth(numStrings);
    const h = this.getDiagramHeight(numFrets);

    const svg = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;svg&apos;);
    svg.setAttribute(&apos;width&apos;, w);
    svg.setAttribute(&apos;height&apos;, h);
    svg.setAttribute(&apos;viewBox&apos;, `0 0 ${w} ${h}`);
    svg.setAttribute(&apos;role&apos;, &apos;img&apos;);
    svg.setAttribute(&apos;aria-label&apos;, `${chordName} chord diagram`);

    let startFret = 1;
    if (maxFret &gt; numFrets) {
      startFret = Math.max(1, minFret);
      if (maxFret - startFret &gt;= numFrets) {
        startFret = maxFret - numFrets + 1;
      }
    }
    const atNut = startFret === 1;

    // Chord name title
    svg.appendChild(this.svgText(w / 2, 16, chordName, {
      fontSize: c.titleFontSize, fontWeight: &apos;bold&apos;, textAnchor: &apos;middle&apos;,
    }));

    // Fretboard geometry
    const fretboardTop = c.topMargin;
    const fretboardLeft = c.leftMargin;
    const fretboardWidth = (numStrings - 1) * c.stringSpacing;

    // Fret lines
    for (let i = 0; i &lt;= numFrets; i++) {
      const y = fretboardTop + i * c.fretSpacing;
      svg.appendChild(this.svgLine(fretboardLeft, y, fretboardLeft + fretboardWidth, y, {
        stroke: &apos;#333&apos;,
        strokeWidth: i === 0 &amp;&amp; atNut ? c.nutWidth : 1,
      }));
    }

    // String lines
    for (let i = 0; i &lt; numStrings; i++) {
      const x = fretboardLeft + i * c.stringSpacing;
      svg.appendChild(this.svgLine(x, fretboardTop, x, fretboardTop + numFrets * c.fretSpacing, {
        stroke: &apos;#333&apos;,
        strokeWidth: 1,
      }));
    }

    // Fret numbers on the left
    for (let i = 0; i &lt; numFrets; i++) {
      const y = fretboardTop + (i + 0.5) * c.fretSpacing + 5;
      svg.appendChild(this.svgText(
        fretboardLeft - 16, y,
        String(startFret + i),
        { fontSize: 11, textAnchor: &apos;middle&apos;, fill: &apos;#999&apos; }
      ));
    }

    // Indicator Y position: vertically centered between title and nut
    const indicatorY = fretboardTop - c.indicatorRadius - 6;

    // Open / muted indicators and finger dots
    for (let s = 0; s &lt; numStrings; s++) {
      const x = fretboardLeft + s * c.stringSpacing;
      const fret = voicing.frets[s];

      if (fret === -1) {
        const r = c.indicatorRadius * 0.7;
        const cx = x;
        const cy = indicatorY;
        svg.appendChild(this.svgLine(cx - r, cy - r, cx + r, cy + r, {
          stroke: &apos;#666&apos;, strokeWidth: 2,
        }));
        svg.appendChild(this.svgLine(cx - r, cy + r, cx + r, cy - r, {
          stroke: &apos;#666&apos;, strokeWidth: 2,
        }));
      } else if (fret === 0) {
        svg.appendChild(this.svgCircle(x, indicatorY, c.indicatorRadius, {
          fill: &apos;none&apos;, stroke: &apos;#333&apos;, strokeWidth: 1.5,
        }));
      } else {
        const displayFret = fret - startFret + 1;
        if (displayFret &gt;= 1 &amp;&amp; displayFret &lt;= numFrets) {
          const y = fretboardTop + (displayFret - 0.5) * c.fretSpacing;
          svg.appendChild(this.svgCircle(x, y, c.dotRadius, {
            fill: &apos;#333&apos;, stroke: &apos;none&apos;,
          }));
          svg.appendChild(this.svgText(x, y + 4, voicing.notes[s], {
            fontSize: 11, textAnchor: &apos;middle&apos;, fill: &apos;#fff&apos;, fontWeight: &apos;bold&apos;,
          }));
        }
      }
    }

    // String labels at bottom
    for (let s = 0; s &lt; numStrings; s++) {
      const x = fretboardLeft + s * c.stringSpacing;
      svg.appendChild(this.svgText(
        x, fretboardTop + numFrets * c.fretSpacing + 18,
        tuningNotes[s],
        { fontSize: 12, textAnchor: &apos;middle&apos;, fill: &apos;#999&apos; }
      ));
    }

    return svg;
  }

  svgLine(x1, y1, x2, y2, attrs = {}) {
    const line = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;line&apos;);
    line.setAttribute(&apos;x1&apos;, x1);
    line.setAttribute(&apos;y1&apos;, y1);
    line.setAttribute(&apos;x2&apos;, x2);
    line.setAttribute(&apos;y2&apos;, y2);
    for (const [key, val] of Object.entries(attrs)) {
      line.setAttribute(key === &apos;strokeWidth&apos; ? &apos;stroke-width&apos; : key, val);
    }
    return line;
  }

  svgCircle(cx, cy, r, attrs = {}) {
    const circle = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;circle&apos;);
    circle.setAttribute(&apos;cx&apos;, cx);
    circle.setAttribute(&apos;cy&apos;, cy);
    circle.setAttribute(&apos;r&apos;, r);
    for (const [key, val] of Object.entries(attrs)) {
      circle.setAttribute(key === &apos;strokeWidth&apos; ? &apos;stroke-width&apos; : key, val);
    }
    return circle;
  }

  svgText(x, y, text, attrs = {}) {
    const el = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;text&apos;);
    el.setAttribute(&apos;x&apos;, x);
    el.setAttribute(&apos;y&apos;, y);
    el.textContent = text;
    const attrMap = {
      fontSize: &apos;font-size&apos;, fontWeight: &apos;font-weight&apos;,
      textAnchor: &apos;text-anchor&apos;, strokeWidth: &apos;stroke-width&apos;,
    };
    for (const [key, val] of Object.entries(attrs)) {
      el.setAttribute(attrMap[key] || key, val);
    }
    return el;
  }
}

// === widget.js ===
/**
 * Chord-finder UI controller.
 *
 * Pick a tuning, root, quality and inversion; the tool shows every distinct
 * playable voicing up the neck. Click a voicing to add it to the collection,
 * which can be exported as an SVG or PNG chord sheet.
 */
class BanjoToolController {
  constructor() {
    this.theory = new MusicalTheory();
    this.chordLib = new ChordLibrary();
    this.tunings = new BanjoTunings(this.theory);
    this.voicer = new BanjoVoicer(this.theory, this.tunings);
    this.renderer = new ChordDiagramRenderer();
    this.storage = new StorageManager(&apos;banjo-chord-&apos;);

    this.currentTuning = this.storage.load(&apos;tuning&apos;, &apos;mini&apos;);
    this.currentRoot = this.storage.load(&apos;root&apos;, &apos;G&apos;);
    this.currentQuality = this.storage.load(&apos;quality&apos;, &apos;major&apos;);
    this.currentInversion = this.storage.load(&apos;inversion&apos;, 0);
    this.showAll = this.storage.load(&apos;showAll&apos;, false);
    this.voicingIndex = 0;
    // Drop any collection entries saved by the old scoring-based version; they
    // lack the concrete `frets` the renderer now needs.
    this.chords = this.storage.load(&apos;chords&apos;, []).filter(c =&gt; c &amp;&amp; Array.isArray(c.frets));
  }

  init() {
    document.querySelectorAll(&apos;[data-tuning]&apos;).forEach(btn =&gt; {
      btn.addEventListener(&apos;click&apos;, () =&gt; this.setTuning(btn.dataset.tuning));
    });
    document.querySelectorAll(&apos;[data-root]&apos;).forEach(btn =&gt; {
      btn.addEventListener(&apos;click&apos;, () =&gt; this.setRoot(btn.dataset.root));
    });
    document.querySelectorAll(&apos;[data-quality]&apos;).forEach(btn =&gt; {
      btn.addEventListener(&apos;click&apos;, () =&gt; this.setQuality(btn.dataset.quality));
    });

    document.getElementById(&apos;clear-chords&apos;).addEventListener(&apos;click&apos;, () =&gt; {
      this.chords = [];
      this.persist();
      this.renderCollection();
    });
    document.getElementById(&apos;export-svg&apos;).addEventListener(&apos;click&apos;, () =&gt; this.exportSVG());
    document.getElementById(&apos;export-png&apos;).addEventListener(&apos;click&apos;, () =&gt; this.exportPNG());

    this.syncToggleButtons();
    this.buildInversionButtons();
    this.renderVoicings();
    this.renderCollection();
  }

  getBassSemitone(root, quality, inversion) {
    root = root || this.currentRoot;
    quality = quality || this.currentQuality;
    inversion = inversion !== undefined ? inversion : this.currentInversion;
    const chord = this.chordLib.getChord(root, quality);
    const semitones = this.theory.chordSemitones(root, chord.intervals);
    return semitones[inversion] !== undefined ? semitones[inversion] : semitones[0];
  }

  getChordDisplayName(root, quality, inversion) {
    const chord = this.chordLib.getChord(root, quality);
    if (!inversion) return chord.displayName;
    const spelling = this.theory.chordSpelling(root, chord.intervals);
    const bassSemitone = this.theory.chordSemitones(root, chord.intervals)[inversion];
    const bassNote = spelling[bassSemitone] || this.theory.semitoneToNote(bassSemitone);
    return chord.displayName + &apos;/&apos; + bassNote;
  }

  buildInversionButtons() {
    const container = document.getElementById(&apos;inversion-buttons&apos;);
    container.innerHTML = &apos;&apos;;

    const chord = this.chordLib.getChord(this.currentRoot, this.currentQuality);
    const spelling = this.theory.chordSpelling(this.currentRoot, chord.intervals);
    const semitones = this.theory.chordSemitones(this.currentRoot, chord.intervals);

    if (this.currentInversion &gt;= chord.intervals.length) {
      this.currentInversion = 0;
      this.storage.save(&apos;inversion&apos;, 0);
    }

    for (let i = 0; i &lt; chord.intervals.length; i++) {
      const btn = document.createElement(&apos;button&apos;);
      btn.className = &apos;toggle-btn toggle-sm&apos;;
      if (i === 0) {
        btn.textContent = &apos;Root&apos;;
      } else {
        const noteName = spelling[semitones[i]] || this.theory.semitoneToNote(semitones[i]);
        btn.textContent = &apos;/&apos; + noteName;
      }
      btn.dataset.inversion = i;
      const active = i === this.currentInversion;
      btn.classList.toggle(&apos;toggle-active&apos;, active);
      btn.setAttribute(&apos;aria-pressed&apos;, active);
      btn.addEventListener(&apos;click&apos;, () =&gt; this.setInversion(i));
      container.appendChild(btn);
    }
  }

  setInversion(inv) {
    this.currentInversion = inv;
    this.voicingIndex = 0;
    this.storage.save(&apos;inversion&apos;, inv);
    document.querySelectorAll(&apos;[data-inversion]&apos;).forEach(btn =&gt; {
      const active = Number(btn.dataset.inversion) === inv;
      btn.classList.toggle(&apos;toggle-active&apos;, active);
      btn.setAttribute(&apos;aria-pressed&apos;, active);
    });
    this.renderVoicings();
  }

  syncToggleButtons() {
    document.querySelectorAll(&apos;[data-tuning]&apos;).forEach(btn =&gt; {
      const active = btn.dataset.tuning === this.currentTuning;
      btn.classList.toggle(&apos;toggle-active&apos;, active);
      btn.setAttribute(&apos;aria-pressed&apos;, active);
    });
    document.querySelectorAll(&apos;[data-root]&apos;).forEach(btn =&gt; {
      const active = btn.dataset.root === this.currentRoot;
      btn.classList.toggle(&apos;toggle-active&apos;, active);
      btn.setAttribute(&apos;aria-pressed&apos;, active);
    });
    document.querySelectorAll(&apos;[data-quality]&apos;).forEach(btn =&gt; {
      const active = btn.dataset.quality === this.currentQuality;
      btn.classList.toggle(&apos;toggle-active&apos;, active);
      btn.setAttribute(&apos;aria-pressed&apos;, active);
    });
  }

  setTuning(tuningKey) {
    this.currentTuning = tuningKey;
    this.voicingIndex = 0;
    this.storage.save(&apos;tuning&apos;, tuningKey);
    this.syncToggleButtons();
    this.renderVoicings();
  }

  setRoot(root) {
    this.currentRoot = root;
    this.voicingIndex = 0;
    this.storage.save(&apos;root&apos;, root);
    this.syncToggleButtons();
    this.buildInversionButtons();
    this.renderVoicings();
  }

  setQuality(quality) {
    this.currentQuality = quality;
    this.voicingIndex = 0;
    this.storage.save(&apos;quality&apos;, quality);
    this.syncToggleButtons();
    this.buildInversionButtons();
    this.renderVoicings();
  }

  currentVoicings() {
    // Cache by selection so stepping/toggling doesn&apos;t re-enumerate the whole neck.
    const key = `${this.currentTuning}|${this.currentRoot}|${this.currentQuality}|${this.currentInversion}`;
    if (this._voicingsKey === key) return this._voicings;

    const chord = this.chordLib.getChord(this.currentRoot, this.currentQuality);
    const semitones = this.theory.chordSemitones(this.currentRoot, chord.intervals);
    const rootSemitone = this.theory.noteToSemitone(this.currentRoot);
    const spelling = this.theory.chordSpelling(this.currentRoot, chord.intervals);
    const bassSemitone = this.getBassSemitone();

    this._voicingsKey = key;
    this._voicings = this.voicer.enumerateVoicings(semitones, rootSemitone, this.currentTuning, bassSemitone, spelling);
    return this._voicings;
  }

  voicingPosition(voicing) {
    const fretted = voicing.frets.filter(f =&gt; f &gt; 0);
    return fretted.length === 0 ? 0 : Math.min(...fretted);
  }

  positionLabel(voicing) {
    const pos = this.voicingPosition(voicing);
    return pos === 0 ? &apos;open position&apos; : &apos;fret &apos; + pos;
  }

  // A chip per distinct neck position, jumping to the first shape there.
  makeJumpChips(voicings) {
    const positions = [];
    voicings.forEach((v, idx) =&gt; {
      const fret = this.voicingPosition(v);
      if (!positions.some(p =&gt; p.fret === fret)) positions.push({ fret, idx });
    });
    if (positions.length &lt; 2) return null;

    const row = document.createElement(&apos;div&apos;);
    row.className = &apos;stepper-jump&apos;;

    const lead = document.createElement(&apos;span&apos;);
    lead.className = &apos;stepper-jump-label&apos;;
    lead.textContent = &apos;jump:&apos;;
    row.appendChild(lead);

    const activeFret = this.voicingPosition(voicings[this.voicingIndex]);
    for (const p of positions) {
      const chip = document.createElement(&apos;button&apos;);
      chip.className = &apos;jump-chip&apos;;
      chip.textContent = p.fret === 0 ? &apos;Open&apos; : String(p.fret);
      chip.classList.toggle(&apos;jump-active&apos;, p.fret === activeFret);
      chip.addEventListener(&apos;click&apos;, () =&gt; {
        this.voicingIndex = p.idx;
        this.renderVoicings();
      });
      row.appendChild(chip);
    }
    return row;
  }

  makeAddButton(voicing, displayName) {
    const addBtn = document.createElement(&apos;button&apos;);
    addBtn.className = &apos;add-voicing-btn&apos;;
    addBtn.textContent = &apos;+ add&apos;;
    addBtn.setAttribute(&apos;aria-label&apos;, `Add ${displayName} voicing to collection`);
    addBtn.addEventListener(&apos;click&apos;, () =&gt; this.addVoicing(voicing, displayName));
    return addBtn;
  }

  makeShowAllToggle(count) {
    const toggle = document.createElement(&apos;button&apos;);
    toggle.className = &apos;show-all-toggle&apos;;
    toggle.textContent = this.showAll ? &apos;show fewer ▴&apos; : `show all ${count} ▾`;
    toggle.addEventListener(&apos;click&apos;, () =&gt; {
      this.showAll = !this.showAll;
      this.storage.save(&apos;showAll&apos;, this.showAll);
      this.renderVoicings();
    });
    return toggle;
  }

  renderVoicings() {
    const container = document.getElementById(&apos;preview-area&apos;);
    const jumpArea = document.getElementById(&apos;jump-area&apos;);
    container.innerHTML = &apos;&apos;;
    jumpArea.innerHTML = &apos;&apos;;

    const tuning = this.tunings.get(this.currentTuning);
    const displayName = this.getChordDisplayName(this.currentRoot, this.currentQuality, this.currentInversion);
    const voicings = this.currentVoicings();

    if (voicings.length === 0) {
      const empty = document.createElement(&apos;p&apos;);
      empty.className = &apos;voicings-empty&apos;;
      empty.textContent = `No playable ${displayName} voicings in this tuning.`;
      container.appendChild(empty);
      return;
    }

    if (this.showAll) {
      const grid = document.createElement(&apos;div&apos;);
      grid.className = &apos;voicings-grid&apos;;
      for (const voicing of voicings) {
        const wrapper = document.createElement(&apos;div&apos;);
        wrapper.className = &apos;chord-card chord-voicing&apos;;
        wrapper.appendChild(this.renderer.render(voicing, displayName, tuning.openNotes));
        wrapper.appendChild(this.makeAddButton(voicing, displayName));
        grid.appendChild(wrapper);
      }
      container.appendChild(grid);
      container.appendChild(this.makeShowAllToggle(voicings.length));
      return;
    }

    // Stepper: one voicing at a time with prev/next navigation.
    this.voicingIndex = Math.max(0, Math.min(this.voicingIndex, voicings.length - 1));
    const voicing = voicings[this.voicingIndex];

    const jump = this.makeJumpChips(voicings);
    if (jump) jumpArea.appendChild(jump);

    const stepper = document.createElement(&apos;div&apos;);
    stepper.className = &apos;voicings-stepper&apos;;

    const nav = document.createElement(&apos;div&apos;);
    nav.className = &apos;stepper-nav&apos;;

    const prev = document.createElement(&apos;button&apos;);
    prev.className = &apos;stepper-arrow&apos;;
    prev.textContent = &apos;◀&apos;;
    prev.setAttribute(&apos;aria-label&apos;, &apos;Previous voicing&apos;);
    prev.disabled = this.voicingIndex === 0;
    prev.addEventListener(&apos;click&apos;, () =&gt; this.stepVoicing(-1));

    const label = document.createElement(&apos;span&apos;);
    label.className = &apos;stepper-label&apos;;
    label.innerHTML = `shape ${this.voicingIndex + 1} of ${voicings.length}` +
      `&lt;span class=&quot;stepper-pos&quot;&gt;${this.positionLabel(voicing)}&lt;/span&gt;`;

    const next = document.createElement(&apos;button&apos;);
    next.className = &apos;stepper-arrow&apos;;
    next.textContent = &apos;▶&apos;;
    next.setAttribute(&apos;aria-label&apos;, &apos;Next voicing&apos;);
    next.disabled = this.voicingIndex === voicings.length - 1;
    next.addEventListener(&apos;click&apos;, () =&gt; this.stepVoicing(1));

    nav.appendChild(prev);
    nav.appendChild(label);
    nav.appendChild(next);

    const card = document.createElement(&apos;div&apos;);
    card.className = &apos;chord-card chord-voicing&apos;;
    card.appendChild(this.renderer.render(voicing, displayName, tuning.openNotes));

    const actions = document.createElement(&apos;div&apos;);
    actions.className = &apos;stepper-actions&apos;;
    actions.appendChild(this.makeAddButton(voicing, displayName));
    actions.appendChild(this.makeShowAllToggle(voicings.length));

    stepper.appendChild(nav);
    stepper.appendChild(card);
    stepper.appendChild(actions);
    container.appendChild(stepper);
  }

  stepVoicing(delta) {
    this.voicingIndex += delta;
    this.renderVoicings();
  }

  addVoicing(voicing, displayName) {
    this.chords.push({
      root: this.currentRoot,
      quality: this.currentQuality,
      inversion: this.currentInversion,
      tuningKey: this.currentTuning,
      openNotes: this.tunings.get(this.currentTuning).openNotes.slice(),
      displayName,
      frets: voicing.frets.slice(),
      notes: voicing.notes.slice(),
    });
    this.persist();
    this.renderCollection();
  }

  persist() {
    this.storage.save(&apos;chords&apos;, this.chords);
  }

  voicingFromStored(c) {
    return { frets: c.frets, notes: c.notes, muted: c.frets.map(f =&gt; f === -1) };
  }

  renderCollection() {
    const container = document.getElementById(&apos;chord-collection&apos;);
    container.innerHTML = &apos;&apos;;

    const actions = document.getElementById(&apos;collection-actions&apos;);
    if (actions) actions.style.display = this.chords.length &gt; 0 ? &apos;flex&apos; : &apos;none&apos;;

    if (this.chords.length === 0) return;

    for (let i = 0; i &lt; this.chords.length; i++) {
      const c = this.chords[i];
      const svg = this.renderer.render(this.voicingFromStored(c), c.displayName, c.openNotes);
      const wrapper = document.createElement(&apos;div&apos;);
      wrapper.className = &apos;chord-card&apos;;
      wrapper.appendChild(svg);

      const removeBtn = document.createElement(&apos;button&apos;);
      removeBtn.textContent = &apos;remove&apos;;
      removeBtn.className = &apos;remove-btn&apos;;
      removeBtn.addEventListener(&apos;click&apos;, () =&gt; {
        this.chords.splice(i, 1);
        this.persist();
        this.renderCollection();
      });
      wrapper.appendChild(removeBtn);
      container.appendChild(wrapper);
    }
  }

  buildExportSVG() {
    const gap = 10;
    let xOffset = 10;
    let maxHeight = 0;
    let body = &apos;&apos;;

    for (const c of this.chords) {
      const numStrings = c.frets.length;
      const fretted = c.frets.filter(f =&gt; f &gt; 0);
      const span = fretted.length &gt; 0 ? Math.max(...fretted) - Math.min(...fretted) : 0;
      const numFrets = Math.max(this.renderer.config.numFrets, span + 1);
      const dw = this.renderer.getDiagramWidth(numStrings);
      const dh = this.renderer.getDiagramHeight(numFrets);
      maxHeight = Math.max(maxHeight, dh);

      const svg = this.renderer.render(this.voicingFromStored(c), c.displayName, c.openNotes);
      body += `&lt;g transform=&quot;translate(${xOffset}, 10)&quot;&gt;\n${svg.innerHTML}\n&lt;/g&gt;\n`;
      xOffset += dw + gap;
    }

    const totalWidth = xOffset - gap + 10;
    const totalHeight = maxHeight + 40;

    const footerTuning = this.tunings.get(this.chords[0].tuningKey) || this.tunings.get(this.currentTuning);
    let svgContent = `&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;${totalWidth}&quot; height=&quot;${totalHeight}&quot; viewBox=&quot;0 0 ${totalWidth} ${totalHeight}&quot;&gt;\n`;
    svgContent += `&lt;rect width=&quot;${totalWidth}&quot; height=&quot;${totalHeight}&quot; fill=&quot;white&quot;/&gt;\n`;
    svgContent += body;
    svgContent += `&lt;text x=&quot;${totalWidth / 2}&quot; y=&quot;${totalHeight - 5}&quot; text-anchor=&quot;middle&quot; font-size=&quot;10&quot; fill=&quot;#999&quot;&gt;${footerTuning.shortName}: ${footerTuning.openNotes.join(&apos; &apos;)}&lt;/text&gt;\n`;
    svgContent += `&lt;/svg&gt;`;

    const chordNames = this.chords.map(c =&gt; c.displayName).join(&apos;-&apos;);
    const filename = `chords-${footerTuning.shortName.replace(/\s+/g, &apos;-&apos;).toLowerCase()}-${chordNames.replace(/\s+/g, &apos;&apos;).replace(/[#]/g, &apos;sharp&apos;).replace(/\//g, &apos;-&apos;)}`;

    return { svgContent, totalWidth, totalHeight, filename };
  }

  exportSVG() {
    if (this.chords.length === 0) return;
    const { svgContent, filename } = this.buildExportSVG();
    const blob = new Blob([svgContent], { type: &apos;image/svg+xml&apos; });
    const url = URL.createObjectURL(blob);
    const a = document.createElement(&apos;a&apos;);
    a.href = url;
    a.download = filename + &apos;.svg&apos;;
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    URL.revokeObjectURL(url);
  }

  exportPNG() {
    if (this.chords.length === 0) return;
    const { svgContent, totalWidth, totalHeight, filename } = this.buildExportSVG();
    const scale = 2;
    const canvas = document.createElement(&apos;canvas&apos;);
    canvas.width = totalWidth * scale;
    canvas.height = totalHeight * scale;
    const ctx = canvas.getContext(&apos;2d&apos;);
    ctx.scale(scale, scale);
    const img = new Image();
    const blob = new Blob([svgContent], { type: &apos;image/svg+xml&apos; });
    const url = URL.createObjectURL(blob);
    img.onload = () =&gt; {
      ctx.drawImage(img, 0, 0, totalWidth, totalHeight);
      URL.revokeObjectURL(url);
      const a = document.createElement(&apos;a&apos;);
      a.href = canvas.toDataURL(&apos;image/png&apos;);
      a.download = filename + &apos;.png&apos;;
      document.body.appendChild(a);
      a.click();
      document.body.removeChild(a);
    };
    img.onerror = () =&gt; {
      URL.revokeObjectURL(url);
    };
    img.src = url;
  }
}

document.addEventListener(&apos;DOMContentLoaded&apos;, () =&gt; {
  window.banjoTool = new BanjoToolController();
  window.banjoTool.init();
});


&lt;/script&gt;

&lt;style&gt;
/* Voicings gallery */
.voicings-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.chord-voicing {
  position: relative;
}

.add-voicing-btn {
  font-size: 0.7rem;
  cursor: pointer;
  color: #137752;
  background: none;
  border: none;
  margin-top: 2px;
  font-family: inherit;
  transition: opacity 0.15s ease;
}

.add-voicing-btn:hover {
  opacity: 0.6;
}

.voicings-empty {
  font-size: 0.85rem;
  color: #888;
  padding: 1rem 0;
}

/* Voicing stepper */
.voicings-stepper {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.voicings-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 12px;
}

.stepper-jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.stepper-jump-label {
  font-size: 0.72rem;
  color: #888;
}

.jump-chip {
  border: 1.5px solid #d1d5db;
  background: #fff;
  color: #333;
  border-radius: 5px;
  padding: 2px 9px;
  font-size: 0.72rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.jump-chip:hover { border-color: #333; }

.jump-chip.jump-active {
  background: #333;
  color: #fff;
  border-color: #333;
}

.stepper-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}

.stepper-arrow {
  border: 2px solid #d1d5db;
  background: #fff;
  color: #333;
  border-radius: 6px;
  width: 34px;
  height: 34px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}

.stepper-arrow:hover:not(:disabled) { border-color: #333; }
.stepper-arrow:disabled { opacity: 0.3; cursor: default; }

.stepper-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #333;
  min-width: 130px;
  text-align: center;
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.stepper-pos {
  font-size: 0.7rem;
  font-weight: 400;
  color: #999;
}

.stepper-actions {
  display: flex;
  gap: 18px;
  align-items: center;
}

.show-all-toggle {
  font-size: 0.75rem;
  color: #137752;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s ease;
}

.show-all-toggle:hover { opacity: 0.6; }

#banjo-tool {
  max-width: 100%;
  overflow: hidden;
}

/* Ensure flex-wrap works regardless of Tailwind build */
#banjo-tool .flex-wrap,
#root-buttons,
#quality-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Toggle buttons */
.toggle-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fff;
  color: #333;
  border: 2px solid #d1d5db;
  user-select: none;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.toggle-btn:hover {
  border-color: #333;
}

.toggle-btn.toggle-active {
  background: #333;
  color: #fff;
  border-color: #333;
}

.toggle-btn.toggle-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Chord display area */
#voicings-section {
  min-height: 220px;
}

.chord-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: 166px;
}

.green-text-button {
  color: #137752;
}

#chord-collection {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.remove-btn {
  font-size: 0.7rem;
  cursor: pointer;
  color: #999;
  background: none;
  border: none;
  margin-top: 2px;
  font-family: inherit;
  transition: opacity 0.15s ease;
}

.remove-btn:hover {
  opacity: 0.6;
}

.chord-card svg {
  display: block;
  height: auto;
}

/* Responsive */
@media (max-width: 640px) {
  #banjo-tool {
    padding: 12px;
  }

  .toggle-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .toggle-btn.toggle-sm {
    padding: 5px 8px;
    font-size: 0.75rem;
  }

  .chord-card {
    width: 100%;
  }

  .chord-card svg {
    width: 100% !important;
  }

  #preview-area {
    width: 100%;
  }

  .remove-btn {
    font-size: 0.9rem;
    padding: 8px 16px;
  }
}

/* Print styles */
@media print {
  @page {
    size: landscape;
    margin: 0.5in;
  }

  .noprint, #controls, footer, nav, header {
    display: none !important;
  }

  body { margin: 0; padding: 0; }

  #banjo-tool {
    max-width: none;
    width: 100vw;
    margin: 0;
    padding: 20px;
    box-shadow: none;
  }
}
&lt;/style&gt;

&lt;h2 id=&quot;background&quot;&gt;Background&lt;/h2&gt;

&lt;p&gt;This tool started life as a simple transposition chart for my &lt;a href=&quot;https://goldtonemusicgroup.com/goldtone/instruments/bg-mini&quot;&gt;Gold Tone BG-Mini&lt;/a&gt; — a short-scale banjo tuned a perfect fourth higher than standard, so every chord shape produces a different chord than what you’d expect. The standard 5-string banjo is tuned to open G (&lt;strong&gt;g D G B D&lt;/strong&gt;) while the mini gives you open C (&lt;strong&gt;c G C E G&lt;/strong&gt;), which means a “G shape” on the mini sounds as C, a “D shape” sounds as G, and so on.&lt;/p&gt;

&lt;p&gt;Once the voicing search was working for banjo, adding mandolin (GDAE) and guitar (EADGBE) was straightforward — the same search works on any tuning, you just change the string layout. Inversions came later, along with a rework that surfaces every voicing instead of guessing a single “best” one.&lt;/p&gt;

&lt;h2 id=&quot;how-it-works&quot;&gt;How It Works&lt;/h2&gt;

&lt;p&gt;Given a set of chord tones and a tuning, it walks every fingering up the neck and keeps the ones that are &lt;strong&gt;complete&lt;/strong&gt; — all chord tones sounding and nothing else — and &lt;strong&gt;playable&lt;/strong&gt;: within a hand’s fret span, and no more than four fingers, allowing for an index barre. The &lt;strong&gt;Inversion&lt;/strong&gt; selector constrains which chord tone sits in the bass.&lt;/p&gt;

&lt;p&gt;Earlier versions scored all those candidates and showed only the single highest-scoring fingering. This one drops the scoring entirely and shows them all. Shapes that differ only by muting a doubled string collapse into one, so you aren’t wading through redundant variations. The results run from the nut upward — the &lt;strong&gt;jump&lt;/strong&gt; chips skip you to a position on the neck, and &lt;strong&gt;show all&lt;/strong&gt; lays every shape out at once for comparison.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Unified Stringed Instrument Scale Pattern Visualizer</title>
   <link href="https://donald.merand.org//projects/2025/01/11/unified-guitar-scale-pattern-visualizer.html"/>
   <updated>2025-01-11T00:00:00-05:00</updated>
   <id>https://donald.merand.org/projects/2025/01/11/unified-guitar-scale-pattern-visualizer</id>
   <content type="html">&lt;div class=&quot;text-sm&quot;&gt;
  &lt;p&gt;
    &lt;em&gt;Updated 2026/05/25: Added mandolin, banjo (open G and open C), and 12-string perfect-fifths tunings.&lt;/em&gt;
  &lt;/p&gt;
  &lt;p&gt;
    Here&apos;s an interactive unified scale pattern visualizer which can be used to find the best &quot;unified&quot; single pattern on guitar or bass for any scale. 
  &lt;/p&gt;
  &lt;p&gt;
    Select a scale and adjust the notes per string to see how the patterns adapt across the fretboard. See below for an explanation.
  &lt;/p&gt;
&lt;/div&gt;

&lt;div id=&quot;instrument-visualizer&quot; class=&quot;bg-white rounded-lg shadow-lg p-6 mt-8&quot;&gt;
&lt;div id=&quot;controls&quot; class=&quot;grid grid-cols-2 md:grid-cols-3 gap-4 mb-6 pt-4&quot;&gt;
&lt;div&gt;
&lt;label for=&quot;tuning-preset&quot; class=&quot;block text-sm font-medium mb-2&quot;&gt;Tuning:&lt;/label&gt;
&lt;select id=&quot;tuning-preset&quot; class=&quot;border border-gray-300 rounded px-3 py-2 w-full form-input-styled&quot; style=&quot;font-size: 1rem; font-family: ui-sans-serif, system-ui, sans-serif;&quot;&gt;
&lt;option value=&quot;perfect-fourths&quot; selected=&quot;&quot;&gt;12-String Perfect 4ths&lt;/option&gt;
&lt;option value=&quot;perfect-fifths&quot;&gt;12-String Perfect 5ths&lt;/option&gt;
&lt;option value=&quot;standard-guitar&quot;&gt;6-String Guitar&lt;/option&gt;
&lt;option value=&quot;mandolin&quot;&gt;Mandolin&lt;/option&gt;
&lt;option value=&quot;banjo-open-g&quot;&gt;Banjo (Open G)&lt;/option&gt;
&lt;option value=&quot;banjo-open-c&quot;&gt;Banjo (Open C)&lt;/option&gt;
&lt;option value=&quot;bass-5-string&quot;&gt;5-String Bass&lt;/option&gt;
&lt;option value=&quot;bass-4-string&quot;&gt;4-String Bass&lt;/option&gt;
&lt;/select&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;label for=&quot;selected-scale-degree&quot; class=&quot;block text-sm font-medium mb-2&quot;&gt;Selected Scale Degree:&lt;/label&gt;
&lt;input type=&quot;number&quot; id=&quot;selected-scale-degree&quot; class=&quot;border border-gray-300 rounded px-3 py-2 w-full&quot; min=&quot;1&quot; max=&quot;12&quot; value=&quot;1&quot; style=&quot;font-size: 1rem; font-family: ui-sans-serif, system-ui, sans-serif;&quot; /&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;label for=&quot;notes-per-string&quot; class=&quot;block text-sm font-medium mb-2&quot;&gt;Notes per String: &lt;span id=&quot;nps-value&quot;&gt;3&lt;/span&gt;&lt;/label&gt;
&lt;input type=&quot;range&quot; id=&quot;notes-per-string&quot; class=&quot;w-full&quot; min=&quot;1&quot; max=&quot;12&quot; value=&quot;3&quot; /&gt;
&lt;/div&gt;

&lt;div class=&quot;md:col-span-2&quot;&gt;
&lt;label for=&quot;scale-intervals&quot; class=&quot;block text-sm font-medium mb-2&quot;&gt;Scale Intervals:&lt;/label&gt;
&lt;input type=&quot;text&quot; id=&quot;scale-intervals&quot; class=&quot;border border-gray-300 rounded px-3 py-2 w-full&quot; value=&quot;2,2,1,2,2,2,1&quot; placeholder=&quot;Comma-separated intervals (e.g., 2,2,1,2,2,2,1)&quot; style=&quot;font-size: 1rem; font-family: ui-sans-serif, system-ui, sans-serif;&quot; /&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;label for=&quot;scale-title&quot; class=&quot;block text-sm font-medium mb-2&quot;&gt;Scale Title:&lt;/label&gt;
&lt;input type=&quot;text&quot; id=&quot;scale-title&quot; class=&quot;border border-gray-300 rounded px-3 py-2 w-full&quot; value=&quot;Major Scale&quot; placeholder=&quot;Custom scale name&quot; style=&quot;font-size: 1rem; font-family: ui-sans-serif, system-ui, sans-serif;&quot; /&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;label for=&quot;scale-type&quot; class=&quot;block text-sm font-medium mb-2&quot;&gt;Select a scale:&lt;/label&gt;
&lt;select id=&quot;scale-type&quot; class=&quot;border border-gray-300 rounded px-3 py-2 w-full form-input-styled&quot; style=&quot;font-size: 1rem; font-family: ui-sans-serif, system-ui, sans-serif;&quot;&gt;
&lt;option value=&quot;major&quot; selected=&quot;&quot;&gt;Major&lt;/option&gt;
&lt;option value=&quot;natural-minor&quot;&gt;Natural Minor&lt;/option&gt;
&lt;option value=&quot;harmonic-minor&quot;&gt;Harmonic Minor&lt;/option&gt;
&lt;option value=&quot;melodic-minor&quot;&gt;Melodic Minor&lt;/option&gt;
&lt;option value=&quot;pentatonic&quot;&gt;Pentatonic&lt;/option&gt;
&lt;option value=&quot;whole-tone&quot;&gt;Whole Tone&lt;/option&gt;
&lt;option value=&quot;chromatic&quot;&gt;Chromatic&lt;/option&gt;
&lt;option value=&quot;blues&quot;&gt;Blues&lt;/option&gt;
&lt;option value=&quot;custom&quot;&gt;Custom Scale&lt;/option&gt;
&lt;/select&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;label for=&quot;root-note&quot; class=&quot;block text-sm font-medium mb-2&quot;&gt;Root Note:&lt;/label&gt;
&lt;select id=&quot;root-note&quot; class=&quot;border border-gray-300 rounded px-3 py-2 w-full form-input-styled&quot; style=&quot;font-size: 1rem; font-family: ui-sans-serif, system-ui, sans-serif;&quot;&gt;
&lt;option value=&quot;C&quot; selected=&quot;&quot;&gt;C&lt;/option&gt;
&lt;option value=&quot;C#&quot;&gt;C#&lt;/option&gt;
&lt;option value=&quot;D&quot;&gt;D&lt;/option&gt;
&lt;option value=&quot;D#&quot;&gt;D#&lt;/option&gt;
&lt;option value=&quot;E&quot;&gt;E&lt;/option&gt;
&lt;option value=&quot;F&quot;&gt;F&lt;/option&gt;
&lt;option value=&quot;F#&quot;&gt;F#&lt;/option&gt;
&lt;option value=&quot;G&quot;&gt;G&lt;/option&gt;
&lt;option value=&quot;G#&quot;&gt;G#&lt;/option&gt;
&lt;option value=&quot;A&quot;&gt;A&lt;/option&gt;
&lt;option value=&quot;A#&quot;&gt;A#&lt;/option&gt;
&lt;option value=&quot;B&quot;&gt;B&lt;/option&gt;
&lt;/select&gt;
&lt;/div&gt;

&lt;div class=&quot;flex items-end gap-2&quot;&gt;
&lt;button id=&quot;update-preset-button&quot; class=&quot;text-2xl cursor-pointer px-3 py-2 hover:opacity-70 transition-opacity transparent-button&quot; title=&quot;Update current preset&quot; aria-label=&quot;Update current preset&quot;&gt;
💾
&lt;/button&gt;
&lt;button id=&quot;delete-preset-button&quot; class=&quot;text-2xl cursor-pointer px-3 py-2 hover:opacity-70 transition-opacity transparent-button&quot; title=&quot;Delete current preset&quot; aria-label=&quot;Delete current preset&quot;&gt;
🗑️
&lt;/button&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div class=&quot;text-left mt-4&quot;&gt;
&lt;button id=&quot;save-preset-button&quot; class=&quot;text-sm mr-4 cursor-pointer hover:opacity-70 transition-opacity green-text-button&quot;&gt;
Save as new preset
&lt;/button&gt;
&lt;button id=&quot;export-button&quot; class=&quot;text-sm mr-4 cursor-pointer hover:opacity-70 transition-opacity green-text-button&quot;&gt;
Export Pattern
&lt;/button&gt;
&lt;label for=&quot;import-file&quot; class=&quot;text-sm cursor-pointer hover:opacity-70 transition-opacity green-text-button&quot;&gt;
Import Pattern
&lt;/label&gt;
&lt;input type=&quot;file&quot; id=&quot;import-file&quot; accept=&quot;.json&quot; style=&quot;display: none;&quot; /&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div class=&quot;text-right mt-4 mb-2&quot;&gt;
&lt;button id=&quot;save-svg-button&quot; class=&quot;text-sm cursor-pointer hover:opacity-70 transition-opacity green-text-button&quot;&gt;
Save as SVG
&lt;/button&gt;
&lt;/div&gt;

&lt;div id=&quot;fretboard-container&quot; class=&quot;relative overflow-x-auto mt-2 mb-4&quot;&gt;
&lt;svg id=&quot;fretboard&quot; width=&quot;800&quot; height=&quot;700&quot; viewBox=&quot;0 0 800 700&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; aria-label=&quot;Guitar fretboard visualization&quot;&gt;&lt;/svg&gt;
&lt;/div&gt;

&lt;div class=&quot;text-center text-xs text-gray-400 mt-6 pt-4 border-t border-gray-200&quot;&gt;
&lt;p&gt;Version 1.4.0 • Last updated: May 25, 2026 • &lt;a href=&quot;https://github.com/dmerand/donald.merand.org/tree/master/lib/unified-nps&quot; class=&quot;text-gray-500 hover:text-gray-700 underline&quot;&gt;Source code&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;script&gt;
/*
 * Guitar Scale Visualizer
 * Version: 1.4.0
 * Built: 2026-05-26T00:48:41.423Z
 * Generated automatically - do not edit directly
 */
// === core/musical-theory.js ===
/**
 * Core musical theory utilities for the guitar scale visualizer
 * Pure functions with no DOM dependencies - fully testable
 */

class MusicalTheory {
  constructor() {
    this.noteValues = { C: 0, D: 2, E: 4, F: 5, G: 7, A: 9, B: 11 };
    this.noteNames = [&apos;C&apos;, &apos;C#&apos;, &apos;D&apos;, &apos;D#&apos;, &apos;E&apos;, &apos;F&apos;, &apos;F#&apos;, &apos;G&apos;, &apos;G#&apos;, &apos;A&apos;, &apos;A#&apos;, &apos;B&apos;];
  }

  /**
   * Parse a note string (e.g., &quot;C3&quot;, &quot;F#2&quot;) into semitone value
   * @param {string} noteStr - Note in format like &quot;C3&quot; or &quot;F#2&quot;
   * @returns {number} Semitone value
   */
  parseNote(noteStr) {
    const noteMatch = noteStr.match(/^([A-G])(b|#?)(\d+)$/);
    if (!noteMatch) throw new Error(`Invalid note format: ${noteStr}`);
    
    const [, noteName, accidental, octave] = noteMatch;
    const accidentalOffset = accidental === &apos;#&apos; ? 1 : accidental === &apos;b&apos; ? -1 : 0;
    
    return this.noteValues[noteName] + accidentalOffset + parseInt(octave) * 12;
  }

  /**
   * Convert semitone value back to note string
   * @param {number} semitone - Semitone value
   * @returns {string} Note string like &quot;C3&quot; or &quot;F#2&quot;
   */
  semitoneToNote(semitone) {
    return `${this.noteNames[semitone % 12]}${Math.floor(semitone / 12)}`;
  }

  /**
   * Extract just the note name from a full note string
   * @param {string} noteStr - Full note string like &quot;C3&quot;
   * @returns {string} Just note name like &quot;C&quot; or &quot;F#&quot;
   */
  getNoteName(noteStr) {
    const match = noteStr.match(/^([A-G])(b|#?)/);
    return match ? match[1] + (match[2] || &apos;&apos;) : noteStr;
  }

  /**
   * Parse interval string into array of integers
   * @param {string} intervalString - Comma-separated intervals like &quot;2,2,1,2,2,2,1&quot;
   * @returns {number[]} Array of interval values
   */
  parseIntervals(intervalString) {
    return intervalString.split(&apos;,&apos;).map(str =&gt; parseInt(str.trim())).filter(n =&gt; !isNaN(n));
  }

  /**
   * Calculate greatest common divisor
   * @param {number} a 
   * @param {number} b 
   * @returns {number}
   */
  gcd(a, b) {
    return b === 0 ? a : this.gcd(b, a % b);
  }

  /**
   * Calculate least common multiple
   * @param {number} a 
   * @param {number} b 
   * @returns {number}
   */
  lcm(a, b) {
    return (a * b) / this.gcd(a, b);
  }

  /**
   * Generate extended scale sequence starting from selected scale degree
   * @param {string} rootNote - Root note like &quot;C3&quot;
   * @param {string} intervalString - Comma-separated intervals
   * @param {number} notesPerString - Notes per string constraint
   * @param {number} selectedScaleDegree - Starting scale degree (1-based)
   * @returns {string[]} Array of note strings
   */
  generateExtendedScale(rootNote, intervalString, notesPerString, selectedScaleDegree = 1) {
    const rootSemitone = this.parseNote(rootNote);
    const intervals = this.parseIntervals(intervalString);
    
    if (intervals.length === 0) return [];

    // Calculate LCM for extended sequence length + one extra note (first note repeat)
    const patternLength = intervals.length;
    const baseExtendedLength = this.lcm(patternLength, notesPerString);
    const extendedLength = baseExtendedLength + 1;
    
    // Calculate starting semitone for the selected scale degree
    let startingSemitone = rootSemitone;
    for (let i = 0; i &lt; selectedScaleDegree - 1; i++) {
      startingSemitone += intervals[i % intervals.length];
    }
    
    // Generate the extended scale sequence starting from the selected degree
    const scaleNotes = [];
    let currentSemitone = startingSemitone;
    
    scaleNotes.push(this.semitoneToNote(currentSemitone));
    
    // Start interval rotation from the selected scale degree
    const startIntervalIndex = (selectedScaleDegree - 1) % intervals.length;
    for (let i = 0; i &lt; extendedLength - 1; i++) {
      const intervalIndex = (startIntervalIndex + i) % intervals.length;
      currentSemitone += intervals[intervalIndex];
      scaleNotes.push(this.semitoneToNote(currentSemitone));
    }
    
    return scaleNotes;
  }

}



// === core/scale-patterns.js ===
/**
 * Scale pattern definitions and management
 * Contains all built-in scales and their default preferences
 */

class ScalePatterns {
  constructor() {
    // Scale interval patterns (semitones between consecutive notes)
    this.scaleIntervalPatterns = {
      &apos;major&apos;: [2, 2, 1, 2, 2, 2, 1],
      &apos;natural-minor&apos;: [2, 1, 2, 2, 1, 2, 2],
      &apos;harmonic-minor&apos;: [2, 1, 2, 2, 1, 3, 1],
      &apos;melodic-minor&apos;: [2, 1, 2, 2, 2, 2, 1],
      &apos;pentatonic&apos;: [2, 2, 3, 2, 3],
      &apos;whole-tone&apos;: [2, 2, 2, 2, 2, 2],
      &apos;chromatic&apos;: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
      &apos;blues&apos;: [3, 2, 1, 1, 3, 2]
    };

    // Default scale preferences
    this.defaultScalePreferences = {
      &apos;major&apos;: { title: &apos;Major Scale&apos;, notesPerString: 3, selectedScaleDegree: 1, rootNote: &apos;C&apos; },
      &apos;natural-minor&apos;: { title: &apos;Natural Minor Scale&apos;, notesPerString: 3, selectedScaleDegree: 1, rootNote: &apos;A&apos; },
      &apos;harmonic-minor&apos;: { title: &apos;Harmonic Minor Scale&apos;, notesPerString: 3, selectedScaleDegree: 1, rootNote: &apos;A&apos; },
      &apos;melodic-minor&apos;: { title: &apos;Melodic Minor Scale&apos;, notesPerString: 3, selectedScaleDegree: 1, rootNote: &apos;A&apos; },
      &apos;pentatonic&apos;: { title: &apos;Pentatonic Scale&apos;, notesPerString: 2, selectedScaleDegree: 1, rootNote: &apos;C&apos; },
      &apos;whole-tone&apos;: { title: &apos;Whole Tone Scale&apos;, notesPerString: 2, selectedScaleDegree: 1, rootNote: &apos;D&apos; },
      &apos;chromatic&apos;: { title: &apos;Chromatic Scale&apos;, notesPerString: 4, selectedScaleDegree: 1, rootNote: &apos;D&apos; },
      &apos;blues&apos;: { title: &apos;Blues Scale&apos;, notesPerString: 2, selectedScaleDegree: 1, rootNote: &apos;A&apos; },
      &apos;custom&apos;: { title: &apos;Custom Scale&apos;, notesPerString: 3, selectedScaleDegree: 1, rootNote: &apos;C&apos; }
    };
  }

  /**
   * Get intervals for a scale type
   * @param {string} scaleType - Scale identifier
   * @returns {number[]|null} Array of intervals or null if not found
   */
  getScaleIntervals(scaleType) {
    return this.scaleIntervalPatterns[scaleType] || null;
  }

  /**
   * Get default preferences for a scale type
   * @param {string} scaleType - Scale identifier
   * @returns {Object|null} Preferences object or null if not found
   */
  getScalePreferences(scaleType) {
    return this.defaultScalePreferences[scaleType] || null;
  }

  /**
   * Find scale type from interval pattern
   * @param {number[]} intervals - Array of intervals
   * @returns {string|null} Scale type or null if no match
   */
  findScaleTypeFromIntervals(intervals) {
    const matchingScale = Object.entries(this.scaleIntervalPatterns).find(([_, scaleIntervals]) =&gt;
      scaleIntervals.length === intervals.length &amp;&amp; 
      scaleIntervals.every((interval, index) =&gt; interval === intervals[index])
    );
    
    return matchingScale ? matchingScale[0] : null;
  }

  /**
   * Get all available scale types
   * @returns {string[]} Array of scale type identifiers
   */
  getAvailableScales() {
    return Object.keys(this.defaultScalePreferences);
  }

  /**
   * Validate if a scale type exists
   * @param {string} scaleType - Scale identifier to check
   * @returns {boolean} True if scale type exists
   */
  isValidScaleType(scaleType) {
    return scaleType in this.defaultScalePreferences;
  }
}



// === core/fretboard-algorithm.js ===
/**
 * Fretboard note-finding algorithm
 * Pure algorithmic logic for finding optimal note positions on stringed instruments
 */

class FretboardAlgorithm {
  constructor(options = {}) {
    this.maxFret = options.maxFret || 24;
    this.maxInterval = options.maxInterval || 6;  // Hand span limit
    this.FRET_PADDING_BELOW = options.fretPaddingBelow || 2;
    this.FRET_PADDING_ABOVE = options.fretPaddingAbove || 1;
  }

  /**
   * Tuning preset definitions
   */
  static get TUNING_PRESETS() {
    return {
      &apos;perfect-fourths&apos;: [&apos;B1&apos;, &apos;E2&apos;, &apos;A2&apos;, &apos;D3&apos;, &apos;G3&apos;, &apos;C4&apos;, &apos;F4&apos;, &apos;Bb4&apos;, &apos;Eb5&apos;, &apos;Ab5&apos;, &apos;Db6&apos;, &apos;Gb6&apos;],
      &apos;perfect-fifths&apos;: [&apos;Eb1&apos;, &apos;Bb1&apos;, &apos;F2&apos;, &apos;C3&apos;, &apos;G3&apos;, &apos;D4&apos;, &apos;A4&apos;, &apos;E5&apos;, &apos;B5&apos;, &apos;F#6&apos;, &apos;C#7&apos;, &apos;G#7&apos;],
      &apos;standard-guitar&apos;: [&apos;E2&apos;, &apos;A2&apos;, &apos;D3&apos;, &apos;G3&apos;, &apos;B3&apos;, &apos;E4&apos;],
      &apos;mandolin&apos;: [&apos;G3&apos;, &apos;D4&apos;, &apos;A4&apos;, &apos;E5&apos;],
      &apos;banjo-open-g&apos;: [&apos;D3&apos;, &apos;G3&apos;, &apos;B3&apos;, &apos;D4&apos;, &apos;G4&apos;],
      &apos;banjo-open-c&apos;: [&apos;G3&apos;, &apos;C4&apos;, &apos;E4&apos;, &apos;G4&apos;, &apos;C5&apos;],
      &apos;bass-5-string&apos;: [&apos;B1&apos;, &apos;E2&apos;, &apos;A2&apos;, &apos;D3&apos;, &apos;G3&apos;],
      &apos;bass-4-string&apos;: [&apos;E2&apos;, &apos;A2&apos;, &apos;D3&apos;, &apos;G3&apos;]
    };
  }

  /**
   * Find optimal note positions for a scale on the fretboard
   * @param {string[]} targetNotes - Array of note strings to find
   * @param {string[]} tuning - Array of open string notes
   * @param {number} notesPerString - Maximum notes per string
   * @param {MusicalTheory} musicalTheory - Musical theory instance for note parsing
   * @returns {Array[]} Array of [stringIndex, fret] positions
   */
  findNotes(targetNotes, tuning, notesPerString, musicalTheory) {
    const tuningValues = tuning.map(note =&gt; musicalTheory.parseNote(note));
    const targetValues = targetNotes.map(note =&gt; musicalTheory.parseNote(note));
    
    if (targetValues.length === 0) return [];
    
    let bestPattern = [];
    
    // Try multiple starting positions to find the longest pattern
    for (let startFret = 1; startFret &lt;= this.maxFret; startFret += this.maxInterval) {
      const pattern = this.findSinglePattern(targetNotes, targetValues, tuning, tuningValues, notesPerString, startFret);
      
      if (pattern.length &gt; bestPattern.length) {
        bestPattern = pattern;
        if (bestPattern.length === targetValues.length) break;
      }
    }
    return bestPattern;
  }

  /**
   * Find a single pattern starting from a specific fret position
   * @param {string[]} targetNotes - Target note strings
   * @param {number[]} targetValues - Target semitone values
   * @param {string[]} tuning - Tuning note strings
   * @param {number[]} tuningValues - Tuning semitone values
   * @param {number} notesPerString - Notes per string limit
   * @param {number} minStartFret - Minimum starting fret
   * @returns {Array[]} Array of [stringIndex, fret] positions
   */
  findSinglePattern(targetNotes, targetValues, tuning, tuningValues, notesPerString, minStartFret = 1) {
    const foundNotes = [];
    
    if (targetValues.length === 0) return foundNotes;
    
    // Step 1: Find the first note using grid-based search
    const firstTargetValue = targetValues[0];
    let firstNoteFound = false;
    let currentStringIndex = 0;
    let currentFret = minStartFret;
    
    // Search for first note in grids, starting from minStartFret
    for (let gridStart = minStartFret; gridStart &lt;= this.maxFret &amp;&amp; !firstNoteFound; gridStart += this.maxInterval) {
      const gridEnd = Math.min(gridStart + this.maxInterval - 1, this.maxFret);
      
      // Search all strings in this grid before moving to next grid
      for (let stringIndex = 0; stringIndex &lt; tuning.length &amp;&amp; !firstNoteFound; stringIndex++) {
        const openStringValue = tuningValues[stringIndex];
        
        for (let fret = Math.max(gridStart, minStartFret); fret &lt;= gridEnd; fret++) {
          const fretValue = openStringValue + fret;
          
          if (fretValue === firstTargetValue) {
            foundNotes.push([stringIndex, fret]);
            currentStringIndex = stringIndex;
            currentFret = fret;
            firstNoteFound = true;
            break;
          }
        }
      }
    }
    
    if (!firstNoteFound) return foundNotes;
    
    // Step 2: Continue finding remaining notes using sequential string approach
    let targetIndex = 1;
    let notesOnCurrentString = 1;
    
    while (targetIndex &lt; targetValues.length &amp;&amp; currentStringIndex &lt; tuning.length) {
      const targetValue = targetValues[targetIndex];
      const openStringValue = tuningValues[currentStringIndex];
      let noteFound = false;
      
      // Look for next note on current string (up to reasonable fret limit)
      if (notesOnCurrentString &lt; notesPerString) {
        for (let fret = currentFret + 1; fret &lt;= this.maxFret; fret++) {
          const fretValue = openStringValue + fret;
          
          if (fretValue === targetValue) {
            foundNotes.push([currentStringIndex, fret]);
            currentFret = fret;
            notesOnCurrentString++;
            targetIndex++;
            noteFound = true;
            break;
          }
        }
      }
      
      // If note not found on current string or string is full, move to next string
      if (!noteFound || notesOnCurrentString &gt;= notesPerString) {
        currentStringIndex++;
        notesOnCurrentString = 0;
        // Reset current fret to allow finding notes at lower positions on new string
        currentFret = Math.max(0, currentFret - 6);
        
        // Search for current target on new string
        if (currentStringIndex &lt; tuning.length) {
          const newOpenStringValue = tuningValues[currentStringIndex];
          const currentTargetValue = targetValues[targetIndex];
          const startFret = Math.max(1, currentFret - 3);
          
          for (let fret = startFret; fret &lt;= this.maxFret; fret++) {
            const fretValue = newOpenStringValue + fret;
            
            if (fretValue === currentTargetValue) {
              foundNotes.push([currentStringIndex, fret]);
              currentFret = fret;
              notesOnCurrentString = 1;
              targetIndex++;
              noteFound = true;
              break;
            }
          }
        }
        
        // If still not found, skip this target
        if (!noteFound) {
          targetIndex++;
        }
      }
    }
    
    return foundNotes;
  }

  /**
   * Calculate optimal fret range for visualization
   * @param {Array[]} notePositions - Array of [stringIndex, fret] positions
   * @returns {number[]} [minFret, maxFret] range for display
   */
  calculateFretRange(notePositions) {
    if (notePositions.length === 0) {
      return [0, 4]; // Default range when no notes
    }

    const frets = notePositions.map(([, fret]) =&gt; fret);
    const minFret = Math.max(0, Math.min(...frets) - this.FRET_PADDING_BELOW);
    const maxFret = Math.max(...frets) + this.FRET_PADDING_ABOVE;
    
    return [minFret, maxFret];
  }

  /**
   * Validate tuning preset
   * @param {string} tuningName - Name of tuning preset
   * @returns {boolean} True if valid tuning
   */
  static isValidTuning(tuningName) {
    return tuningName in FretboardAlgorithm.TUNING_PRESETS;
  }

  /**
   * Get tuning by name
   * @param {string} tuningName - Name of tuning preset
   * @returns {string[]|null} Array of note strings or null if not found
   */
  static getTuning(tuningName) {
    return FretboardAlgorithm.TUNING_PRESETS[tuningName] || null;
  }
}



// === core/scale-visualizer.js ===
/**
 * Scale Visualizer - Core orchestration for scale generation and visualization
 * Coordinates between musical theory, scale patterns, and fretboard algorithm
 */

class ScaleVisualizer {
  constructor(musicalTheory, scalePatterns, fretboardAlgorithm) {
    this.musicalTheory = musicalTheory;
    this.scalePatterns = scalePatterns;
    this.fretboardAlgorithm = fretboardAlgorithm;
  }

  /**
   * Generate complete visualization data for a scale configuration
   * @param {Object} config - Scale configuration
   * @param {string} config.rootNote - Root note (e.g., &apos;C&apos;, &apos;F#&apos;)
   * @param {string} config.scaleType - Scale type key or &apos;custom&apos;
   * @param {string} config.customIntervals - Comma-separated intervals for custom scales
   * @param {string} config.tuningName - Tuning preset name
   * @param {number} config.notesPerString - Notes per string constraint
   * @param {number} config.selectedScaleDegree - Starting scale degree (1-based)
   * @returns {Object} Visualization data
   */
  generateVisualizationData(config) {
    const {
      rootNote,
      scaleType,
      customIntervals,
      tuningName,
      notesPerString,
      selectedScaleDegree
    } = config;

    // Get scale intervals
    const intervals = this.getScaleIntervals(scaleType, customIntervals);
    
    // Get tuning
    const tuning = this.fretboardAlgorithm.constructor.getTuning(tuningName);
    if (!tuning) {
      throw new Error(`Invalid tuning: ${tuningName}`);
    }

    // Apply octave optimization for root note based on tuning range
    const optimizedRootNote = this.getOptimalRootNote(rootNote, tuning);
    
    // Generate scale notes
    const scaleNotes = this.musicalTheory.generateExtendedScale(
      optimizedRootNote,
      intervals.join(&apos;,&apos;),
      notesPerString,
      selectedScaleDegree
    );
    
    // Find note positions on fretboard
    const notePositions = this.fretboardAlgorithm.findNotes(
      scaleNotes,
      tuning,
      notesPerString,
      this.musicalTheory
    );
    
    // Calculate fret range for visualization
    const fretRange = this.fretboardAlgorithm.calculateFretRange(notePositions);
    
    // Generate metadata
    const metadata = this.generateMetadata(config, intervals, tuning, scaleNotes);
    
    return {
      notePositions,
      scaleNotes,
      fretRange,
      tuning,
      intervals,
      scaleLength: intervals.length,
      metadata
    };
  }

  /**
   * Get scale intervals from type or custom input
   * @param {string} scaleType - Scale type key
   * @param {string} customIntervals - Custom intervals string
   * @returns {number[]} Array of interval numbers
   */
  getScaleIntervals(scaleType, customIntervals) {
    // Handle custom scales and custom preset IDs
    if (scaleType === &apos;custom&apos; || scaleType.startsWith(&apos;custom-&apos;)) {
      return this.musicalTheory.parseIntervals(customIntervals);
    }
    
    const pattern = this.scalePatterns.scaleIntervalPatterns[scaleType];
    if (!pattern) {
      throw new Error(`Unknown scale type: ${scaleType}`);
    }
    
    return pattern;
  }

  /**
   * Apply octave optimization to root note
   * @param {string} rootNote - Base root note (e.g., &apos;C&apos;, &apos;F#&apos;)
   * @returns {string} Octave-optimized root note (e.g., &apos;C3&apos;, &apos;F#2&apos;)
   */
  getOptimalRootNote(rootNote, tuning) {
    const lowestOpenSemitone = this.musicalTheory.parseNote(tuning[0]);
    const noteValue = this.musicalTheory.noteValues[rootNote.replace(/[#b]/, &apos;&apos;)] +
      (rootNote.includes(&apos;#&apos;) ? 1 : rootNote.includes(&apos;b&apos;) ? -1 : 0);
    const lowestOctave = Math.floor(lowestOpenSemitone / 12);
    const candidate = noteValue + lowestOctave * 12;
    const octave = candidate &lt; lowestOpenSemitone ? lowestOctave + 1 : lowestOctave;
    return rootNote + octave;
  }

  /**
   * Calculate scale degree for a position in the note sequence
   * @param {number} index - Position index in the note sequence
   * @param {number} scaleLength - Length of the scale
   * @param {number} selectedScaleDegree - Starting scale degree
   * @returns {number} Scale degree (1-based)
   */
  calculateScaleDegreeForPosition(index, scaleLength, selectedScaleDegree) {
    const rotatedDegree = (index % scaleLength) + 1;
    return ((rotatedDegree - 1 + selectedScaleDegree - 1) % scaleLength) + 1;
  }

  /**
   * Generate metadata for the visualization
   * @param {Object} config - Original configuration
   * @param {number[]} intervals - Scale intervals
   * @param {string[]} tuning - Tuning notes
   * @param {string[]} scaleNotes - Generated scale notes
   * @returns {Object} Metadata object
   */
  generateMetadata(config, intervals, tuning, scaleNotes) {
    const { rootNote, scaleType, notesPerString, selectedScaleDegree } = config;
    
    // Detect scale type from intervals if custom
    const detectedScaleType = (scaleType === &apos;custom&apos; || scaleType.startsWith(&apos;custom-&apos;))
      ? this.scalePatterns.findScaleTypeFromIntervals(intervals) || &apos;custom&apos;
      : scaleType;
    
    // Generate tuning description
    const tuningDescription = this.generateTuningDescription(tuning);
    
    return {
      rootNote,
      scaleType: detectedScaleType,
      intervals,
      tuning: tuningDescription,
      notesPerString,
      selectedScaleDegree,
      scaleNotes: scaleNotes.slice(0, intervals.length), // First iteration only
      totalNotesGenerated: scaleNotes.length
    };
  }

  /**
   * Generate human-readable tuning description
   * @param {string[]} tuning - Array of tuning notes
   * @returns {string} Tuning description
   */
  generateTuningDescription(tuning) {
    const stringCount = tuning.length;
    const noteNames = tuning.map(note =&gt; this.musicalTheory.getNoteName(note));
    
    if (stringCount === 12) return &apos;12-String Perfect 4ths&apos;;
    if (stringCount === 6) return &apos;6-String Guitar&apos;;
    if (stringCount === 5) return &apos;5-String Bass&apos;;
    if (stringCount === 4) return &apos;4-String Bass&apos;;
    
    return `${stringCount}-String (${noteNames.join(&apos;-&apos;)})`;
  }

  /**
   * Validate configuration object
   * @param {Object} config - Configuration to validate
   * @throws {Error} If configuration is invalid
   */
  validateConfiguration(config) {
    const required = [&apos;rootNote&apos;, &apos;scaleType&apos;, &apos;tuningName&apos;, &apos;notesPerString&apos;, &apos;selectedScaleDegree&apos;];
    
    for (const field of required) {
      if (config[field] === undefined || config[field] === null) {
        throw new Error(`Missing required field: ${field}`);
      }
    }
    
    if ((config.scaleType === &apos;custom&apos; || config.scaleType.startsWith(&apos;custom-&apos;)) &amp;&amp; !config.customIntervals) {
      throw new Error(&apos;Custom intervals required when scaleType is &quot;custom&quot;&apos;);
    }
    
    if (config.notesPerString &lt; 1 || config.notesPerString &gt; 12) {
      throw new Error(&apos;Notes per string must be between 1 and 12&apos;);
    }
    
    if (config.selectedScaleDegree &lt; 1) {
      throw new Error(&apos;Selected scale degree must be &gt;= 1&apos;);
    }
    
    // Validate tuning exists
    if (!this.fretboardAlgorithm.constructor.isValidTuning(config.tuningName)) {
      throw new Error(`Invalid tuning: ${config.tuningName}`);
    }
  }
}



// === core/preset-manager.js ===
/**
 * Preset Manager - Handle all preset and preference storage operations
 * Manages localStorage operations for scale preferences and custom presets
 */

class PresetManager {
  constructor() {
    // Storage keys
    this.SCALE_PREFERENCES_KEY = &apos;guitar-scale-visualizer-scale-preferences&apos;;
    this.GLOBAL_PREFERENCES_KEY = &apos;guitar-scale-visualizer-global-preferences&apos;;
    this.CUSTOM_PRESETS_KEY = &apos;guitar-scale-visualizer-custom-presets&apos;;
  }

  /**
   * Save preferences for a specific scale type
   * @param {string} scaleType - Scale type identifier
   * @param {Object} preferences - Preference object
   * @param {string} preferences.title - Scale title
   * @param {number} preferences.notesPerString - Notes per string setting
   * @param {number} preferences.selectedScaleDegree - Selected scale degree
   * @param {string} preferences.rootNote - Root note
   */
  saveScalePreferences(scaleType, preferences) {
    try {
      const allPreferences = this.getScalePreferences();
      allPreferences[scaleType] = {
        title: preferences.title,
        notesPerString: preferences.notesPerString,
        selectedScaleDegree: preferences.selectedScaleDegree,
        rootNote: preferences.rootNote
      };
      
      localStorage.setItem(this.SCALE_PREFERENCES_KEY, JSON.stringify(allPreferences));
    } catch (error) {
      console.warn(&apos;Failed to save scale preferences:&apos;, error);
    }
  }

  /**
   * Load preferences for a specific scale type
   * @param {string} scaleType - Scale type identifier
   * @returns {Object|null} Preference object or null if not found
   */
  loadScalePreferences(scaleType) {
    const allPreferences = this.getScalePreferences();
    return allPreferences[scaleType] || null;
  }

  /**
   * Get all scale preferences
   * @returns {Object} All scale preferences object
   */
  getScalePreferences() {
    try {
      const stored = localStorage.getItem(this.SCALE_PREFERENCES_KEY);
      return stored ? JSON.parse(stored) : {};
    } catch (error) {
      console.warn(&apos;Failed to load scale preferences:&apos;, error);
      return {};
    }
  }

  /**
   * Save global preferences (tuning, last scale, etc.)
   * @param {Object} preferences - Global preference object
   * @param {string} preferences.tuning - Selected tuning
   * @param {string} preferences.lastScaleType - Last selected scale type
   */
  saveGlobalPreferences(preferences) {
    try {
      const current = this.getGlobalPreferences();
      const updated = { ...current, ...preferences };
      localStorage.setItem(this.GLOBAL_PREFERENCES_KEY, JSON.stringify(updated));
    } catch (error) {
      console.warn(&apos;Failed to save global preferences:&apos;, error);
    }
  }

  /**
   * Load global preferences
   * @returns {Object} Global preferences object
   */
  getGlobalPreferences() {
    try {
      const stored = localStorage.getItem(this.GLOBAL_PREFERENCES_KEY);
      return stored ? JSON.parse(stored) : {};
    } catch (error) {
      console.warn(&apos;Failed to load global preferences:&apos;, error);
      return {};
    }
  }

  /**
   * Save a custom preset
   * @param {string} presetName - Unique preset name
   * @param {Object} preset - Preset data
   * @param {string} preset.title - Display title
   * @param {number[]} preset.intervals - Scale intervals
   * @param {number} preset.notesPerString - Notes per string
   * @param {number} preset.selectedScaleDegree - Selected scale degree
   * @param {string} preset.rootNote - Root note
   */
  saveCustomPreset(presetName, preset) {
    try {
      const customPresets = this.getCustomPresets();
      customPresets[presetName] = {
        title: preset.title,
        intervals: preset.intervals,
        notesPerString: preset.notesPerString,
        selectedScaleDegree: preset.selectedScaleDegree,
        rootNote: preset.rootNote,
        isCustom: true,
        createdAt: new Date().toISOString()
      };
      
      localStorage.setItem(this.CUSTOM_PRESETS_KEY, JSON.stringify(customPresets));
    } catch (error) {
      console.warn(&apos;Failed to save custom preset:&apos;, error);
      throw new Error(&apos;Failed to save preset&apos;);
    }
  }

  /**
   * Load a custom preset
   * @param {string} presetName - Preset name
   * @returns {Object|null} Preset data or null if not found
   */
  loadCustomPreset(presetName) {
    const customPresets = this.getCustomPresets();
    return customPresets[presetName] || null;
  }

  /**
   * Get all custom presets
   * @returns {Object} All custom presets object
   */
  getCustomPresets() {
    try {
      const stored = localStorage.getItem(this.CUSTOM_PRESETS_KEY);
      return stored ? JSON.parse(stored) : {};
    } catch (error) {
      console.warn(&apos;Failed to load custom presets:&apos;, error);
      return {};
    }
  }

  /**
   * Delete a custom preset
   * @param {string} presetName - Preset name to delete
   * @returns {boolean} True if deleted successfully
   */
  deleteCustomPreset(presetName) {
    try {
      const customPresets = this.getCustomPresets();
      if (customPresets[presetName]) {
        delete customPresets[presetName];
        localStorage.setItem(this.CUSTOM_PRESETS_KEY, JSON.stringify(customPresets));
        return true;
      }
      return false;
    } catch (error) {
      console.warn(&apos;Failed to delete custom preset:&apos;, error);
      return false;
    }
  }

  /**
   * Check if a preset name is a custom preset
   * @param {string} presetName - Preset name to check
   * @returns {boolean} True if it&apos;s a custom preset
   */
  isCustomPreset(presetName) {
    const customPresets = this.getCustomPresets();
    return presetName in customPresets;
  }

  /**
   * Get all preset names (built-in + custom)
   * @param {Object} builtInScalePatterns - Built-in scale patterns object
   * @returns {string[]} Array of all preset names
   */
  getAllPresetNames(builtInScalePatterns) {
    const builtInNames = Object.keys(builtInScalePatterns);
    const customNames = Object.keys(this.getCustomPresets());
    return [...builtInNames, ...customNames];
  }

  /**
   * Export all presets and preferences to JSON
   * @returns {Object} Complete export data
   */
  exportAllData() {
    return {
      scalePreferences: this.getScalePreferences(),
      globalPreferences: this.getGlobalPreferences(),
      customPresets: this.getCustomPresets(),
      exportedAt: new Date().toISOString(),
      version: &apos;1.0&apos;
    };
  }

  /**
   * Import presets and preferences from JSON data
   * @param {Object} data - Import data object
   * @param {Object} options - Import options
   * @param {boolean} options.overwrite - Whether to overwrite existing data
   * @returns {Object} Import result summary
   */
  importAllData(data, options = { overwrite: false }) {
    const result = {
      scalePreferences: 0,
      customPresets: 0,
      globalPreferences: 0,
      errors: []
    };

    try {
      // Validate import data structure
      if (!data || typeof data !== &apos;object&apos;) {
        throw new Error(&apos;Invalid import data format&apos;);
      }

      // Import scale preferences
      if (data.scalePreferences) {
        if (options.overwrite) {
          localStorage.setItem(this.SCALE_PREFERENCES_KEY, JSON.stringify(data.scalePreferences));
        } else {
          const current = this.getScalePreferences();
          const merged = { ...current, ...data.scalePreferences };
          localStorage.setItem(this.SCALE_PREFERENCES_KEY, JSON.stringify(merged));
        }
        result.scalePreferences = Object.keys(data.scalePreferences).length;
      }

      // Import custom presets
      if (data.customPresets) {
        if (options.overwrite) {
          localStorage.setItem(this.CUSTOM_PRESETS_KEY, JSON.stringify(data.customPresets));
        } else {
          const current = this.getCustomPresets();
          const merged = { ...current, ...data.customPresets };
          localStorage.setItem(this.CUSTOM_PRESETS_KEY, JSON.stringify(merged));
        }
        result.customPresets = Object.keys(data.customPresets).length;
      }

      // Import global preferences
      if (data.globalPreferences) {
        if (options.overwrite) {
          localStorage.setItem(this.GLOBAL_PREFERENCES_KEY, JSON.stringify(data.globalPreferences));
        } else {
          const current = this.getGlobalPreferences();
          const merged = { ...current, ...data.globalPreferences };
          localStorage.setItem(this.GLOBAL_PREFERENCES_KEY, JSON.stringify(merged));
        }
        result.globalPreferences = Object.keys(data.globalPreferences).length;
      }

    } catch (error) {
      result.errors.push(error.message);
    }

    return result;
  }

  /**
   * Clear all stored data (useful for testing or reset)
   * @param {Object} options - Clear options
   * @param {boolean} options.scalePreferences - Clear scale preferences
   * @param {boolean} options.globalPreferences - Clear global preferences  
   * @param {boolean} options.customPresets - Clear custom presets
   */
  clearAllData(options = { scalePreferences: true, globalPreferences: true, customPresets: true }) {
    try {
      if (options.scalePreferences) {
        localStorage.removeItem(this.SCALE_PREFERENCES_KEY);
      }
      if (options.globalPreferences) {
        localStorage.removeItem(this.GLOBAL_PREFERENCES_KEY);
      }
      if (options.customPresets) {
        localStorage.removeItem(this.CUSTOM_PRESETS_KEY);
      }
    } catch (error) {
      console.warn(&apos;Failed to clear data:&apos;, error);
    }
  }

  /**
   * Validate preset data structure
   * @param {Object} preset - Preset to validate
   * @returns {boolean} True if valid
   */
  validatePreset(preset) {
    if (!preset || typeof preset !== &apos;object&apos;) return false;
    
    const required = [&apos;title&apos;, &apos;intervals&apos;, &apos;notesPerString&apos;, &apos;selectedScaleDegree&apos;, &apos;rootNote&apos;];
    return required.every(field =&gt; Object.prototype.hasOwnProperty.call(preset, field));
  }
}



// === core/ui-controller.js ===
/**
 * UI Controller - Manages UI coordination, event handling, and form state
 * Separates UI logic from rendering concerns in the widget
 */

class UIController {
  constructor(widget, presetManager, scaleVisualizer, musicalTheory, scalePatterns) {
    this.widget = widget;
    this.presetManager = presetManager;
    this.scaleVisualizer = scaleVisualizer;
    this.musicalTheory = musicalTheory;
    this.scalePatterns = scalePatterns;
    
    // Store event handler references for cleanup
    this.eventHandlers = new Map();
    
    // UI state
    this.isInitialized = false;
  }

  /**
   * Initialize the UI controller and set up event listeners
   */
  initialize() {
    if (this.isInitialized) return;
    
    this.setupEventListeners();
    this.loadGlobalPreferences();
    this.updateScaleDropdown();
    this.loadScalePreferences(this.widget.scaleTypeSelect.value);
    this.updatePresetButtonVisibility();
    this.updateNPSConstraints();
    
    this.isInitialized = true;
  }

  /**
   * Clean up event listeners and resources
   */
  cleanup() {
    // Remove all event listeners
    for (const [element, handlers] of this.eventHandlers) {
      for (const [event, handler] of handlers) {
        element.removeEventListener(event, handler);
      }
    }
    this.eventHandlers.clear();
    this.isInitialized = false;
  }

  /**
   * Set up all event listeners
   */
  setupEventListeners() {
    // Create and store event handlers
    const handlers = {
      tuningChange: () =&gt; {
        this.widget.updateVisualization();
        this.saveGlobalPreferences();
      },
      rootNoteChange: () =&gt; {
        this.widget.updateVisualization();
        this.saveScalePreferences();
      },
      scaleTypeChange: () =&gt; {
        this.loadScalePreferences(this.widget.scaleTypeSelect.value);
        this.updatePresetButtonVisibility();
        this.widget.updateVisualization();
      },
      scaleIntervalsChange: () =&gt; {
        this.updateScaleTypeFromIntervals();
        this.updateNPSConstraints();
        this.widget.updateVisualization();
        this.saveScalePreferences();
      },
      notesPerStringChange: () =&gt; {
        document.getElementById(&apos;nps-value&apos;).textContent = this.widget.notesPerStringInput.value;
        this.widget.updateVisualization();
        this.saveScalePreferences();
      },
      selectedScaleDegreeChange: () =&gt; {
        const newDegree = parseInt(this.widget.selectedScaleDegreeInput.value);
        if (newDegree &gt;= 1 &amp;&amp; newDegree &lt;= this.musicalTheory.parseIntervals(this.widget.scaleIntervalsInput.value).length) {
          this.widget.selectedScaleDegree = newDegree;
          this.widget.updateVisualization();
          this.saveScalePreferences();
        }
      },
      scaleTitleChange: () =&gt; {
        this.saveScalePreferences();
      },
      saveSvgClick: () =&gt; this.widget.saveSvgVisualization(),
      exportClick: () =&gt; this.widget.exportCurrentPattern(),
      savePresetClick: () =&gt; this.promptSaveCustomPreset(),
      updatePresetClick: () =&gt; this.updateCurrentPreset(),
      deletePresetClick: () =&gt; this.deleteCurrentPreset(),
      importFileChange: (e) =&gt; this.handleImportFile(e)
    };

    // Add event listeners and store references
    this.addEventHandler(this.widget.tuningPresetSelect, &apos;change&apos;, handlers.tuningChange);
    this.addEventHandler(this.widget.rootNoteSelect, &apos;change&apos;, handlers.rootNoteChange);
    this.addEventHandler(this.widget.scaleTypeSelect, &apos;change&apos;, handlers.scaleTypeChange);
    this.addEventHandler(this.widget.scaleIntervalsInput, &apos;input&apos;, handlers.scaleIntervalsChange);
    this.addEventHandler(this.widget.notesPerStringInput, &apos;input&apos;, handlers.notesPerStringChange);
    this.addEventHandler(this.widget.selectedScaleDegreeInput, &apos;input&apos;, handlers.selectedScaleDegreeChange);
    this.addEventHandler(this.widget.scaleTitleInput, &apos;input&apos;, handlers.scaleTitleChange);
    this.addEventHandler(this.widget.saveSvgButton, &apos;click&apos;, handlers.saveSvgClick);
    this.addEventHandler(this.widget.exportButton, &apos;click&apos;, handlers.exportClick);
    this.addEventHandler(this.widget.savePresetButton, &apos;click&apos;, handlers.savePresetClick);
    this.addEventHandler(this.widget.updatePresetButton, &apos;click&apos;, handlers.updatePresetClick);
    this.addEventHandler(this.widget.deletePresetButton, &apos;click&apos;, handlers.deletePresetClick);
    this.addEventHandler(this.widget.importFile, &apos;change&apos;, handlers.importFileChange);
  }

  /**
   * Helper method to add event listener and store reference for cleanup
   */
  addEventHandler(element, event, handler) {
    if (!this.eventHandlers.has(element)) {
      this.eventHandlers.set(element, new Map());
    }
    this.eventHandlers.get(element).set(event, handler);
    element.addEventListener(event, handler);
  }

  /**
   * Update scale type based on current intervals
   */
  updateScaleTypeFromIntervals() {
    const inputArray = this.musicalTheory.parseIntervals(this.widget.scaleIntervalsInput.value);
    const matchingScale = this.scalePatterns.findScaleTypeFromIntervals(inputArray);
    this.widget.scaleTypeSelect.value = matchingScale || &apos;custom&apos;;
  }

  /**
   * Update notes per string constraints based on current scale
   */
  updateNPSConstraints() {
    const scaleLength = this.musicalTheory.parseIntervals(this.widget.scaleIntervalsInput.value).length;
    
    // Handle case where scale has no valid notes (empty or invalid intervals)
    if (scaleLength === 0) {
      this.widget.notesPerStringInput.max = 1;
      this.widget.notesPerStringInput.value = 1;
      document.getElementById(&apos;nps-value&apos;).textContent = 1;
      this.widget.selectedScaleDegreeInput.max = 1;
      this.widget.selectedScaleDegree = 1;
      this.widget.selectedScaleDegreeInput.value = 1;
      return;
    }
    
    this.widget.notesPerStringInput.max = scaleLength;
    const currentNPS = parseInt(this.widget.notesPerStringInput.value);
    if (currentNPS &gt; scaleLength) {
      this.widget.notesPerStringInput.value = scaleLength;
      document.getElementById(&apos;nps-value&apos;).textContent = scaleLength;
    }
    
    this.widget.selectedScaleDegreeInput.max = scaleLength;
    if (this.widget.selectedScaleDegree &gt; scaleLength) {
      this.widget.selectedScaleDegree = 1;
      this.widget.selectedScaleDegreeInput.value = 1;
    }
  }

  /**
   * Handle note click from the visualization
   */
  onNoteClick(clickedScaleDegree) {
    this.widget.selectedScaleDegree = clickedScaleDegree;
    this.widget.selectedScaleDegreeInput.value = clickedScaleDegree;
    this.widget.updateVisualization();
  }

  /**
   * Save preferences for the current scale type
   */
  saveScalePreferences() {
    const scaleType = this.widget.scaleTypeSelect.value;
    const preferences = {
      title: this.widget.scaleTitleInput.value,
      notesPerString: parseInt(this.widget.notesPerStringInput.value),
      selectedScaleDegree: this.widget.selectedScaleDegree,
      rootNote: this.widget.rootNoteSelect.value
    };
    
    this.presetManager.saveScalePreferences(scaleType, preferences);
  }

  /**
   * Load preferences for a specific scale type
   */
  loadScalePreferences(scaleType) {
    // Check if it&apos;s a custom preset first
    const customPreset = this.presetManager.loadCustomPreset(scaleType);
    if (customPreset) {
      this.widget.scaleIntervalsInput.value = customPreset.intervals.join(&apos;,&apos;);
      this.widget.scaleTitleInput.value = customPreset.title;
      this.widget.notesPerStringInput.value = customPreset.notesPerString;
      document.getElementById(&apos;nps-value&apos;).textContent = customPreset.notesPerString;
      this.widget.selectedScaleDegree = customPreset.selectedScaleDegree;
      this.widget.selectedScaleDegreeInput.value = customPreset.selectedScaleDegree;
      this.widget.rootNoteSelect.value = customPreset.rootNote;
      this.updateNPSConstraints();
      return;
    }
    
    // Handle built-in scales
    const scalePrefs = this.presetManager.loadScalePreferences(scaleType) || this.widget.defaultScalePreferences[scaleType];
    
    if (scalePrefs) {
      // Load intervals from built-in pattern
      const intervals = this.widget.scaleIntervalPatterns[scaleType];
      if (intervals) {
        this.widget.scaleIntervalsInput.value = intervals.join(&apos;,&apos;);
      }
      
      // Load scale-specific preferences
      this.widget.scaleTitleInput.value = scalePrefs.title;
      this.widget.notesPerStringInput.value = scalePrefs.notesPerString;
      document.getElementById(&apos;nps-value&apos;).textContent = scalePrefs.notesPerString;
      this.widget.selectedScaleDegree = scalePrefs.selectedScaleDegree;
      this.widget.selectedScaleDegreeInput.value = scalePrefs.selectedScaleDegree;
      this.widget.rootNoteSelect.value = scalePrefs.rootNote;
      
      this.updateNPSConstraints();
    }
  }

  /**
   * Save global preferences (tuning, last scale type)
   */
  saveGlobalPreferences() {
    const globalPrefs = {
      tuning: this.widget.tuningPresetSelect.value,
      lastScaleType: this.widget.scaleTypeSelect.value
    };
    
    this.presetManager.saveGlobalPreferences(globalPrefs);
  }

  /**
   * Load global preferences
   */
  loadGlobalPreferences() {
    const globalPrefs = this.presetManager.getGlobalPreferences();
    if (globalPrefs.tuning) this.widget.tuningPresetSelect.value = globalPrefs.tuning;
    if (globalPrefs.lastScaleType) this.widget.scaleTypeSelect.value = globalPrefs.lastScaleType;
  }

  /**
   * Handle file import
   */
  handleImportFile(event) {
    const file = event.target.files[0];
    if (!file) return;
    
    const reader = new FileReader();
    reader.onload = (e) =&gt; {
      try {
        const pattern = JSON.parse(e.target.result);
        this.importPattern(pattern);
      } catch (error) {
        alert(&apos;Error reading file: Invalid JSON format&apos;);
        console.error(&apos;Import error:&apos;, error);
      }
    };
    reader.readAsText(file);
    
    // Reset file input
    event.target.value = &apos;&apos;;
  }

  /**
   * Import a pattern from JSON data
   */
  importPattern(pattern) {
    try {
      // Validate required fields
      if (!pattern.intervals || !Array.isArray(pattern.intervals)) {
        throw new Error(&apos;Invalid pattern: missing or invalid intervals&apos;);
      }
      
      // Apply pattern to UI
      if (pattern.rootNote) this.widget.rootNoteSelect.value = pattern.rootNote;
      if (pattern.tuning &amp;&amp; this.widget.tuningPresets[pattern.tuning]) {
        this.widget.tuningPresetSelect.value = pattern.tuning;
      }
      if (pattern.notesPerString) {
        this.widget.notesPerStringInput.value = pattern.notesPerString;
        document.getElementById(&apos;nps-value&apos;).textContent = pattern.notesPerString;
      }
      if (pattern.selectedScaleDegree) {
        this.widget.selectedScaleDegree = pattern.selectedScaleDegree;
        this.widget.selectedScaleDegreeInput.value = pattern.selectedScaleDegree;
      }
      
      // Set intervals and update scale type
      this.widget.scaleIntervalsInput.value = pattern.intervals.join(&apos;,&apos;);
      this.updateScaleTypeFromIntervals();
      
      // Set scale title if provided
      if (pattern.name) {
        this.widget.scaleTitleInput.value = pattern.name;
      }
      
      // Save as custom preset to make it persistent
      const presetName = pattern.name || &apos;Imported Pattern&apos;;
      this.saveCustomPreset(presetName, pattern.intervals);
      
      // Update constraints and visualization
      this.updateNPSConstraints();
      this.widget.updateVisualization();
      this.saveScalePreferences();
      this.saveGlobalPreferences();
      
    } catch (error) {
      alert(`Error importing pattern: ${error.message}`);
      console.error(&apos;Import pattern error:&apos;, error);
    }
  }

  /**
   * Save a custom preset
   */
  saveCustomPreset(name, intervals) {
    const presetId = `custom-${Date.now()}`;
    
    const preset = {
      title: name,
      intervals: intervals || this.musicalTheory.parseIntervals(this.widget.scaleIntervalsInput.value),
      notesPerString: parseInt(this.widget.notesPerStringInput.value),
      selectedScaleDegree: this.widget.selectedScaleDegree,
      rootNote: this.widget.rootNoteSelect.value
    };
    
    try {
      this.presetManager.saveCustomPreset(presetId, preset);
      this.updateScaleDropdown();
      this.widget.scaleTypeSelect.value = presetId; // Select the newly created preset
      this.updatePresetButtonVisibility(); // Update button visibility for the new preset
      return presetId;
    } catch (e) {
      alert(&apos;Failed to save preset. Please try again.&apos;);
      return null;
    }
  }

  /**
   * Prompt user to save current settings as a custom preset
   */
  promptSaveCustomPreset() {
    const currentTitle = this.widget.scaleTitleInput.value || &apos;Custom Scale&apos;;
    const presetName = prompt(&apos;Save current pattern as preset:&apos;, currentTitle);
    
    if (presetName &amp;&amp; presetName.trim()) {
      this.saveCustomPreset(presetName.trim());
    }
  }

  /**
   * Update the current custom preset
   */
  updateCurrentPreset() {
    const scaleType = this.widget.scaleTypeSelect.value;
    
    if (this.presetManager.isCustomPreset(scaleType)) {
      const currentPreset = this.presetManager.loadCustomPreset(scaleType);
      const currentTitle = this.widget.scaleTitleInput.value || currentPreset.title;
      
      const updatedPreset = {
        title: currentTitle,
        intervals: this.musicalTheory.parseIntervals(this.widget.scaleIntervalsInput.value),
        notesPerString: parseInt(this.widget.notesPerStringInput.value),
        selectedScaleDegree: this.widget.selectedScaleDegree,
        rootNote: this.widget.rootNoteSelect.value
      };
      
      try {
        this.presetManager.saveCustomPreset(scaleType, updatedPreset);
        this.updateScaleDropdown();
        this.widget.scaleTypeSelect.value = scaleType; // Keep current preset selected
      } catch (e) {
        alert(&apos;Failed to update preset. Please try again.&apos;);
      }
    }
  }

  /**
   * Delete the current custom preset
   */
  deleteCurrentPreset() {
    const scaleType = this.widget.scaleTypeSelect.value;
    
    if (this.presetManager.isCustomPreset(scaleType)) {
      const preset = this.presetManager.loadCustomPreset(scaleType);
      const presetTitle = preset.title;
      
      if (confirm(`Are you sure you want to delete the preset &quot;${presetTitle}&quot;? This action cannot be undone.`)) {
        if (this.presetManager.deleteCustomPreset(scaleType)) {
          this.updateScaleDropdown();
          this.widget.scaleTypeSelect.value = &apos;major&apos;; // Switch to default preset
          this.loadScalePreferences(&apos;major&apos;);
          this.updatePresetButtonVisibility();
          this.widget.updateVisualization();
        } else {
          alert(&apos;Failed to delete preset. Please try again.&apos;);
        }
      }
    }
  }

  /**
   * Update visibility of preset management buttons
   */
  updatePresetButtonVisibility() {
    const scaleType = this.widget.scaleTypeSelect.value;
    const isCustomPreset = this.presetManager.isCustomPreset(scaleType);
    
    this.widget.updatePresetButton.style.display = isCustomPreset ? &apos;block&apos; : &apos;none&apos;;
    this.widget.deletePresetButton.style.display = isCustomPreset ? &apos;block&apos; : &apos;none&apos;;
  }

  /**
   * Update the scale dropdown with built-in and custom presets
   */
  updateScaleDropdown() {
    const currentValue = this.widget.scaleTypeSelect.value;
    
    // Clear existing options
    this.widget.scaleTypeSelect.innerHTML = &apos;&apos;;
    
    // Add built-in scales from existing scale definitions
    Object.keys(this.widget.defaultScalePreferences).forEach(scaleKey =&gt; {
      const option = document.createElement(&apos;option&apos;);
      option.value = scaleKey;
      option.textContent = this.widget.defaultScalePreferences[scaleKey].title.replace(&apos; Scale&apos;, &apos;&apos;).replace(&apos; Mode&apos;, &apos;&apos;);
      this.widget.scaleTypeSelect.appendChild(option);
    });
    
    // Add custom presets
    const customPresets = this.presetManager.getCustomPresets();
    const customPresetIds = Object.keys(customPresets);
    
    if (customPresetIds.length &gt; 0) {
      // Add separator
      const separator = document.createElement(&apos;option&apos;);
      separator.disabled = true;
      separator.textContent = &apos;────── Custom Presets ──────&apos;;
      this.widget.scaleTypeSelect.appendChild(separator);
      
      // Add custom presets
      customPresetIds.forEach(presetId =&gt; {
        const preset = customPresets[presetId];
        const option = document.createElement(&apos;option&apos;);
        option.value = presetId;
        option.textContent = `⭐ ${preset.title}`;
        this.widget.scaleTypeSelect.appendChild(option);
      });
    }
    
    // Restore previous selection if it still exists
    if (currentValue) {
      const optionExists = Array.from(this.widget.scaleTypeSelect.options).some(opt =&gt; opt.value === currentValue);
      if (optionExists) {
        this.widget.scaleTypeSelect.value = currentValue;
      } else {
        this.widget.scaleTypeSelect.value = &apos;major&apos;; // Default fallback
      }
    }
    
    // Update button visibility after dropdown rebuild
    this.updatePresetButtonVisibility();
  }
}



// === widget.js ===
class StringedInstrumentVisualizer {
  constructor() {
    // Get DOM elements with error checking
    const requiredElements = {
      svg: &apos;fretboard&apos;,
      tuningPresetSelect: &apos;tuning-preset&apos;,
      rootNoteSelect: &apos;root-note&apos;,
      scaleTypeSelect: &apos;scale-type&apos;,
      scaleIntervalsInput: &apos;scale-intervals&apos;,
      notesPerStringInput: &apos;notes-per-string&apos;,
      selectedScaleDegreeInput: &apos;selected-scale-degree&apos;,
      saveSvgButton: &apos;save-svg-button&apos;,
      exportButton: &apos;export-button&apos;,
      savePresetButton: &apos;save-preset-button&apos;,
      updatePresetButton: &apos;update-preset-button&apos;,
      deletePresetButton: &apos;delete-preset-button&apos;,
      importFile: &apos;import-file&apos;,
      scaleTitleInput: &apos;scale-title&apos;
    };

    // Initialize DOM elements with error checking
    for (const [property, elementId] of Object.entries(requiredElements)) {
      this[property] = document.getElementById(elementId);
      if (!this[property]) {
        throw new Error(`Required DOM element not found: ${elementId}`);
      }
    }
    
    // Initialize core modules
    this.musicalTheory = new (window.MusicalTheory || MusicalTheory)();
    this.scalePatterns = new (window.ScalePatterns || ScalePatterns)();
    this.fretboardAlgorithm = new (window.FretboardAlgorithm || FretboardAlgorithm)();
    
    // Initialize new core modules 
    // eslint-disable-next-line no-undef
    this.scaleVisualizer = new (window.ScaleVisualizer || ScaleVisualizer)(
      this.musicalTheory,
      this.scalePatterns,
      this.fretboardAlgorithm
    );
    // eslint-disable-next-line no-undef
    this.presetManager = new (window.PresetManager || PresetManager)();
    
    // Initialize UI Controller
    // eslint-disable-next-line no-undef
    this.uiController = new (window.UIController || UIController)(
      this,
      this.presetManager,
      this.scaleVisualizer,
      this.musicalTheory,
      this.scalePatterns
    );
    
    // Visualization settings
    this.fretSpacing = 60;
    this.stringSpacing = 40;
    this.margin = { top: 40, right: 20, bottom: 60, left: 80 };
    this.titleHeight = 60;
    this.noteCircleRadius = 18;
    
    this.selectedScaleDegree = 1;
    
    this.init();
  }

  // Getter for tuning presets (delegated to core)
  get tuningPresets() {
    return this.fretboardAlgorithm.constructor.TUNING_PRESETS;
  }

  // Getter for scale interval patterns (delegated to core)
  get scaleIntervalPatterns() {
    return this.scalePatterns.scaleIntervalPatterns;
  }

  // Getter for default scale preferences (delegated to core)
  get defaultScalePreferences() {
    return this.scalePatterns.defaultScalePreferences;
  }
  
  init() {
    // Initialize UI controller (handles all UI coordination)
    this.uiController.initialize();
    
    // Initial visualization
    this.updateVisualization();
  }
  
  destroy() {
    // Clean up UI controller
    this.uiController.cleanup();
    
    // Clear SVG content
    if (this.svg) this.svg.innerHTML = &apos;&apos;;
  }
  
  // Note click handler - called by UI controller
  onNoteClick(clickedScaleDegree) {
    this.uiController.onNoteClick(clickedScaleDegree);
  }

  generateTitleInfo() {
    const scaleTitle = this.scaleTitleInput.value || &apos;Scale&apos;;
    const rootNote = this.rootNoteSelect.value;
    const tuningText = this.tuningPresetSelect.options[this.tuningPresetSelect.selectedIndex].text;
    const nps = this.notesPerStringInput.value;
    const scaleDegree = this.selectedScaleDegree;
    
    return {
      titleText: `${rootNote} ${scaleTitle} Unified Pattern`,
      subtitleText: `${tuningText} • ${nps} Notes per String • Starting from Scale Degree ${scaleDegree}`,
      filename: `${rootNote}_${scaleTitle}_Unified_Pattern`.replace(/[^a-zA-Z0-9]/g, &apos;_&apos;),
      tuning: tuningText.replace(/\s+/g, &apos;_&apos;),
      npsFormatted: `${nps}NPS`,
      degree: `Deg${scaleDegree}`,
      timestamp: new Date().toISOString().slice(0, 10)
    };
  }

  
  estimateTextWidth(text, fontSize) {
    // Rough estimation: average character width is about 0.6 * fontSize for most fonts
    return text.length * fontSize * 0.6;
  }
  
  calculateTitleDimensions() {
    const { titleText, subtitleText } = this.generateTitleInfo();
    const baseTitleSize = 18;
    const baseSubtitleSize = 12;
    const padding = 40; // Minimum padding on each side
    
    // Calculate required width for both texts at base sizes
    const titleWidth = this.estimateTextWidth(titleText, baseTitleSize);
    const subtitleWidth = this.estimateTextWidth(subtitleText, baseSubtitleSize);
    const maxTextWidth = Math.max(titleWidth, subtitleWidth);
    
    return {
      titleText,
      subtitleText,
      requiredWidth: maxTextWidth + (padding * 2),
      baseTitleSize,
      baseSubtitleSize
    };
  }
  
  addTitleToSvg(svgWidth) {
    const { titleText, subtitleText, requiredWidth, baseTitleSize, baseSubtitleSize } = this.calculateTitleDimensions();
    
    // Calculate scaling factor if text is too wide
    const availableWidth = svgWidth - 40; // Leave 20px padding on each side
    const scaleFactor = requiredWidth &gt; availableWidth ? availableWidth / requiredWidth : 1;
    
    const titleSize = Math.max(12, baseTitleSize * scaleFactor); // Minimum 12px
    const subtitleSize = Math.max(10, baseSubtitleSize * scaleFactor); // Minimum 10px
    
    // Create title element
    const title = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;text&apos;);
    title.setAttribute(&apos;x&apos;, svgWidth / 2);
    title.setAttribute(&apos;y&apos;, 25);
    title.setAttribute(&apos;text-anchor&apos;, &apos;middle&apos;);
    title.setAttribute(&apos;font-size&apos;, titleSize.toString());
    title.setAttribute(&apos;font-weight&apos;, &apos;bold&apos;);
    title.setAttribute(&apos;fill&apos;, &apos;#1f2937&apos;); // Gray-800
    title.textContent = titleText;
    this.svg.appendChild(title);
    
    // Create subtitle element
    const subtitle = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;text&apos;);
    subtitle.setAttribute(&apos;x&apos;, svgWidth / 2);
    subtitle.setAttribute(&apos;y&apos;, 45);
    subtitle.setAttribute(&apos;text-anchor&apos;, &apos;middle&apos;);
    subtitle.setAttribute(&apos;font-size&apos;, subtitleSize.toString());
    subtitle.setAttribute(&apos;fill&apos;, &apos;#4b5563&apos;); // Gray-600
    subtitle.textContent = subtitleText;
    this.svg.appendChild(subtitle);
  }
  
  saveSvgVisualization() {
    // Get the current SVG content
    const svgElement = this.svg.cloneNode(true);
    
    // Add XML namespace and DOCTYPE for proper SVG file
    svgElement.setAttribute(&apos;xmlns&apos;, &apos;http://www.w3.org/2000/svg&apos;);
    
    // Create the SVG content with proper XML declaration
    const svgContent = `&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE svg PUBLIC &quot;-//W3C//DTD SVG 1.1//EN&quot; &quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&quot;&gt;
${svgElement.outerHTML}`;
    
    // Generate filename based on current settings
    const { filename, tuning, npsFormatted, degree, timestamp } = this.generateTitleInfo();
    const svgFilename = `${filename}_${tuning}_${npsFormatted}_${degree}_${timestamp}.svg`;
    
    // Create and download the file
    const blob = new Blob([svgContent], { type: &apos;image/svg+xml&apos; });
    const url = URL.createObjectURL(blob);
    const a = document.createElement(&apos;a&apos;);
    a.href = url;
    a.download = svgFilename;
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    URL.revokeObjectURL(url);
  }
  
  updateVisualization() {
    try {
      // Collect configuration from UI
      const config = {
        rootNote: this.rootNoteSelect.value,
        scaleType: this.scaleTypeSelect.value,
        customIntervals: this.scaleIntervalsInput.value,
        tuningName: this.tuningPresetSelect.value,
        notesPerString: parseInt(this.notesPerStringInput.value),
        selectedScaleDegree: this.selectedScaleDegree
      };

      // Generate visualization data using ScaleVisualizer
      const visualizationData = this.scaleVisualizer.generateVisualizationData(config);
      
      // Render the fretboard with the generated data
      this.renderFretboard(visualizationData);
    } catch (error) {
      console.error(&apos;Error updating visualization:&apos;, error);
      // Clear the visualization on error to prevent broken display
      if (this.svg) {
        this.svg.innerHTML = &apos;&lt;text x=&quot;50%&quot; y=&quot;50%&quot; text-anchor=&quot;middle&quot; fill=&quot;red&quot;&gt;Error: Unable to generate visualization&lt;/text&gt;&apos;;
      }
    }
  }
  
  
  renderFretboard(visualizationData) {
    this.svg.innerHTML = &apos;&apos;;
    
    const { notePositions, tuning, scaleLength, fretRange } = visualizationData;
    const stringCount = tuning.length;
    const [minFretToShow, maxFretToShow] = fretRange;
    
    const fretRangeSize = maxFretToShow - minFretToShow + 1;
    const fretboardWidth = fretRangeSize * this.fretSpacing + this.margin.left + this.margin.right;
    
    // Calculate minimum width needed for title text
    const { requiredWidth: titleWidth } = this.calculateTitleDimensions();
    
    // Use the larger of fretboard width or title width to ensure everything fits
    const width = Math.max(fretboardWidth, titleWidth);
    
    const titleHeight = this.titleHeight; // Space for title and subtitle
    const height = stringCount * this.stringSpacing + this.margin.top + this.margin.bottom + titleHeight;

    this.svg.setAttribute(&apos;width&apos;, width);
    this.svg.setAttribute(&apos;height&apos;, height);
    this.svg.setAttribute(&apos;viewBox&apos;, `0 0 ${width} ${height}`);
    
    // Add title and subtitle to SVG
    this.addTitleToSvg(width);
    
    // Adjust margin.top to account for title space
    const adjustedMarginTop = this.margin.top + titleHeight;
    
    // Draw strings (horizontal lines) - reversed so lowest pitch is at bottom
    for (let string = 0; string &lt; stringCount; string++) {
      const y = adjustedMarginTop + (stringCount - 1 - string) * this.stringSpacing;
      const line = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;line&apos;);
      line.setAttribute(&apos;x1&apos;, this.margin.left);
      line.setAttribute(&apos;y1&apos;, y);
      line.setAttribute(&apos;x2&apos;, this.margin.left + (fretRangeSize - 1) * this.fretSpacing);
      line.setAttribute(&apos;y2&apos;, y);
      line.setAttribute(&apos;stroke&apos;, &apos;#333&apos;);
      line.setAttribute(&apos;stroke-width&apos;, &apos;2&apos;);
      this.svg.appendChild(line);
    }
    
    // Draw frets (vertical lines)
    for (let fret = minFretToShow; fret &lt;= maxFretToShow; fret++) {
      const x = this.margin.left + (fret - minFretToShow) * this.fretSpacing;
      const line = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;line&apos;);
      line.setAttribute(&apos;x1&apos;, x);
      line.setAttribute(&apos;y1&apos;, adjustedMarginTop);
      line.setAttribute(&apos;x2&apos;, x);
      line.setAttribute(&apos;y2&apos;, adjustedMarginTop + (stringCount - 1) * this.stringSpacing);
      line.setAttribute(&apos;stroke&apos;, fret === 0 ? &apos;#000&apos; : &apos;#ccc&apos;);
      line.setAttribute(&apos;stroke-width&apos;, fret === 0 ? &apos;4&apos; : &apos;1&apos;);
      this.svg.appendChild(line);
    }
    
    // Draw Y-axis string labels - reversed so lowest pitch is at bottom
    for (let string = 0; string &lt; stringCount; string++) {
      const y = adjustedMarginTop + (stringCount - 1 - string) * this.stringSpacing;
      const stringName = this.musicalTheory.getNoteName(tuning[string]);
      
      const text = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;text&apos;);
      text.setAttribute(&apos;x&apos;, this.margin.left - 20);
      text.setAttribute(&apos;y&apos;, y + 5);
      text.setAttribute(&apos;text-anchor&apos;, &apos;middle&apos;);
      text.setAttribute(&apos;font-size&apos;, &apos;12&apos;);
      text.setAttribute(&apos;font-weight&apos;, &apos;bold&apos;);
      text.setAttribute(&apos;fill&apos;, &apos;#333&apos;);
      text.textContent = stringName;
      this.svg.appendChild(text);
    }
    
    // Draw X-axis fret number labels
    for (let fret = minFretToShow + 1; fret &lt;= maxFretToShow; fret++) {
      const x = this.margin.left + (fret - minFretToShow - 0.5) * this.fretSpacing;
      const y = adjustedMarginTop + (stringCount - 1) * this.stringSpacing + 30;
      
      const text = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;text&apos;);
      text.setAttribute(&apos;x&apos;, x);
      text.setAttribute(&apos;y&apos;, y);
      text.setAttribute(&apos;text-anchor&apos;, &apos;middle&apos;);
      text.setAttribute(&apos;font-size&apos;, &apos;12&apos;);
      text.setAttribute(&apos;font-weight&apos;, &apos;bold&apos;);
      text.setAttribute(&apos;fill&apos;, &apos;#666&apos;);
      text.textContent = fret;
      this.svg.appendChild(text);
    }
    
    notePositions.forEach(([stringIndex, fret], index) =&gt; {
      const scaleDegree = this.scaleVisualizer.calculateScaleDegreeForPosition(
        index, 
        scaleLength, 
        this.selectedScaleDegree
      );
      this.drawNote(stringIndex, fret, scaleDegree, minFretToShow);
    });
  }
  
  drawNote(stringIndex, fret, scaleDegree, minFretToShow = 0) {
    const tuning = this.tuningPresets[this.tuningPresetSelect.value];
    const stringCount = tuning.length;
    
    const titleHeight = this.titleHeight; // Must match the titleHeight in renderFretboard
    const adjustedMarginTop = this.margin.top + titleHeight;
    const x = this.margin.left + (fret - minFretToShow - 0.5) * this.fretSpacing;
    const y = adjustedMarginTop + (stringCount - 1 - stringIndex) * this.stringSpacing;
    
    const openStringNote = tuning[stringIndex];
    const actualNoteName = this.musicalTheory.semitoneToNote(this.musicalTheory.parseNote(openStringNote) + fret);
    const isSelected = scaleDegree === this.selectedScaleDegree;
    
    const circle = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;circle&apos;);
    circle.setAttribute(&apos;cx&apos;, x);
    circle.setAttribute(&apos;cy&apos;, y);
    circle.setAttribute(&apos;r&apos;, this.noteCircleRadius.toString());
    circle.setAttribute(&apos;fill&apos;, isSelected ? &apos;#fff&apos; : &apos;#000&apos;);
    circle.setAttribute(&apos;stroke&apos;, isSelected ? &apos;#000&apos; : &apos;#fff&apos;);
    circle.setAttribute(&apos;stroke-width&apos;, &apos;2&apos;);
    circle.setAttribute(&apos;class&apos;, &apos;note clickable-note&apos;);
    circle.setAttribute(&apos;data-note&apos;, actualNoteName);
    circle.setAttribute(&apos;data-scale-degree&apos;, scaleDegree);
    circle.style.cursor = &apos;pointer&apos;;
    
    circle.addEventListener(&apos;click&apos;, () =&gt; this.onNoteClick(scaleDegree));
    
    const title = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;title&apos;);
    title.textContent = this.musicalTheory.getNoteName(actualNoteName);
    circle.appendChild(title);
    
    this.svg.appendChild(circle);
    
    const text = document.createElementNS(&apos;http://www.w3.org/2000/svg&apos;, &apos;text&apos;);
    text.setAttribute(&apos;x&apos;, x);
    text.setAttribute(&apos;y&apos;, y + 5);
    text.setAttribute(&apos;text-anchor&apos;, &apos;middle&apos;);
    text.setAttribute(&apos;font-size&apos;, &apos;14&apos;);
    text.setAttribute(&apos;font-weight&apos;, &apos;bold&apos;);
    text.setAttribute(&apos;fill&apos;, isSelected ? &apos;#000&apos; : &apos;#fff&apos;);
    text.setAttribute(&apos;class&apos;, &apos;note clickable-note&apos;);
    text.setAttribute(&apos;data-note&apos;, actualNoteName);
    text.setAttribute(&apos;data-scale-degree&apos;, scaleDegree);
    text.style.cursor = &apos;pointer&apos;;
    text.style.pointerEvents = &apos;none&apos;;
    text.textContent = scaleDegree;
    this.svg.appendChild(text);
  }
  
  exportCurrentPattern() {
    const pattern = {
      name: this.scaleTitleInput.value || `${this.rootNoteSelect.value} ${this.scaleTypeSelect.options[this.scaleTypeSelect.selectedIndex].text} Pattern`,
      intervals: this.musicalTheory.parseIntervals(this.scaleIntervalsInput.value),
      rootNote: this.rootNoteSelect.value,
      notesPerString: parseInt(this.notesPerStringInput.value),
      tuning: this.tuningPresetSelect.value,
      selectedScaleDegree: this.selectedScaleDegree,
      scaleType: this.scaleTypeSelect.value
    };
    
    const blob = new Blob([JSON.stringify(pattern, null, 2)], { type: &apos;application/json&apos; });
    const url = URL.createObjectURL(blob);
    const a = document.createElement(&apos;a&apos;);
    a.href = url;
    a.download = `${pattern.name.replace(/[^a-zA-Z0-9]/g, &apos;_&apos;)}.json`;
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    URL.revokeObjectURL(url);
  }
}

// Initialize the visualizer when the page loads
document.addEventListener(&apos;DOMContentLoaded&apos;, () =&gt; {
  window.visualizer = new StringedInstrumentVisualizer();
});
&lt;/script&gt;

&lt;style&gt;
#instrument-visualizer {
  max-width: 100%;
}

#fretboard-container {
  border: 2px solid #333;
  border-radius: 8px;
  background: #fff;
  padding: 20px;
}


.controls select {
  font-family: inherit;
}

.note {
  cursor: pointer;
}

.note:hover {
  opacity: 0.8;
}

.clickable-note {
  transition: opacity 0.2s ease;
}

.clickable-note:hover {
  opacity: 0.7;
}

/* Match the grid-like appearance from the provided image */
#fretboard {
  background: #fff;
}

/* Print styles */
@media print {
  /* Force portrait orientation */
  @page {
    size: portrait;
    margin: 0.5in;
  }
  
  /* Hide everything except visualization and title */
  .noprint,
  .controls,
  footer,
  #print-button,
  #export-button,
  #save-preset-button,
  #import-file,
  label[for=&quot;import-file&quot;] {
    display: none !important;
  }
  
  /* Hide the intro text */
  .noprint {
    display: none !important;
  }
  
  /* Hide site title and page title when printing */
  body &gt; div &gt; div:first-child,
  body &gt; div &gt; .text-2xl,
  h1 {
    display: none !important;
  }
  
  /* Make visualization fill the page */
  body {
    margin: 0;
    padding: 0;
  }
  
  #instrument-visualizer {
    max-width: none;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  
  #visualization-title {
    margin-bottom: 20px;
    page-break-inside: avoid;
    page-break-after: avoid;
    text-align: center;
  }
  
  #fretboard-container {
    border: none !important;
    padding: 0;
    margin: 0;
    overflow: visible;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    page-break-before: avoid;
  }
  
  /* Scale the fretboard to use full width */
  #fretboard {
    width: 100%;
    height: auto;
    max-width: none;
  }
}
&lt;/style&gt;

&lt;h2 id=&quot;explanation&quot;&gt;Explanation&lt;/h2&gt;

&lt;p&gt;Most guitarists are taught scales in a horribly complicated way. It’s typical to memorize scales in “boxes” with combinations of 2 or three notes per string. When you divide scales this way you have to memorize 4 or 5 or six “boxes” up the neck for each scale type. That’s too many shapes to memorize, which is too easy to give up.&lt;/p&gt;

&lt;p&gt;I’ve been experimenting with easier ways to remember scales over the last year and independently came to a thing that metal guitarists have known for years called the &lt;a href=&quot;https://fretscience.com/2022/10/09/3nps-one-pattern-to-rule-them-all/&quot;&gt;Grand Unified Pattern&lt;/a&gt;. It’s absolutely worth reading that article, it’ll save you years of scale anguish. The &lt;strong&gt;tl;dr&lt;/strong&gt; is: for any musical scale on any stringed instrument, if you limit yourself to a consistent number of notes per string, a symmetry arises &lt;del&gt;at the least common multiple of 1) #notes in the scale and 2) #notes per string.&lt;/del&gt; at the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;least common multiple(notes in scale, notes per string) / notes per string&lt;/code&gt;. Therefore there’s a single “box” you can learn for any scale that applies across the entire neck.&lt;/p&gt;

&lt;p class=&quot;text-sm i&quot;&gt;I was corrected on the formula here by Keith Martin of Fret Science. --D&lt;/p&gt;

&lt;p&gt;Let me say that again: &lt;strong&gt;for any scale that exists you can learn a single “box” and it’ll work acros the entire neck of your instrument.&lt;/strong&gt; The article I linked above walks through it for the major scale and also shows how to derive modes from that same shape, which is a bonus.&lt;/p&gt;

&lt;h2 id=&quot;notes-on-the-method&quot;&gt;Notes on the Method&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;For seven-note scales, the “unified” scale box is seven strings wide. Your guitar is only six strings wide – that’s why it seems like you have to learn a bunch of different shapes! But you don’t! Just figure out which note you’re on in the pattern and go from there.
    &lt;ul&gt;
      &lt;li&gt;Side note: One reason pentatonic scales are so easy on guitar is because they’re 5-note scales typically played in 2NPS. Played this way, they’re symmetrical over 5 strings, which fits nicely. The unified pattern still applies - the other “box” shapes you learn for a pentatonic are the &lt;em&gt;same pattern&lt;/em&gt;, just starting on a different note. Learn the pattern, you don’t have to memorize the boxes.&lt;/li&gt;
      &lt;li&gt;This is also true of major/minor pentatonics: same pattern but minor starts on the 5th interval of the major shape. Try it yourself!&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;I’ve defaulted to a fictional many-stringed instrument tuned in perfect 4ths (like the bottom four strings of a guitar) because I find it helpful to think of the pattern symmetrically. On a guitar in standard tuning, this means that when moving up from the G to B string you need to shift the pattern one fret left, or one fret right when moving down. I’ve added a selector for standard guitar/bass tuning if it helps to visualize how the pattern shifts.&lt;/li&gt;
  &lt;li&gt;Modes are just scale patterns starting on a different note. This is easy in the visualizer - just click on a note or type the starting interval and the pattern will shift to start with that note but keep the NPS the same. It’s a handy way to help learn how the “shifting” works. But &lt;em&gt;remember&lt;/em&gt;: modes are the same exact pattern! Just starting at a different place.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;next-steps&quot;&gt;Next Steps&lt;/h2&gt;

&lt;p&gt;There are plenty of next steps you can take with this tool. For example, with traditional 7-note scales, you can learn to leverage the fact that the pattern natually moves you up the neck on guitar, combined with the fact that the high and low E strings are the same piece of the pattern, and you can move all the way up the neck “rotating” the pattern.&lt;/p&gt;

&lt;p&gt;Another next step you can take is to learn the scales on one string (i.e. 7NPS for a 7-note scale). Then learn how to pick a random spot on the scale and start moving up strings instead of up the neck. The visualizer allows you to pick any NPS you want up to the number of notes in the scale pattern, so you can see what this looks like if that helps.&lt;/p&gt;

&lt;h2 id=&quot;notes-on-the-visualizer-tool&quot;&gt;Notes on the Visualizer Tool&lt;/h2&gt;

&lt;p&gt;This tool was “vibe-coded” with Claude Code. This is my first greenfield coding project done in this way, and I have to say it was actually a blast. I never would have made the tool this polished if I’d had to write all the code - not from inability, but from lack of time or desire.&lt;/p&gt;

&lt;p&gt;The current version of the &lt;a href=&quot;https://github.com/dmerand/donald.merand.org/tree/master/lib/unified-nps&quot;&gt;source&lt;/a&gt; will be linked below the diagram. I’ve designed the repo to leave lots of breadcrumbs for Claude to pick up work so that I can work between sessions. If you’re interested in that workflow, check out the &lt;a href=&quot;https://github.com/dmerand/donald.merand.org/blob/master/lib/unified-nps/TODO.md&quot;&gt;TODO.md&lt;/a&gt; and &lt;a href=&quot;https://github.com/dmerand/donald.merand.org/blob/master/lib/unified-nps/.claude/README.md&quot;&gt;.claude/README.md&lt;/a&gt;, which are designed to provide agent context when working with the repo.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Working on Anxiety</title>
   <link href="https://donald.merand.org//writing/2020/11/16/working-on-anxiety.html"/>
   <updated>2020-11-16T00:00:00-05:00</updated>
   <id>https://donald.merand.org/writing/2020/11/16/working-on-anxiety</id>
   <content type="html">&lt;div class=&quot;noprint mb-10 italic text-sm&quot;&gt;
  &lt;p&gt;
    I am often anxious and it manifests in bodily tension. With help from various physical therapists, chiropractors, and craniosacral therapists I&apos;ve come up with some strategies to help mitigate this tension. I&apos;m putting them here as my own reference, and in case they are helpful for anybody with similar issues. It should print out pretty well.
  &lt;/p&gt;
  &lt;p&gt;
    -Donald
  &lt;/p&gt;
&lt;/div&gt;

&lt;p class=&quot;my-3&quot;&gt;
  focus on separating breath from tension. find a way to keep breathing steady even if your muscles pull.
&lt;/p&gt;

&lt;p class=&quot;my-3&quot;&gt;
  notice your diaphragm, your chest, and your belly. breath should enter and exit all of these places mostly without noise. if it does not, this is an indicator that you&apos;re holding tension.
&lt;/p&gt;

&lt;p class=&quot;my-3&quot;&gt;
  tongue on the roof of the mouth can help breath flow. use it if it works.
&lt;/p&gt;

&lt;p class=&quot;my-3&quot;&gt;
  be a comfortable temperature, for me that&apos;s extra warm. it&apos;s hard to be calm if i&apos;m cold.
&lt;/p&gt;

&lt;p class=&quot;my-3&quot;&gt;
  smiling can help to relax. it even works if you&apos;re alone.
&lt;/p&gt;

&lt;p class=&quot;my-3&quot;&gt;
  tension will enter your awareness. allow your body to do what it needs to - don&apos;t fight tension with active relaxation. instead keep breathing and see where the tension is guiding you - it&apos;s usually the opposite of where you are.
&lt;/p&gt;

&lt;p class=&quot;my-3&quot;&gt;
  allow the tension but don&apos;t stop breathing well. you might feel shaking. this is muscles vibrating from over-fatigue. 
&lt;/p&gt;

&lt;p class=&quot;my-3&quot;&gt;
  feel gravity pulling your muscles down. be aware of your entire body.
&lt;/p&gt;

&lt;p class=&quot;my-3&quot;&gt;
  allow vocalization to happen during breathing if you can. humming stimulates the vagas nerve.
&lt;/p&gt;

&lt;p class=&quot;my-3&quot;&gt;
  take the time you need. five minutes helps, but an hour helps more.
&lt;/p&gt;

&lt;p class=&quot;my-3&quot;&gt;
  things rarely feel better the day you shake them out. Usually it takes a day or two to realize you&apos;ve made an improvement. 
&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>ExAirtable - Airtable in your Elixir</title>
   <link href="https://donald.merand.org//portfolio/2020/11/09/exairtable.html"/>
   <updated>2020-11-09T00:00:00-05:00</updated>
   <id>https://donald.merand.org/portfolio/2020/11/09/exairtable</id>
   <content type="html">&lt;p&gt;&lt;strong&gt;tl;dr: If you use Elixir and like Airtable, check out a new library I wrote called &lt;a href=&quot;https://github.com/exploration/ex_airtable&quot;&gt;ExAirtable&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At &lt;a href=&quot;https://www.explo.org&quot;&gt;EXPLO&lt;/a&gt;, we often reach for &lt;a href=&quot;https://airtable.com&quot;&gt;Airtable&lt;/a&gt; when we’re trying out new ideas. We love it because it really reduces friction for putting together simple relational systems that are the backbone of knowledge work. We are also very happy with &lt;a href=&quot;https://elixir-lang.org&quot;&gt;Elixir&lt;/a&gt; and &lt;a href=&quot;https://www.phoenixframework.org&quot;&gt;Phoenix&lt;/a&gt; when it comes time to build apps for the web, which seems to happen more and more these days!&lt;/p&gt;

&lt;p&gt;I’ve often wondered whether we could use Airtable as a content management back-end for some of these sites. It solves a few problems that we consistently have:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;A simple and consistent management front-end that includes relational data along with tabular views, forms, calendars, etc.&lt;/li&gt;
  &lt;li&gt;File-hosting and image auto-resizing! You just make a “file” field type and you can upload files right into your ‘tables. Images get automatically scaled to a variety of sizes.&lt;/li&gt;
  &lt;li&gt;API! Every project has the same API structure and the API is sane to use.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We’ve used Ruby with Sinatra or Rails and the excellent &lt;a href=&quot;https://github.com/Sirupsen/airrecord&quot;&gt;AirRecord &lt;/a&gt; library to do Airtable-based sites before. But for Elixir, the current Airtable API libraries didn’t seem to be in active development, and didn’t have features like rate-limiting or caching. But it would be so cool if we had an Elixir library that would allow us to handle Airtable rate-limiting and caching as a single Elixir-native dependency!&lt;/p&gt;

&lt;p&gt;Meanwhile, Ricardo Garcia Vega wrote &lt;a href=&quot;https://dev.to/bigardone/headless-cms-fun-with-phoenix-liveview-and-airtable-pt-1-4anj&quot;&gt;this amazing article&lt;/a&gt; demonstrating the use of Elixir and Phoenix as a caching layer for Airtable for a content management system. This “native” Elixir solution was just the push I needed to fix Elixir’s Airtable library problem.&lt;/p&gt;

&lt;p&gt;So here’s the buried lede: I wrote an Airtable library (actually two! read onward…) for Elixir called &lt;a href=&quot;https://github.com/exploration/ex_airtable&quot;&gt;ExAirtable&lt;/a&gt;. This library aims to provide a solid foundation to use Elixir (&lt;a href=&quot;https://github.com/exploration/ex_airtable_phoenix&quot;&gt;with&lt;/a&gt; or without Phoenix) with Airtable interaction. It handles rate-limiting against the Airtable API, and (optionally) caches all requests in local memory to drastically speed up reads.&lt;/p&gt;

&lt;h2 id=&quot;a-solid-foundation&quot;&gt;A Solid Foundation&lt;/h2&gt;

&lt;p&gt;I designed ExAirtable to work in two different ways:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Just hit the Airtable API directly. Don’t worry about rate limits too much and give me all of the pages of data when I want a list. You’d use this method if you have a simple case where you don’t expect things to get crazy in terms of number of requests or size of data.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Run as a supervised, cached, and rate-limited server tree. All client requests will go into a per-base queue which will never exceed 5 API requests per second. All desired data will be stored in an in-memory cache that is periodically refreshed via the API. Client request retrieved from the cache whenever possible to drastically speed up read times. This mode is useful when you’re dealing with larger bases or apps that may have a lot of clients performing read and write operations.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s how the system comes together:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/i/sg85ziscccoxl6v3g3io.png&quot; alt=&quot;ExAirtable - System Overview&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you decide to run the service in cached and rate-limited mode, here’s how the supervision tree comes together:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/i/guy0qqcj9n0ntrezyc34.png&quot; alt=&quot;ExAirtable - Supervision Structure&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If folks are interested, I can write more articles with code examples. In the meantime &lt;a href=&quot;https://hexdocs.pm/ex_airtable/ExAirtable.html&quot;&gt;the documentation&lt;/a&gt; has tons of examples and information. I’ve tried hard to make it comprehensive and useful all by itself, which is a truly game-changing trick that I’ve learned from the Elixir community.&lt;/p&gt;

&lt;h2 id=&quot;use-with-phoenix-andor-ecto&quot;&gt;Use with Phoenix and/or Ecto&lt;/h2&gt;

&lt;p&gt;Realistically, most folks who want to try this with Elixir are going to use Phoenix as their application framework. Since Phoenix plays so well with Ecto, I found it beneficial to create a set of conventions around creating ExAirtable Table models in an Ecto context with embedded schemas.&lt;/p&gt;

&lt;p&gt;That library (called ExAirtable.Phoenix) is here: &lt;a href=&quot;https://github.com/exploration/ex_airtable_phoenix&quot;&gt;https://github.com/exploration/ex_airtable_phoenix&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once again, I can write more follow-up if folks are interested. In the meantime, give it a try and let me know what you think!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Things I've Recently Made - Some Apps, Some Electronics, Some Art</title>
   <link href="https://donald.merand.org//portfolio/2020/08/24/things-ive-recently-made.html"/>
   <updated>2020-08-24T00:00:00-04:00</updated>
   <id>https://donald.merand.org/portfolio/2020/08/24/things-ive-recently-made</id>
   <content type="html">&lt;p&gt;I’ve done some projects over the years which never really got properly written up. Some are art projects, some are things I did for work that we decided to open-source, and some are just fun things that I couldn’t help but make. At some point I might make fuller blog posts about this stuff, but I thought it might be nice to start with a small catalog so that they don’t get lost to time.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The &lt;a href=&quot;https://enigmas.ploration.org&quot;&gt;Enigma Explorer&lt;/a&gt; (&lt;a href=&quot;https://bitbucket.org/explo/enigma/src/master/&quot;&gt;source&lt;/a&gt;) uses Elixir, Phoenix and LiveView to generate art inspired by Seymour Papert and Cynthia Solomon’s LOGO language, which was my first exposure to coding.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://lab.explo.org/facesofexplo/#&quot;&gt;The Faces of EXPLO&lt;/a&gt; is an exploration (pun so very intended) into generative image composition. This was powered by some &lt;a href=&quot;https://gist.github.com/dmerand/2490678&quot;&gt;shell scripting and ImageMagick fun&lt;/a&gt;. I just realized that &lt;a href=&quot;https://donald.merand.org/code/2012/05/13/rakefiles-face-merging-and-wheres-the-missing-html.html&quot;&gt;I wrote about this&lt;/a&gt; but that’s OK, I’m keeping it in the list.&lt;/li&gt;
  &lt;li&gt;The &lt;a href=&quot;https://github.com/exploration/markov_words&quot;&gt;Markov Words&lt;/a&gt; Ruby Gem uses Markov chains to make English-sounding words that aren’t (usually) &lt;em&gt;real&lt;/em&gt; English words. Actually, the gem allows you to use any dictionary, so you could just as easily make “Elvish-sounding” or “Klingon-sounding” words or whatever, just by feeding it a different dictionary. We use this at EXPLO sometimes to &lt;a href=&quot;https://lab.explo.org/password&quot;&gt;generate passwords&lt;/a&gt; with a fun little &lt;a href=&quot;https://bitbucket.org/explo/password-generator/src/master/&quot;&gt;Elm app&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin&quot;&gt;My Pile of Shell Scripts&lt;/a&gt; that I use on a daily basis. I actually keep this up-to-date. It’s my most popular repository on GitHub, with a whopping 19 stars at the time of publication. Some favorites include a &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/dpaste&quot;&gt;dpaste frontend&lt;/a&gt;, WSL versions of the Mac utilities &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/pbcopy&quot;&gt;pbcopy&lt;/a&gt; and &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/pbpaste&quot;&gt;pbpaste&lt;/a&gt;, and &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/tsvfmt&quot;&gt;tsvfmt&lt;/a&gt;/&lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/tsv2html&quot;&gt;tsv2html&lt;/a&gt; which make TSVs easier on the command line.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://quarantine-poem-anthology.herokuapp.com/&quot;&gt;Quarantine Poem Anthology&lt;/a&gt; was an early and quickly aborted attempt to reconcile stay-at-home Feelings. It is also a fun &lt;a href=&quot;https://github.com/dmerand/quarantine-poem-anthology&quot;&gt;Sinatra app&lt;/a&gt; that explores using Airtable as the CMS for a web site, with basic caching. I did a similar thing for &lt;a href=&quot;http://merand-homeschool-resources.herokuapp.com/&quot;&gt;Homeschool Resources&lt;/a&gt; with Google Docs as the backend instead of Airtable, but I never published the source for that app.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/exploration/compliment-bot&quot;&gt;Compliment Bot&lt;/a&gt; was how I learned about Arduino and GPIO programming on the Raspberry Pi. It’s a robot that gives you compliments and prints them out on a receipt! Later, I converted it to draw random mazes, and also give you compliments, at which point I changed the name to aMazeBot. PS: you can visit the robot online at &lt;a href=&quot;https://robot.lab.explo.org&quot;&gt;https://robot.lab.explo.org&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Along similar lines, &lt;a href=&quot;https://github.com/exploration/EXTROVRT&quot;&gt;EXTROVRT&lt;/a&gt; was a “telepresence robot” that was basically a phone or tablet holder that you could drive through a &lt;a href=&quot;https://github.com/exploration/EXTROVRT-Control&quot;&gt;web interface&lt;/a&gt;. This was another Arduino project, experimenting with MQTT via &lt;a href=&quot;https://io.adafruit.com&quot;&gt;https://io.adafruit.com&lt;/a&gt;. This project also had some fun &lt;a href=&quot;https://www.thingiverse.com/thing:1419043&quot;&gt;3d-printed design elements&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;A bunch of custom quadcopter designs: &lt;a href=&quot;https://www.thingiverse.com/thing:972795&quot;&gt;Micro X&lt;/a&gt;, &lt;a href=&quot;https://www.thingiverse.com/thing:966442&quot;&gt;Spiral Arm&lt;/a&gt;, and &lt;a href=&quot;https://www.thingiverse.com/thing:966385&quot;&gt;Dreamcatcher&lt;/a&gt;, all of which use electronics pulled from a Syma X1 quad. I’m especially proud of those designs because they are all parametric - the CAD is code too! This project was also where I learned how to properly use and tune a 3D printer.&lt;/li&gt;
  &lt;li&gt;A DIY &lt;a href=&quot;https://www.thingiverse.com/thing:335958&quot;&gt;CNC Pendant&lt;/a&gt; that works with a Shopbot. The Adafruit Leonardo was an early Arduino that allowed keyboard emulation, which is what I used here to make it control a CNC machine.&lt;/li&gt;
  &lt;li&gt;A &lt;a href=&quot;https://www.thingiverse.com/thing:822258&quot;&gt;Drill Press Laser Centering Device&lt;/a&gt; inspired by &lt;a href=&quot;https://www.youtube.com/channel/UCYA1VjSKXgNVh03wjw_HSRA&quot;&gt;Dan Gelbart&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Fully 3d-printable &lt;a href=&quot;https://www.thingiverse.com/thing:1404307&quot;&gt;paper rollers&lt;/a&gt; that allow you to re-use all of that Amazon packing paper as an infinite-scroll paper tabletop.&lt;/li&gt;
  &lt;li&gt;A series of soldering fan &lt;a href=&quot;https://www.thingiverse.com/thing:1501388&quot;&gt;fume extractors&lt;/a&gt;, which can be battery- or wall-powered. One design has a very fancy cell pattern inspired by &lt;a href=&quot;https://n-e-r-v-o-u-s.com&quot;&gt;NERVOUS System&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>DNS is a Thing that People Hack Now, I Made an Open-Source App to Help</title>
   <link href="https://donald.merand.org//code/2020/01/30/dns-is-a-thing.html"/>
   <updated>2020-01-30T00:00:00-05:00</updated>
   <id>https://donald.merand.org/code/2020/01/30/dns-is-a-thing</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;https://krebsonsecurity.com/2020/01/does-your-domain-have-a-registry-lock/&quot;&gt;This article&lt;/a&gt; about recent DNS hijacking attacks is a wake-up call. I recommend you read it, but here’s a bit of a summary in case you’re not a big link-clicker (emphasis mine):&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;In the case of e-hawk.net, however, the scammers managed to trick an OpenProvider customer service rep into transferring the domain to another registrar with a … social engineering ruse — and without triggering any verification to the real owners of the domain.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These folks were able to hijack DNS using old-fashioned social engineering techniques. They got a domain registrar to transfer a domain over the phone! Then they stole all of the data.  Okay, there’s a lot more to it, you should maybe go read the article…&lt;/p&gt;

&lt;p&gt;The big take-home actions for me (they’re listed at the end of that article) were:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Set up multi-factor authentication at your domain registrar. If they don’t do multi-factor, consider changing to a registrar that does, because you are now at risk due to their lax security.&lt;/li&gt;
  &lt;li&gt;Configure DNSSEC signing zones + validating responses. See above if your registrar doesn’t have this.&lt;/li&gt;
  &lt;li&gt;Lock your domains with a &lt;a href=&quot;https://www.icann.org/resources/pages/locked-2013-05-03-en&quot;&gt;domain lock&lt;/a&gt;. This is different from a “transfer lock” because it requires a laborious personal contact process to undo. This is what you want once your domain is configured correctly. Don’t do it until you’ve got things configured correctly!&lt;/li&gt;
  &lt;li&gt;Monitor your DNS&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On that last point, I have some news for you:&lt;/p&gt;

&lt;h1 id=&quot;dns-monitor-a-new-ruby-based-cli-tool&quot;&gt;DNS-Monitor, a New Ruby-Based CLI Tool&lt;/h1&gt;

&lt;p&gt;I found myself wishing that I had a little robot to monitor all of my hostnames and warn me if there were any changes to them. So, I wrote that app yesterday and open-sourced it as the &lt;a href=&quot;https://github.com/exploration/dns-monitor&quot;&gt;DNS-Monitor Gem&lt;/a&gt;. The big thing you get is a command-line utility called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dns-monitor&lt;/code&gt;. Here’s how it works:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;You feed it a text file with all of your host names (just one line per host).&lt;/li&gt;
  &lt;li&gt;You figure out the &lt;a href=&quot;https://en.wikipedia.org/wiki/Registration_Data_Access_Protocol&quot;&gt;RDAP&lt;/a&gt; (JSON WHOIS) endpoint of your domain registrar. I’ve done zero research on who uses RDAP, but it seems like a thing many of them use? &lt;a href=&quot;https://www.explo.org&quot;&gt;Where I work&lt;/a&gt;, we use &lt;a href=&quot;https://pairdomains.com&quot;&gt;Pair Networks&lt;/a&gt;, so I put their server in as a default, but you can change it with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-u&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--rdap_url&lt;/code&gt; flag.
    &lt;ul&gt;
      &lt;li&gt;Note that in the current configuration, I’m assuming only one registrar (because that’s what we have). Send a pull request if you’d like to add the ability for multiple RDAP servers! :)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;You run the app like this: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dns-monitor --check&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dns-monitor -c&lt;/code&gt;. It will run through your list of hosts, and compare the current RDAP (WHOIS) value for that host with a (SQLite3) database of previous values.&lt;/li&gt;
  &lt;li&gt;The output of the program is a JSON array of all of your domain RDAP (WHOIS) information, with a diff showing changes for any domains that have them.&lt;/li&gt;
  &lt;li&gt;At work we use Google Hangouts Chat for ‘bot notifications, and Mandrill for transactional email, so I put in some extra functionality for those two things. If you send a Mandrill API key + email you can get email notifications if any domain has changed. But even if you use neither of those things, you can just pipe the program output into whichever utility you do use.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I’m using it currently, and it works pretty well for my use case. If you’d like to give it a try, just &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gem install dns-monitor&lt;/code&gt; to get it for yourself. Here’s an example cron script for how we use it in practice. It does some extra work to specify where the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hosts.txt&lt;/code&gt; and database files live:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/dmerand/236fd3f66ebc751dbf0e9c3fb56350db.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;In summary, DNS is scary now, I hope this helps. Send me a note if you end up using it!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Explain It Like I’m {[5, 10, 15, 20]}</title>
   <link href="https://donald.merand.org//code/2018/03/06/explain-it.html"/>
   <updated>2018-03-06T00:00:00-05:00</updated>
   <id>https://donald.merand.org/code/2018/03/06/explain-it</id>
   <content type="html">&lt;p&gt;&lt;strong&gt;Note: This was originally published on &lt;a href=&quot;https://dev.to/explo/explain-it-like-im-5-10-15-20--4odf&quot;&gt;dev.to&lt;/a&gt;, where it makes a bit more sense contextually.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;According to &lt;a href=&quot;https://kottke.org/17/06/if-you-cant-explain-something-in-simple-terms-you-dont-understand-it&quot;&gt;Richard Feynmann&lt;/a&gt;, the true measure of understanding a concept is to be able to relate it to a toddler. This is what I love about &lt;a href=&quot;https://dev.to/t/explainlikeimfive&quot;&gt;#explainlikeimfive&lt;/a&gt; channels: explaining tech concepts in a couple of pithy paragraphs, without too much technical jargon, is a fun challenge to see if I myself truly understand the concept. I &lt;a href=&quot;https://dev.to/dmerand/comment/2fih&quot;&gt;may&lt;/a&gt; &lt;a href=&quot;https://dev.to/dmerand/comment/2fn5&quot;&gt;have&lt;/a&gt; &lt;a href=&quot;https://dev.to/dmerand/comment/2fn1&quot;&gt;a&lt;/a&gt; &lt;a href=&quot;https://dev.to/dmerand/comment/2fnn&quot;&gt;problem&lt;/a&gt; with compulsively commenting on these discussions…&lt;/p&gt;

&lt;p&gt;But there &lt;em&gt;is&lt;/em&gt; one thing that bothers me: I’m not sure that the asker always wants an answer suitable for a five-year-old! Five-year-olds aren’t typically concerned with specific terminology, but responses to &lt;a href=&quot;https://dev.to/t/explainlikeimfive&quot;&gt;#explainlikeimfive&lt;/a&gt; are often very jargon-heavy. The requester may have wanted that, but that’s not an answer you’d want to give a 5-year-old! Not that it matters whether the requester &lt;em&gt;truly&lt;/em&gt; wanted a 5-year-old response versus a 7-year-old response, or what-have-you. What truly matters is that when your response doesn’t match the question, you run the risk of being ignored or misunderstood.&lt;/p&gt;

&lt;p&gt;I think understanding these nuances is fun! I’m going to try explaining the same concept to a theoretical 5, 10, 15, and 20-year old. In doing this, I hope to learn something about my own process of teaching, and hopefully find some varying approaches that work well. I’ll attempt to &lt;a href=&quot;https://dev.to/webdevdeja/explain-git--github-like-im-five--3pak&quot;&gt;Explain Git + GitHub Like I’m Five&lt;/a&gt; (and Ten, and Fifteen, and Twenty).&lt;/p&gt;

&lt;h2 id=&quot;explainlikeimfive&quot;&gt;#EXPLAINLIKEIMFIVE&lt;/h2&gt;
&lt;p&gt;One good way to #explainlikeimfive is to tell a short story which is an analogy. Five-year-olds aren’t typically concerned with specific terminology, but they are very good at understanding metaphor. Your goal here would be to get them to understand how this idea solves a problem that’s very similar to one that they may have had.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Say you are writing a short story and you want to do a really good job. You might write the story on one sheet of paper, and then get another sheet of paper and write another version, and then keep writing more versions on more sheets of paper. After a while, you’d end up with lots of sheets of paper that weren’t the version you were currently writing. You might put those sheets in a folder so that you can go back and see old drafts of your story.&lt;/p&gt;

  &lt;p&gt;You give that folder to your mom to keep track of, because you know that you can always ask mom for one of the versions of your story if you need it. Plus, mom keeps photocopies so she can give versions of your story to your siblings. Mom also keeps similar folders for the stories that your siblings write.&lt;/p&gt;

  &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Git&lt;/code&gt; is the folder, and your pieces of paper are &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;code&lt;/code&gt;. Your mom is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GitHub&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Notice that in the story above, technical terms aren’t integrated into the story, and the list of actual terms is drastically simplified (and could be omitted entirely without negatively impacting understanding).&lt;/p&gt;

&lt;h2 id=&quot;explainlikeimten&quot;&gt;#EXPLAINLIKEIMTEN&lt;/h2&gt;
&lt;p&gt;Ten-year-olds are ready for terminology, but they can lose a thread if you digress too much or get too technical. You can still succesfully employ an analogy, but they also tend to enjoy more integrated references to technical terms. &lt;a href=&quot;https://xkcd.com/thing-explainer/&quot;&gt;Thing Explainer&lt;/a&gt; by Randall Munroe is another approach that works - explain how a thing works using universal words and concepts, because at ten, people tend to understand all of the truly important concepts already.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Think of computer &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apps&lt;/code&gt; as stories. Say you are writing a story and you want to do a really good job. You might write several revisions of your story. You don’t want to lose your revisions though - what if you had a good idea earlier that you want to revisit later? So you decide to keep all of your revisions in a folder. You can think of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git&lt;/code&gt; as the idea of folders that hold revisions, and your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repository&lt;/code&gt; (or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt;) is the folder that holds this one story you’re writing, and all of its revisions.&lt;/p&gt;

  &lt;p&gt;You might want to share the story that you’re writing! Maybe you want to share the writing with friends, or maybe you just want a place for folks to go to read it. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GitHub&lt;/code&gt; is such a place - a web &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app&lt;/code&gt; that holds your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repos&lt;/code&gt;, and gives you a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;web site&lt;/code&gt; for them to share. From &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GitHub&lt;/code&gt;, anybody you allow can get their own photocopy of your story, and make changes to their copy. In &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git&lt;/code&gt; that’s called a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fork&lt;/code&gt;. If the person who &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;forked&lt;/code&gt; your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt; wants to share their changes with you, so that you can have them in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt;, they can give you a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pull request&lt;/code&gt; on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GitHub&lt;/code&gt; - a bit like handing you a version of your story with changes in red, and asking you to use that as your story instead.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;explainlikeimfifteen&quot;&gt;#EXPLAINLIKEIMFIFTEEN&lt;/h2&gt;
&lt;p&gt;At fifteen, people are capable of truly excelling in areas that interest them. They can handle terminology and abstract concepts: metaphor, while helpful, isn’t a tool you need to lean on quite so much. But you might still be dealing with a short attention span, so keep your descriptions on-topic and don’t concern yourself too much with asides.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Say you are writing some code, but you worry that when you change your code you might want to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;undo&lt;/code&gt; your changes. So you need a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;version control&lt;/code&gt; system that you can tell “I’ve made some changes, please remember them”. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Git&lt;/code&gt; is an example of a version control system. Your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repository&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt; is your code, which you &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;check in&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commit&lt;/code&gt; to your version control system as you work. Later, you might create other &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repos&lt;/code&gt; for other code projects you’re working on.&lt;/p&gt;

  &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GitHub&lt;/code&gt; is an app that gives you a web site for your repo. Others can go to this web site, and download your repo to run the code, or make their own changes in their own copy (if they want to!). The idea of everybody getting their own copy of your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt; and being able to make their own changes to it is called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;distributed version control&lt;/code&gt;. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GitHub&lt;/code&gt; gives you the ability to manage &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pull requests&lt;/code&gt;. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Pull requests&lt;/code&gt; are changes that other people have made to their copies of your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt;, that they’d like you to include in (or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;merge&lt;/code&gt; into) your copy.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;explainlikeimtwenty&quot;&gt;#EXPLAINLIKEIMTWENTY&lt;/h2&gt;
&lt;p&gt;For a twenty-year-old, you can lay out all of your terms once, and then explain the concept using those fully-explained terms. A twenty-year-old can be expected to look up words in the dictionary, or check out concepts on Wikipedia, without needing prompting, so you don’t need to belabor your explanations. Your job is to explain how those terms relate to each other. You can also diverge a bit into related topics without worrying that the person will lose track of the main thread.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Git&lt;/code&gt; is a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;version control system&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VCS&lt;/code&gt;), similar to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CVS&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SVN&lt;/code&gt;, or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mercurial&lt;/code&gt;. A &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;VCS&lt;/code&gt; is a system for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;committing&lt;/code&gt; code changes to a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;code repository&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt;) in an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;append-only&lt;/code&gt; fashion such that at any given point you can see the history of all changes made to the code up to that point.&lt;/p&gt;

  &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Git&lt;/code&gt; is a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;distributed version control system&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DVCS&lt;/code&gt;), meaning that if multiple people are working on the same code project, they each have an independent copy (a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fork&lt;/code&gt;) of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt;, which can diverge from other copies. Changes from other copies (called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;remotes&lt;/code&gt; in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git&lt;/code&gt;), are &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;merged&lt;/code&gt; into a given &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt; through a text-based &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;differential comparison&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;algorithm&lt;/code&gt;. Changes in a given &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt; can also be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;branched&lt;/code&gt; and then &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;merged later&lt;/code&gt;, to give the developer an opportunity to work on specific ideas without the pressure of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;committing&lt;/code&gt; them to the main &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;branch&lt;/code&gt; of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt;. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mercurial&lt;/code&gt; is another &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DVCS&lt;/code&gt;, whereas &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SVN&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CVS&lt;/code&gt; rely on a central “master” code &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt; on a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server&lt;/code&gt;, which is typically referred to as a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;trunk&lt;/code&gt;.&lt;/p&gt;

  &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GitHub&lt;/code&gt; is a web app that provides a social network around &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repos&lt;/code&gt;. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GitHub&lt;/code&gt; will give each repo a unique &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;URL&lt;/code&gt;, which can be used for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;forking&lt;/code&gt; or downloading a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt;. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GitHub&lt;/code&gt; also provides &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pull requests&lt;/code&gt;, wherein a developer can &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fork&lt;/code&gt; a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;repo&lt;/code&gt;, create changes, and then request that those changes be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;merged&lt;/code&gt; into another fork. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GitHub&lt;/code&gt; provides other services such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;issue tracking&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wikis&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;visualizations&lt;/code&gt; of code history, and more. People often use services such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GitHub&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Bitbucket&lt;/code&gt; because they don’t want to have to manage their own git server, or because they want the extra features such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pull requests&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;issue tracking&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Notice that this version is the first time that alternatives to Git, such as SVN or Mercurial, even get mentioned. I’m assuming that a twenty-year-old will want to do further research if they’re interested, so providing bigger context such as naming alternative approaches can be very helpful toward that end.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Explaining things to people is fun! It is a good test of your personal knowledge on a topic, and it is also deeply rewarding to share knowledge with people who want to learn. Keeping your audience’s abilities and desires in mind drastically increases the likelihood that what you say will be received and absorbed.&lt;/p&gt;

&lt;p&gt;Do I think you should start using the hashtag #explainlikeimten or #explainlikeimtwenty just to be more precise? No, I do not! Please don’t do that! I love that we have the one hashtag here which generally means “I’m new to this and would like some help.” This was just a fun thought experiment meant to shed some light onto my own teaching process. I’m hoping that posting it here will be inspiring in some way!&lt;/p&gt;

&lt;p&gt;Who have you found (here on Dev.to, or elsewhere) that’s good at explaining? What is it that you like about their explanations?&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Converting from Notational Velocity to GitHub's Atom</title>
   <link href="https://donald.merand.org//code/2014/12/08/converting-from-notational-velocity-to-githubs-atom.html"/>
   <updated>2014-12-08T00:00:00-05:00</updated>
   <id>https://donald.merand.org/code/2014/12/08/converting-from-notational-velocity-to-githubs-atom</id>
   <content type="html">&lt;p&gt;I used Notational Velocity (the &lt;a href=&quot;https://brettterpstra.com/projects/nvalt/&quot;&gt;nvALT fork&lt;/a&gt;), writing the notes in Markdown and synching them via Dropbox/Google Drive, for 3-4 years. I’ve recently made the switch to GitHub’s &lt;a href=&quot;https://atom.io&quot;&gt;Atom&lt;/a&gt; for note-taking, because a) I was concerned about the lack of development on the Notational projects and b) I wanted a few customizations to the user experience without having to hack the source and re-compile that project etc. Atom seems like a much more extensible editor, so I’m trying it on the theory that I can make it very Notational-like. It’s been working very well for the way I use it for about a month now.&lt;/p&gt;

&lt;p&gt;Here are some of the things I do to make it more NV-like / use it like I used NV:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Used &lt;a href=&quot;https://www.macosxautomation.com/services/learn/tut01/index.html&quot;&gt;an OS X service keyboard shortcut&lt;/a&gt; to make the application launch with a hotkey. This was my favorite part of NV and Atom lacks it as a built-in option. I like this approach because I can use it for other apps, and I don’t need to install any third-party software to make it work.&lt;/li&gt;
  &lt;li&gt;I still keep all of my notes in one single folder, like NV did. This aids sync, and makes it so I can do a ⌘-Shift-F to do a text search of all notes, similar to the “omnibar search” of NV.&lt;/li&gt;
  &lt;li&gt;For simpler note reference, or where I already know the note title, I use the ⌘-T keyboard shortcut to call up the “file opener” dialog window.&lt;/li&gt;
  &lt;li&gt;If you want the “notes list” like you had in NV, you can use the ⌘-\ or ⌘-Shift-\ keyboard shortcut to show the “Tree View”, which is pretty similar, especially if (like me) you had the notes list on the left in NV.&lt;/li&gt;
  &lt;li&gt;I also made some stylesheet changes so that my text editing is always centered in the pane, and the line numbering in the left gutter is right-justified:&lt;/li&gt;
&lt;/ul&gt;

&lt;script src=&quot;https://gist.github.com/dmerand/fbc93057ade43e2165d7.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;Here are some other things that I can do now that I couldn’t in NV:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/atom/vim-mode&quot;&gt;VIM Mode&lt;/a&gt;. Yay for using VIM shortcuts in my note-taking app! YMMV. I also installed a plugin that lets me open files in VIM for when the VIM mode plugin doesn’t cut it (regex search/replace comes to mind)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/travs/markdown-pdf&quot;&gt;Markdown PDF Export&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://ethanschoonover.com/solarized&quot;&gt;Solarized&lt;/a&gt; color scheme, both for editing and UI. I had to hack NV to make this work.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hopefully some of that info is helpful to those of you considering making the switch.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Batch Convert Doc Files to Text in OS X</title>
   <link href="https://donald.merand.org//code/2014/12/03/batch-convert-doc-files-to-text-in-osx.html"/>
   <updated>2014-12-03T00:00:00-05:00</updated>
   <id>https://donald.merand.org/code/2014/12/03/batch-convert-doc-files-to-text-in-osx</id>
   <content type="html">&lt;h1 id=&quot;oh-no-ms-word-batch-conversion&quot;&gt;OH NO MS Word Batch Conversion!&lt;/h1&gt;
&lt;p&gt;I recently had to convert an entire directory of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.doc&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.docx&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.rtf&lt;/code&gt; files into plain text files. If you’ve ready anything else I’ve written here, you’ll have figured out that I’m not a big fan of word processors (&lt;em&gt;especially&lt;/em&gt; MS Word), &lt;a href=&quot;https://donald.merand.org/code/2012/07/20/how-i-actually-convert-dokuwiki-to-latex.html&quot;&gt;opting &lt;/a&gt; &lt;a href=&quot;https://donald.merand.org/code/2011/09/20/tsv-the-best-spreadsheet-format.html&quot;&gt;instead&lt;/a&gt; for the lighter-weight syntax of &lt;a href=&quot;https://daringfireball.net/projects/markdown/syntax&quot;&gt;markdown&lt;/a&gt; and text-based formats in general. I &lt;em&gt;really&lt;/em&gt; wanted to solve this problem without having to resort to opening up a full-blown word processor and converting these files manually. Ideally, I’d be able to make an Automator drop-application that would do the conversion automatically.&lt;/p&gt;

&lt;p&gt;I searched fruitlessly around the internet for a while, trying various Automator and Applescript hacks, searched the App Store, searched the &lt;a href=&quot;https://brew.sh/&quot;&gt;homebrew&lt;/a&gt; repositories, and eventually made my way to Stack Overflow, where I saw &lt;a href=&quot;https://stackoverflow.com/questions/1043768/quickly-convert-rtf-doc-files-to-markdown-syntax-with-php&quot;&gt;this gem&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Get this: if you’ve got an OS X machine, you have a built-in batch text converter than can handle the following formats: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;txt, html, rtf, rtfd, doc, docx, wordml, odt, or webarchive&lt;/code&gt;. That’s right, it can read + write old &lt;em&gt;and&lt;/em&gt; new MS Word documents, as well as a variety of other standbys. It is a command-line utility called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;textutil&lt;/code&gt;, and it is the glorious solution for this one painful job. It has the ability to infer file types based on file content, take files from a directory listing, or from STDIN, and output files concatenated together, batched out individually, or to STDOUT.&lt;/p&gt;

&lt;p&gt;The STDIN/STDOUT capability also means that you can chain it with my &lt;a href=&quot;https://donald.merand.org/code/2012/07/20/how-i-actually-convert-dokuwiki-to-latex.html&quot;&gt;other favorite text converter&lt;/a&gt; &lt;a href=&quot;https://johnmacfarlane.net/pandoc/&quot;&gt;pandoc&lt;/a&gt;. This gives you a mind-blowing toolchain of text file conversion.&lt;/p&gt;

&lt;p&gt;I’ve put together a few sample incantations to do amazing things. Weep with joy at what you can now do. And try not to weep further that it was hidden on your machine since version 10.4.&lt;/p&gt;

&lt;h1 id=&quot;textutil-tips-and-tricks&quot;&gt;Textutil Tips and Tricks&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;Convert a web page to a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FORMAT&lt;/code&gt; document.
  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;curl www.google.com | textutil -stdin -convert FORMAT&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Find all word-type documents and convert them to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FORMAT&lt;/code&gt;
  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;textutil -convert FORMAT *.doc*&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Find all word-type documents and concatenate them into one &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FORMAT&lt;/code&gt; document
  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;textutil -cat FORMAT *.doc*&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Use in combination with &lt;a href=&quot;https://johnmacfarlane.net/pandoc/&quot;&gt;pandoc&lt;/a&gt; to get even more file conversion possibilites (eg markdown to docx).
  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pandoc -f markdown -t html file.markdown | textutil -stdin -convert docx -o file.docx&lt;/code&gt;
    &lt;ul&gt;
      &lt;li&gt;pandoc’s input formats: docbook, docx, epub, haddock, html, json, latex, markdown, markdown_github, markdown_mmd, markdown_phpextra, markdown_strict, mediawiki, native, opml, org, rst, t2t, textile&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Doing One Thing Well with SetGetGo</title>
   <link href="https://donald.merand.org//code/2014/02/28/doing-one-thing-well-with-setgetgo.html"/>
   <updated>2014-02-28T00:00:00-05:00</updated>
   <id>https://donald.merand.org/code/2014/02/28/doing-one-thing-well-with-setgetgo</id>
   <content type="html">&lt;p&gt;&lt;strong&gt;UPDATE (2020.01.26)&lt;/strong&gt;: SetGetGo has been defunct for a while now. I really liked their random word generator though, so I &lt;a href=&quot;https://github.com/exploration/markov_words/&quot;&gt;made a Ruby Gem&lt;/a&gt; to generate English-sounding words, and then &lt;a href=&quot;https://lab.explo.org/password&quot;&gt;an Elm app&lt;/a&gt; to generate passwords with them.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Unix_philosophy#McIlroy:_A_Quarter_Century_of_Unix&quot;&gt;UNIX philosophy&lt;/a&gt; has been a real guiding force in my work with computers:&lt;/p&gt;

&lt;blockquote class=&quot;mv3 ml3 i gray&quot;&gt;
  &lt;p&gt;Write programs that do one thing and do it well. Write programs to work together.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I may have &lt;a href=&quot;http://donald.merand.org/code/2011/09/20/tsv-the-best-spreadsheet-format.html&quot;&gt;alluded&lt;/a&gt; to this &lt;a href=&quot;http://donald.merand.org/code/2012/07/20/how-i-actually-convert-dokuwiki-to-latex.html&quot;&gt;before&lt;/a&gt; without ever explicitly stating it, but the designers of UNIX really had it right. The best programs are the ones that stick to a limited problem domain, but &lt;em&gt;really nail it&lt;/em&gt; within that domain. The worst programs (Microsoft Word comes to mind) try to branch out and solve every problem for everybody, and end up getting in the way of everybody’s workflow with all of their options. In UNIX, you chain simple programs together and they give you immense power.&lt;/p&gt;

&lt;p&gt;A few years back, I came across the &lt;a href=&quot;http://setgetgo.com/&quot;&gt;SetGetGo API&lt;/a&gt;, and only recently noticed how perfect this service is at what it does, and how much I’ve come to rely on it. I use it in two ways: remote variable storage, and random word generation.&lt;/p&gt;

&lt;h2 id=&quot;remote-variable-storage-with-setgetgo&quot;&gt;Remote Variable Storage with SetGetGo&lt;/h2&gt;

&lt;p&gt;This is the most basic usage of the SetGetGo API, and all I did was write a couple of simple command-line wrappers around it called &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/wwwset&quot;&gt;wwwset&lt;/a&gt; and &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/wwwset&quot;&gt;wwwget&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When I’m in the command line, I can call &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wwwset key value&lt;/code&gt; and it sends the key/value pair off to the SetGetGo server for storage. As long as I’m using the same API key, I can retrieve that value from any computer anywhere with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wwwget key&lt;/code&gt;. This has been the building block of many a shell script, and even for use as a temporary scratchpad or for sending values to others.&lt;/p&gt;

&lt;p&gt;Obviously, the caveat of this service is that your data is stored on the SetGetGo servers. If I were to use it for anything serious (I dunno, password storage, say), I’d probably encrypt my values before sending them off. Maybe someday I’ll update the script with GPG hooks for that kind of thing.&lt;/p&gt;

&lt;h2 id=&quot;generating-random-words-with-setgetgo&quot;&gt;Generating Random Words with SetGetGo&lt;/h2&gt;

&lt;p&gt;The makers of SetGetGo also helpfully provide a &lt;a href=&quot;http://randomword.setgetgo.com/&quot;&gt;random word API&lt;/a&gt;. I use these in my work almost every single day. For example, I’ll use them to generate passwords for my users by generating 10 or twenty random words, and picking a few to string together in combination. By using words that aren’t real, and combining at least two or three words together, with spaces, you make a password that is hard to crack against a dictionary, takes too long to crack with brute force, but that is surprisingly simple to remember and type in, especially on a mobile keyboard. I also use random words as my name on social media services where I want to fly more under the radar.&lt;/p&gt;

&lt;p&gt;My implementation of this is similar to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wwwset&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wwwget&lt;/code&gt;. I made a shell script called &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/randomword&quot;&gt;randomword&lt;/a&gt;. You call it with the number of random words you want like this: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;randomword 10&lt;/code&gt;, and it returns the string of them.&lt;/p&gt;

&lt;p&gt;I made another web-based implementation of this for the others in my office who aren’t as apt to open up a &lt;a href=&quot;http://www.iterm2.com/#/section/home&quot;&gt;terminal&lt;/a&gt; as I am. That one is hosted on Explo’s lab; you can visit it &lt;a href=&quot;http://lab.explo.org/randomword&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Simple utilities like these really ease along the workday for information workers. You might not use it for 3 months, but when you do it’s really handy to have it in your back pocket. That’s what coding is all about!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Music - Latif Learned - The Big Finish</title>
   <link href="https://donald.merand.org//projects/2012/09/23/music-latif-learned-the-big-finish.html"/>
   <updated>2012-09-23T00:00:00-04:00</updated>
   <id>https://donald.merand.org/projects/2012/09/23/music-latif-learned-the-big-finish</id>
   <content type="html">&lt;p&gt;The final album that I recorded as Latif Learned was called The Big Finish. I wrote and recorded it in a month in February 2007 as part of the &lt;a href=&quot;http://rpmchallenge.com/index.php?option=com_comprofiler&amp;amp;task=userProfile&amp;amp;user=690&amp;amp;Itemid=296&quot;&gt;RPM Challenge&lt;/a&gt;. The album is aptly named since I decided to “retire” the Latif Learned persona after 2007.&lt;/p&gt;

&lt;p&gt;I’m making the songs available for download here – you can’t do that over on the RPM site.&lt;/p&gt;

&lt;h2 id=&quot;latif-learned---the-big-finish&quot;&gt;Latif Learned - The Big Finish&lt;/h2&gt;

&lt;p&gt;Download the entire album as a compressed ZIP archive &lt;a href=&quot;http://embed.merand.org/ll/ll-the-big-finish.zip&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Why Ought I To&lt;/li&gt;
  &lt;li&gt;No Cause for Alarm&lt;/li&gt;
  &lt;li&gt;Nantucket&lt;/li&gt;
  &lt;li&gt;Death of a Salesman&lt;/li&gt;
  &lt;li&gt;Think&lt;/li&gt;
  &lt;li&gt;The Great Decline&lt;/li&gt;
  &lt;li&gt;Commuter Rail&lt;/li&gt;
  &lt;li&gt;Nantucket (Reprise)&lt;/li&gt;
  &lt;li&gt;The Finish Line&lt;/li&gt;
  &lt;li&gt;Big Peepers&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>How I Actually Convert Dokuwiki to LaTeX</title>
   <link href="https://donald.merand.org//code/2012/07/20/how-i-actually-convert-dokuwiki-to-latex.html"/>
   <updated>2012-07-20T00:00:00-04:00</updated>
   <id>https://donald.merand.org/code/2012/07/20/how-i-actually-convert-dokuwiki-to-latex</id>
   <content type="html">&lt;p&gt;I &lt;a href=&quot;http://donald.merand.org/code/2011/07/18/dokuwiki-to-latex-converter.html&quot;&gt;wrote an article&lt;/a&gt; a while back about a utility that I wrote to convert &lt;a href=&quot;http://dokuwiki.org&quot;&gt;DokuWiki&lt;/a&gt; files into &lt;a href=&quot;http://www.latex-project.org&quot;&gt;LaTeX&lt;/a&gt; files. I’ve noticed that a lot of the web traffic that I get is about this topic, so I thought I’d write a followup post to describe my new improved dokuwiki conversion method.&lt;/p&gt;

&lt;p&gt;The disadvantage of my &lt;a href=&quot;https://gist.github.com/2414353&quot;&gt;old utility&lt;/a&gt; is mainly that it is incomplete - it doesn’t catch all of the syntax that DokuWiki supports. This is partly because I wrote it as an exercise in writing Awk/Sed code (regular expressions - so hot right now), and partly because at the time that I wrote it I didn’t need any fancy features like tables, etc. The other disadvantage of that code is that in &lt;em&gt;only&lt;/em&gt; converts to &lt;a href=&quot;http://www.latex-project.org&quot;&gt;LaTeX&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I used to write my personal notes in &lt;a href=&quot;http://dokuwiki.org&quot;&gt;DokuWiki&lt;/a&gt; format using &lt;a href=&quot;http://notational.net&quot;&gt;Notational Velocity&lt;/a&gt;. But then I learned about &lt;a href=&quot;http://daringfireball.net/projects/markdown&quot;&gt;Markdown&lt;/a&gt; and &lt;a href=&quot;http://donald.merand.org/code/2011/09/20/tsv-the-best-spreadsheet-format.html&quot;&gt;became enamored of that syntax&lt;/a&gt;, so now I write my notes in &lt;a href=&quot;http://daringfireball.net/projects/markdown&quot;&gt;Markdown&lt;/a&gt; instead. The reason I bring this up is that my needs shifted once I started using Markdown, and I wanted a more general-purpose way to convert my &lt;a href=&quot;http://daringfireball.net/projects/markdown&quot;&gt;Markdown&lt;/a&gt; notes into LaTeX, but also HTML, Textile, whatever the situation calls for. Enter &lt;a href=&quot;http://johnmacfarlane.net/pandoc&quot;&gt;Pandoc&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let me take a moment to talk about how awesome &lt;a href=&quot;http://johnmacfarlane.net/pandoc&quot;&gt;Pandoc&lt;/a&gt; is. I don’t know what you’re doing right now, but if you use &lt;a href=&quot;http://daringfireball.net/projects/markdown&quot;&gt;Markdown&lt;/a&gt;, you need to have &lt;a href=&quot;http://johnmacfarlane.net/pandoc&quot;&gt;Pandoc&lt;/a&gt; installed. It will convert &lt;em&gt;all of the formats&lt;/em&gt;, to and from each other. Markdown to LaTeX? No problem. Textile to HTML? HTML to epub? Whatever. It is amazing. Except it doesn’t support DokuWiki.&lt;/p&gt;

&lt;p&gt;However, knowing what I now know about &lt;a href=&quot;http://johnmacfarlane.net/pandoc&quot;&gt;Pandoc&lt;/a&gt;, I realized that all I really need is to be able to convert &lt;a href=&quot;http://dokuwiki.org&quot;&gt;DokuWiki&lt;/a&gt; to HTML, and I could then feed that structured HTML into &lt;a href=&quot;http://johnmacfarlane.net/pandoc&quot;&gt;Pandoc&lt;/a&gt; to convert &lt;a href=&quot;http://dokuwiki.org&quot;&gt;DokuWiki&lt;/a&gt; syntax into any other format, including, yes, LaTeX. Fortunately for me, DokuWiki does all of the hard work, since converting DokuWiki syntax into HTML is, you know, precisely what the whole thing is designed to do. So what I needed is merely a way to access DokuWiki’s syntax conversion from the command line. Here’s how I do it:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Install &lt;a href=&quot;http://johnmacfarlane.net/pandoc&quot;&gt;Pandoc&lt;/a&gt; following whichever instructions suit your fancy on John McFarlane’s site.&lt;/li&gt;
  &lt;li&gt;Install an empty copy of &lt;a href=&quot;http://dokuwiki.org&quot;&gt;DokuWiki&lt;/a&gt; that you will use merely as a syntax converter.&lt;/li&gt;
  &lt;li&gt;Download the &lt;a href=&quot;http://www.dokuwiki.org/tips:dokuwiki_parser_cli&quot;&gt;DokuWiki CLI Utility&lt;/a&gt;, which I have handily found for you.&lt;/li&gt;
  &lt;li&gt;Download my script, called &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/doku2html&quot;&gt;doku2html&lt;/a&gt;. This script (you’ll notice from looking at the line that says &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;phpcli=~/.bin/lib/dokuwiki/bin/dokucli.php&lt;/code&gt;) assumes that you’ve installed your DokuWiki installation into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.bin/lib/dokuwiki/&lt;/code&gt; and the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dokucli.php&lt;/code&gt; file into the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/bin/&lt;/code&gt; folder of your DokuWiki installation.&lt;/li&gt;
  &lt;li&gt;Put that script into your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$PATH&lt;/code&gt;, and you’ll be able to say &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;doku2html FILE&lt;/code&gt;, or even just run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;doku2html&lt;/code&gt; on Standard Input, and get HTML as the output.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I wrote &lt;em&gt;another script&lt;/em&gt; called &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/doku2md&quot;&gt;doku2md&lt;/a&gt;, which illustrates how you might convert &lt;a href=&quot;http://dokuwiki.org&quot;&gt;DokuWiki&lt;/a&gt; to &lt;a href=&quot;http://daringfireball.net/projects/markdown&quot;&gt;Markdown&lt;/a&gt; using a system script. Modifying this script for &lt;a href=&quot;http://www.latex-project.org&quot;&gt;LaTeX&lt;/a&gt; is pretty trivial.&lt;/p&gt;

&lt;p&gt;In practice, I usually use a command like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;doku2html FILE | pandoc -f html -s -t latex&lt;/code&gt; to create a &lt;a href=&quot;http://www.latex-project.org&quot;&gt;LaTeX&lt;/a&gt; document from a &lt;a href=&quot;http://dokuwiki.org&quot;&gt;DokuWiki&lt;/a&gt; file. Then if I want to get &lt;em&gt;really&lt;/em&gt; fancy and make a PDF straight from my &lt;a href=&quot;http://www.latex-project.org&quot;&gt;LaTeX&lt;/a&gt; file I will pipe that over to my &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/pdl&quot;&gt;pdl&lt;/a&gt; (PDFLaTex) utility which expects a LaTeX file or pipe, and passes it to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xelatex&lt;/code&gt; and makes a PDF, and then opens it up in Preview (on OSX).&lt;/p&gt;

&lt;p&gt;So easy, right? Well, it’s easier than converting by hand.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>More Music of Mine - Latif Learned - Little Ruins</title>
   <link href="https://donald.merand.org//projects/2012/07/19/more-music-of-mine-latif-learned-little-ruins.html"/>
   <updated>2012-07-19T00:00:00-04:00</updated>
   <id>https://donald.merand.org/projects/2012/07/19/more-music-of-mine-latif-learned-little-ruins</id>
   <content type="html">&lt;p&gt;&lt;em&gt;Little Ruins&lt;/em&gt; is an album that I wrote and recorded in 2006, in Upstate New York, Montpelier, France, and Boston, MA. I wrote it under the moniker “Latif Learned”, which strangely enough is an actual way to interpret my real name.&lt;/p&gt;

&lt;p&gt;In spite of my lengthy previous post about the “Demo” and “Conversations” EP, I’m not going to write much about these songs. I alluded to this in the last post, but I think it’s generally best if you come to your own conclusions without my biases operating on you.&lt;/p&gt;

&lt;p&gt;I hope you enjoy it, and feel free to share it. I’ve decided to release the album under a &lt;a href=&quot;https://creativecommons.org&quot;&gt;Creative Commons&lt;/a&gt; license. Details at the bottom of the page.&lt;/p&gt;

&lt;p&gt;Download the entire album as one compressed ZIP file &lt;a href=&quot;https://embed.merand.org/ll/ll-little-ruins.zip&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/1342710016/01-Something-Close-to-Happy.mp3&quot;&gt;Something Close to Happy&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/1342709986/02-Moans.mp3&quot;&gt;Moans&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/1342710342/03-Alone-Together.mp3&quot;&gt;Alone, Together&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/1342710396/04-QuestionMark.mp3&quot;&gt;?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/1342710466/05-A-Minor-Victory.mp3&quot;&gt;A Minor Victory&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/1342710543/06-Carrier.mp3&quot;&gt;Carrier&lt;/a&gt; – This one was &lt;a href=&quot;https://www.npr.org/templates/story/story.php?storyId=5298286&quot;&gt;featured on NPR&lt;/a&gt; at one point.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/1342710671/07-Give.mp3&quot;&gt;Give&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/1342710725/08-As-if-You&apos;d-Wanted-to.mp3&quot;&gt;As If You’d Wanted To&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/1342710991/09-This-Song.mp3&quot;&gt;This Song&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/1342712345/10-Memory.mp3&quot;&gt;Memory&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/1342711871/11-Little-Ruins.mp3&quot;&gt;Little Ruins&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;(right-click the links to save them to your computer)&lt;/em&gt;.&lt;/p&gt;

&lt;h2 id=&quot;license&quot;&gt;License&lt;/h2&gt;

&lt;p&gt;&lt;a rel=&quot;license&quot; href=&quot;https://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US&quot;&gt;&lt;img alt=&quot;Creative Commons License&quot; src=&quot;https://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png&quot; class=&quot;left pad-right&quot; /&gt;&lt;/a&gt;
Little Ruins by &amp;lt;a xmlns:cc=”https://creativecommons.org/ns#” href=”https://donald.merand.org/a&amp;gt; is licensed under a &lt;a rel=&quot;license&quot; href=&quot;https://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US&quot;&gt;Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Music - The Latif Learned "Conversations" EP and "Demo" EP</title>
   <link href="https://donald.merand.org//projects/2012/07/12/music-the-latif-learned-conversations-ep-and-demo-ep.html"/>
   <updated>2012-07-12T00:00:00-04:00</updated>
   <id>https://donald.merand.org/projects/2012/07/12/music-the-latif-learned-conversations-ep-and-demo-ep</id>
   <content type="html">&lt;p&gt;I’ve got a pile of songs that I wrote as Latif Learned sitting on my hard drive, which have never seen the light of the internet. Sometimes I go back and listen to them and enjoy them (and I hope you do too). Other times I start playing one and have to turn it off because I’m so embarrased, usually about the lyrics. Since I’ve let go of my ambitions as famous/sad/yet strangely alluring singer/songwriter, I think it’s time to get over my embarrasment at the blemishes and just put these songs out there for posterity.&lt;/p&gt;

&lt;p&gt;I’ll write a brief description of the song if I can remember what was going on when I wrote it. These songs were originally grouped into two albums: “Demo” and “Conversations”. “Demo” was just my catch-all for songs-that-are-pretty-good-but-don’t-have-an-album, and “Conversations” was sort of an EP, mostly instrumental/electric stuff.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(right-click the links to save them to your computer)&lt;/em&gt;.&lt;/p&gt;

&lt;h1 id=&quot;the-demo-ep&quot;&gt;The “Demo” EP&lt;/h1&gt;

&lt;p&gt;Download the entire EP as one compressed ZIP file &lt;a href=&quot;https://embed.merand.org/ll/ll-demo.zip&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;dream&quot;&gt;Dream&lt;/h2&gt;
&lt;p&gt;Listen/download &lt;a href=&quot;https://embed.merand.org/1342053957/Dream.mp3&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;strike&gt;This song is quite literal. I actually had a dream just like the one described in the song. I seem to recall that I woke up and immediately wrote the song, and recorded it the same day. I was listening to a lot of Mark Kozelek (Sun Kil Moon/Red House Painters) when I wrote and recorded it - can you tell?&lt;/strike&gt;

&lt;p&gt;**Update: ** My partner tells me it went like this (from chat):&lt;/p&gt;

&lt;div class=&quot;language-plaintext mv3 highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;we talked about our flying dreams and how we both had them and how awesome
they were, the first time we hung out

and we also talked about other recurrent dreams we had

and one of mine is defending someone i care about against some kind of
horrific attack

hence the second verse

you went home and wrote the song.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Her memory is much better than mine, and I &lt;strike&gt;feel like&lt;/strike&gt; am a real jerk for not remembering that this happened. Anyhow, this song was inspired by my lovely partner-for-life, and her somewhat disturbing dreams!&lt;/p&gt;

&lt;h2 id=&quot;my-red-shirt&quot;&gt;My Red Shirt&lt;/h2&gt;

&lt;p&gt;Listen/download &lt;a href=&quot;https://embed.merand.org/1342054474/my-red-shirt.mp3&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I remember that I wrote this somewhere in late 2005 - my first year in Boston. It’s mostly about being socially awkward and confused all of the time. It’s probably the most pop-like tune that I’ve ever written - conventional chord changes and guitar solos, no strange meter, no dissonant harmonies. I think I like it more now than I did then, because I’ve come to terms with the pop vernacular in a way that I wasn’t able to do when I was in/just out of music school.&lt;/p&gt;

&lt;h2 id=&quot;not-myself&quot;&gt;Not Myself&lt;/h2&gt;
&lt;p&gt;Listen/download &lt;a href=&quot;https://embed.merand.org/1342054630/not-myself.mp3&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I woke up with the melody of this song fully developed from a dream, and an idea that it should be a song about existential doubt. Existential doubt was kind of my big thing in 2005 - I just moved to the big city, was living alone and supporting myself for the first time. I had my first full-time job, no school, and only a couple of friends in town. So I had lots of time to doubt myself and have panic attacks and write song.&lt;/p&gt;

&lt;p&gt;So I woke up with the melody of this song in my head, and also had a certainty that it needed an upright bass. My roomate had an upright bass, but he wasn’t around. So I spent the morning learning how to play his upright bass well enough to record the bassline for this song. I had the whole recording finished by noon. When I played it for my friend Megan, she said “this is going to have a guitar solo now isn’t it?” right about the time that the guitar solo happened. What can I say - sometimes the guitar solo is the only way.&lt;/p&gt;

&lt;h2 id=&quot;fond-but-not-in-love&quot;&gt;Fond But Not In Love&lt;/h2&gt;

&lt;p&gt;Listen/downlaod &lt;a href=&quot;https://embed.merand.org/1342054248/fond-but-not-in-love.mp3&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s a song about wanting somebody to like you, and then wishing you hadn’t wanted that.&lt;/p&gt;

&lt;h2 id=&quot;force-of-habit&quot;&gt;Force of Habit&lt;/h2&gt;
&lt;p&gt;Listen/download &lt;a href=&quot;https://embed.merand.org/1342054466/force-of-habit.mp3&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have no idea when or why I wrote this song. It’s not my favorite, but it exists, so here you go.&lt;/p&gt;

&lt;h1 id=&quot;the-conversations-ep&quot;&gt;The “Conversations” EP&lt;/h1&gt;

&lt;p&gt;Download the entire EP as one compressed ZIP file &lt;a href=&quot;https://embed.merand.org/ll/ll-conversations.zip&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;seewantlikeneed&quot;&gt;See/Want/Like/Need&lt;/h2&gt;

&lt;p&gt;Listen/download &lt;a href=&quot;https://embed.merand.org/1342054678/see-want-like-need.mp3&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a re-make of a song that originally appeared on &lt;a href=&quot;https://donald.merand.org/projects/2011/08/16/album-exploration-slideshow.html&quot;&gt;Exploration Slideshow&lt;/a&gt;, except with more electric guitars and the vocals forward instead of backward.&lt;/p&gt;

&lt;h2 id=&quot;for-sara&quot;&gt;For Sara&lt;/h2&gt;

&lt;p&gt;Listen/download &lt;a href=&quot;https://embed.merand.org/1342054268/for-sara.mp3&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is an instrumental song that I wrote for the woman who would eventually become my wife. I don’t think it was on the strength of this song – it must have been my incredible charm and charisma, and the fact that she didn’t listen too closely to the lyrics of all my songs about failed relationships and longing. On the plus side, I haven’t had any failed relationships since I met her!&lt;/p&gt;

&lt;h2 id=&quot;moment&quot;&gt;Moment&lt;/h2&gt;

&lt;p&gt;Listen/download &lt;a href=&quot;https://embed.merand.org/1342028322/moment.mp3&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All songs are a reflection of how the songwriter felt in the moment that they wrote the song. I think it’s important not to spend too long writing songs for this reason - you can end up with a conflicting message, which translates poorly to the recipient/audience.&lt;/p&gt;

&lt;h2 id=&quot;alone-with-trains&quot;&gt;Alone with Trains&lt;/h2&gt;

&lt;p&gt;Listen/download &lt;a href=&quot;https://embed.merand.org/1342054104/alone-with-trains.mp3&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instrumental tracks really shouldn’t have titles, since one you’ve named something you can’t help but influence the imagery that happens in the listener’s mind. I should call all of my instrumental tracks “untitled”, but what can I say? I have to feel like I have some semblance of control over things, and I’ll use the black magic of language to do so if I have to. Someday, all of my songs will be “untitled”, and you’ll know that I’ve reached enlightenment, or at least peace, at that time.&lt;/p&gt;

&lt;h2 id=&quot;anysayer&quot;&gt;Anysayer&lt;/h2&gt;

&lt;p&gt;Listen/download &lt;a href=&quot;https://embed.merand.org/1342054099/anysayer.mp3&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An anysayer is the opposite of a naysayer. Get it?&lt;/p&gt;

&lt;h1 id=&quot;license&quot;&gt;License&lt;/h1&gt;
&lt;hr /&gt;

&lt;p&gt;&lt;a rel=&quot;license&quot; href=&quot;https://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US&quot;&gt;&lt;img alt=&quot;Creative Commons License&quot; src=&quot;https://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png&quot; class=&quot;left pad-right&quot; /&gt;&lt;/a&gt;
The “Conversations” and “Demo” EPs by &amp;lt;a xmlns:cc=”https://creativecommons.org/ns#” href=”https://donald.merand.org/a&amp;gt; are licensed under a &lt;a rel=&quot;license&quot; href=&quot;https://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US&quot;&gt;Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>I Made Some HipChat Utilities</title>
   <link href="https://donald.merand.org//code/2012/06/02/i-made-some-hipchat-utilities.html"/>
   <updated>2012-06-02T00:00:00-04:00</updated>
   <id>https://donald.merand.org/code/2012/06/02/i-made-some-hipchat-utilities</id>
   <content type="html">&lt;p&gt;We recently converted to &lt;a href=&quot;https://hipchat.com&quot; title=&quot;Chat it up real nice&quot;&gt;HipChat&lt;/a&gt; at one of my jobs. Because we’re geographically distributed, we need a solid chat client to handle our internal discussions. We landed on HipChat after trying a bunch of others such as CampFire, Skype, GChat/IM. The thing is, it’s not any one feature that makes it killer for getting things done. It’s the combination of &lt;em&gt;all the things&lt;/em&gt;, and how well they all work together.&lt;/p&gt;

&lt;p&gt;For example, when you upload a file it’s stored at Amazon (S3), and is available forever, no matter what your client. That is rad. There are clients for any conceivable device, especially considering that there’s XMPP/Jabber integration, so you could even use your favorite chat client to connect in that way. As a bonus, the search is good, which you’d expect except that all other clients have non-existent or crappy search. That’s just a few examples, but in short there are no barriers to getting in contact with people and sharing stuff, which makes it ideal for distributed teams.&lt;/p&gt;

&lt;p&gt;Also, there’s a API for it, which I love. I love it so much that I wrote &lt;em&gt;two&lt;/em&gt; different interfaces to it. I wrote &lt;a href=&quot;https://github.com/dmerand/FMHipChat&quot; title=&quot;FMHipChat - Post to HipChat from FileMaker!&quot;&gt;FMHipChat&lt;/a&gt; for posting from FileMaker, and I wrote a &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/hipchat&quot; title=&quot;HipChat from the CLI&quot;&gt;HipChat CLI&lt;/a&gt; (command line) client as well, mostly because I didn’t notice that &lt;a href=&quot;https://github.com/hipchat/hipchat-cli&quot;&gt;there already was one&lt;/a&gt;.&lt;/p&gt;

&lt;h1 id=&quot;fmhipchat&quot;&gt;FMHipChat&lt;/h1&gt;

&lt;p&gt;Yeah, so I made a utility for posting messages to HipChat from FileMaker. It’s called &lt;a href=&quot;https://github.com/dmerand/FMHipChat&quot; title=&quot;FMHipChat - Post to HipChat from FileMaker!&quot;&gt;FMHipChat&lt;/a&gt; and you can find it on my &lt;a href=&quot;https://github.com/dmerand/&quot; title=&quot;Donald Merand on GitHub - epic.&quot;&gt;GitHub&lt;/a&gt; page. The super, awesome, amazing thing about it is that it is cross-platform, and should even work from FileMaker Go! I managed to do cross-platform POST to the API by using a webviewer that constructs a dynamic HTML form, then posts it automatically via javascript. It’s a technique that’s worth a look, though slow. I also included an alternate, OSX-only version that uses CURL, master of the URLs, to do API calls, and it’s fast as can be.&lt;/p&gt;

&lt;p&gt;There are some caveats to using the file, such as the fact that you have to get an API key, and import your group’s rooms before the thing works. But, you know, there &lt;em&gt;are&lt;/em&gt; instructions on how to do that.&lt;/p&gt;

&lt;p&gt;I imagine using it mainly as a notifier for the end of long script runs, but let me know if you’ve got some novel use..&lt;/p&gt;

&lt;h1 id=&quot;hipchat-cli&quot;&gt;HipChat CLI&lt;/h1&gt;

&lt;p&gt;If you’re like me (got this far? you’re probably like me.), then you probably wanna post to HipChat from some shell scripts every now and then. Say a CRON job that runs an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fmsadmin&lt;/code&gt; task, or something like that. So I cooked up a &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/hipchat&quot; title=&quot;HipChat from the CLI&quot;&gt;real nice client&lt;/a&gt; for that as well.&lt;/p&gt;

&lt;p&gt;Similar caveats to FMHipChat apply - you need an API token, and you have to modify the script to use it.&lt;/p&gt;

&lt;p&gt;Usage is pretty simple - type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hipchat -h&lt;/code&gt; for options.&lt;/p&gt;

&lt;p&gt;By the way, while you’re at &lt;a href=&quot;https://github.com/dmerand/&quot; title=&quot;Donald Merand on GitHub - epic.&quot;&gt;GitHub&lt;/a&gt; check out some of the &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin&quot;&gt;other shell scripts&lt;/a&gt; I wrote that I use from time to time.&lt;/p&gt;

&lt;p&gt;Thanks for reading, and happy HipChatting.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>My Own Personal Embed Server</title>
   <link href="https://donald.merand.org//code/2012/05/27/my-own-personal-embed-server.html"/>
   <updated>2012-05-27T00:00:00-04:00</updated>
   <id>https://donald.merand.org/code/2012/05/27/my-own-personal-embed-server</id>
   <content type="html">&lt;p&gt;I’ve stopped hosting this site on my own webserver, and moved to &lt;a href=&quot;https://github.com&quot;&gt;Github’s&lt;/a&gt; &lt;a href=&quot;http://pages.github.com/&quot;&gt;Pages&lt;/a&gt; using &lt;a href=&quot;https://github.com/mojombo/jekyll&quot;&gt;Jekyll&lt;/a&gt;, and I couldn’t be happier. I don’t have to worry about the 1KB/month in bandwidth of people reading the site, load times are fast, and deployment is dead simple. I love the static site concept, and am very grateful to Github for being magnanimous enough to host all of us hacker types’ personal web pages using their totally rad system.&lt;/p&gt;

&lt;p&gt;I do have one problem though: what if I want to host big files, or media files, the kind that you don’t exactly want in a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git&lt;/code&gt; repository? For example, &lt;a href=&quot;http://donald.merand.org/projects/2011/08/16/album-exploration-slideshow.html&quot;&gt;entire albums of mp3s&lt;/a&gt; or &lt;a href=&quot;http://donald.merand.org/art/2011/12/04/old-drawings.html&quot;&gt;a bunch of images&lt;/a&gt;? Naturally, I could use one of the zillion “cloud” providers of file storage (eg. Dropbox, Photobucket, Imgur, Soundcloud, etc.), and indeed I do use &lt;a href=&quot;http://www.flickr.com/photos/79212667@N07/&quot;&gt;Flickr&lt;/a&gt; to host my photos. But in general, I don’t trust/don’t want to pay for cloud providers, and I also want a little bit more control over how/where my files are being stored.&lt;/p&gt;

&lt;p&gt;The simplest thing to do would be this: upload files to my existing webserver by hand, put them in custom folders, and link to those files using manual URLs when I’m writing blog posts. But I write programs for a living, I can do something better than that! Right in the middle of writing a post, I want to be able to quickly upload a file to &lt;em&gt;my&lt;/em&gt; webserver, and get the URL for that file back, paste that URL into my blog post and continue right on writing. Low friction - it’s the only kind of friction I can handle when I’m working. When things get in my way I have a bad habit of moving on to something more fun or (worse) avoiding the difficult/boring thing completely.&lt;/p&gt;

&lt;h1 id=&quot;so-i-wrote-it&quot;&gt;So I Wrote It…&lt;/h1&gt;

&lt;p&gt;I figure that all I need are two things:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;A web-side script which can take files via POST, put them into folders, and return the URL of the file on the server.&lt;/li&gt;
  &lt;li&gt;A client-side script which I can use to pass files to my webscript.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;… So I wrote it. I wrote it in PHP, which is still the easiest for droppin’ on webservers and having it just work. I posted the code &lt;a href=&quot;https://github.com/dmerand/post_file&quot;&gt;right here&lt;/a&gt;, so go and clone it!&lt;/p&gt;

&lt;h1 id=&quot;usage&quot;&gt;Usage&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;Put the entire &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;public/&lt;/code&gt; directory somewhere on your server.&lt;/li&gt;
  &lt;li&gt;Then, use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;post_file.sh&lt;/code&gt; script like this:
    &lt;ul&gt;
      &lt;li&gt;Modify the script to point to your server, with your username etc, and your security token (see below).&lt;/li&gt;
      &lt;li&gt;Type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sh post_file.sh file_name&lt;/code&gt; in &lt;a href=&quot;http://www.iterm2.com/&quot;&gt;your favorite terminal program&lt;/a&gt;.&lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;You should get a link like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://your.site/1338166636/your_file&lt;/code&gt;&lt;/p&gt;

        &lt;ul&gt;
          &lt;li&gt;The directory before your file is the UNIX timestamp of when you uploaded the file. The thinking is that you might want to upload the same file twice, so you want each file to be located in its own unique directory.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Take that link and paste it wherever you need it.&lt;/li&gt;
      &lt;li&gt;If you need/want to delete that uploaded file for whatever reason, use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sh post_file.sh 1338166636&lt;/code&gt;. More on this below.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;The ability to delete files via the “api” becomes necessary on shared hosts (such as mine) where the web user and the SSH user don’t have the same privileges. You upload a file, but then you can’t delete it when you’re logged on to the webserver since the ‘www’ user (or some such) is the owner! To get around this, I modified the PHP script to accept HTTP DELETE requests as well. That’s like web 3.0 right there. You still need a token though.&lt;/li&gt;
  &lt;li&gt;Security is handled two different ways. One, there is an API “token” that you need for the PHP script to do anything. I recommend changing the default. Two, I’ve enabled HTTP Basic Authentication and built that into the scripts. So, when cloning the files be sure to change both the API token, and to add a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.htaccess&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.passwd&lt;/code&gt; file to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;public&lt;/code&gt; directory if you want to use HTTP authentication (I’ve omitted mine from the repository to make it four seconds harder for you to figure out the information contained in them).&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;notes&quot;&gt;Notes&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;I found out the hard way that my webserver has an upload filesize limit. If you’re in the same situation as me, you may need to update your php.ini files, or .htaccess, or the PHP files themselves, in order to get around this. I found &lt;a href=&quot;http://www.php.net/manual/en/features.file-upload.php#107406&quot;&gt;this post&lt;/a&gt; to be pretty helpful in that regard.&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Rakefiles, Face Merging, and Where's the Missing HTML?</title>
   <link href="https://donald.merand.org//code/2012/05/13/rakefiles-face-merging-and-wheres-the-missing-html.html"/>
   <updated>2012-05-13T00:00:00-04:00</updated>
   <id>https://donald.merand.org/code/2012/05/13/rakefiles-face-merging-and-wheres-the-missing-html</id>
   <content type="html">&lt;h2 id=&quot;face-merging&quot;&gt;Face Merging&lt;/h2&gt;

&lt;p&gt;At &lt;a href=&quot;https://www.explo.org&quot;&gt;Explo&lt;/a&gt;, we take an ID photograph for each student and faculty member when they show up. We take the photos with a mobile device, and within a day they get a lanyard with their photo ID, which they have to carry around all summer. It’s nice when you’ve got 3000 students across three campuses, running field trips all over New England and beyond, to be able to tell who is associated with Explo and who isn’t.&lt;/p&gt;

&lt;p&gt;Recently I had the idea: we’ve got these 3000 photo IDs, what does the “average” Explo person look like? I did a quick search online for things like “face morph”, “merge faces”, etc, and you’d be surprised at the proliferation of &lt;a href=&quot;https://www.mergingfaces.com/Index.php&quot;&gt;hideously&lt;/a&gt; &lt;a href=&quot;https://www.morphthing.com/&quot;&gt;designed&lt;/a&gt; sites claiming to do this. Most of them allow you to merge two different photographs together. None of them allow uploading of 3000 images :)&lt;/p&gt;

&lt;p&gt;I don’t have the time to create a solution which does &lt;a href=&quot;https://www.faceresearch.org/demos/average&quot;&gt;facial geography mapping&lt;/a&gt; and morphs each image into another face, so I figured an approach more like &lt;a href=&quot;https://www.faceresearch.org/tech/prototyping&quot;&gt;Francis Galton’s&lt;/a&gt; “multiple exposure” method from the 1800s, except using computers, would be the ticket. Now I love me some &lt;a href=&quot;https://imagemagick.org&quot;&gt;ImageMagick&lt;/a&gt; and &lt;a href=&quot;https://tldp.org/LDP/abs/html/&quot;&gt;BASH scripting&lt;/a&gt;, so I figured I could probably do this that way.&lt;/p&gt;

&lt;p&gt;I knew I had to present the results in a better way than just emailing a photo to my coworkers, so &lt;a href=&quot;https://www.explo.org/facesofexplo&quot;&gt;I made a website&lt;/a&gt; to display the results and the process. Go &lt;a href=&quot;https://www.explo.org/facesofexplo&quot;&gt;check it out&lt;/a&gt;. That page also has more about my failed attempts and what’s going on. You can also view the source of the &lt;a href=&quot;https://gist.github.com/2490678&quot;&gt;image merge&lt;/a&gt; script I wrote, and the &lt;a href=&quot;https://github.com/exploration/faces-of-explo&quot;&gt;source for the entire “Faces of Explo” page&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;rakefiles&quot;&gt;Rakefiles&lt;/h2&gt;

&lt;p&gt;“Wait,” you’re asking, “You promised me rakefiles! You promised me HTML!” You’re absolutely right, thanks for hanging in there, I’m getting to that.&lt;/p&gt;

&lt;p&gt;Since creating the web page itself was a relatively trivial process, I thought I’d take the opportunity to try out a couple of new things that had been on my list of cool things I keep reading about on &lt;a href=&quot;https://news.ycombinator.com/&quot;&gt;Hacker News&lt;/a&gt;. One of those things is using a Rakefile to help with development and deployment. For those of you who don’t know what the hell that is, I found &lt;a href=&quot;https://jasonseifer.com/2010/04/06/rake-tutorial&quot;&gt;these&lt;/a&gt; &lt;a href=&quot;https://railscasts.com/episodes/66-custom-rake-tasks&quot;&gt;three&lt;/a&gt; &lt;a href=&quot;https://www.jbarnette.com/2009/08/27/on-rake.html&quot;&gt;articles&lt;/a&gt; to be immensely helpful. In short, you write a file that contains the typical things you’d want to do in whatever software project you’re working on, and you can quickly access them from the shell.&lt;/p&gt;

&lt;p&gt;For example, on this project, I wanted to be able to:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Watch/compile my &lt;a href=&quot;https://jashkenas.github.com/coffee-script/&quot;&gt;CoffeeScript&lt;/a&gt; and &lt;a href=&quot;https://sass-lang.com/&quot;&gt;SCSS&lt;/a&gt; while I was developing without always having to open up two tabs in my terminal and run the watcher routine for both.&lt;/li&gt;
  &lt;li&gt;Compress, strip, interlace, and otherwise prepare any image files for the web.&lt;/li&gt;
  &lt;li&gt;Deploy the entire site using rsync (since this is a static site).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I managed to be able to do all of that. Now I can type things like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rake compile:all&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rake deploy&lt;/code&gt; instead of having to remember the command line incantation every time I just want to make a simple change. &lt;a href=&quot;https://github.com/exploration/faces-of-explo/blob/master/Rakefile&quot;&gt;Here is the rakefile&lt;/a&gt; – I owe much to the rakefile from the &lt;a href=&quot;https://octopress.org/&quot;&gt;Octopress&lt;/a&gt; project, which is a nice thing to behold.&lt;/p&gt;

&lt;h2 id=&quot;wheres-the-missing-html&quot;&gt;Where’s the Missing HTML?&lt;/h2&gt;

&lt;p&gt;Take a look at &lt;a href=&quot;https://github.com/exploration/faces-of-explo/blob/master/public/index.html&quot;&gt;the source for the Faces of Explo index HTML page&lt;/a&gt;. If you write any HTML code at all, a few things will probably stick out for you immediately: “Hey! He’s not closing any of his paragraph tags? Where’s the HTML tag? Where’s the body? WHAT THE HELL IS GOING ON HERE?”&lt;/p&gt;

&lt;p&gt;That’s what I would have thought a week ago looking at the source. That’s before I read &lt;a href=&quot;https://google-styleguide.googlecode.com/svn/trunk/htmlcssguide.xml&quot;&gt;Google’s HTML/CSS StyleGuide&lt;/a&gt;. As it turns out, &lt;a href=&quot;https://google-styleguide.googlecode.com/svn/trunk/htmlcssguide.xml?showone=Optional_tags#Optional_tags&quot;&gt;many HTML tags are optional&lt;/a&gt; in HTML5. Whoa. As they say in the guide,&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;(This approach may require a grace period to be established as a wider guideline as it is significantly different from what web developers are typically taught. For consistency and simplicity reasons it is best served omitting all optional tags, not just a selection.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Why is it that nobody’s talking about this new part of the HTML5 spec? I’ve been reading the cool “learn HTML5” sites, and haven’t seen anything about this. I learned it from a footnote in the Google styleguide: let’s bring this syntax into a wider discussion.&lt;/p&gt;

&lt;p&gt;I’ve found that you can learn a lot from a style guide. Since they are a condensation of all the things that bug people when they read other people’s code, they are a good guideline for how to write good code, even if you don’t necessarily agree with everything they say. I for one am probably not going to use the abbreviated HTML syntax in my bigger public-facing pages just yet, as I’m concerned about it breaking on older browsers, and maybe even breaking tools like &lt;a href=&quot;https://www.modernizr.com/&quot;&gt;Modernizr&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;the-takeaway&quot;&gt;The Takeaway&lt;/h2&gt;

&lt;p&gt;Stay away from doing Google searches for image morphing, use Rakefiles for automating development tasks, and read other people’s style guides - you might learn something fascinating! Thanks for reading.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;a href=&quot;https://lab.explo.org/facesofexplo&quot; target=&quot;_blank&quot;&gt;
  &lt;img src=&quot;https://lab.explo.org/facesofexplo/assets/images/1/1.jpg&quot; width=&quot;480px&quot; /&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;
</content>
 </entry>
 
 <entry>
   <title>How to Convert a Spreadsheet Into a DokuWiki Table</title>
   <link href="https://donald.merand.org//code/2012/05/08/convert-a-spreadsheet-to-dokuwiki-format.html"/>
   <updated>2012-05-08T00:00:00-04:00</updated>
   <id>https://donald.merand.org/code/2012/05/08/convert-a-spreadsheet-to-dokuwiki-format</id>
   <content type="html">&lt;p&gt;Remember &lt;a href=&quot;https://donald.merand.org/code/2011/09/20/tsv-the-best-spreadsheet-format.html&quot;&gt;that article I wrote&lt;/a&gt; about how TSV is the best format for spreadsheets? Well, here’s some more proof:&lt;/p&gt;

&lt;p&gt;Earlier today I needed to convert a spreadsheet in XLS format into a table in DokuWiki. I’ve been avoiding using tables in DokuWiki until now because I find that typing table markup by hand is error-prone and frustrating. But I had to for this job, so I went to review the &lt;a href=&quot;https://www.dokuwiki.org/syntax#tables&quot;&gt;DokuWiki syntax for tables&lt;/a&gt;, and what I saw seemed… familiar to me. It looked exactly like the output from my &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/tsvfmt&quot;&gt;tsvfmt&lt;/a&gt; command line utility!&lt;/p&gt;

&lt;p&gt;(Incidentally, you can also download tsvfmt as part of a bundle of command line utilities I’ve made in my &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin&quot;&gt;dlm-dot-bin&lt;/a&gt; repository on GitHub.)&lt;/p&gt;

&lt;p&gt;As it turns out, the output of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tsvfmt&lt;/code&gt; is Dokuwiki-syntax tables. Who knew? The only caveat is that if you a header row, you have to convert the “|” character into a “^” character. I’ll leave modifying the script to do that as an exercise to my one reader.&lt;/p&gt;

&lt;h2 id=&quot;heres-how-it-works&quot;&gt;Here’s How It Works&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Save your spreadsheet in Tab-delimited (TSV) format. We’ll assume for the purposes of this document that you saved it in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/Users/phil/Desktop/spreadsheet.tsv&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Download &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/tsvfmt&quot; title=&quot;https://github.com/dmerand/dlm-dot-bin/blob/master/tsvfmt&quot;&gt;Donald’s tsvfmt Command-Line Utility&lt;/a&gt;. I’ll assume you’ve put it in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/Users/phil/Desktop/tsvfmt&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Open up your favorite &lt;a href=&quot;https://www.iterm2.com/&quot; title=&quot;https://www.iterm2.com/&quot;&gt;Terminal Application&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Generally, you type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tsvfmt &amp;lt; spreadsheet.tsv&lt;/code&gt;. That command will output the Dokuwiki-formatted version of your table.
    &lt;ul&gt;
      &lt;li&gt;For the purposes of this file, you might want to first type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cd /Users/phil/Desktop/&lt;/code&gt; and then type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sh tsvfmt spreadsheet.tsv|pbcopy&lt;/code&gt;. That will run the conversion and copy the results to the system clipboard.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;The &lt;strong&gt;ONE CAVEAT&lt;/strong&gt; of this conversion is that if your spreadsheet has a header row, you’ll want to convert the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;|&lt;/code&gt; characters to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;^&lt;/code&gt; characters in the first row. See &lt;a href=&quot;https://www.dokuwiki.org/syntax#tables&quot; title=&quot;https://www.dokuwiki.org/syntax#tables&quot;&gt;DokuWiki Syntax&lt;/a&gt; for details on why.&lt;/li&gt;
  &lt;li&gt;Paste your results into your DokuWiki and bask in glory.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;source&quot;&gt;Source&lt;/h2&gt;

&lt;p&gt;For those too lazy to click links, here’s the source:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/2577157.js&quot;&gt; &lt;/script&gt;

</content>
 </entry>
 
 <entry>
   <title>Can You Be Inspired by Objects?</title>
   <link href="https://donald.merand.org//writing/2012/04/23/can-you-be-inspired-by-objects.html"/>
   <updated>2012-04-23T00:00:00-04:00</updated>
   <id>https://donald.merand.org/writing/2012/04/23/can-you-be-inspired-by-objects</id>
   <content type="html">&lt;p&gt;Inspiration comes from everywhere. Mentors and role models, movies, music. I’ve
been thinking about inspiration, and I’ve realized that in addition to those
standard sources of inspiration, I’m also inspired by mundane objects. Things.
Stuff.&lt;/p&gt;

&lt;p&gt;It was a surprise to realize this, because I’m not very attached to my things,
even the ones that I really like. I honestly believe that if tomorrow you took
away my stuff: my house, my bike and guitar collection, my computer etc., it
wouldn’t change who I was as a person. It might make me uncomfortable to have no
shelter, and bummed to have no internet (I’m not made of stone), but those
things don’t matter in the scheme of my personhood, my actual being.&lt;/p&gt;

&lt;p&gt;But that’s not to say that I can’t grow as a person because of a &lt;em&gt;thing&lt;/em&gt;. Let me
give a really long-winded example:&lt;/p&gt;

&lt;h1 id=&quot;a-really-long-winded-example&quot;&gt;A Really Long-Winded Example&lt;/h1&gt;

&lt;p&gt;I have always ridden my bicycle for transportation. All the way back to my very
first bicycle moment, it was clear to me that the bicycle was a great tool to
get me from one place to another. But it was never my &lt;em&gt;identity&lt;/em&gt;: I was never a
bicycle &lt;em&gt;person&lt;/em&gt; - I was perfectly happy to ride a creaky, half-broken,
ill-sized, ugly hybrid bicycle over to my friends house, or from my dorm to my
classroom.&lt;/p&gt;

&lt;p&gt;There was a catalyst for my transition to bike person - my first road bike. It
was a Univega touring frame, donated to me by a friend for whom it was
completely the wrong size. It had been sitting in a garage for years. Up until
that bike, I had been (like most Americans at the time) riding and preferring
mountain-style bike frames. Sturdy bikes, easy to hop over a curb, but not
pretty and not fast.  I didn’t think I’d even like to ride road bikes. I’m from
the woods! Who needs pavement? But one ride on this bicycle and it was clear to
see: it was beautiful, and fast(er).&lt;/p&gt;

&lt;p&gt;I &lt;em&gt;wanted&lt;/em&gt; to ride that bicycle. I also wanted to clean it up, and learn how to
fix it myself. I wanted to &lt;em&gt;own&lt;/em&gt; that bicycle in a way that was completely
separate from the way I had owned my other bicycles. The other bicycles were
mere tools - this one was an extension of my identity, and it sent a message
about who I am.&lt;/p&gt;

&lt;p&gt;I learned how to clean that bicycle, and replace its parts when they wore out.
I amassed a collection of tools. I built another 15 or 20 bicycles. Along the
way I came across &lt;a href=&quot;https://www.sheldonbrown.org&quot; title=&quot;Sheldon Brown - Everything about bikes&quot;&gt;Sheldon Brown&lt;/a&gt;’s web site.  Sheldon Brown was an
encyclopedia of a man, whose knowledge of bicycles was so complete that he
barely seemed to need any reference material. He left a great legacy to the
world through his desire/compulsion to document his projects and thoughts. He
was idiosyncratic (a 78-speed bicycle? really?), but he inspired legions of new
bicyclists to perform their own bike maintenance because, hey, all you have to
do is read his instructions. In addition to this, he was active on web fora, and
at &lt;a href=&quot;https://harriscyclery.com&quot; title=&quot;Harris Cyclery&quot;&gt;Harris Cyclery&lt;/a&gt;, spreading the word.&lt;/p&gt;

&lt;p&gt;I learned about Grant Pederson at &lt;a href=&quot;https://rivbike.com&quot; title=&quot;Rivendell Bicycles&quot;&gt;Rivendell Bicycles&lt;/a&gt;.  Through his
website, and his writings, I was inspired to try a totally new approach to
bicycling - being comfortable, not (necessarily) fast. Letting things wear out
instead of proactively replacing them. But Grant inspired me beyond just
bicycles. Just reading the descriptions of the products he sells (and
occasionally actually purchasing something) inspired me to look for quality
things that are going to last a long time. Usually, those things, or the
materials used to make them, have been used for decades, sometimes even
centuries. Carbon fiber is great, but, you know, wood is better, because it
lasts and works (and looks) great while it’s wearing out. Steel is the same way.&lt;/p&gt;

&lt;p&gt;It’s probably more accurate to say that Grant re-inspired me to look at things
this way, since he’s not the only person in my life sending that message.
Perhaps it was the confluence of his industry being my main obsession and his
words coming along at the right time, but he changed my whole pattern of
consumption, for the better I think. Like Sheldon Brown, he was a catalyst for
change in my life, simply by being himself and writing about it.&lt;/p&gt;

&lt;p&gt;I wouldn’t have come to this place without getting that one junky, beaten-up
road bicycle that had been sitting in a garage for years. It’s just a thing, but
for me it became much more, and now I’m a better person for having had it.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Moving to Jekyll - First Impressions</title>
   <link href="https://donald.merand.org//code/2012/04/20/moving-to-jekyll-first-impressions.html"/>
   <updated>2012-04-20T00:00:00-04:00</updated>
   <id>https://donald.merand.org/code/2012/04/20/moving-to-jekyll-first-impressions</id>
   <content type="html">&lt;p&gt;I got the itch about two weeks ago to make some changes to this site. I felt the need to ditch the entire thing and start over, but my lovely wife pointed out the futility of ditching all of the good work it represented. Maybe it would be better to just change the design? She was right, like she always is.&lt;/p&gt;

&lt;p&gt;So I decided on a basic re-design. Maybe some CSS overhaul, maybe a few navigation changes. Nothing big. But then I learned about &lt;a href=&quot;https://github.com/mojombo/jekyll&quot; title=&quot;Jekyll: Static Site Generator written in Ruby&quot;&gt;Jekyll&lt;/a&gt;, and I got motivated again to make a bigger switch. As it turns out, Jekyll very elegantly does &lt;a href=&quot;http://donald.merand.org/code/2012/02/29/about-this-site.html&quot;&gt;what I was trying to all along&lt;/a&gt; with my PHP code:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Posts formatted in &lt;a href=&quot;http://daringfireball.net/projects/markdown/&quot; title=&quot;Markdown: Text markup for people&quot;&gt;Markdown&lt;/a&gt;. I &lt;a href=&quot;http://donald.merand.org/code/2011/09/20/tsv-the-best-spreadsheet-format.html&quot;&gt;believe very strongly&lt;/a&gt; in Markdown as the way to do all of your text editing. I &lt;a href=&quot;http://512pixels.net/markdown-new-word51/&quot;&gt;am&lt;/a&gt; &lt;a href=&quot;http://scienceblogs.com/gregladen/2010/02/what_is_markdown_and_why_use_i.php&quot;&gt;not&lt;/a&gt; &lt;a href=&quot;http://www.hiltmon.com/blog/2012/02/20/the-markdown-mindset/&quot;&gt;alone&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Post metadata contained in a special section at the top of each post. Since my original idea was also using one file/field per post, it makes sense to try to keep all the metadata in the same place. Evidently, this is a common problem: Jekyll uses (what I have now learned is a “standard”) &lt;a href=&quot;https://github.com/mojombo/jekyll/wiki/yaml-front-matter&quot;&gt;YAML Front Matter&lt;/a&gt;. It’s always better to go with standards (that make sense), because it ensures portability and/or understandability.&lt;/li&gt;
  &lt;li&gt;Fast. Static HTML pages. They are the fastest.&lt;/li&gt;
  &lt;li&gt;Straightforward editing. What could be more straightforward than editing in your favorite text editor?&lt;/li&gt;
  &lt;li&gt;Straightforward deployment, in my case using &lt;a href=&quot;http://github.com/dmerand&quot;&gt;Github&lt;/a&gt; as the engine. Assuming you think version control with Git is straightforward, that is :)&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;conversion&quot;&gt;Conversion&lt;/h1&gt;

&lt;p&gt;Learning about &lt;a href=&quot;https://github.com/mojombo/jekyll&quot; title=&quot;Jekyll: Static Site Generator written in Ruby&quot;&gt;Jekyll&lt;/a&gt; took me about an hour. I liked that part. I wish Ruby on Rails had taken me an hour. Converting my whole site to &lt;a href=&quot;https://github.com/mojombo/jekyll&quot; title=&quot;Jekyll: Static Site Generator written in Ruby&quot;&gt;Jekyll&lt;/a&gt;, including deployment, took about 3 more hours. Granted, I already had a pile of posts in Markdown format, with the post metadata at the top. My templates were already abstracted in PHP, so conversion there was also minor and mostly involved changing things to Liquid. Also, I only had about 10 posts to work with. If it had been much more, I probably would have had to spend another 1/2 hour writing a script to convert my posts. But still, considering that the entire architecture of how the page is served has been altered, that’s a pretty quick conversion.&lt;/p&gt;

&lt;h1 id=&quot;differences&quot;&gt;Differences&lt;/h1&gt;

&lt;p&gt;Static sites are faster, so that’s good. I was concerned about the development side being awkward or slow, but in practice it’s actually simpler than developing with PHP. I put a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server:true&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;auto:true&lt;/code&gt; in my &lt;a href=&quot;https://github.com/mojombo/jekyll&quot; title=&quot;Jekyll: Static Site Generator written in Ruby&quot;&gt;Jekyll&lt;/a&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_config.yml&lt;/code&gt;. That way, my changes get refreshed automatically, and I can preview them locally before deployment. Once everything looks good, I just run a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git commit&lt;/code&gt; and then a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git push&lt;/code&gt;. The Liquid template engine is fine: I should probably have been using a template engine before, but I wasn’t so this is an improvement.&lt;/p&gt;

&lt;p&gt;The new version of the page doesn’t do everything the old version did. There is no site search (use a site: parameter in your search engine of choice). RSS exists, but only for the whole site, not for individual categories. Initially I was concerned about removing features, but after seeing my test version using &lt;a href=&quot;https://github.com/mojombo/jekyll&quot; title=&quot;Jekyll: Static Site Generator written in Ruby&quot;&gt;Jekyll&lt;/a&gt;, I was actually relieved. The site is simpler to use, and more understandable at a glance, which it needs to be.&lt;/p&gt;

&lt;h1 id=&quot;summary&quot;&gt;Summary&lt;/h1&gt;

&lt;p&gt;I am very pleased with &lt;a href=&quot;https://github.com/mojombo/jekyll&quot; title=&quot;Jekyll: Static Site Generator written in Ruby&quot;&gt;Jekyll&lt;/a&gt;. It is conceptually very simple, which lets me focus on what I should be doing: writing content. Removing features, even ones that I thought were necessary like search, has actually made this site better. In a world where there are almost no constraints on what you &lt;em&gt;can&lt;/em&gt; do, working within constrained environments can force you to do better work.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Another Batch of Drawings</title>
   <link href="https://donald.merand.org//art/2012/04/19/another-batch-of-drawings.html"/>
   <updated>2012-04-19T00:00:00-04:00</updated>
   <id>https://donald.merand.org/art/2012/04/19/another-batch-of-drawings</id>
   <content type="html">&lt;p&gt;I scanned some more old drawings from my notepad.&lt;/p&gt;

&lt;h2&gt;&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/7091472879/&quot; title=&quot;moleskine 12 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm8.staticflickr.com/7239/7091472879_f546e36d67.jpg&quot; width=&quot;312&quot; height=&quot;500&quot; alt=&quot;moleskine 12&quot; /&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6945404420/&quot; title=&quot;moleskine 13 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5333/6945404420_c5e2e302e0.jpg&quot; width=&quot;315&quot; height=&quot;500&quot; alt=&quot;moleskine 13&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6945404740/&quot; title=&quot;moleskine 14 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm8.staticflickr.com/7186/6945404740_31d4debcce.jpg&quot; width=&quot;317&quot; height=&quot;500&quot; alt=&quot;moleskine 14&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/7091473895/&quot; title=&quot;moleskine 15 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5323/7091473895_e9b690c718.jpg&quot; width=&quot;500&quot; height=&quot;396&quot; alt=&quot;moleskine 15&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6945405474/&quot; title=&quot;moleskine 16 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm8.staticflickr.com/7238/6945405474_313e57d5f0.jpg&quot; width=&quot;316&quot; height=&quot;500&quot; alt=&quot;moleskine 16&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/7091475787/&quot; title=&quot;moleskine 17 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5454/7091475787_3ab1096faf.jpg&quot; width=&quot;322&quot; height=&quot;500&quot; alt=&quot;moleskine 17&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/7091476145/&quot; title=&quot;moleskine 18 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5460/7091476145_6291ed665b.jpg&quot; width=&quot;318&quot; height=&quot;500&quot; alt=&quot;moleskine 18&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>About This Site</title>
   <link href="https://donald.merand.org//code/2012/02/29/about-this-site.html"/>
   <updated>2012-02-29T00:00:00-05:00</updated>
   <id>https://donald.merand.org/code/2012/02/29/about-this-site</id>
   <content type="html">&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt; 2012.05.02 11:40:21 - If you want to download the source that I’m talking about below, visit my &lt;a href=&quot;https://github.com/dmerand/blogulator&quot;&gt;blogulator&lt;/a&gt; project on GitHub.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note - Since writing this article, I’ve decided to migrate my page to being hosted on &lt;a href=&quot;https://github.com/dmerand&quot;&gt;GitHub&lt;/a&gt; using &lt;a href=&quot;https://github.com/mojombo/jekyll&quot;&gt;jekyll&lt;/a&gt;. Sooo, it’s all basically out-of-date. Still, the PHP code was a fun exercise, and a lot of the points are still valid.&lt;/em&gt;&lt;/p&gt;

&lt;h1 id=&quot;about-this-site&quot;&gt;About This Site&lt;/h1&gt;

&lt;p&gt;When designing this site, I envisioned it as a blog/pulpit,résume, and code/ideas repository. My mission is to make the site as usable as possible with as few elements as possible. Within that framework, I still want to have the elements one expects a modern web site, such as cross-platform compatibility, site search, RSS feeds, web-based content management, syntax highlighting of code snippets, and so forth. I’m also using the opportunity to try new approaches, and thought maybe it would be nice to share how the site works.&lt;/p&gt;

&lt;h1 id=&quot;why&quot;&gt;Why?&lt;/h1&gt;

&lt;p&gt;I’ve gone back and forth for a long time about whether it’s even worth having a web site. The reason I quit Friendster and MySpace and never even joined Facebook is because of the self-referential black hole having an online presence can be. You can get really tied up in an identity that’s not you, it’s just self-marketing.&lt;/p&gt;

&lt;p&gt;But on the other hand, self-marketing can be a good thing if, for instance, you &lt;em&gt;are&lt;/em&gt; your own brand because you work for yourself. Also, I want to be able to share the cool things I learn like &lt;a href=&quot;https://donald.merand.org/Code/2011/07/18/dokuwiki-to-latex-converter.html&quot;&gt;how to convert DokuWiki to LaTeX&lt;/a&gt; and &lt;a href=&quot;https://donald.merand.org/Projects/2011/08/16/album-exploration-slideshow.html&quot;&gt;the album I wrote and recorded in six weeks&lt;/a&gt;. Maybe somebody can find my code useful, or get some enjoyment out of an album or drawing or photo I made.&lt;/p&gt;

&lt;h1 id=&quot;the-idea&quot;&gt;The Idea&lt;/h1&gt;

&lt;p&gt;When I started on this site I was really getting into BASH scripting and the whole UNIX toolset. I &lt;em&gt;love&lt;/em&gt; the UNIX philosophy of each program doing one thing, and one thing well. Then you chain the programs together in arbitrary ways and you have Real Ultimate Power on your hands. The UNIX toolset is &lt;em&gt;so&lt;/em&gt; powerful, in fact, that you can actually just use BASH to be the content management for your web page as a CGI script.&lt;/p&gt;

&lt;p&gt;While the concept of having my entire web page be a big fat BASH script is appealing, I didn’t want to actually injure my brain writing the site. So I decided to use PHP for the scripting,  but use the file-system for my content management instead of a database system like MySQL. That way, I can get the relative easy of inline scripting that you get with PHP, but also have access to the UNIX utilities like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grep&lt;/code&gt; that I have come to love for some of the functions of the site.&lt;/p&gt;

&lt;h1 id=&quot;the-execution&quot;&gt;The Execution&lt;/h1&gt;

&lt;p&gt;The articles themselves are stored as plain-text files on the webserver. The text files are written using the &lt;a href=&quot;https://daringfireball.net/projects/markdown/&quot;&gt;markdown&lt;/a&gt; syntax, with a slight modification that allows me to tag files arbitrarily. Have I mentioned how awesome Markdown is? I converted all of my notes a year or so back, and now I can use &lt;a href=&quot;https://johnmacfarlane.net/pandoc/&quot;&gt;pandoc&lt;/a&gt; to convert my notes to any format under the sun! PDF, you got it. LaTeX, no problem. Textile (for BaseCamp)? Okay! But I digress…&lt;/p&gt;

&lt;p&gt;I keep a single text-based cache of all of text files under content management. Using a cache, iterating through things like titles and tags doesn’t rely on a filesystem traversal of the whole document tree. Article files are stored and referenced using the timestamp of their creation. Uploaded content for articles (such as MP3s, images, etc) all get stored in a directory named after the file timestamp. Effectively the creation timestamp is the article ID. This system would work for content management for anybody except people who might have content being simultaneously submitted by multiple users at the exact same time: a pretty rare case in my usage.&lt;/p&gt;

&lt;p&gt;I wrote &lt;a href=&quot;https://donald.merand.org/code/2011/07/24/checklist-for-making-friendly-web-pages.html&quot;&gt;an article&lt;/a&gt; about the kinds of things I have come to think friendly web sites should do. Here’s how I do those things:&lt;/p&gt;

&lt;h1 id=&quot;clean-urls&quot;&gt;Clean URLs&lt;/h1&gt;

&lt;p&gt;Since I’m using Apache as the webserver for this site, I’ve been able to use .htaccess re-writes to modify the URLs from a basic HTML post-based URL system. You might notice that when viewing an article you might see a URL such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https://donald.merand.org/view/1313497556&lt;/code&gt;, instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https://donald.merand.org/view.php?id=1313497556&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;People tell you a lot of reasons why you should have clean URLs. The Rails community will go on and on about RESTfulness, which is a lofty if confusing goal. You’ll hear about search engines who spit on your doorstep after seeing your ugly question marks in the URLs (a question mark in a URL is like a rusty car on blocks in the front yard ). But my reason for doing clean URLs is aesthetics. I don’t like ugly URLs because they look ugly. So that had to go.&lt;/p&gt;

&lt;p&gt;I can tell you that writing them by hand can be painful unless you’re up on your regular expressions. But then, you should be up on your regular expressions because using them properly makes you feel like a wizard. I learned from the book &lt;a href=&quot;https://shop.oreilly.com/product/9781565922259.do&quot;&gt;Sed and Awk&lt;/a&gt;, which I heartily recommend for any UNIX user.&lt;/p&gt;

&lt;h1 id=&quot;search&quot;&gt;Search&lt;/h1&gt;

&lt;p&gt;Speaking of regular expressions, you can use them in the search bar of this site. Why? Because I’m using grep as my search engine. Since my pages are all stored as text files, grep is a logical choice to do search because you can assume that the people writing grep are more concerned with optimizing regular expressions edge cases than you are. It’s going to be pretty fast. I don’t know how fast for zillions of articles, but I don’t plan on writing zillions of articles. I think it’ll scale pretty well over the life of this site.&lt;/p&gt;

&lt;p&gt;And yes, I do escape search input so you can’t do any funky filesystem calls in my search bar. Jeez.&lt;/p&gt;

&lt;h1 id=&quot;rss-feeds&quot;&gt;RSS Feeds&lt;/h1&gt;

&lt;p&gt;People will tell you that Twitter and Facebook are replacing the RSS feed. This may be true for people who don’t care about computers, but it’s not true for me. You can pry RSS out of my cold dead hands. My site needs to have RSS.&lt;/p&gt;

&lt;p&gt;For this site, I’ve implemented my own RSS functions in PHP. I wrote it so that you can get an RSS feed for either the whole site, or for any of the sub-categories (Projects, Code, etc.). That was a lot of fun, but there’s not a lot to report about it. RSS is a pretty easy and well-defined syntax.&lt;/p&gt;

&lt;h1 id=&quot;printpdf-ability&quot;&gt;Print/PDF-Ability&lt;/h1&gt;

&lt;p&gt;Sometimes you want to print a web page. Or if you’re like me, sometimes you want to make a PDF out of a web page. CSS print stylesheets are a remarkably under-used thing on the web, but it always irks me when I go to print a web page and it’s all munged up.&lt;/p&gt;

&lt;p&gt;In this site, you’ll notice that the navigation elements disappear, and the text size and margins adjust for an optimal on-paper/PDF reading experience when you print. Like RSS, it’s a thing into which you put a lot of effort as a site designer that most people will never see. But it’s important!&lt;/p&gt;

&lt;h1 id=&quot;what-not-to-include&quot;&gt;What Not to Include&lt;/h1&gt;

&lt;p&gt;It’s just as important to make choices about what &lt;em&gt;not&lt;/em&gt; to include. I opt against social network integration, comment systems, and advertising on this site. Among those things, comments are the only thing I’ve chosen against that would add any value for users of the site. But I don’t want to write a comment system, so sorry folks, you’ll have to send me an email.&lt;/p&gt;

&lt;p&gt;I realize that all web applications at this point are social to some degree, but I believe you should be able to make the choice not to have little “pin this, like that” buttons everywhere and not be made a pariah for it. I hope you’ll agree. I don’t want advertising because I don’t want my identity to be associated with other people’s schemes to get your money and make you feel bad.&lt;/p&gt;

&lt;h1 id=&quot;credits&quot;&gt;Credits&lt;/h1&gt;

&lt;p&gt;This site uses:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://bitbucket.org/davidchambers/hashify-editor&quot;&gt;Hashify Editor&lt;/a&gt; for editing and previewing page content.&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;You should check out &lt;a href=&quot;https://hashify.me&quot;&gt;Hashify&lt;/a&gt; for a great online Markdown previewer/editor.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/valums/file-uploader&quot;&gt;File Uploader&lt;/a&gt; for uploading files.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://code.google.com/p/google-code-prettify/&quot;&gt;Prettify&lt;/a&gt; for syntax highlighting of code snippets.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The rest was all me. Thanks for getting this far!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Old Drawings</title>
   <link href="https://donald.merand.org//art/2011/12/04/old-drawings.html"/>
   <updated>2011-12-04T00:00:00-05:00</updated>
   <id>https://donald.merand.org/art/2011/12/04/old-drawings</id>
   <content type="html">&lt;p&gt;Here are some old drawings from various places.&lt;/p&gt;

&lt;h2&gt;&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/7091465797/&quot; title=&quot;france notebook cover by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5457/7091465797_0e1cb1d4d3.jpg&quot; width=&quot;500&quot; height=&quot;365&quot; alt=&quot;france notebook cover&quot; /&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6945397340/&quot; title=&quot;takeout cardboard by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5152/6945397340_7ca5fd92c1.jpg&quot; width=&quot;364&quot; height=&quot;500&quot; alt=&quot;takeout cardboard&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6945397894/&quot; title=&quot;green cardstock by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm8.staticflickr.com/7249/6945397894_596ea7d661.jpg&quot; width=&quot;221&quot; height=&quot;500&quot; alt=&quot;green cardstock&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/7091467119/&quot; title=&quot;notepad by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5462/7091467119_45db8f5a4b.jpg&quot; width=&quot;500&quot; height=&quot;428&quot; alt=&quot;notepad&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6945398690/&quot; title=&quot;explo_stationery by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5349/6945398690_68a8b5b5b2.jpg&quot; width=&quot;337&quot; height=&quot;500&quot; alt=&quot;explo_stationery&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6945399032/&quot; title=&quot;back_of_notepad by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5159/6945399032_cec2640b44.jpg&quot; width=&quot;188&quot; height=&quot;500&quot; alt=&quot;back_of_notepad&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Some Map Drawings</title>
   <link href="https://donald.merand.org//art/2011/11/30/some-map-drawings.html"/>
   <updated>2011-11-30T00:00:00-05:00</updated>
   <id>https://donald.merand.org/art/2011/11/30/some-map-drawings</id>
   <content type="html">&lt;p&gt;Here are some more old drawings from a notebook. Mostly they’re old maps that I draw myself when I can’t take the internet with me. It’s funny how such a utilitarian thing can look like art in retrospect.&lt;/p&gt;

&lt;h2&gt;&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/7091468225/&quot; title=&quot;moleskine 1 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5463/7091468225_6e5eff2be7.jpg&quot; width=&quot;318&quot; height=&quot;500&quot; alt=&quot;moleskine 1&quot; /&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/7091468883/&quot; title=&quot;moleskine 2 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5272/7091468883_b1a567554c.jpg&quot; width=&quot;315&quot; height=&quot;500&quot; alt=&quot;moleskine 2&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/7091469197/&quot; title=&quot;moleskine 3 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5111/7091469197_e804eab8a1.jpg&quot; width=&quot;316&quot; height=&quot;500&quot; alt=&quot;moleskine 3&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6945401154/&quot; title=&quot;moleskine 4 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5334/6945401154_a1acda73b9.jpg&quot; width=&quot;500&quot; height=&quot;396&quot; alt=&quot;moleskine 4&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6945401508/&quot; title=&quot;moleskine 5 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5342/6945401508_a55c03b550.jpg&quot; width=&quot;319&quot; height=&quot;500&quot; alt=&quot;moleskine 5&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/7091470685/&quot; title=&quot;moleskine 6 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5031/7091470685_2d19d48d89.jpg&quot; width=&quot;500&quot; height=&quot;396&quot; alt=&quot;moleskine 6&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6945402472/&quot; title=&quot;moleskine 7 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5337/6945402472_66ab6579cb.jpg&quot; width=&quot;313&quot; height=&quot;500&quot; alt=&quot;moleskine 7&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6945403126/&quot; title=&quot;moleskine 9 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm8.staticflickr.com/7261/6945403126_0eb1e98546.jpg&quot; width=&quot;313&quot; height=&quot;500&quot; alt=&quot;moleskine 9&quot; /&gt;&lt;/a&gt;
—
&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6945403462/&quot; title=&quot;moleskine 10 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;https://farm6.staticflickr.com/5275/6945403462_43f35f5dd9.jpg&quot; width=&quot;313&quot; height=&quot;500&quot; alt=&quot;moleskine 10&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>TSV - The Best Spreadsheet Format</title>
   <link href="https://donald.merand.org//code/2011/09/20/tsv-the-best-spreadsheet-format.html"/>
   <updated>2011-09-20T00:00:00-04:00</updated>
   <id>https://donald.merand.org/code/2011/09/20/tsv-the-best-spreadsheet-format</id>
   <content type="html">&lt;p&gt;There’s no question that &lt;a href=&quot;https://daringfireball.net/projects/markdown/&quot;&gt;Markdown&lt;/a&gt; is the darling of the coding/internet/people who write communities. It’s the default syntax at &lt;a href=&quot;https://github.com/&quot;&gt;GitHub&lt;/a&gt;, &lt;a href=&quot;http://stackoverflow.com/&quot;&gt;Stack Overflow&lt;/a&gt;, &lt;a href=&quot;http://reddit.com&quot;&gt;Reddit&lt;/a&gt; and others. A &lt;a href=&quot;http://markedapp.com/&quot;&gt;lot&lt;/a&gt; of &lt;a href=&quot;http://brettterpstra.com/project/nvalt/&quot;&gt;popular&lt;/a&gt; &lt;a href=&quot;http://itunes.apple.com/us/app/elements-dropbox-and-markdown/id382752422?mt=8&quot;&gt;text&lt;/a&gt; &lt;a href=&quot;http://sourceforge.net/p/retext/home/ReText/&quot;&gt;editors&lt;/a&gt; are built around it.&lt;/p&gt;

&lt;p&gt;Markdown’s appeal is its simplicity. It is easy to learn, and easy to read even in native form. It’s easy to extend: the pages on this site, for example, are written in a Markdown variant – something I’ll write more about later.&lt;/p&gt;

&lt;p&gt;Okay, we all love Markdown - great, but what does this have to do with spreadsheets? Well, there’s a Markdown for spreadsheets, and it’s been hiding in plain sight practically as long as we’ve had computers. – tab separated variables. Think about it – TSV format is so simple that you can view it on any device. You can import it into practically &lt;em&gt;any&lt;/em&gt; spreadsheet software. And it’s one &lt;em&gt;hell&lt;/em&gt; of a lot easier to parse programatically than CSV format.&lt;/p&gt;

&lt;p&gt;Parsing a CSV file is a pain in the ass. There are at least four different implementations, mostly centering around the concept of whether variables should be quoted or not, and under what circumstances, and what to do with internal quotes. The only question with TSV is… what to do if you want to put a tab in your data. Most software I’ve seen just substitutes a space, or a few spaces. But only one exception to catch means that when you’re parsing a TSV file programatically you don’t have to look for a lot.&lt;/p&gt;

&lt;p&gt;There aren’t a lot of great utilities out there for working with TSV files, so I’m going to post a couple that I use all the time.&lt;/p&gt;

&lt;h1 id=&quot;tsvfmt&quot;&gt;TSVFMT&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;A Spreadsheet for Your Command Line&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I wrote this BASH script, which I’ve named &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tsvfmt&lt;/code&gt;, to address the problem of alignment when viewing TSV files in the command line or a text editor. It takes a TSV and uses awk to space it out and place a “|” character between columns. So this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext mv3 highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;this	is	a	test
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;… would become this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext mv3 highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;this | is | a | test | 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here’s the script:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/2577157.js&quot;&gt; &lt;/script&gt;

&lt;h1 id=&quot;tsv2html&quot;&gt;TSV2HTML&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Convert a TSV File to an HTML Snippet&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This one is a little more self-explanatory. Pass it a TSV file, either from STDIN or piped over, and it’ll convert it to an HTML table. Best used in conjunction with &lt;a href=&quot;https://rtomayko.github.com/bcat/&quot;&gt;bcat&lt;/a&gt;, which is &lt;em&gt;awesome&lt;/em&gt;.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/2577179.js&quot;&gt; &lt;/script&gt;

&lt;p&gt;&lt;em&gt;UPDATE&lt;/em&gt; (2012.05.02 10:58:18) - both of the above files are now available as part of the &lt;a href=&quot;https://github.com/dmerand/dlm-dot-bin&quot;&gt;dlm-dot-bin&lt;/a&gt; project that I’ve shared on GitHub.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Free is Not Free</title>
   <link href="https://donald.merand.org//writing/2011/08/28/free-is-not-free.html"/>
   <updated>2011-08-28T00:00:00-04:00</updated>
   <id>https://donald.merand.org/writing/2011/08/28/free-is-not-free</id>
   <content type="html">&lt;p&gt;Let’s talk about your information. I mean your basic details: name, email
address, gender, address, phone number. This is the kind of information that
most people will freely give out. You make an acquaintance, you give them your
phone number. You sell something on Craigslist, you might give your address so
that the purchaser can come and pick it up. For most people, not a week goes by
that you don’t hand away some way to communicate with you or identify you.&lt;/p&gt;

&lt;p&gt;Since you freely give this information out, you might assume that there’s
nothing inherently valuable in it. It’s not as though your friends
or coworkers are going to make money from having your phone number or knowing
where you live. How are people going to know whether they should friend you
on Facebook or follow you on Twitter if they don’t know all about your obsession
with Metroid cosplay? But this information &lt;em&gt;is&lt;/em&gt; valuable. In most places on
the internet it’s the only currency you’ve got.&lt;/p&gt;

&lt;p&gt;Big sites (Google, Facebook, um.. basically everything that you
use but don’t “pay” for) tend to serve the same function that magazines serve:
to deliver customers to advertisers. Don’t be silly and think that the purpose
of Vogue is to tell you about fashion. It’s to tell fashion companies about you,
or at least to get their wares in front of your face. In the same way, Google
isn’t about getting you accurate search results. It’s about allowing advertisers
to show you targeted advertisements based on those search results.&lt;/p&gt;

&lt;p&gt;Facebook is the largest marketing database on the planet. You just &lt;em&gt;gave&lt;/em&gt; them all the
information they need to be valued at 2 zillion dollars. All for the convenience
of not having to put people’s birthdays in your own calendar or call them to
invite them to a party. Or, you know, to let potentially good-looking strangers
know how deeply you love Bon Iver.&lt;/p&gt;

&lt;p&gt;If you have any doubt about the point of Google, Facebook, Vogue, whatever, take a
look at the latest &lt;a href=&quot;https://adage.com&quot;&gt;Advertising Age&lt;/a&gt;. It’s best to get a print
copy, because then you can see the ads. Yes, there are advertisements in a
magazine about advertisements. Who’s doing the advertising? Mostly magazines.
Condé Nast, for example. And they say things like “You want to market to
Northeastern males between 24 and 35? We’ll give ‘em to you on a platter”.&lt;/p&gt;

&lt;p&gt;Let it sink in for a moment:&lt;/p&gt;

&lt;blockquote class=&quot;ma3 i&quot;&gt;
  &lt;p&gt;I am not a customer, I am a product.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Which gets me back to my original point: why are you just giving your
information away? You should guard it ferociously. You’re not getting something 
for free, you’re making an exchange.&lt;/p&gt;

&lt;p&gt;“Okay”, you might be saying, “but what if I don’t care about advertisements? I’m
really good at ignoring them.” Great. Good for you. But let me pose one other
question: is your time worth nothing? Because the time you spend recycling junk
mail, calling to be taken off of mailing lists, filtering spam emails, fielding
telemarketing calls, that’s time you could be spending doing something that you
love, or at least making money. That time adds up. Think long-term: it’s what
advertisers do, and you’re playing their game whether you like it or not.&lt;/p&gt;

&lt;p&gt;So if you leave with one notion you didn’t come with, let it be this: your basic
information is currency, and it’s just as valuable as dollars and cents.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Album - Exploration Slideshow</title>
   <link href="https://donald.merand.org//projects/2011/08/16/album-exploration-slideshow.html"/>
   <updated>2011-08-16T00:00:00-04:00</updated>
   <id>https://donald.merand.org/projects/2011/08/16/album-exploration-slideshow</id>
   <content type="html">&lt;p&gt;Exploration Slideshow was my first solo album. I wrote and recorded it in the summer of 2004 in New Haven, CT, while working as a summer IT coordinator for &lt;a href=&quot;https://www.explo.org&quot;&gt;Explo&lt;/a&gt;. The album was entirely conceived, written, performed, and recorded by me over the span of about 7 weeks.&lt;/p&gt;

&lt;p&gt;I’m posting all the tracks from this album, and will be posting all of my other music up here as well. At some point I may post the lyrics as well. Do with this music what you will - remix, put it in your slideshow, whatever. I hope you enjoy it.&lt;/p&gt;

&lt;p&gt;Download the entire album as one compressed ZIP file &lt;a href=&quot;https://embed.merand.org/ll/ll-exploration-slideshow.zip&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/explo_slideshow/01%20Love.mp3&quot;&gt;love&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/explo_slideshow/02%20Secret%20Like%20Affair.mp3&quot;&gt;secret like affair&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/explo_slideshow/03%20Green.mp3&quot;&gt;green&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/explo_slideshow/04%20See%20Want%20Like%20Need.mp3&quot;&gt;see/want/like/need&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/explo_slideshow/05%20Room.mp3&quot;&gt;room&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/explo_slideshow/06%20Don%27t%20Be%20Sad.mp3&quot;&gt;don’t be sad&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/explo_slideshow/07%20Hipster%20Band.mp3&quot;&gt;hipster band&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/explo_slideshow/08%20Bench.mp3&quot;&gt;bench&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/explo_slideshow/09%20Song%20for%20Amy.mp3&quot;&gt;song for amy&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/explo_slideshow/10%20Changes%20of%20Season.mp3&quot;&gt;changes of season&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://embed.merand.org/explo_slideshow/11%20Asleep.mp3&quot;&gt;asleep&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;(right-click the links to save them to your computer)&lt;/em&gt;.&lt;/p&gt;

&lt;h2 id=&quot;license&quot;&gt;License&lt;/h2&gt;

&lt;p&gt;&lt;a rel=&quot;license&quot; href=&quot;https://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US&quot;&gt;&lt;img alt=&quot;Creative Commons License&quot; src=&quot;https://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png&quot; class=&quot;left pad-right&quot; /&gt;&lt;/a&gt;
Exploration Slideshow by &lt;a xmlns:cc=&quot;https://creativecommons.org/ns#&quot; href=&quot;https://donald.merand.org&quot; property=&quot;cc:attributionName&quot; rel=&quot;cc:attributionURL&quot;&gt;Donald Merand&lt;/a&gt; is licensed under a &lt;a rel=&quot;license&quot; href=&quot;https://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US&quot;&gt;Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>iPad Drawings</title>
   <link href="https://donald.merand.org//art/2011/08/14/ipad-drawings.html"/>
   <updated>2011-08-14T00:00:00-04:00</updated>
   <id>https://donald.merand.org/art/2011/08/14/ipad-drawings</id>
   <content type="html">&lt;p&gt;Click images for bigger versions.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6947567258/&quot; title=&quot;untitled 3-1 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;http://farm6.staticflickr.com/5445/6947567258_046c6feab1.jpg&quot; width=&quot;386&quot; height=&quot;500&quot; alt=&quot;untitled 3-1&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;a href=&quot;https://www.flickr.com/photos/79212667@N07/6947567420/&quot; title=&quot;untitled 1-1 by dmerand, on Flickr&quot;&gt;&lt;img src=&quot;http://farm8.staticflickr.com/7038/6947567420_9c6ef3e6e5.jpg&quot; width=&quot;386&quot; height=&quot;500&quot; alt=&quot;untitled 1-1&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Checklist for Making Friendly Web Pages</title>
   <link href="https://donald.merand.org//code/2011/07/24/checklist-for-making-friendly-web-pages.html"/>
   <updated>2011-07-24T00:00:00-04:00</updated>
   <id>https://donald.merand.org/code/2011/07/24/checklist-for-making-friendly-web-pages</id>
   <content type="html">&lt;p&gt;When I wrote the code for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;donaldmerand.com&lt;/code&gt;, I decided to try my best to adhere to good programming practices and standards for as many elements of the site as possible - the generated HTML, the CSS, the RSS feed, and everything else I could think of. Some people might say that &lt;em&gt;all&lt;/em&gt; code projects that &lt;em&gt;everybody&lt;/em&gt; does at &lt;em&gt;all times&lt;/em&gt; should adhere to best practices and be syntactically valid. People who say that have never worked in a production environment of any sort. That, or they work in very well-supported, well-managed, and well-funded programming environments and have few deadlines.&lt;/p&gt;

&lt;p&gt;Here’s what I found about web standards: good programming practice is a somewhat moving target, having just as much to do with æsthetic preference as any hard-and-fast rules. Syntactical validity is basically concrete in programming languages, but on the web it’s different. For example, a &lt;a href=&quot;https://diveintohtml5.org/past.html&quot;&gt;big point&lt;/a&gt; of the HTML5 standard is to slyly, quietly deal with the poor syntax that’s all over the web. If we &lt;em&gt;all&lt;/em&gt; wanted pure and perfect web standards, then we’d have all jumped on the XHTML 2.0 bandwagon. How many of us actually did?&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;crickets...&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Having said all of that, there are some things you can do as a web programmer that most everybody agrees are Good Things, and you should probably be doing in Most of your Projects. There are also some things that &lt;em&gt;I&lt;/em&gt; say you should do, because I’m biased just like everybody else, and you’re here to listen to me, right?&lt;/p&gt;

&lt;p&gt;To spare myself (and maybe you) from having to remember all of those things when making my next site, I made a list. So here you go…&lt;/p&gt;

&lt;h1 id=&quot;checklist-for-making-friendly-web-pages&quot;&gt;Checklist for Making Friendly Web Pages&lt;/h1&gt;

&lt;ol&gt;
  &lt;li&gt;HTML4 should be validated by the &lt;a href=&quot;https://validator.w3.org/&quot;&gt;W3C HTML Validator&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;Don’t bother with a &amp;lt;!DOCTYPE&amp;gt; of anything XHTML unless you’re actually going to modify your headers to send a MIME type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;application/xhtml+xml&lt;/code&gt;. As it turns out, if you send a regular &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;text/html&lt;/code&gt; MIME-type, your page &lt;a href=&quot;https://diveintohtml5.org/past.html#xhtml&quot;&gt;isn’t being parsed as XML at all&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;HTML5 should be validated with a &lt;a href=&quot;https://html5.validator.nu/&quot;&gt;HTML5 validator&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;Bonus points for passing &lt;a href=&quot;https://lint.brihten.com/html/&quot;&gt;HTML lint&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;If you’re going with HTML5, you might want to check for browser compatibility eg. with &lt;a href=&quot;https://www.modernizr.com/&quot;&gt;modernizr&lt;/a&gt;.
    &lt;ul&gt;
      &lt;li&gt;Also check &lt;a href=&quot;https://diveintohtml5.org/everything.html&quot;&gt;this link&lt;/a&gt; for single-item compatibility if you don’t need more that a couple of HTML5 functions.&lt;/li&gt;
      &lt;li&gt;Also &lt;a href=&quot;https://diveintohtml5.org/peeks-pokes-and-pointers.html&quot;&gt;this link&lt;/a&gt; is a great resource for what’s new in HTML5.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;CSS should be validated by the &lt;a href=&quot;https://jigsaw.w3.org/css-validator/&quot;&gt;W3C CSS Validator&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;Bonus points for passing &lt;a href=&quot;https://csslint.net/&quot;&gt;CSS lint&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;Bonus points for &lt;a href=&quot;https://secure.wikimedia.org/wikipedia/en/wiki/Minification_%28programming%29&quot;&gt;minifying&lt;/a&gt; your CSS.&lt;/li&gt;
      &lt;li&gt;Bonus points for using &lt;a href=&quot;https://sass-lang.com/&quot;&gt;sass&lt;/a&gt; for your own CSS sanity.&lt;/li&gt;
      &lt;li&gt;&lt;em&gt;Double-extra&lt;/em&gt; bonus points for including style elements for different &lt;a href=&quot;https://www.w3.org/TR/CSS2/media.html&quot;&gt;media types&lt;/a&gt;. For example, you might want to include a “print” stylesheet that hides your sidebar/navigation elements, so that when articles are printed, only the content comes out.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;If you have &lt;em&gt;any&lt;/em&gt; sort of dynamic content (blog posts, etc.), you should have an &lt;a href=&quot;https://secure.wikimedia.org/wikipedia/en/wiki/RSS&quot;&gt;RSS/atom&lt;/a&gt; feed.
    &lt;ul&gt;
      &lt;li&gt;Your RSS feed should be validated by a &lt;a href=&quot;https://feedvalidator.org/&quot;&gt;RSS Validator&lt;/a&gt;
        &lt;ul&gt;
          &lt;li&gt;Though it’s technically optional, you should include a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; href=&quot;/rss/&quot; /&amp;gt;&lt;/code&gt; tag in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section, to indicate to feed readers such as Google Reader that visit your main URL where the rss feed is (in this case a RSS 2.0 feed at https://yoursite.com/rss/).&lt;/li&gt;
          &lt;li&gt;Your feed needs to be in the proper XML format, obviously.&lt;/li&gt;
          &lt;li&gt;You have to encode your feed elements. For example, you can’t say &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;a href&amp;gt;&lt;/code&gt;, you have to say &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;a href&amp;gt;&lt;/code&gt;. There’s something called &lt;a href=&quot;https://www.w3schools.com/xml/xml_cdata.asp&quot;&gt;CDATA&lt;/a&gt; that makes this relatively straightforward if your web development language of choice doesn’t have escape functions, and you don’t feel like writing your own.&lt;/li&gt;
          &lt;li&gt;Your RSS links can’t be relative - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/index.html&lt;/code&gt; should be replaced with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https://yoursite.com/index.html&lt;/code&gt;.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;The site should have a &lt;a href=&quot;https://secure.wikimedia.org/wikipedia/en/wiki/Favicon&quot;&gt;favicon&lt;/a&gt;. Use the &lt;a href=&quot;https://favicon-generator.org/&quot;&gt;favicon generator&lt;/a&gt; to get one from a regular image.
    &lt;ul&gt;
      &lt;li&gt;You should include a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;link rel=&quot;shortcut icon&quot; href=&quot;/favicon.ico&quot; /&amp;gt;&lt;/code&gt; in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section to make sure this gets used. Some browsers (like Chrome) don’t seem to need it, but it’s better to be safe if you want people to see your nifty icon.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;You should be licensing your content. See &lt;a href=&quot;https://creativecommons.org/&quot;&gt;creative commons&lt;/a&gt; for more details and a license-link generator.&lt;/li&gt;
  &lt;li&gt;You should be compressing your content. See &lt;a href=&quot;https://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/&quot;&gt;this article&lt;/a&gt;.
    &lt;ul&gt;
      &lt;li&gt;If you’re using PHP, I’d recommend doing both the PHP compression &lt;em&gt;and&lt;/em&gt; the Apache compression. Apache compression doesn’t seem to catch PHP files that serve HTML content. I’m guessing this is the same for other web scripting languages, but I’ll admit my expertise in this area is limited.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;You should have clean URL syntax. Try to avoid URLS like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https://mysite.com?somequery=value&amp;amp;some_other_query=some_othervalue&lt;/code&gt;. Instead, go for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://mysite.com/somequery/value&lt;/code&gt;. Search engines love it, humans love it, everybody is happy.
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://quoderat.megginson.com/2007/02/15/rest-the-quick-pitch/&quot;&gt;This site&lt;/a&gt; gives a good overwiew of the RESTful URL situation, and provides good guidelines on URL management.&lt;/li&gt;
      &lt;li&gt;..and unless you’re using a framework like &lt;a href=&quot;https://rubyonrails.org/&quot;&gt;rails&lt;/a&gt;, you’ll probably want to brush up on &lt;a href=&quot;http://corz.org/serv/tricks/htaccess.php&quot;&gt;this .htaccess primer&lt;/a&gt;, because you’ll need to know it to make your own custom URLs by hand. You can also learn other neat tricks, like &lt;a href=&quot;http://corz.org/serv/tricks/htaccess2.php#section-more_banning&quot;&gt;banning specific user agents&lt;/a&gt; or &lt;a href=&quot;http://corz.org/serv/tricks/htaccess2.php#section-prevent_hot-linking&quot;&gt;preventing hot-linking&lt;/a&gt;.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;You should probably have a page search. You can redirect to a google &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;search_term site:yoursite.com&lt;/code&gt; query at the very least.
    &lt;ul&gt;
      &lt;li&gt;Bonus points if your search returns with &lt;a href=&quot;https://beatgates.blogspot.com/2011/07/extend-jqueryhighlight-to-highlight.html&quot;&gt;highlighting&lt;/a&gt;. This might not be applicable, depending on how your search page returns results.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</content>
 </entry>
 
 <entry>
   <title>Recipe - Vegan Sourdough Pancakes</title>
   <link href="https://donald.merand.org//writing/2011/07/18/recipe-vegan-sourdough-pancakes.html"/>
   <updated>2011-07-18T00:00:00-04:00</updated>
   <id>https://donald.merand.org/writing/2011/07/18/recipe-vegan-sourdough-pancakes</id>
   <content type="html">&lt;p&gt;When you make sourdough starter, you have to “feed” it periodically, which involves throwing a fair portion of the starter out. Don’t throw it away - use it to make pancakes! Or muffins. I’ll post some muffins later.&lt;/p&gt;

&lt;p&gt;I used &lt;a href=&quot;https://www.breadtopia.com/whole-grain-sourdough/&quot;&gt;this method&lt;/a&gt; to create my starter, and it worked quite well!&lt;/p&gt;

&lt;h1 id=&quot;ingredients&quot;&gt;Ingredients&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;3 eggs worth of egg replacer, or 1/4 cup applesauce.&lt;/li&gt;
  &lt;li&gt;1 cup soy milk (you might need more)&lt;/li&gt;
  &lt;li&gt;2 cups sourdough starter&lt;/li&gt;
  &lt;li&gt;1 cup all-purpose flour&lt;/li&gt;
  &lt;li&gt;3/4 cup whole wheat flour&lt;/li&gt;
  &lt;li&gt;1 teaspoon baking soda&lt;/li&gt;
  &lt;li&gt;2 teaspoons baking powder&lt;/li&gt;
  &lt;li&gt;1 1/2 teaspoons salt&lt;/li&gt;
  &lt;li&gt;1/4 cup granulated sugar&lt;/li&gt;
  &lt;li&gt;1/4 cup earth balance, melted&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;procedure&quot;&gt;Procedure&lt;/h1&gt;

&lt;ol&gt;
  &lt;li&gt;Mix up that egg replacer if you’re using it.&lt;/li&gt;
  &lt;li&gt;Add milk and sourdough starter.&lt;/li&gt;
  &lt;li&gt;Sift together flour, baking soda, baking powder, salt, and sugar; add to
the egg-like mixture, mixing &lt;em&gt;pretty&lt;/em&gt; well, but don’t overmix. You want the batter to be fluid, but not liquid.&lt;/li&gt;
  &lt;li&gt;Stir in the melted butter.&lt;/li&gt;
  &lt;li&gt;Lightly grease a hot griddle (or use a non-stick pan with no grease). don’t make that griddle so hot that you burn your pancakes!&lt;/li&gt;
  &lt;li&gt;Pour the batter onto the griddle and cook until light brown, turning once after maybe 2-3 minutes. My mom always used to say “Wait until you see bubbles in the middle of the pancake”, but I’m not sure that method is reliable. Your mileage may vary.&lt;/li&gt;
&lt;/ol&gt;
</content>
 </entry>
 
 <entry>
   <title>DokuWiki to LaTeX Converter</title>
   <link href="https://donald.merand.org//code/2011/07/18/dokuwiki-to-latex-converter.html"/>
   <updated>2011-07-18T00:00:00-04:00</updated>
   <id>https://donald.merand.org/code/2011/07/18/dokuwiki-to-latex-converter</id>
   <content type="html">&lt;p&gt;**NOTE: ** See my &lt;a href=&quot;https://donald.merand.org/code/2012/07/20/how-i-actually-convert-dokuwiki-to-latex.html&quot;&gt;updated post&lt;/a&gt; on how I actually convert &lt;a href=&quot;https://dokuwiki.org&quot;&gt;dokuwiki&lt;/a&gt; formats these days.&lt;/p&gt;

&lt;p&gt;Up until recently I was taking all of my personal notes in &lt;a href=&quot;https://dokuwiki.org&quot;&gt;dokuwiki&lt;/a&gt; format, because that’s what we use at my job for our internal wiki. It’s convenient to be able to copy notes straight into the wiki without having to convert.&lt;/p&gt;

&lt;p&gt;Sometimes, however, I would want to print my notes. Since I’ve always been a fan of the beautiful output of &lt;a href=&quot;https://www.latex-project.org/&quot;&gt;LaTeX&lt;/a&gt;, and I wanted to work on my &lt;a href=&quot;https://secure.wikimedia.org/wikipedia/en/wiki/Sed&quot;&gt;sed&lt;/a&gt; and &lt;a href=&quot;https://secure.wikimedia.org/wikipedia/en/wiki/AWK&quot;&gt;awk&lt;/a&gt; chops, I wrote a utility to convert from DokuWiki to LaTeX based on regular expressions.&lt;/p&gt;

&lt;p&gt;I’ve stopped using this code on my own computer in favor of a &lt;a href=&quot;https://johnmacfarlane.net/pandoc/&quot;&gt;pandoc&lt;/a&gt; solution, which I’ll detail in a later post.&lt;/p&gt;

&lt;p&gt;The script was originally one long BASH script which included calls to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cat&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sed&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;awk&lt;/code&gt;. However, for the purposes of illustration I’m going to just show each important piece. If you want to download the complete script, you can get it &lt;a href=&quot;https://gist.github.com/2414353&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first part of the script is to wrap the document in a (xe)LaTeX header and footer. I chose xelatex because it can handle Unicode fonts. That’s the reason why I was using Lucida Grande as my font face, but any Unicode font would work.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-latex&quot; data-lang=&quot;latex&quot;&gt;  &lt;span class=&quot;k&quot;&gt;\documentclass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;article&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;\pagestyle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;empty&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;\setlength&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;\parindent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}{&lt;/span&gt;0pt&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;\setlength&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;\parskip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}{&lt;/span&gt;1ex plus 0.5ex minus 0.2ex&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;\usepackage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;ulem&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;\usepackage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;fontspec,xunicode&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;\defaultfontfeatures&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;Mapping=tex-text&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;\setromanfont&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;[Mapping=tex-text]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;Gill Sans&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;\newfontfamily\specialfont&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;Lucida Grande&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;\setcounter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;secnumdepth&lt;span class=&quot;p&quot;&gt;}{&lt;/span&gt;-1&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;\begin{document}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;..then comes the code for the conversion. Then the footer:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-latex&quot; data-lang=&quot;latex&quot;&gt;  &lt;span class=&quot;nt&quot;&gt;\end{document}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The conversion code has two parts: an awk script to parse multi-line elements, such as list items, and a sed script to parse single-line conversions. The awk script is as follows:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-awk&quot; data-lang=&quot;awk&quot;&gt;  &lt;span class=&quot;o&quot;&gt;/^&lt;/span&gt;        &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*|-&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
    &lt;span class=&quot;nb&quot;&gt;sub&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/^        &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;[\*&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;|-&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt; /&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\t\t\t\\item &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;list4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
      &lt;span class=&quot;nx&quot;&gt;list4&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\t\t\t\\begin{itemize}&quot;&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;next&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;list4&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;list4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\t\t\t\\end{itemize}&quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;sr&quot;&gt;/^      &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;[\*&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;|-&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt; /&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
    &lt;span class=&quot;nb&quot;&gt;sub&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/^      &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;[\*&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;|-&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt; /&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\t\t\\item &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;list3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
      &lt;span class=&quot;nx&quot;&gt;list3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\t\t\\begin{itemize}&quot;&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;next&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;list3&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;list3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\t\t\\end{itemize}&quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;sr&quot;&gt;/^    &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;[\*&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;|-&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt; /&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
    &lt;span class=&quot;nb&quot;&gt;sub&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/^    &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;[\*&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;|-&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt; /&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\t\\item &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;list2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
      &lt;span class=&quot;nx&quot;&gt;list2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\t\\begin{itemize}&quot;&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;next&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;list2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;list2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\t\\end{itemize}&quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;sr&quot;&gt;/^  &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;[\*&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;|-&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt; /&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
    &lt;span class=&quot;nb&quot;&gt;sub&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/^  &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;[\*&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;|-&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt; /&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\\item &quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;list1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; 
      &lt;span class=&quot;nx&quot;&gt;list1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\\begin{itemize}&quot;&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;next&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;list1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;list1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\\end{itemize}&quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;#default case&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;#catch itemize at the end of the file&lt;/span&gt;
  &lt;span class=&quot;kr&quot;&gt;END&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;	&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;list1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;list2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;list3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;\\end{itemize}&quot;&lt;/span&gt; 
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The results of the awk script get piped to a sed script which parses single-line items, such as bold, italic, etc:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;  s/&lt;span class=&quot;o&quot;&gt;======&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;======&lt;/span&gt;/&lt;span class=&quot;se&quot;&gt;\\\s&lt;/span&gt;ection&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;/
  s/&lt;span class=&quot;o&quot;&gt;=====&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=====&lt;/span&gt;/&lt;span class=&quot;se&quot;&gt;\\\s&lt;/span&gt;ubsection&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;/
  s/&lt;span class=&quot;o&quot;&gt;====&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;====&lt;/span&gt;/&lt;span class=&quot;se&quot;&gt;\\\s&lt;/span&gt;ubsubsection&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;/
  &lt;span class=&quot;c&quot;&gt;#remaining headers do not translate to latex. Just make them bold&lt;/span&gt;
  s/&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;/&lt;span class=&quot;se&quot;&gt;\\\t&lt;/span&gt;extbf&lt;span class=&quot;se&quot;&gt;\{\1\}&lt;/span&gt;/g
  &lt;span class=&quot;c&quot;&gt;#bold, underline, italic&lt;/span&gt;
  s/&lt;span class=&quot;se&quot;&gt;\*\*\(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)\*\*&lt;/span&gt;/&lt;span class=&quot;se&quot;&gt;\\\t&lt;/span&gt;extbf&lt;span class=&quot;se&quot;&gt;\{\1\}&lt;/span&gt;/g
  s/__&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;__/&lt;span class=&quot;se&quot;&gt;\\\u&lt;/span&gt;nderline&lt;span class=&quot;se&quot;&gt;\{\1\}&lt;/span&gt;/g
  s|&lt;span class=&quot;se&quot;&gt;\/\/\(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)\/\/&lt;/span&gt;|&lt;span class=&quot;se&quot;&gt;\\\e&lt;/span&gt;mph&lt;span class=&quot;se&quot;&gt;\{\1\}&lt;/span&gt;|g
  &lt;span class=&quot;c&quot;&gt;#footnotes&lt;/span&gt;
  s|&lt;span class=&quot;o&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;|&lt;span class=&quot;se&quot;&gt;\\\f&lt;/span&gt;ootnote&lt;span class=&quot;se&quot;&gt;\{\1\}&lt;/span&gt;|g
  &lt;span class=&quot;c&quot;&gt;#ellipses&lt;/span&gt;
  s|&lt;span class=&quot;se&quot;&gt;\.\.\.&lt;/span&gt;|&lt;span class=&quot;se&quot;&gt;\\\l&lt;/span&gt;dots |g
  &lt;span class=&quot;c&quot;&gt;#double-single quotes (remember LONGEST MATCH)&lt;/span&gt;
  s|&lt;span class=&quot;s1&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;&apos;&lt;/span&gt;|&lt;span class=&quot;se&quot;&gt;\`\`\1&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;&apos;&lt;/span&gt;|g
  &lt;span class=&quot;c&quot;&gt;#quote character&lt;/span&gt;
  s|&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;|&lt;span class=&quot;se&quot;&gt;\`\`\1&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;&apos;&lt;/span&gt;|g
  &lt;span class=&quot;c&quot;&gt;#arrows&lt;/span&gt;
  s|-&amp;gt;|---|g
  &lt;span class=&quot;c&quot;&gt;#underscores do not work unless escaped&lt;/span&gt;
  s|&lt;span class=&quot;se&quot;&gt;\_&lt;/span&gt;|&lt;span class=&quot;se&quot;&gt;\\\_&lt;/span&gt;|g
  &lt;span class=&quot;c&quot;&gt;#special cases for @done for strikethrough&lt;/span&gt;
  s|item &lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;@done&lt;span class=&quot;nv&quot;&gt;$|&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;item &lt;span class=&quot;se&quot;&gt;\\\s&lt;/span&gt;out&lt;span class=&quot;se&quot;&gt;\{\1\}&lt;/span&gt;|g
  s|&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;@done&lt;span class=&quot;nv&quot;&gt;$|&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\\\s&lt;/span&gt;out&lt;span class=&quot;se&quot;&gt;\{\1\}&lt;/span&gt;|g
  &lt;span class=&quot;c&quot;&gt;#fractions, numbers&lt;/span&gt;
  s| &lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;0-9][0-9]&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;/&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;0-9][0-9]&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt; | &lt;span class=&quot;se&quot;&gt;\$\\\f&lt;/span&gt;rac&lt;span class=&quot;se&quot;&gt;\{\1\}\{\2\}\$&lt;/span&gt; |g
  s| &lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;0-9][0-9]&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt; | &lt;span class=&quot;se&quot;&gt;\$\1\$&lt;/span&gt; |g
  s|&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;||&lt;/span&gt;g
  &lt;span class=&quot;c&quot;&gt;#link. no special character at end. &lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;#matches file:///syntax, and allows spaces as a result&lt;/span&gt;
  s?&lt;span class=&quot;se&quot;&gt;\(&lt;/span&gt;https&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;:&lt;span class=&quot;se&quot;&gt;\/\/&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-a-zA-Z0-9&lt;/span&gt;.&amp;amp;_&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/&lt;span class=&quot;se&quot;&gt;\\\?&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;a-zA-Z0-9]&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;? &lt;span class=&quot;se&quot;&gt;\\\u&lt;/span&gt;rl&lt;span class=&quot;se&quot;&gt;\{\1\}&lt;/span&gt;?
  s?file:&lt;span class=&quot;se&quot;&gt;\/\/\/\(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-a-zA-Z0-9&lt;/span&gt; .&lt;span class=&quot;se&quot;&gt;\/\\&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\)&lt;/span&gt;? &lt;span class=&quot;se&quot;&gt;\\\u&lt;/span&gt;rl&lt;span class=&quot;se&quot;&gt;\{\/\1\}&lt;/span&gt;?&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;So there you have it. It’s very informative to take on a project of this size: you learn pretty quickly how big of a mess regular expressions can be. But that’s the beauty of sed and awk - you can combine simple expressions until you have one big (ugly) program that does something significant. It’s amazing the power of what you can do with a few basic utilities that are included by default on just about every non-windows machine on the planet (and are available for windows machines as well).&lt;/p&gt;

&lt;p&gt;I also learned that most of what you can do with sed can be done right from inside the amazing text editor, &lt;a href=&quot;https://www.vim.org/&quot;&gt;vim&lt;/a&gt;. An unintended consequence of learning sed is that you become a vim search/replace &lt;em&gt;master&lt;/em&gt;. That alone is a great reason to learn how to use sed.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>OS X Terminal Tips and Tricks</title>
   <link href="https://donald.merand.org//code/2011/07/15/osx-terminal-tips-and-tricks.html"/>
   <updated>2011-07-15T00:00:00-04:00</updated>
   <id>https://donald.merand.org/code/2011/07/15/osx-terminal-tips-and-tricks</id>
   <content type="html">&lt;p&gt;These are some shortcuts and programs that make my life easier in the terminal on OS X.&lt;/p&gt;

&lt;h1 id=&quot;terminal&quot;&gt;TERMINAL&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CTRL-V&lt;/code&gt; then any character - will allow you to type special characters eg. tab in the terminal&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CTRL-X-E&lt;/code&gt; - open Vim (actually whatever’s stored in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$EDITOR&lt;/code&gt;) with whatever’s on the command line&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;bash&quot;&gt;BASH&lt;/h1&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;  &lt;span class=&quot;c&quot;&gt;# Last error
&lt;/span&gt;
  &lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;?
  &lt;span class=&quot;c&quot;&gt;# # of commands passed to a script
&lt;/span&gt;
  &lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;c&quot;&gt;# 
&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;# All commands passed to a script
&lt;/span&gt;
  &lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;@ 

  &lt;span class=&quot;nv&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;basename&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;fullfile&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;# Alternately:
&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;fullfile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;##*/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;nv&quot;&gt;filename_no_final_extension&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;\%.*&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;nv&quot;&gt;extension&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;##*.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;# Alternately:
&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;extension&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;/*.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h1 id=&quot;utilities&quot;&gt;UTILITIES&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pushd&lt;/code&gt; / &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;popd&lt;/code&gt; - Same as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cd&lt;/code&gt; but stores &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$PWD&lt;/code&gt; on the stack. Push and pop directories instead of always changing to full paths. &lt;em&gt;Use this more&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dirs&lt;/code&gt; shows the stack&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ps -cax&lt;/code&gt; - List each program by the program that called it - better for quitting GUI apps&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;osascript -e &apos;tell application &quot;Application&quot; to quit&apos;&lt;/code&gt; - safely Quit a GUI program&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;open -a &apos;Program&apos; file_name&lt;/code&gt; - Open a GUI program (with an optional file_name)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pbcopy&lt;/code&gt;/&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pbpaste&lt;/code&gt; - copy/paste to the OS X clipboard&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;awk &apos;{gsub(/\r/, &quot;\n&quot;, $0); print $0}&apos;&lt;/code&gt; - convert Mac line endings to UNIX line endings
    &lt;ul&gt;
      &lt;li&gt;(used to use tr, but it doesn’t handle unicode very well. awk isn’t pretty, but it does it)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tr &apos;&amp;lt;&apos; &apos;\n&amp;lt;&apos;&lt;/code&gt; - find all &amp;lt; characters and put a newline before them (NOT ELEGANT IN OS X SED)
    &lt;ul&gt;
      &lt;li&gt;alternately &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;awk &apos;{sub(/&amp;lt;/, &quot;\n&amp;lt;&quot;, $0); print $0}&apos;&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sort -k 2.3,5&lt;/code&gt; - sort based on the second column, third character through the fifth character&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sort -M&lt;/code&gt; - sort based on months (closest to a date sort on text sorts)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls -1 &amp;gt; ALLFILES; sort MANIFEST MANIFEST ALLFILES | uniq -u | xargs rm&lt;/code&gt; - to remove everything in the file list ALLFILES that’s not contained in MANIFEST
    &lt;ul&gt;
      &lt;li&gt;(you’d probably want to quote the results, because xargs isn’t friendly with space characters in filenames)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;find . -name &quot;REGEXP&quot;&lt;/code&gt; - find a file, based on a regular expression&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;find . -iname &quot;REGEXP&quot; -exec COMMAND {} \;&lt;/code&gt; - find a file, case-insensitive, then exec COMMAND on every matched file
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{}&lt;/code&gt; is a substitute for the filename&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;find . -type f -name &quot;.*&quot;&lt;/code&gt; - find all hidden files (type d for directories)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;find / -type f -name *.zip -size +100M -exec rm -i {} \;&lt;/code&gt; - remove all .zip files on the computer, larger than 100M, interactively&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;syslog | grep -i &quot;error&quot;&lt;/code&gt; - Dump the entire system log file, check for errors&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ruby -ne &apos;puts $_&apos;&lt;/code&gt; - takes standard input, runs with $_ being current line until end-of-file (CTRL-D) character&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jot 10&lt;/code&gt; - prints 1 2 3 4 5 6 7 8 9 10 with newlines between them.
    &lt;ul&gt;
      &lt;li&gt;use “-r” for random&lt;/li&gt;
      &lt;li&gt;two numbers starts at the first and does the second number of prints&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;defaults write com.apple.dock pinning -string end&lt;/code&gt; - dock in the lower-right corner&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plutil -convert xml1 PLIST_FILE&lt;/code&gt; - convert a plist file into an XCode-readable format&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;resources&quot;&gt;RESOURCES&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;Good sort examples: &lt;a href=&quot;https://www.cyberciti.biz/faq/linux-unix-sort-date-data-using-sortcommand/&quot;&gt;https://www.cyberciti.biz/faq/linux-unix-sort-date-data-using-sortcommand/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Good find examples: &lt;a href=&quot;https://www.thegeekstuff.com/2009/03/15-practical-linux-find-command-examples/&quot;&gt;https://www.thegeekstuff.com/2009/03/15-practical-linux-find-command-examples/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;BASH Scripting guide: &lt;a href=&quot;https://tldp.org/LDP/abs/html/&quot;&gt;https://tldp.org/LDP/abs/html/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;OSX Server Command Line: &lt;a href=&quot;https://www.scribd.com/doc/15339783/Command-Line&quot;&gt;https://www.scribd.com/doc/15339783/Command-Line&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 
</feed>
