Skip to content

Instantly share code, notes, and snippets.

@aembleton
aembleton / docx2md.md
Last active May 17, 2023 07:04 — forked from vdavez/docx2md.md
Convert a Word Document into MD

Converting a Word Document to Markdown in One Move

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

Installing Pandoc

On a mac you can use homebrew by running the command brew install pandoc.

The Solution

@aembleton
aembleton / gist:5063b7f2ad6889e06f27
Created July 15, 2015 11:36
Use apache commons StringUtils to pretty print an arrayt
"(" + StringUtils.join(params, ",") + ")"
@aembleton
aembleton / getPrettyDateRange.php
Created April 15, 2015 12:02
PHP function to create a date range such as '1st - 4th May 2015' or '28th August - 2nd September 2015'
function getPrettyDateRange($fromDate, $toDate) {
$fromTime = strtotime($fromDate);
$toTime = strtotime($toDate);
$fromDay = date("jS", $fromTime);
$fromMonth = date("F", $fromTime);
$fromYear = date("Y", $fromTime);
$toDay = date("jS", $toTime);
$toMonth = date("F", $toTime);
@aembleton
aembleton / Ordnance-Survey.tms
Created February 19, 2015 20:56
Ordnance Survey map to be used in QLandkarte GT.
<TMS>
<Title>Ordnance Survey</Title>
<Layer idx="0">
<Script><![CDATA[
(
function convert(z1, x1, y1)
{
serverpart = 0
serverpart = (serverpart + 1) % 4;
function encodeQuadTree(zoom, tilex, tiley)
@aembleton
aembleton / UnicodeTranslator.scala
Last active August 29, 2015 14:11
Translates between ASCII and unicode.
import scala.annotation.tailrec
object UnicodeTranslator {
private lazy val unicodeRegex = """(\\u[0-9a-fA-F]{4})""".r
def escapeUnicode(stringToEscape:String) = stringToEscape.foldLeft("") { (escaped, char) =>
if (char <= 127) {
escaped + char
} else {
@aembleton
aembleton / activator.fish
Created July 16, 2014 20:45
Add Activator for Play Framework to fish command line
function activator
~/Downloads/activator-1.2.3-minimal/./activator $argv
end
@aembleton
aembleton / StringUtils.scala
Last active December 28, 2015 15:58
Implict String Utilities
package util
/**
* Created with IntelliJ IDEA.
* User: arthur
* Date: 17/11/13
* Time: 22:26
* To change this template use File | Settings | File Templates.
*/
object StringUtils {
@aembleton
aembleton / ImageUtil.scala
Created November 18, 2013 09:28
Implicit ImageUtil class for manipulating images
package util
import java.awt.image.BufferedImage
import java.awt.{Color, Image}
/**
* Created with IntelliJ IDEA.
* User: arthur
* Date: 17/11/13
* Time: 22:26
@aembleton
aembleton / CookiesUtil.scala
Created November 18, 2013 09:27
Util for Play Cookies
package util
import play.api.mvc.{Cookie, Cookies}
/**
* Created with IntelliJ IDEA.
* User: arthur
* Date: 17/11/13
* Time: 22:26
* To change this template use File | Settings | File Templates.
package uk.transactis.csvParsing.util;
public class ArrayUtil {
/**
* Trims all elements of an array without side affect.
*
* @param array
* Array from which to base the output array
* @return A new array that equals input array but with each element