Skip to content

Instantly share code, notes, and snippets.

View ScottHelme's full-sized avatar

Scott Helme ScottHelme

View GitHub Profile

Keybase proof

I hereby claim:

  • I am scotthelme on github.
  • I am scotthelme (https://keybase.io/scotthelme) on keybase.
  • I have a public key whose fingerprint is 0379 8197 A04C ADE5 52D6 D982 4CAB 47EE 69B5 C17D

To claim this, I am signing this object:

@ScottHelme
ScottHelme / find.sh
Created August 7, 2016 16:28
Find dev path of USB GPS device.
#!/bin/bash
for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do
(
syspath="${sysdevpath%/dev}"
devname="$(udevadm info -q name -p $syspath)"
[[ "$devname" == "bus/"* ]] && continue
eval "$(udevadm info -q property --export -p $syspath)"
[[ -z "$ID_SERIAL" ]] && continue
echo "/dev/$devname - $ID_SERIAL"
@ScottHelme
ScottHelme / netxml2kml.py
Last active December 13, 2018 02:59
Convert XML files from Kismet into KML for Google Maps or Fusion Tables
#!/usr/bin/env python
# coding=utf-8
#
# Converts netxml files from Kismet Newcore into KML or KMZ files for Google Earth
#
# Author: Patrick Salecker
# URL: http://www.salecker.org/software/netxml2kml/en
# Last modified: 13.06.2011
import os
@ScottHelme
ScottHelme / changes.txt
Created September 4, 2016 13:32
Update Ghost 0.10.0 to use Google AMP Cache
/var/www/ghost/core/server/apps/amp/lib/helpers/amp_content.js
// make relative URLs abolute
html = makeAbsoluteUrl(html, config.url, post.url).html();
html = html.replace("https://scotthelme.co.uk/content/images/", "https://cdn.ampproject.org/i/s/scotthelme.co.uk/content/images/");
/var/www/ghost/core/server/data/meta/amp_url.js
if (_.includes(context, 'post') && !_.includes(context, 'amp')) {
var cacheUrl = config.urlJoin(config.getBaseUrl(false), getUrl(data, false)) + 'amp/';
@ScottHelme
ScottHelme / amp.hbs
Last active August 31, 2018 20:20
My custom amp.hbs template for Ghost v0.10.0
<!DOCTYPE html>
<html ⚡>
<head>
<meta charset="utf-8">
<title>{{meta_title}}</title>
<meta name="description" content="{{meta_description}}" />
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<link rel="shortcut icon" href="/assets/images/favicon.ico">
{{amp_ghost_head}}
@ScottHelme
ScottHelme / brotli-compress.sh
Created October 2, 2016 14:04
Compress all blog assets with Brotli.
#!/bin/bash
for x in `find /var/www/ghost/content/themes/futura/assets/js/ -type f -iname '*.js'`
do
sudo /home/scott/nginx/brotli/bin/bro --input ${x} --output ${x}.br
sudo chown scott:ghost ${x}.br
sudo chmod 664 ${x}.br
done
for x in `find /var/www/ghost/content/themes/futura/assets/css/ -type f -iname '*.css'`
do
@ScottHelme
ScottHelme / clear-cache.sh
Created October 2, 2016 14:05
Clear Nginx cache.
#!/bin/bash
sudo find /home/nginx/ghostcache -type f -delete
@ScottHelme
ScottHelme / upgrade.sh
Created October 2, 2016 14:05
Upgrade Ghost to latest version.
#!/bin/bash
# Written by Andy Boutte and David Balderston of howtoinstallghost.com, ghostforbeginners.com, allaboutghost.com
# updateghost_digitalocean.sh will update your current Digital Ocean Ghost install to the latest version without you losing any content
if [[ `whoami` != root ]]; then
echo "This script must be run as root."
exit 1
fi
# Make temporary directory and download latest Ghost.
@ScottHelme
ScottHelme / disqus.html
Created October 20, 2016 10:03
An iframe to load Disqus comments in an AMP document.
<div id="disqus_thread"></div>
<script>
window.addEventListener('message', receiveMessage, false);
function receiveMessage(event)
{
if (event.data) {
var msg;
try {
msg = JSON.parse(event.data);
} catch (err) {
@ScottHelme
ScottHelme / test-js
Created June 22, 2018 12:22
test.js
alert(123);