Skip to content

Instantly share code, notes, and snippets.

View arthurattwell's full-sized avatar

Arthur Attwell arthurattwell

View GitHub Profile
@arthurattwell
arthurattwell / merge-a-forked-gist.md
Created May 4, 2020 12:22
Merge someone's fork of your gist into your gist

How to merge someone's fork of your gist into your gist

I created a gist, then someone else forked it and improved it. With a full repository, I might get their improvements in a pull request. But that isn't availabe for gists.

This is how to get their changes into my gist.

  1. Clone your own gist

     git clone git@gist.github.com:YOUR_GIST_ID_GOES_HERE.git
    
@arthurattwell
arthurattwell / electric-book-tools-setup-osx.md
Last active September 16, 2023 04:20
Setting up the Electric Book toolset on OSX

Setting up the EBW tools on Mac OSX

These steps have worked for us on several machines. Every machine is a bit different, so your mileage may vary.

https://jekyllrb.com/docs/installation/macos/

On Windows? I've written up guidance for installing on Windows here.

  1. Install Homebrew (without XCode -- you do not need to install XCode!). This is done in two steps from the Terminal. See ryanwinchester.ca/posts/installing-homebrew-without-xcode. Essentially:
    1. Install XCode developer tools (lets Homebrew work):
@arthurattwell
arthurattwell / pandoc-docx-md.bat
Last active September 5, 2023 02:35
Script to convert docx to markdown with Pandoc
:: pandoc-docx-md.bat
::
:: Don't show these commands to the user
@ECHO off
:: Set the title of the window
TITLE Convert docx to markdown with Pandoc
:: Select file marker
:selectfile
:: Clear any preexisting filename variables
SET filename=
@arthurattwell
arthurattwell / also-save-idml.js
Last active August 22, 2023 19:25
InDesign Startup Script that saves an IDML copy alongside INDD automatically
// This InDesign Startup Script saves an IDML copy of the INDD file you're saving.
// Save it in your Startup Scripts folder. For how to do that, open the tutorial
// for your version of InDesign here: https://www.adobe.com/devnet/indesign/documentation.html
// and look for the section titled 'Installing scripts'.
// Thanks to fabiantheblind here http://graphicdesign.stackexchange.com/a/71736/67488
// for the original script, which I've adapted to work as a startup script.
// Set a targetengine to make this work
#targetengine "session"
@arthurattwell
arthurattwell / epub2mobi.bat
Last active August 6, 2023 17:11
Batch script to convert multiple epubs to mobi
:: This batch script converts all the epubs in its folder to mobi.
:: It requires that you have Kindlegen installed, see
:: https://www.amazon.com/gp/feature.html?docId=1003018611
:: Thanks http://www.mobileread.com/forums/showpost.php?p=2554984&postcount=2
:: For the latest version of this script, see
:: https://gist.github.com/arthurattwell/79a69ad9cda5e5518c6fe4c32d207b2c
:: Don't show these commands to the user
@echo off
:: Keep variables local, and expand at execution time not parse time
@arthurattwell
arthurattwell / userChrome.css
Last active July 3, 2023 11:51
Add numbers to Firefox tabs for easier Ctrl+n tab switching
/* userChrome.css can change the Firefox UI.
For details, see https://www.userchrome.org/
Instructions
------------
Save it to your Firefox 'Profile Folder'. To find that folder:
enter about:support in the Firefox address bar and look for it in the list.
Save this file to that folder. Then tell Firefox to load it:
enter about:config in the address bar, and search for userprof
and if that setting exists, set the following value to true:
@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 / random
Last active April 26, 2023 13:21
Jekyll include for generating random strings
{% 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 / 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 / md-to-betterquiz.md
Last active January 10, 2023 14:22
Converting markdown MCQs to Betterquiz BQF format

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.