Skip to content

Instantly share code, notes, and snippets.

View nottrobin's full-sized avatar

Robin Winslow nottrobin

View GitHub Profile
@nottrobin
nottrobin / old-insights-url-paths.sh
Created February 7, 2018 15:46
URL paths from the old insights.ubuntu.com, and whether to redirect them to a new place or not
# URLs to redirect
/articles
/{anything}/feed
/canonical-announcements
/case-studies
/category/{category}
/category/{category}/year/{year}
/group/{slug}
/group/{slug}?cat=1172
@nottrobin
nottrobin / remove-blank-lines.sh
Created October 16, 2017 15:02
Remove multiple blank lines next to each other from a file
#!/bin/sh
grep -v -A1 '^[[:blank:]]*$' $1 | grep -v "^--$" > $1.tmp
mv $1.tmp $1
@nottrobin
nottrobin / fix-dates.py
Created October 16, 2017 14:06
Fix dates in markdown frontmatter files for the new usn.ubuntu.com site
#! /usr/bin/env python3
import re
import dateutil.parser
import glob
import frontmatter
date_re = re.compile(r'(?<=\n[*]).*(?=[*]\n)')
@nottrobin
nottrobin / gist:23b09ef2732cc9d0e71e7663178a5b56
Created October 1, 2017 17:40
Blog posts to do something with
https://robinwinslow.uk/2013/01/18/where-do-i-sign-up-for-the-open-access-movement/ (follow-up)
https://robinwinslow.uk/2012/12/13/oss-projects-i-d-love-to-get-involved-with/ (revisit)
https://robinwinslow.uk/2012/12/12/note-to-self-technical-aspirations/ (revisit)
https://robinwinslow.uk/2012/12/07/continuous-improvement-and-tdd-bdd/ (follow-up)
https://robinwinslow.uk/2012/12/07/a-blogs-existential-quest/ (mention)
https://robinwinslow.uk/2012/09/28/i-am-a-published-author-of-a-journal-article/ (rename)
https://robinwinslow.uk/2012/08/06/finding-a-free-version-of-gill-sans/ (delete?)
https://robinwinslow.uk/2012/07/17/installing-vagrant-on-centos-the-more-reliable-way/ (delete?)
https://robinwinslow.uk/2012/04/10/sending-emails-individually-to-many-people-in-php/ (collate?)
https://robinwinslow.uk/2012/03/13/website-front-end-performance-tips/ (follow-up)
@nottrobin
nottrobin / replace-blog-images-with-assets.sh
Created September 15, 2017 16:31
The script I used for replacing image URLs for my blog with URLs to the assets server
import frontmatter
import glob
import urllib
import requests
import mimetypes
import subprocess
import json
import re
for filename in glob.glob('*.md'):
@nottrobin
nottrobin / clean-juju-model.sh
Last active May 12, 2021 19:09
To clean out a Juju model so you can use it from scratch, without deleting and recreating it
# Clear out a model, for Juju 2
# ==
# Destroy all machines and remove applications
# --
clean_model() {
model_name=${1}
juju status --model ${model_name} --format json | jq '.machines' | jq -r 'keys[]' | xargs -n 1 juju remove-machine --force # Force destroy all machines
juju status --model ${model_name} --format json | jq '.applications' | jq -r 'keys[]' | xargs -n 1 juju remove-application # Remove all applications
watch -c -n 10 juju status --model ${model_name} --color
@nottrobin
nottrobin / .gitignore
Last active May 25, 2017 07:24
A .gitignore template for Canonical's web projects
# [os] OS & editor files
Desktop.ini
Thumbs.db
._*
*.DS_Store
*~
\#*\#
__*
.AppleDouble
.LSOverride
#! /usr/bin/env python
# Core packages
import os
# Third party packages
import yaml
# Local packages
from lib.retriever import get_documentation_set
@nottrobin
nottrobin / package_has_script.sh
Created April 12, 2017 08:27
A shell function to run a docker command to check if package.json contains a specific script name
package_has_script () {
script_name="${1}"
# Check if package.json contains a script of the given name
docker run \
--volume `pwd`:`pwd` --workdir `pwd` `# Use the current directory` \
--entrypoint node `# Run plain old node` \
canonicalwebteam/yarn:v0.2.0 `# Run a short inline node script to check the package.json` \
--eval "
process.exit(
@nottrobin
nottrobin / example-codeblocks.html
Created February 28, 2017 18:32
Examples of codeblock highlighting with Pygments and the GitHub theme
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Documentation</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* docs-vanilla-theme */