Skip to content

Instantly share code, notes, and snippets.

View JonTheNiceGuy's full-sized avatar

Jon "The Nice Guy" Spriggs JonTheNiceGuy

View GitHub Profile
@JonTheNiceGuy
JonTheNiceGuy / ec2_start.php
Created June 5, 2014 20:19
This code snippet lets you start an EC2 instance using the PHP SDK (and means you don't need to spin up a JVM for it)
<?php
// This code is released under a CC-Zero license
// https://creativecommons.org/publicdomain/zero/1.0/
// You need the AWS SDK - get the zip file from here:
// http://pear.amazonwebservices.com/get/aws.zip
// And then unpack it to this directory.
require dirname(__FILE__) . '/aws-autoloader.php';
// Use the Ec2Client libraries by referring just to Ec2Client
@JonTheNiceGuy
JonTheNiceGuy / AA_Manipulating yaml tree data using Ansible.md
Last active February 21, 2019 09:35
Manipulating yaml tree data using Ansible

Manipulating yaml tree data using Ansible

I sometimes need to convert from a dictionary tree (like in data.yml) to a specific json formatted output file using Ansible.

In this case, I've used a combination of set_fact, a for loop and a combine filter to build my output. I'm also using a regex_search to make sure I'm only getting records where the data I'm interested in is there!

Hope it's useful to people!

Mapping the FortiGate Timezone Field with the TZ Database

This yml file shows the relationship between the tz_database values for regions (e.g. Europe/London) and the Fortigate "system global timezone" value (e.g. 25 = Europe/London).

The TZ Database names are taken from a Wikipedia entry on TZ values, and the Fortigate values are found by me splitting the strings (on comma's) from when I have tried auto-completing the timezone field on a Fortigate model.

It is not a perfect list! Updates welcome!!

@JonTheNiceGuy
JonTheNiceGuy / AAA_Readme for KPSync.md
Created April 25, 2019 22:35
Three-way sync on Keepass files, using Keepass2 and KPScript on a Linux based system.

This script is used if you want to do a three-way sync between (for example) Dropbox, Nextcloud and Syncthing (depending on your personal deployment capabilities).

It should be relatively easy to determine what tweaks are needed to reduce this to a 2-way sync, or up to a 4, 5 or even 6 way sync.

@JonTheNiceGuy
JonTheNiceGuy / ddns-update-multi-source
Last active May 1, 2019 00:28
This is a DDNS updater for the freedns.afraid.org service. It updates the DNS entries for two separate connected IP networks (for example, if you have work and personal ADSL) by amending the routing on the box. Note, you'll still need proper routing once it's inside your network!
#! /bin/sh
# Authored by Jon Spriggs (jon@sprig.gs) on 2015-03-10
# Based on the DDNS script at afraid.org
#!/bin/bash
# ALTERNATE ROUTE
# This is the path for the second DDNS update to take
NEW_ROUTE=192.168.1.1
# TUNNELBROKER.NET CONFIGURATION
@JonTheNiceGuy
JonTheNiceGuy / Vagrantfile
Created August 6, 2019 15:36
Wordpress Development Machine in Vagrant
# Some of this is based on https://peteris.rocks/blog/unattended-installation-of-wordpress-on-ubuntu-server/
# and https://www.hongkiat.com/blog/install-wordpress-locally-vagrant/
Vagrant.configure("2") do |config|
config.vm.define "wordpress" do |wordpress|
wordpress.vm.hostname = "wordpress"
wordpress.vm.provider "virtualbox" do |vb|
vb.name = "wordpress"
end
@JonTheNiceGuy
JonTheNiceGuy / ssb_description.sh
Created November 19, 2019 16:14
How to publish an "about" message on Secure Scuttlebutt
ssb_id="$(if command -v jq >/dev/null 2>&1 ; then ssb-server whoami | jq -r .id ; else ssb-server whoami | grep id | cut -d\" -f4 ; fi)"
ssb-server publish --type about --about "$ssb_id" --name "JonTheNiceGuy" --description "Linux advocating geek. Fujitsu Distinguished Engineer since 2018. Blogging @ [jon.sprig.gs](jon.sprig.gs)
[Twitter](https://twitter.com/JonTheNiceGuy)|[FB](https://facebook.com/JonTheNiceGuy)|[LinkedIn](https://linkedin.com/in/JonTheNiceGuy) @ JonTheNiceGuy
🗺️ [Glossop, Derbyshire, UK : Maidenhead Grid: IO93ak](http://levinecentral.com/ham/grid_square?Grid=IO93ak) - Amateur Radio Callsign: [G7VRI](https://hamqth.com/g7vri)
He/Him
SameAs [Blog](@EFWzZK2K+b++CbBszsVkAB+WHlRJtX2kX8ynaJp0nHA=.ed25519), [Mobile](@3SEA7qNZQPiYFCzY6K57f0LTc9l+Bk6cewQc6lbs/Ek=.ed25519), [Laptop 1](@p3gu8eLHxXC0cuvZ0yXSC05ZROB4X7dpxGCEydIHZ0o=.ed25519), [Laptop 2](@3xnWXOEsfSNvazULuT54WL8AxGcUNCRyBPbCWcR/1ow=.ed25519), [Tablet](@ayUZ+IXBH8zX0HLk8A6h9YzIGy+LKy/RDIKJOT/xeVQ=.ed25519), [dispatch.sprig.gs Pub](@xp+Z

Thoughts on #SameAs

Preamble

I am not a particularly good coder. As such take these as a suggestion of what could be, not what is happening! If this were to be accepted, it would need to be adopted by all the SSB clients (ssb-server, manyverse, etc). Also, this may be extremely simplistic and may produce far too many messages to the pool very quickly!

I asked on the Scuttlebutt IRC channel, and it was suggested that @MixMix might be interested in this?

Actors