Skip to content

Instantly share code, notes, and snippets.

@markgarrigan
markgarrigan / creds.json
Created January 7, 2025 18:36
Github Action Azure Login json
{
"clientId": "xxxxx-xxxxx-xxxxx-xxxxx",
"clientSecret": "xxxxx-xxxxx-xxxxx-xxxxx",
"subscriptionId": "xxxxx-xxxxx-xxxxx-xxxxx",
"tenantId": "xxxxx-xxxxx-xxxxx-xxxxx",
"activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
"resourceManagerEndpointUrl": "https://management.azure.com/",
"activeDirectoryGraphResourceId": "https://graph.windows.net/",
"sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
"galleryEndpointUrl": "https://gallery.azure.com/",
@markgarrigan
markgarrigan / generateAssociationRoutes.js
Last active December 19, 2024 17:28
Dynamic API Generation
/**
* Generates association routes for a model.
* @param {object} router - Express Router instance.
* @param {object} model - Sequelize model instance.
* @param {string} modelName - Singular name of the model.
* @param {object} associations - Associations for the model.
* @param {string} service - Service name.
*/
function generateAssociationRoutes(router, model, modelName, associations, service) {
for (const [associationName, association] of Object.entries(associations)) {
@markgarrigan
markgarrigan / ldif_to_json.sh
Last active March 27, 2024 19:23
LDAP LDIF to JSON
#!/bin/bash
# Check if an LDIF file was provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <ldif_file>"
exit 1
fi
ldif_file=$1
@markgarrigan
markgarrigan / netlify-sse.js
Last active May 26, 2023 19:55
Netlify Edge Function for SSE
export default function sse({ path, body }) {
let timerId;
const response = new ReadableStream({
start(controller) {
timerId = setInterval(() => {
const msg = new TextEncoder().encode(
`data: hello at ${new Date().toUTCString()}\r\n\r\n`,
);
controller.enqueue(msg);
}, 1000);
@markgarrigan
markgarrigan / deepDiff.js
Last active December 30, 2022 05:37
Deep diff of javascript object.
// Not really needed. Just used for logging the FULL diff in the console
const util = require('util')
// Set up the diffs object
let diffs
function compare(item1, item2, diffRef = diffs, key) {
// Make sure we have a key
if (!key && key !== 0) {
@markgarrigan
markgarrigan / dots.js
Created November 1, 2021 18:31
Convert dot notation keys to object keys
const util = require('util')
const obj = {
"city": "De Pere",
"foo.hoo": "loo",
"foo.bar.name": "mark",
"foo.bar.age": 10,
"foo.bar.color": "larry",
"foo.bar.house.number": 523,
}
@markgarrigan
markgarrigan / nginx.conf
Created June 3, 2020 15:33
nginx config file
## user user; ## <- delete this line
worker_processes 1;
error_log /var/log/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
@markgarrigan
markgarrigan / .gitignore
Created May 19, 2020 12:45
Riot starter files.
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream {{name}} {
server {{name}};
}
upstream websocket {