Skip to content

Instantly share code, notes, and snippets.

@dansimau
dansimau / git-fetch-reminder.sh
Last active March 31, 2020 11:48
Prints a reminder if you haven't fetched from a git repo for some period of time
#!/bin/bash
#
# Print a reminder if a fetch has not been done in n hours.
#
# There are multiple ways you could invoke this; for example, to have it run
# whenever you change directory you could do:
#
# cd() { command cd "$@"; ~/bin/git-fetch-reminder.sh 2>/dev/null; }
#
#
# Filter input to remove content matching regexp, then output to stdout.
#
# Example:
# cat data.sql | python3 re-filter.py "CREATE TRIGGER.*?;"
#
import re
import sys
matcher = re.compile(sys.argv[1], re.MULTILINE | re.DOTALL | re.IGNORECASE)
@dansimau
dansimau / spfincludelookup.sh
Last active April 28, 2022 08:44
Recursively return all SPF includes for a given domain
spfincludelookup() { for entry in $(dig +short TXT "$@" |grep --color=never spf); do [ "${entry:0:7}" == "include" -o "${entry:0:6}" == "exists" ] && echo $entry && spfincludelookup ${entry:8}; done; }
spfincludelookup "$@"
@dansimau
dansimau / send-grafana-cloud-metric.sh
Created May 16, 2022 09:14
Push metric to a Grafana Cloud Graphite instance
#!/bin/bash
set -euo pipefail
api_key="" # API key from Grafana Cloud
metrics_user="" # Graphite username from Grafana Cloud console
metrics_endpoint="" # Graphite endpoint from Grafana Cloud console
now=$(date +%s)
@dansimau
dansimau / recursively-list-users-in-azure-ad-group.py
Last active May 18, 2022 14:03
Recursively list users in an Azure AD group
#!/usr/bin/env python3
import json
import subprocess
import sys
from typing import List
def list_users_in_groups(group_names: List[str]):
groups_stack: List[str] = group_names;
users: List[str] = [];
@dansimau
dansimau / README.md
Created August 11, 2022 13:49
Getting PowerShell running on macOS (M1) - August 2022

Getting PowerShell running on macOS (M1) - August 2022

We need to run everything under x86 emulation, because Powershell needs opensslv1 and opensslv1 only builds under x86.

Create home directory and script to launch x86 shell:

mkdir -p $HOME/x86shell
cat <<EOF > $HOME/x86shell/.bash_profile
export PATH=$PATH:/usr/bin
@dansimau
dansimau / README.md
Created September 26, 2023 14:19
Command execution in Maestro

Quick start

  • Start the exec server
tsx exec-server.ts &
  • Run Maestro test