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 / com.apple.ibooks.display-options.xml
Created May 12, 2016
Apple iBooks display options file for META-INF folder in .epub – basic settings
View com.apple.ibooks.display-options.xml
<?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 / start-attribute-workaround.scss
Last active Jul 11, 2016
Workaround in Sass for EPUB2's XHTML not supporting `start` attribute
View start-attribute-workaround.scss
// 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 / regular-myrepos-update.sh
Last active Sep 14, 2016
Script to run regular updates to Git repos
View regular-myrepos-update.sh
#! /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 / underline-control.scss
Created Oct 13, 2016
Sass mixin to control text underline (designed for use with PrinceXML)
View underline-control.scss
@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-no-crop-marks.css
Created Oct 15, 2016
CSS to remove crop marks when creating PDFs with PrinceXML
View print-no-crop-marks.css
@charset "utf-8";
/* Remove crop marks */
@page {
marks: none !important;
}
@arthurattwell
arthurattwell / print-no-bleed.css
Created Oct 15, 2016
CSS to remove bleed when creating PDFs with PrinceXML
View print-no-bleed.css
@charset "utf-8";
/* Remove bleed */
@page {
prince-bleed: 0 !important;
prince-trim: 0 !important;
}
@arthurattwell
arthurattwell / README.md
Last active Dec 20, 2016
PrinceXML workaround for 'border-inside' (or 'border-outside')
View README.md

PrinceXML workaround for 'border-inside' (or 'border-outside')

Currently, Prince does not give us 'border-inside', only margin-inside (e.g. see http://www.princexml.com/forum/topic/717/padding-inside-padding-outside). But sometimes we really want a border-inside or border-outside, for example when we have sidenotes in an outer sidebar.

Hence this workaround! We position this element relative and give it a background color, then we put a pseudo element with a solid background colour exactly behind it (position: absolute) adjusting top and bottom for padding if necessary.

We need to put some invisible content in there to make it appear.

Finally, we shift it inside slightly exposing its edge as a 'border', and hide the rest behind its parent with a negative z-index.

@arthurattwell
arthurattwell / basic-git-for-editorial-teams.md
Created Feb 22, 2017
Basic GitHub steps for editorial teams
View basic-git-for-editorial-teams.md

This is a telegraphic overview of the steps for using Git in a non-technical (e.g. editorial) team. It assumes you're using GitHub to host your files (the 'origin'), and GitHub Desktop on your computer as your 'Git client'.

Overview

  1. Git takes snapshots of everything inside a given folder, which we call a repository or 'repo'.
  2. We call each snapshot a 'commit'. Git gives every commit a unique ID number, called a 'hash'.
  3. When working on a team, you make a copy of the original repo in your own GitHub account. Your copy is called a 'fork'.
  4. You take snapshots (commits) of your fork as you work, and sync them to GitHub.com.
  5. From time to time, you submit your changes to be included in the original repo. Technically, Git submits the difference ('diff') between your fork's latest commit and the latest commit on the original.
@arthurattwell
arthurattwell / adjustable-dotted-line.scss
Created Dec 5, 2017
Dotted lines top and bottom, with adjustable size and gap
View adjustable-dotted-line.scss
// This Sass mixin adds a dotted line above and below an element, e.g. a heading.
// It was written for use in print output with PrinceXML,
// but should work as well in browsers. YMMV.
// The dot is an SVG circle encoded into the CSS.
// The SVG includes the dot and space on its left and right.
// To change the gap, change the width attribute.
// A width of 400 means the gap is 3 times the width of the dot.
// That is, width = the dot (at 100) plus the gap.
$dot-svg: 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="100" width="400"><circle cx="50%" cy="50%" r="50"/></svg>';
@arthurattwell
arthurattwell / install phantomjs 2.1.1 - ubuntu
Last active Dec 20, 2017 — forked from telbiyski/install phantomjs 2.1.1 - ubuntu
Install PhantomJS 2.1.1 on Ubuntu 14.04
View install phantomjs 2.1.1 - ubuntu
sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev -y
sudo apt-get install libfreetype6 libfreetype6-dev -y
sudo apt-get install libfontconfig1 libfontconfig1-dev -y
cd ~
export PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"
wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2
sudo mv $PHANTOM_JS /usr/local/share
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/bin
You can’t perform that action at this time.