Skip to content

Instantly share code, notes, and snippets.

Tom Chapman chappy84

  • UK
Block or report user

Report or block chappy84

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
chappy84 / packtPubDownloader.php
Last active Jul 10, 2019
Packt Pub Downloader - Quick hacky script to download all your e-books from This may not always work, they may change their api calls etc.
View packtPubDownloader.php
// config values
$saveParentDir = __DIR__; // Parent dir of the ebooks and extras directories
$ebooksDir = 'ebooks'; // path of the ebooks directory relative to $saveParentDir
$extrasDir = 'ebooks' . DS . 'extras'; // path of the extras directory relative to $saveParentDir
$sleepDuration = 4; // Time to delay between page requests / different book downloads
$booksPerListPage = 25; // Book details to try requesting from the PacktPub API. This can be max 25
chappy84 /
Last active Jun 21, 2019
CloudFlare Dynamic DNS Shell Script
# CloudFlare Dynamic DNS
# Updates CloudFlare records with the current public IP address
# Takes the same basic arguments as A/CNAME updates in the CloudFlare v4 API
# Use with cron jobs etc.
chappy84 / convert_stravactivity_to_gpx
Last active Dec 27, 2018
Quick and dirty PHP script to convert .stravactivity file to basic gpx xml
View convert_stravactivity_to_gpx
#!/usr/bin/env php
function dateInFormat($timestamp)
return date('Y-m-d\TH:i:s\Z', $timestamp);
function latLongInFormat($reference)
return round((float) $reference, 6);
chappy84 / Dockerfile
Last active Sep 5, 2018
Velominati Slack Bot - Names the rule that someone is quoting in slack (Quickly hacked together script)
View Dockerfile
FROM python:2-alpine3.7
ARG slack_api_token
ENV SLACK_API_TOKEN $slack_api_token
WORKDIR /local/bot
RUN apk update && \
chappy84 /
Last active Feb 13, 2018
Install the native kernel on a CentOS 6 and Newer Linode
### Starting from a fresh CentOS 6 or newer Linode
### Enable the native kernel to boot from pvgrub
### It will autoconfigure itself with each yum update.
### This is adapted from a previous script for CentOS 5.5 found here:
### Provided via the linode wiki
### Provided without warranty, although since it should only be run
### on first box build if your box gets broken simply rebuild it
chappy84 /
Last active Jan 23, 2018
Install MongoDB from source on Fedora/RedHat based Linux with SystemD
# MongoDB Version
# Get all the dependencies up to date
yum -y update
yum -y install scons gcc-c++ glibc-devel
# Get the source
chappy84 / HTML5.localStorage.js
Last active Dec 31, 2017
HTML5 Storage without the restrictions on storing objects
View HTML5.localStorage.js
if (typeof HTML5 == 'undefined') {
var HTML5 = {};
* Wrapper class to deal with easily storing values in local storage
* without having to constantly use JSON.parse and JSON.stringify everywhere
* you want to save an object.
* @param {String} index the base index to use in the localStorage global object
* @author Tom Chapman
chappy84 / mysql_pivot.sql
Created Aug 31, 2014
MySQL Pivot Stored Procedure
View mysql_pivot.sql
DROP PROCEDURE IF EXISTS pivot_user_preferences;
CREATE PROCEDURE pivot_user_preferences(IN user_id INT)
DECLARE definition_label CHAR(255);
DECLARE label_cursor CURSOR FOR SELECT DISTINCT label FROM example_db.user_preferences;
chappy84 / githubStarred.php
Last active Nov 20, 2016
Github Starred Dates - displays when you starred repos, which seems to have disappeared from GitHub's UI :(
View githubStarred.php
function errorAndDie($message) {
echo $message . PHP_EOL;
$url = '';
do {
chappy84 / date_iso.php
Last active Dec 11, 2015
Format a local time/date using an ISO Format
View date_iso.php
function date_iso($format, $timestamp = null)
if ($timestamp === null) {
$timestamp = time();
$convert = array(
'a' => 'A' , 'B' => 'B', 'D' => 'z', 'ddd' => 't', 'dd' => 'd', 'd' => 'j',
You can’t perform that action at this time.