Skip to content

Instantly share code, notes, and snippets.

View arthurattwell's full-sized avatar

Arthur Attwell arthurattwell

View GitHub Profile
@arthurattwell
arthurattwell / aliases-windows-.bashrc.sh
Last active June 10, 2023 03:01
Aliases for OSX Terminal and Windows command-prompt
#########################################
# Terminal aliases
# OSX: Save/add this to ~/.bash_profile
# Ubuntu: Add this to ~/.bashrc
# Windows Git Bash: Add this to ~/.bashrc
#########################################
# Uncomment one of the following two options
# - This for OSX:
# alias aliedit="code ~/.bash_profile"
@arthurattwell
arthurattwell / regex-oxford-z.md
Last active January 25, 2019 17:05
Apply Oxford-Z spelling

Apply Oxford-Z spelling

This regex replaces -ise endings with Oxford Z -ize endings. Note that this is not the same as American z endings.

This regex is designed for use in Sublime Text, which uses the PCRE regex engine. It should work elsewhere, too.

Caveat

  • This will probably always be a work in progress. Never apply a regex like this globally – you should eyeball every replacement. For instance, it might replace names that end in 'ise' (it does already leave Louise alone), or book titles like Mandela: The Unauthorised Biography, which should retain their original spelling.
  • This regex will preserve initial capitals, e.g. 'Theorise' becomes 'Theorize', but not capitalisation inside words. If your text includes words entirely in uppercase, make sure you activate 'Preserve case' in your editor (e.g. Sublime Text) to avoid replacing an uppercase S with a lowercase z, such as 'THEORIzE'.
@arthurattwell
arthurattwell / word-freq.ps1
Last active November 4, 2019 14:36
Word frequency with PowerShell
# PowerShell: Counting words in a text file
# Returns a list of the most-used, longest words in a text file.
#
# Adapted slightly from
# https://blogs.technet.microsoft.com/josebda/2015/03/21/powershell-examples-counting-words-in-a-text-file/
#
# Run this with PowerShell in the folder containing your text, from PowerShell with:
# ./word-freq
# It looks for combined.txt. To get this from a set of markdown files,
# I use Cygwin (because native Windows CLIs have encoding issues) and run:
@arthurattwell
arthurattwell / ebtv2-nav-builder.js
Last active February 17, 2023 11:44
Script for grabbing Electric Book nav and toc yaml from HTML
// Standard JS
/* globals window, copy */
// This script returns Electric-Book-compatible
// YAML for use in the nav and toc in _data/works.
// It's intended for EBTv2 (2023).
//
// Usage:
// 1. Generate the output HTML of a book.
// 2. Open the page you need TOC yaml for in a browser (e.g. 01.html)
@arthurattwell
arthurattwell / adjustable-dotted-line.scss
Created December 5, 2017 16:14
Dotted lines top and bottom, with adjustable size and gap
// This Sass mixin adds a dotted line above and below an element, e.g. a heading.
// It was written for use in print output with PrinceXML,
// but should work as well in browsers. YMMV.
// The dot is an SVG circle encoded into the CSS.
// The SVG includes the dot and space on its left and right.
// To change the gap, change the width attribute.
// A width of 400 means the gap is 3 times the width of the dot.
// That is, width = the dot (at 100) plus the gap.
$dot-svg: 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="100" width="400"><circle cx="50%" cy="50%" r="50"/></svg>';
@arthurattwell
arthurattwell / antisocial.user.js
Last active May 8, 2018 15:14
Greasemonkey script to warn me when I open social-media sites
// ==UserScript==
// @name Avoid social media
// @version 1
// @grant none
// @include *://facebook.com*
// @include *://*.facebook.com*
// @include *://twitter.com*
// @include *://*.twitter.com*
// @run-at document-start
// ==/UserScript==
@arthurattwell
arthurattwell / Installing-Jekyll-on-Windows.md
Last active October 20, 2022 16:46
Installing Jekyll on Windows

Installing Jekyll on Windows

Getting Jekyll installed on Windows can be more complicated than on, say, OSX and Ubuntu, but not by much. This outlines the steps I use.

I have similar guidance (plus extra steps for my publishing tools) for OSX written up here.

Why is this tricky?

Because each of the pieces that make Jekyll work is fussy, especially on Windows, which the developers of those pieces rarely use.

@arthurattwell
arthurattwell / convert-indd-to-ebw.md
Created February 3, 2018 13:39
Converting from InDesign to the Electric Book workflow

Converting from InDesign to the Electric Book workflow

Suggested steps

This is what we do when we convert one of our Bettercare textbooks from a traditional InDesign workflow to markdown for this workflow. You'll probably develop your own process for turning existing books into markdown. Maybe this will help.

  1. Open the InDesign file and copy all the text.
  2. Paste the text with formatting into your text editor.
  3. Search and replace (S&R) all line breaks with double line breaks:
    • Tick 'Regular expression' (because you're using the regex \n to mean 'line break', not actually searching for the characters 'slash' and 'lowercase en').
@arthurattwell
arthurattwell / add-file.bat
Created April 13, 2018 16:28
Copy a file to multiple subfolders with the same name
@echo off
:: This batch file copies a file called 'file.txt'
:: from a subfolder called 'sourcefolder'
:: to all subfolders called 'text'.
:: Get current directory
set dir=%~dp0
:: Loop and copy file
for /d /r %dir% %%d in (.) do (
@arthurattwell
arthurattwell / translation-characters.txt
Last active May 30, 2018 11:28
A list of non-ASCII characters/glyphs useful for testing font choices in translation projects
ḓ Ḓ ḽ ṋ ṱ Ṱ µ » ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ø ù ú û ü ý þ ÿ ƒ Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς σ τ υ φ χ ψ ω ϑ ϒ ϖ Œ œ Š š Ÿ