Skip to content

Instantly share code, notes, and snippets.

View arthurattwell's full-sized avatar

Arthur Attwell arthurattwell

View GitHub Profile
@arthurattwell
arthurattwell / com.apple.ibooks.display-options.xml
Created May 12, 2016 17:00
Apple iBooks display options file for META-INF folder in .epub – basic settings
<?xml version="1.0" encoding="UTF-8"?>
<display_options>
<platform name="*">
<option name="specified-fonts">true</option>
<option name="interactive">false</option>
<option name="fixed-layout">false</option>
<option name="open-to-spread">false</option>
<option name="orientation-lock">none</option>
</platform>
</display_options>
@arthurattwell
arthurattwell / dialog.html
Last active August 1, 2022 09:54
Google Sheets script to allow multi-select in cells with data-validation (adapted from https://www.youtube.com/watch?v=dm4z9l26O0I)
<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 / 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 / start-attribute-workaround.scss
Last active July 11, 2016 09:06
Workaround in Sass for EPUB2's XHTML not supporting `start` attribute
// Workaround for EPUB2's XHTML not supporting `start` attribute
// In HTML, regex search-replace
// <ol (.*?)start="(\d+)"
// with
// <ol \1class="start-\2"
// Create 20 options for starting numbering
@for $i from 2 through 20 {
$start: $i + 1;
// If we the list ol to start at 1, the first li will be 2
@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 / regular-myrepos-update.sh
Last active September 14, 2016 05:28
Script to run regular updates to Git repos
#! /bin/bash
#
# ###############################################
# This script updates all my repos regularly.
# It's easier than using cron, where environments
# and permissions are a headache.
# ###############################################
#
# Ask how many seconds to leave between each update.
echo "How many seconds between each update?"
@arthurattwell
arthurattwell / princexml-reset.css
Last active November 21, 2019 13:28
Reset CSS for PrinceXML
/* Reset PrinceXML CSS (XHTML stylesheet) */
h1, h2, h3, h4, h5, h6 {
font-weight: inherit;
font-size: inherit;
}
address {
font-style: inherit;
}
@arthurattwell
arthurattwell / underline-control.scss
Created October 13, 2016 10:07
Sass mixin to control text underline (designed for use with PrinceXML)
@mixin underlined($thickness,$start-position,$end-position,$vertical-position) {
display: inline-block;
position: relative;
&:after {
content: "";
position: absolute;
display: inline-block;
left: $start-position; // 0 is flush with start of text
right: $end-position; // 0 is flush with end of text
bottom: $vertical-position; // Positive units move underline closer to text, negative units further away
@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
*