Skip to content

Instantly share code, notes, and snippets.

View econandrew's full-sized avatar

Andrew Whitby econandrew

View GitHub Profile
@econandrew
econandrew / extract-comments-to-md-yaml.xslt
Created December 23, 2020 15:39
An XSLT template to extract comments from a Wordpress export XML file to a YAML-headed markdown file for Jekyll
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wp="http://wordpress.org/export/1.2/" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="rss/channel/item">
<xsl:variable name="vName" select="wp:post_name"/>
<xsl:variable name="vLink" select="link"/>
<xsl:variable name="vDate" select="wp:post_date"/>
library(ggplot2)
p <- ggplot(mtcars, aes(cyl, mpg)) + geom_point()
res <- 300
fn <- "test.png"
# Default png()
png(fn, res = res)
print(p)
dev.off()
# Load data and create base plot
mtcars$names <- rownames(mtcars)
p <- ggplot(mtcars, aes(x=wt, y=mpg)) +
geom_point(aes(size = disp, color = as.factor(carb))) +
scale_color_brewer(palette="Set1") +
scale_size(range=c(1,20)) +
scale_x_continuous(limits=c(1,4.5)) +
theme_minimal() +
theme(legend.position = "none")
@econandrew
econandrew / fuzzymatch.R
Last active May 3, 2023 03:49
R code for fuzzy sentence matching
############################################################################ ###
# FUZZY MATCHING FUNCTIONS ####
############################################################################ ###
fuzzy_prep_words <- function(words) {
# Prepares a list of words for fuzzy matching. All the other fuzzy matching
# functions will run word through this. Given a list of sentences, returns
# a list of words.
words <- unlist(strsplit(tolower(gsub("[[:punct:]]", " ", words)), "\\W+"))
@econandrew
econandrew / NominatimOnEC2.md
Last active May 19, 2023 17:51
Instructions for installing an OpenStreetMap Nominatim geocoder instance on Amazon Linux / EC2 (Dec 2014)

Installing Nominatim on Amazon Linux / EC2

  1. Introduction

The official instructions for installing Nominatim are complete, but brief in places, and several steps must be changed in the Amazon Linux environment (which is roughly CentOS / Redhat). The steps below are rough record of what I did to get it working, but I didn't keep perfect track so you shouldn't rely on them as a shell script. Just follow each step, make sure it worked, and hopefully you'll need to adapt very little (version numbers, for one thing). (I also skip in and out of root, but you can be more careful if you like.)

  1. Setting up the EC2 instance