Skip to content

Instantly share code, notes, and snippets.

Arthur Attwell arthurattwell

Block or report user

Report or block arthurattwell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@arthurattwell
arthurattwell / split.sh
Last active Dec 10, 2019
Split a markdown file into separate files on YAML frontmatter
View split.sh
#!/bin/bash
# That tells Linux to use a Bourne shell interpreter.
# Run this script from the current directory. (Required on OSX.)
cd -- "$(dirname "$0")"
# Don't echo these commands.
set +v
# Get the filename from the user.
@arthurattwell
arthurattwell / dialog.html
Last active Dec 9, 2019
Google Sheets script to allow multi-select in cells with data-validation (adapted from https://www.youtube.com/watch?v=dm4z9l26O0I)
View dialog.html
<div style="font-family: sans-serif;">
<? var data = valid(); ?>
<form id="form" name="form">
<? if(Object.prototype.toString.call(data) === '[object Array]') { ?>
<? for (var i = 0; i < data.length; i++) { ?>
<? for (var j = 0; j < data[i].length; j++) { ?>
<input type="checkbox" id="ch<?= '' + i + j ?>" name="ch<?= '' + i + j ?>" value="<?= data[i][j] ?>"><?= data[i][j] ?><br>
<? } ?>
<? } ?>
<? } else { ?>
@arthurattwell
arthurattwell / terminal-prompt.sh
Last active Dec 5, 2019
Set the Terminal prompt in Ubuntu
View terminal-prompt.sh
# Set the Terminal prompt in Ubuntu to:
# user directory (git-branch) $
# Add the lines below to your ~/.bashrc file.
## Get Git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
## Simplify prompt and add Git branch
@arthurattwell
arthurattwell / aliases.bat
Last active Nov 28, 2019
Aliases for OSX Terminal and Windows command-prompt
View aliases.bat
::::::::::::::::::::::::::::::::::::::
:: ::
:: Windows Command Prompt aliases ::
:: ::
::::::::::::::::::::::::::::::::::::::
@echo off
DOSKEY alias=echo Listing all aliases in aliases.bat ^& if ".$*." == ".." ( DOSKEY /MACROS ) else ( DOSKEY $* )
DOSKEY aliedit=echo edit aliases in "C:\Users\Arthur\AppData\Roaming\aliases.bat" ^& notepad C:\Users\Arthur\AppData\Roaming\aliases.bat
View epub-show-url.scss
// When producing HTML for the web and epub, links present a challenge:
// on the web and on ereaders with built-in browsers (e.g. the Kindle app
// on a smartphone), links can be clickable text. But on e-ink devices,
// these links aren't accessible or can't be followed. Instead,
// we need to display the link URLs so that they can be copied manually.
// This Sass class lets you choose to display the URLs of links
// that you select, by adding a `class='show-url'` to the link.
//
// First, it displays the URL in parentheses after any `show-url` link.
// Then it hides those URLs on any ereader that supports media queries.
@arthurattwell
arthurattwell / princexml-reset.css
Last active Nov 21, 2019
Reset CSS for PrinceXML
View princexml-reset.css
/* Reset PrinceXML CSS (XHTML stylesheet) */
h1, h2, h3, h4, h5, h6 {
font-weight: inherit;
font-size: inherit;
}
address {
font-style: inherit;
}
@arthurattwell
arthurattwell / random
Last active Nov 7, 2019
Jekyll include for generating random strings
View random
{% capture random %}
{% comment %}This include generates a random string.
Save it to _includes. Then use {% include random %}
to get an 8-character string of numbers and letters.
Optionally:
* Specify the length of string you want. E.g.
{% include random length=16 %} or
{% include random length="16" %}
@arthurattwell
arthurattwell / word-freq.ps1
Last active Nov 4, 2019
Word frequency with PowerShell
View word-freq.ps1
# 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 / keybindings.json
Last active Sep 21, 2019
VS Code key bindings
View keybindings.json
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "ctrl+k",
"command": "extension.changeCase.commands",
"when": "editorTextFocus"
},
{
"key": "ctrl+tab",
"command": "workbench.action.terminal.focusNext"
View epub-reference-types.md

Epub reference types

Copied from the IDPF's EPUB2.0 spec:

The required type attribute describes the publication component referenced by the href attribute. The values for the type attributes must be selected from the list defined below when applicable. Other types may be used when none of the predefined types are applicable; their names must begin with the string other.. The value for the type attribute is case-sensitive.

The following list of type values is derived from the 13th edition of the Chicago Manual of Style:

Attribute Explanation
You can’t perform that action at this time.