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 / create-files-list.md
Last active Jan 21, 2020
Create a files.txt list for an Electric Book project's update folder
View create-files-list.md

Create a files.txt list

Windows

dir /a-D /S /B > files.txt

  • To remove .git folder, replace: ^\.git\\.*\n
  • To remove sass-cache, replace: ^\.sass-cache\\.*\n
  • To remove node_modules, replace: ^node_modules\\.*\n
  • To remove _site folder, replace: ^_site\\.*\n
@arthurattwell
arthurattwell / _Jekyll-SSH-deploy-with-CodeShip-Basic.md
Last active Jan 16, 2020
Test and deploy a Jekyll site with CodeShip Basic
View _Jekyll-SSH-deploy-with-CodeShip-Basic.md

Test and deploy a Jekyll site over SSH with CodeShip Basic

This is a workflow for deploying Jekyll sites with CodeShip Basic. It follows good practices by building once, and deploying a tested build to staging and live webservers based on Git branches and tags.

  1. Ensure you have SSH access to your staging and live webservers. On some web hosts, SSH access must be requested and enabled by support. You may still need to do this for your domain.

  2. Make sure your repo includes the test.sh and deploy.sh scripts here. They should be in the repo's root folder. In addition, our scripts assume that your repo includes an up-to-date _configs/_config.live.yml file, containing any configuration settings for live builds.

  3. Add a project to CodeShip and connect your repo.

  4. In the CodeShip project settings, go to Tests. Choose 'Ruby' from the list of technology defaults.

    1. Under 'Setup commands' you may need to include commands that set up the environment (i.e. the machine that builds your site) correctly
@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
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 / 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
@arthurattwell
arthurattwell / md-to-betterquiz.md
Last active Jun 25, 2019
Converting markdown MCQs to Betterquiz BQF format
View md-to-betterquiz.md

Converting markdown MCQs to Betterquiz BQF format

Betterquiz is a format and engine for creating multiple-choice tests and embedding them on websites in an iframe. It’s an open-source project hosted here.

For Bettercare, we create MCQ quizzes for books in kramdown-flavoured markdown. We then need to quickly convert them to BQF for uploading to our Betterquiz server.

This series of regex search-and-replaces turns a kramdown quiz file into a BQF file. In each case, the first line is the search, and the second line the replace (unless you should replace with nothing).

  1. Remove numbers from questions.
@arthurattwell
arthurattwell / pdf-to-jpg.bat
Created Mar 25, 2019
Batch file to convert PDFs to JPGs (requires GraphicsMagick and Ghostscript installed)
View pdf-to-jpg.bat
:: pdf-to-jpg.bat
::
:: This batch file converts all the PDF files in a folder to JPGs,
:: and each page is a separate, numbered JPG.
::
:: 1. Make sure GraphicsMagick and Ghostscript are installed and in your PATH.
:: 2. Save this pdf-to-jpg.bat file to the folder alongside the files you want to convert.
:: 3. Double-click pdf-to-jpg.bat.
@arthurattwell
arthurattwell / pandoc-html-md.bat
Last active Apr 1, 2019
Script to convert HTML to markdown with Pandoc
View pandoc-html-md.bat
:: pandoc-html-md.bat
::
:: Don't show these commands to the user
@ECHO off
:: Set the title of the window
TITLE Convert HTML to markdown with Pandoc
:: Select file marker
:selectfile
:: Clear any preexisting filename variables
SET filename=
@arthurattwell
arthurattwell / update-path-osx.md
Created Jan 10, 2019
How to update your PATH in Terminal (OSX)
View update-path-osx.md

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.

You can’t perform that action at this time.