Skip to content

Instantly share code, notes, and snippets.

View arthurattwell's full-sized avatar

Arthur Attwell arthurattwell

View GitHub Profile
@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 / print-page-setup-lightning-source-colour.css
Last active March 3, 2018 08:42
CSS page setup for Lightning Source colour books
/* Page setup for Lightning Source colour pages
* --------------------------------------------
*
* Removes bleed on inside edges
* Adjusts trim accordingly
* Removes crop marks as required by LS
* Uses the @left and @right margin boxes to obscure elements (e.g. full-bleed images)
* that otherwise bleed into the margin area.
* YMMV
*
@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 / 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 / epubcheck-all.bat
Created May 10, 2018 18:58
Batch file for validating all the epubs in a folder with EpubCheck
:: Don't show these commands to the user
@echo off
:: Keep variables local, and expand at execution time not parse time
setlocal enabledelayedexpansion
:: Set the title of the window
title Validating epubs
:begin
echo This will run EpubCheck on all the epubs in this folder.
pause
@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
ḓ Ḓ ḽ ṋ ṱ Ṱ µ » ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ø ù ú û ü ý þ ÿ ƒ Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς σ τ υ φ χ ψ ω ϑ ϒ ϖ Œ œ Š š Ÿ
@arthurattwell
arthurattwell / README_live-deploy.md
Created June 4, 2018 15:54
Template readme for Electric Book live builds
layout
min

Deploying this build to a live server

@arthurattwell
arthurattwell / .htaccess
Created June 18, 2018 14:24
Send all traffic to non-www https
# Send www to non-www (thanks http://stackoverflow.com/questions/234723/generic-htaccess-redirect-www-to-non-www)
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@arthurattwell
arthurattwell / WordcountAll.vba
Last active June 28, 2018 14:21
Microsoft Office macro for getting the word count of all Word files in a folder
Sub WordcountAll()
' Add the path to the folder you are counting below in quotes where you see C:\
' Adapted from https://www.datanumen.com/blogs/2-quick-ways-count-total-number-pages-words-multiple-word-documents/
Dim objWordApplication As Word.Application
Dim nPageNumber As Long
Dim nWordNumber As Long
Dim objFile As Variant
Dim objFileSystem As Object
Dim objFolders As Object
@arthurattwell
arthurattwell / update-path-osx.md
Created January 10, 2019 10:11
How to update your PATH in Terminal (OSX)

Updating your PATH in Terminal (OSX)

Background

When you ask your computer to run a program, it needs to be able to find the program's executable files. The PATH is its 'official' list of places to look.

You can have Terminal add locations to your PATH each time you open it. To set this up, you need to create a 'bash profile' ('bash' being the language that Terminal runs in), which Terminal will read each time it launches. The bash profile can list locations that Terminal adds temporarily to the computer's PATH.

These steps show how to do that, in particular for adding Ruby to your PATH after installing it with Homebrew.