Skip to content

Instantly share code, notes, and snippets.

const functionsToOverride = ['overrideMimeType', 'send'];
functionsToOverride.forEach(function(fnName) {
window.XMLHttpRequest.prototype[fnName] = new Proxy(window.XMLHttpRequest.prototype[fnName], {
apply: (target, thisArg, argumentsList) => {
console.log(fnName + ' arguments', argumentsList);
thisArg[fnName + 'Args'] = [...argumentsList];
const retVal = target.apply(thisArg, argumentsList);
console.log(fnName + ' retVal', retVal);
return retVal;
}
@chappy84
chappy84 / Dockerfile
Last active April 18, 2024 16:31
Packt Pub Downloader - Quick hacky script to download all your e-books from packtpub.com. This may not always work, they may change their api calls etc.
FROM php:cli-alpine
RUN mkdir /opt/ppd /mnt/ebooks
COPY packtPubDownloader.php /opt/ppd/
RUN sed -e "s#saveParentDir = __DIR__;#saveParentDir = '/mnt';#" -i /opt/ppd/packtPubDownloader.php
VOLUME /mnt
@chappy84
chappy84 / cloudflare_dyn_dns.sh
Last active October 29, 2023 11:10
CloudFlare Dynamic DNS Shell Script
#!/bin/sh
#
# 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
# https://www.cloudflare.com/docs/client-api.html#s5.2
#
# Use with cron jobs etc.
@chappy84
chappy84 / convert_stravactivity_to_gpx
Last active January 15, 2023 05:25
Quick and dirty PHP script to convert .stravactivity file to basic gpx xml
#!/usr/bin/env php
<?php
function dateInFormat($timestamp)
{
return date('Y-m-d\TH:i:s\Z', $timestamp);
}
function latLongInFormat($reference)
{
return round((float) $reference, 6);
@chappy84
chappy84 / xbrowsersync_api_centos.sh
Last active October 8, 2022 10:01
Setup xBroswerSync API on a CentOS box
#!/bin/sh
####################################################################################################
#
# Setup xBrowserSync API on CentOS
#
# Copyright (c) 2020, Tom Chapman (https://tom-chapman.uk)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
@chappy84
chappy84 / linode-longview-centos8.sh
Created June 5, 2020 20:44
Install script for Linode's Longview on CentOS 8 .... until they stop supporting it completely
#!/bin/sh
####################################################################################################
#
# Install Linode's LongView on CentOS 8
#
# Copyright (c) 2020, Tom Chapman (http://tom-chapman.uk)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
@chappy84
chappy84 / Dockerfile
Last active February 20, 2020 09:19
Velominati Slack Bot - Names the rule that someone is quoting in slack (Quickly hacked together script)
FROM python:2-alpine3.7
ARG slack_api_token
ENV SLACK_API_TOKEN $slack_api_token
WORKDIR /local/bot
COPY velominati-slack-bot.py ./
RUN apk update && \
@chappy84
chappy84 / linode-centos-6-or-newer-native-kernel.sh
Last active February 13, 2018 21:47
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:
### http://www.linode.com/docs/assets/542-centos5-native-kernel-selinux-enforcing.sh
### Provided via the linode wiki
### https://www.linode.com/docs/tools-reference/custom-kernels-distros/run-a-distributionsupplied-kernel-with-pvgrub#centos-5
### Provided without warranty, although since it should only be run
### on first box build if your box gets broken simply rebuild it
@chappy84
chappy84 / mongodb-install.sh
Last active January 23, 2018 16:11
Install MongoDB from source on Fedora/RedHat based Linux with SystemD
#!/bin/sh
# MongoDB Version
MONGODB_VER='2.2.2'
# Get all the dependencies up to date
yum -y update
yum -y install scons gcc-c++ glibc-devel
# Get the source
@chappy84
chappy84 / HTML5.localStorage.js
Last active December 31, 2017 10:46
HTML5 Storage without the restrictions on storing objects
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