Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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 "$@"
#
# 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 / 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; }
#

Keybase proof

I hereby claim:

  • I am dansimau on github.
  • I am dansimau (https://keybase.io/dansimau) on keybase.
  • I have a public key ASBxOKX07kpA124KgQBfA2hD23-v7xTfi0EdIv45ePiv8wo

To claim this, I am signing this object:

@dansimau
dansimau / google-maps-takeout-to-kml.py
Created October 18, 2018 08:10
Convert starred places from Google Maps to a KML document (via Google Takeout).
"""
Takes a list of JSON files from Google Takeout's "Maps (Your Places)" and
converts them into KML documents.
"""
import json
import os
import simplekml
import sys
import unicodedata
import xml.sax.saxutils
@dansimau
dansimau / go-test-pretty.sh
Created April 10, 2017 07:49
Run `go test`, only displaying error output, plus print counts of all tests passed/failed/etc.
#!/bin/bash
#
# Runs `go test -v`, parses the output and only displays errors. Also displays
# a summary of tests passed/failed/skipped/etc.
#
set -o pipefail
declare buffer=
declare test_error=false