Skip to content

Instantly share code, notes, and snippets.

@mattcuk
mattcuk / tampermonkey-feathertest-variable-support.js
Created March 23, 2018 12:57
TamperMonkey script to add variable access to FeatherTest
// ==UserScript==
// @name FeatherTest Variable Support
// @namespace http://mysite
// @include http*://mysite/*
// @description Add support for FeatherTest variable access. Matt Collinge.
// @version 1.0
// @grant all
// ==/UserScript==
function featherTestSupport() {
@mattcuk
mattcuk / feathertest-metadata.txt
Last active March 23, 2018 13:08
FeatherTest - Output Page Metadata
'feathertest'
console.log('%cSUDO - HOMEPAGE', 'color:orange');
location.href = '/site_root/'
60000
console.log('%cSUDO - '+location.href, 'color:orange');
console.log('%cSUDO - meta_title = '+$('meta[name="title"]').attr('content'), 'color:orange');
console.log('%cSUDO - meta_og:title = '+$('meta[property="og:title"]').attr('content'), 'color:orange');
console.log('%cSUDO - meta_description = '+$('meta[name="description"]').attr('content'), 'color:orange');
console.log('%cSUDO - meta_og:description = '+$('meta[property="og:description"]').attr('content'), 'color:orange');
@mattcuk
mattcuk / feathertest-variables.txt
Created March 23, 2018 13:10
FeatherTest - Output Page Variables (and JSON-LD)
'feathertest'
console.log('%cSUDO - HOMEPAGE', 'color:orange');
location.href = '/site_root/'
60000
console.log('%cSUDO - '+location.href, 'color:orange');
// Output JSON-LD on page
$('script[type="application/ld+json"]').each(function(index,json){ console.log('%cSUDO - '+JSON.stringify(JSON.parse(json.innerHTML),null,2), 'color:orange') });
// Output the contents of some JavaScript variables
window.postMessage({ "action": "variable", "value": "myVar.hierarchy"}, window.origin);
@mattcuk
mattcuk / callenergenie.sh
Created April 22, 2018 18:01
This will make the webserver call as a background task, so control will be given back to the service immediately, rather than it waiting for the wget to complete.
echo Calling energenie socket...
wget --quiet --background --output-document="callenergenie.log" "http://192.168.1.99/callenergenie.php?delay=10&switch=2&state=off"
echo Sleeping for 2 seconds
sleep 2
echo Done.
exit 0
@mattcuk
mattcuk / callenergenie.service
Created April 22, 2018 18:02
OSMC shutdown script.. runs when OSMC is shutting down, but before the network code closes
[Unit]
Description=Energenie Remote Call to Secondary Pi
Before=multi-user.target
After=network.target
Conflicts=shutdown.target
[Service]
ExecStart=/bin/true
ExecStop=/bin/sh /home/osmc/callenergenie.sh
Type=oneshot
@mattcuk
mattcuk / callenergenie.php
Created April 22, 2018 18:03
Basic webservice to allow us to control an Energenie power socket
<?php
/* MattC - Call this with various parameters..
callenergenie.php?
delay = time in seconds to sleep before calling Energenie
switch = which socket to talk to
state = turn socket on/off
e.g. callenergenie.php?delay=5&switch=2&state=off
@mattcuk
mattcuk / led-ring-backlight.ino
Created February 25, 2019 14:15
Arduino code to create an ambient backlight using an RGB LED ring
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6 // pin on the Arduino is connected to the LED ring
#define NUMPIXELS 24 // Number of pixels on the LED ring
#define POT_PIN 0 // Potentiometer pin
#define BUTTON_PIN 2 // Button pin
@mattcuk
mattcuk / listAlertIds.sh
Created April 3, 2020 14:24
List out all Azure resources that have Alerts set up (escapes Alert ID to get around issue with spaces)
alerts=$(az resource list --output tsv --resource-type "Microsoft.Insights/metricAlerts" --query [].id)
alerts=${alerts// /SPACEFIX}
for alert in $alerts
do
az resource show --ids "${alert//SPACEFIX/ }" --query properties.scopes[0] --output tsv
done
@mattcuk
mattcuk / listLogicApps.sh
Created April 3, 2020 14:25
Simple script to list out all Logic Apps in a subscription.. one per line
logicapps=$(az resource list --output tsv --resource-type "Microsoft.Logic/workflows" --query [].id)
for logicapp in $logicapps
do
echo "$logicapp"
done
@mattcuk
mattcuk / listMissingAlerts.sh
Created April 3, 2020 14:26
List the Azure Logic Apps which don't have an Alert set up against them
echo Finding what Alerts exist already ...
./listAlertIds.sh > listAlertIds.tmp
echo Finding what Logic Apps exist ...
./listLogicApps.sh > listLogicApps.tmp
echo Logic Apps without an Alert are ...
comm -23 <(sort -u ./listLogicApps.tmp) <(sort -u ./listAlertIds.tmp)