Skip to content

Instantly share code, notes, and snippets.

@mjsqu
mjsqu / env_config_toggle.py
Created January 31, 2024 20:41
Meltano: Env Config Toggle
#!/usr/bin/env python
# Takes an input file and determines if it is a .env or a JSON config file
# outputs the opposite of the input file to stdout for redirection to an env/config file
# useful for moving from meltano to tap testing, vice-versa
# optional arg[2] is prefix, which will chop off an .env prefix or add a prefix if going the other way
import sys
import json
import re
infile = sys.argv[1]
@mjsqu
mjsqu / single_table.py
Created January 31, 2024 20:40
Singer Catalog Single Table Extractor
#!/usr/bin/env python
import json
import sys
full_catalog=sys.argv[1]
schema_table=sys.argv[2]
try:
replication_method = sys.argv[3]
replication_key = sys.argv[4]
except:
@mjsqu
mjsqu / dataverse_pyodata.py
Created January 28, 2024 20:31
Dataverse MSAL pyodata - pyodata not compatible with odata v4 (odata >v2)
import msal
import pyodata
"""
The configuration file would look like this (sans those // comments):
{
"authority": "https://login.microsoftonline.com/Enter_the_Tenant_Name_Here",
"client_id": "your_client_id",
"scope": ["https://graph.microsoft.com/.default"],
@mjsqu
mjsqu / CreateShapes.bas
Created December 4, 2023 18:52
Select a range of cells in Excel - creates shapes containing the text in the cells
Sub CreateShapes()
i = 0
For Each cell In Selection
Set shp = ActiveSheet.Shapes.AddShape(msoShapeRectangle, i * 20, i * 20, 72, 20)
With shp.TextFrame2
.VerticalAnchor = msoAnchorMiddle
.TextRange.ParagraphFormat.Alignment = msoAlignCenter
.AutoSize = msoAutoSizeShapeToFitText
.WordWrap = msoFalse
.TextRange.Characters.Text = cell.Value
@mjsqu
mjsqu / strava_climb.js
Created November 9, 2023 03:14
Strava Challenge Climb Remaining Bookmarklet
/* Construct day month year link for Strava Cycling Climbing Challenge */
const d = new Date()
const m = d.toLocaleString('default', {'month':'long'})
const y = d.getFullYear()
const url="https://www.strava.com/challenges/"+m+"-Cycling-Climbing-Challenge-"+y
window.location = url
/* Alert of climb per day remaining */
var arrCalculation = document.querySelectorAll('[class*="ProgressBar--label-"]')
for (a of arrCalculation) {
@mjsqu
mjsqu / secrets.py
Last active September 28, 2023 02:42
A backend for AWS to obtain Secrets from multiple parameters (untested)
import json
import re
from airflow.providers.amazon.aws.secrets.systems_manager import (
SystemsManagerParameterStoreBackend,
)
class SSMMultiParameterBackend(SystemsManagerParameterStoreBackend):
def _get_secret(
# Prints the lines from a document (docfile) that match a regex (rx)
Function PrintWord($docfile,$rx){
# Expand-Archive to a temporary directory
$tempfile = New-TemporaryFile
$tempzipfile = "{0}{1}" -f $($tempfile.Fullname,'.zip')
Remove-Item $tempfile
Copy-Item $docfile $tempzipfile
# Expand-Archive to a temporary directory
@mjsqu
mjsqu / TA2020.py
Last active February 12, 2020 00:55
Tour Aotearoa File Splitter
#!/usr/bin/python
# TA file reducer, splitter for Garmin Edge 200
# Takes the big file from the website and creates new smaller files with ONLY trkpt tags
# Simple version of code - assumes program, file and output files are all in the same directory
import re
# Assumes the input file is in the current directory
infile = 'Tour-Aotearoa-route-20200123-Kennett-Bros.gpx'
# Regular expression to capture only the first part of the trkpt tag, and encased attributes (usu. lat= long=)
@mjsqu
mjsqu / ReflectionSessionColours.vba
Last active December 5, 2019 23:42
Various functions to change colours on a MicroFocus Reflection for IBM session
Public CyanRGB As Double
Public RedRGB As Double
Public GreenRGB As Double
Public BlueRGB As Double
Public YellowRGB As Double
Public BlackRGB As Double
Public WhiteRGB As Double
Public CurrentScheme As Integer
Public WhiteR As Integer
Public WhiteG As Integer
@mjsqu
mjsqu / LotusNotes Query.vb
Last active September 9, 2019 03:14
Gets Lotus Notes NotesDocument information from a NotesDatabase
' Requires that LotusNotes Item/Field names are entered across the first row in a sheet
' E.g. Try adding Title, Status, Initiator on the first row
' Fills out values based on criteria entered in "SearchString" - currently set to "Author is me"
Sub GetDocProps()
Set Session = CreateObject("Lotus.NotesSession") 'Start a session to notes
strPass = ""
Call Session.Initialize(strPass)
strSrv = ""
strDb = ""
Set Db = Session.GETDATABASE(strSrv, strDb)