Skip to content

Instantly share code, notes, and snippets.

@mattcuk
mattcuk / wifiLogicAppPing.ino
Created Feb 16, 2021
ESP8266 Wifi Connect & Ping to Azure-based Logic App URL over HTTPS
View wifiLogicAppPing.ino
// WIFI SETUP & LOGIC APP URL
char ssid[] = "YOUR_WIFI_SSID";
char pass[] = "YOUR_WIFI_PASSWORD";
char logicAppURL[] = "https://YOUR_LOGIC_APP_URL";
// HTTP AND WIFI
// Needed to go here & install board support for ESP8266. https://github.com/gojimmypi/ESP8266-Arduino
// This gave access to the WiFiClientSecureBearSSL client library (which is needed for HTTPS).
@mattcuk
mattcuk / usb-dal-multiline-registry.reg
Created Oct 26, 2020
Example multi-line registry entry file for USB Detect & Launch
View usb-dal-multiline-registry.reg
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\VB and VBA Program Settings]
[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\USBDetector]
[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\USBDetector\Settings]
"Interval"="10"
"Advanced"=hex(1):6c,00,61,00,62,00,65,00,6c,00,3a,00,28,00,61,00,6e,00,79,00,29,00,0a,00,65,00,78,00,65,00,63,00,3a,00,22,00,43,00,3a,00,5c,00,41,00,70,00,70,00,5c,00,55,00,53,00,42,00,2d,00,57,00,61,00,72,00,6e,00,69,00,6e,00,67,00,2e,00,62,00,61,00,74,00,22,00,20,00,22,00,25,00,31,00,22,00,0a,00,69,00,67,00,6e,00,6f,00,72,00,65,00,3a,00,63,00,3a,00,5c,00,\
00,00
@mattcuk
mattcuk / usb-dal-multiline-registry.vbs
Created Oct 26, 2020
Example multi-line registry entry for USB Detect & Launch
View usb-dal-multiline-registry.vbs
set ShellObj = CreateObject("WScript.Shell")
ShellObj.RegWrite "HKCU\Software\VB and VBA Program Settings\USBDetector\Settings\Advanced", "label:(any)" & vbCrLf & "exec:""C:\App\USB-Warning.bat"" ""%1""" & vbCrLf & "ignore:c:\", "REG_SZ"
ShellObj.RegWrite "HKCU\Software\VB and VBA Program Settings\USBDetector\Settings\Interval", "10", "REG_SZ"
@mattcuk
mattcuk / emailBody.js
Created Apr 12, 2020
Azure Logic App - Inline Code - Generate HTML for an Email Body
View emailBody.js
var titles = workflowContext.actions.Execute_JavaScript_Code.outputs.body;
var html = '';
titles.forEach(function(fulltitle) {
var title = fulltitle.substr(5); // Strip off the first 5 characters.. '12 - Headline' becomes 'Headline'
html += fulltitle +
' | <a href="https://www.somesite.com/find?q='+title+'">Somesite</a>' +
@mattcuk
mattcuk / multiFilter.js
Created Apr 12, 2020
Azure Logic App - Inline Code - Multi Part Filter
View multiFilter.js
var titles = workflowContext.actions.Filter_array_on_year.outputs.body;
var newTitles = [];
const regex = /(.*)(2019|2020|2021).*/i; // Regex for year filtering
titles.forEach(function(item) {
// Additional filter for titles containing 1080p only
if (item.title.indexOf('1080p') > -1) {
// Extract the title and year only
var titleMatch = regex.exec(item.title);
@mattcuk
mattcuk / simpleTextFilter.js
Created Apr 12, 2020
Azure Logic App - Inline Code - Simple Text Filter
View simpleTextFilter.js
const filtered = workflowContext.actions.Current_JSON.outputs.filter(item => item.display_name=='My search string');
return filtered;
@mattcuk
mattcuk / listMissingAlerts.sh
Created Apr 3, 2020
List the Azure Logic Apps which don't have an Alert set up against them
View listMissingAlerts.sh
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)
@mattcuk
mattcuk / listLogicApps.sh
Created Apr 3, 2020
Simple script to list out all Logic Apps in a subscription.. one per line
View listLogicApps.sh
logicapps=$(az resource list --output tsv --resource-type "Microsoft.Logic/workflows" --query [].id)
for logicapp in $logicapps
do
echo "$logicapp"
done
@mattcuk
mattcuk / listAlertIds.sh
Created Apr 3, 2020
List out all Azure resources that have Alerts set up (escapes Alert ID to get around issue with spaces)
View listAlertIds.sh
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 / led-ring-backlight.ino
Created Feb 25, 2019
Arduino code to create an ambient backlight using an RGB LED ring
View led-ring-backlight.ino
#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