Skip to content

Instantly share code, notes, and snippets.

@slmcmahon
slmcmahon / checkprodtags.sh
Created January 26, 2024 13:31
Check if current deployments are tagged as production in Azure Container Registry
#!/bin/bash
ACR_NAME='the name of your ACR'
# Get all the deployment names in the current namespace
deployments=$(kubectl get deployments -o jsonpath='{.items[*].metadata.name}')
# For each deployment
for deployment in $deployments; do
# Extract the image that is currently used in this deployment
@slmcmahon
slmcmahon / azdo-var-list-compare.py
Created October 11, 2023 18:32
Compares two variable lists and reports variables that don't match
import json
import requests
import os
from requests.auth import HTTPBasicAuth
org = 'your-org'
project = 'your-project'
# the variableGroupId values from the variable libs that
# you want to compare
@slmcmahon
slmcmahon / exchangerates.py
Created February 24, 2020 21:56
Python scrape for exchange rates against USD.
from bs4 import BeautifulSoup
import requests
import collections
currencies = []
Currency = collections.namedtuple('Currency', 'country usd')
sd = requests.get("https://www.x-rates.com/table/?from=USD&amount=1")
sp = BeautifulSoup(sd.content, 'html.parser')
table = sp.find('table', {"class": "tablesorter ratesTable"})
@slmcmahon
slmcmahon / statecodes.js
Created February 23, 2020 23:43
U.S. State Codes
const axios = require('axios');
const cheerio = require('cheerio');
const url = 'https://www.infoplease.com/us/postal-information/state-abbreviations-and-state-postal-codes';
axios.get(url).then(response => {
const $ = cheerio.load(response.data);
$('table.sgmltable tr').each((i, elem) => {
const children = $(elem).children()
const stateName = $(children[0]).text();
@slmcmahon
slmcmahon / exchangerates.js
Created February 23, 2020 23:41
Exchange Rates for USD
const axios = require('axios');
const cheerio = require('cheerio');
const url = 'https://www.x-rates.com/table/?from=USD&amount=1';
axios.get(url).then(response => {
const $ = cheerio.load(response.data);
$('table.ratesTable tr').each((i, elem) => {
const children = $(elem).children()
const country = $(children[0]).text();
@slmcmahon
slmcmahon / DecodeJWT.sh
Last active September 8, 2019 22:55
Script to decode JWT from paste buffer.
#!/bin/bash
# Dependencies:
# JQ: https://stedolan.github.io/jq/download/
# if Linux, you'll need xclip: sudo apt install xclip.
# if OSX, then pbpaste is already there.
# To use this tool, just save it on your system and make
# it executable. Then, if you have copied a base64 encoded
# JWT, then you can simply execute this from a command prompt
@slmcmahon
slmcmahon / remove-soap.xslt
Last active September 1, 2019 18:52
Remove NameSpaces and SOAP Envelope
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
exclude-result-prefixes="soapenv">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<!-- remove all elements in the soapenv namespace -->
@slmcmahon
slmcmahon / loadmapping.go
Last active August 12, 2019 11:53
Read an excel document, create a JSON message and send it to an Azure function.
package main
import (
"bytes"
"encoding/json"
"fmt"
"github.com/360EntSecGroup-Skylar/excelize"
"io/ioutil"
"net/http"
"os"
@slmcmahon
slmcmahon / jmp.js
Created February 9, 2019 01:25
JIMP example
const Jimp = require("jimp");
let data = "Dev";
if (process.argv.length > 2) {
data = process.argv[2];
}
var fileName = 'ic_launcher.png';
var imageCaption = `[${data}]`;
@slmcmahon
slmcmahon / PIR_LCD.ino
Created November 21, 2018 17:16
Arduino Mini Motion Sensor with LCD
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Connection details for LCD:
// SDA --> A4
// SCL --> A5
// VCC --> 5V
// lcd is initialized with