Skip to content

Instantly share code, notes, and snippets.

View arthurattwell's full-sized avatar

Arthur Attwell arthurattwell

View GitHub Profile
@arthurattwell
arthurattwell / print-no-crop-marks.css
Created October 15, 2016 13:45
CSS to remove crop marks when creating PDFs with PrinceXML
@charset "utf-8";
/* Remove crop marks */
@page {
marks: none !important;
}
@arthurattwell
arthurattwell / print-no-bleed.css
Created October 15, 2016 13:45
CSS to remove bleed when creating PDFs with PrinceXML
@charset "utf-8";
/* Remove bleed */
@page {
prince-bleed: 0 !important;
prince-trim: 0 !important;
}
@arthurattwell
arthurattwell / doc2txt.bat
Last active August 7, 2019 06:51
Batch file to save Word docs as .txt with Libreoffice
:: doc2txt.bat
::
:: This batch file converts all the files in a folder to .txt,
:: as long as LibreOffice supports them (e.g. .doc, .docx, .odt)
::
:: 1. Make sure soffice.exe is in your PATH, e.g.
:: Edit Environment Variables, add New in user variables, and add C:\Program Files (x86)\LibreOffice 5\program
:: 2. Save this doc2txt.bat file to the folder alongside the files you want to convert.
:: 3. Make sure Libreoffice is not running. (A bug prevents soffice from working while Libreoffice is open.)
:: 4. Double-click doc2txt.bat.
@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 / html2docx.bat
Last active April 5, 2021 12:04
Batch file to convert HTML files to Word docx with Pandoc
:: This batch file converts HTML files in a folder to docx.
:: It requires Pandoc, and a list of files to convert
:: named file-list, in which each file is on a separate line,
:: and contains no spaces in the filename.
::
:: Don't show these commands to the user
@ECHO off
:: Set the title of the window
TITLE Convert html to docx
:: This thing that's necessary.
@arthurattwell
arthurattwell / README.md
Last active December 20, 2016 11:22
PrinceXML workaround for 'border-inside' (or 'border-outside')

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 / install phantomjs 2.1.1 - ubuntu
Last active December 20, 2017 05:47 — forked from telbiyski/install phantomjs 2.1.1 - ubuntu
Install PhantomJS 2.1.1 on Ubuntu 14.04
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
@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 / 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 / basic-git-for-editorial-teams.md
Created February 22, 2017 12:40
Basic GitHub steps for editorial teams

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.