Skip to content

Instantly share code, notes, and snippets.

@NeilMasters
NeilMasters / monitor-for-person.sh
Created October 22, 2024 17:11
Play a sound file when a user posts a message into a specific slack channel
#!/bin/bash
###########################################################################
#
# Very very rough script! Does not work well!
#
# Will monitor a slack channel (has to be public unless you give it special
# permissions) for a specific user and if there is a message in the last 30
# seconds will play a sound file of your choosing. Obviously not great
# for conversational channels.
#
@NeilMasters
NeilMasters / sprint-time-support.php
Created September 26, 2024 12:28
Generic Jira issues script for pulling a JQL list of issues based on type and sprint
<?php
include('vendor/autoload.php');
$sprint = $argv[1];
$email = '';
$token = '';
$domain = '';
$project = '';
$type = '';
@NeilMasters
NeilMasters / db-sizes.sh
Created August 7, 2024 16:41
Generate size data for all databases in a mysql server
#!/bin/bash
# A simple bash script which will generate 2 csv files; database sizes and
# table sizes for all databases.
#
# This does use performance_schema so ya know... take it with a pinch of salt.
CLUSTER_HOST=$1
CLUSTER_PORT=3306
CLUSTER_REF=$2
@NeilMasters
NeilMasters / phpmd-pretty
Created July 26, 2024 10:03
PHPMD Pretty
#!/usr/bin/env php
<?php
/**
* A very simple and basic utility that can be used to pipe phpmd errors and format
* in a cleaner way. This suits MY requirements and you will probably want line numbers
* etc so edit as you see fit.
*
* Example use:
* vendor/bin/phpmd ./src xml ./ruleset.xml | bin/phpmd-pretty
@NeilMasters
NeilMasters / clean-aws-sqs-queues.sh
Created May 30, 2024 09:29
Delete sqs queues using a prefix.
#!/bin/bash
PREFIX=$1
DRY_RUN=$2
echo "Starting the purge of queues that have the prefix of ${PREFIX}"
while true
do
# Get the list of queues with the PREFIX and store as a block of json
QUEUES=$(aws-vault exec $AWS_PROFILE -- aws sqs list-queues --queue-name-prefix=${PREFIX} | jq '.QueueUrls')
@NeilMasters
NeilMasters / mysql-long-running-transactions.sql
Created April 4, 2024 17:33
List all long running transactions on a mysql database server
SELECT
a.trx_id, a.trx_state, a.trx_started,
TIMESTAMPDIFF(SECOND,a.trx_started, now()) as "Seconds Transaction Has Been Open",
a.trx_rows_modified,
b.USER, b.host, b.db, b.command, b.time, b.state
FROM
information_schema.innodb_trx a
INNER JOIN
information_schema.processlist b ON b.id = a.trx_mysql_thread_id
ORDER BY
@NeilMasters
NeilMasters / delete-aws-queues.sh
Created December 12, 2023 20:12
Delete AWS queues using a prefix and optional dry-run
#!/bin/bash
PREFIX=$1
DRY_RUN=$2
echo "Starting the purge of queues that have the prefix of ${PREFIX}"
# Get the list of queues with the $ PREFIX and store as a block of json
QUEUES=$(aws-vault exec $AWS_PROFILE -- aws sqs list-queues --queue-name-prefix=${PREFIX} | jq '.QueueUrls')
echo $QUEUES > /tmp/queues.json
@NeilMasters
NeilMasters / monitor-node-service.sh
Created November 1, 2023 14:07
monitor node service and restart if required
#!/bin/bash
# This small script will check the running processes for the
# node service running the application. If it is not found it
# will start another instance of the service.
SOCKET_SERVICES_RUNNING=$(ps -aux | grep "[n]ode index.js")
if [ "${SOCKET_SERVICES_RUNNING}" == ""]; then
cd /srv/app && (npm run serve&)
@NeilMasters
NeilMasters / get-group-of-url-statuses.sh
Created March 20, 2023 10:15
Get http statuses for a grouped list of urls
#!/bin/bash
###############################################################################
#
# Script accepts a csv of sites by named key.
#
# Usage
#
# ./benchmark-curl.sh 'group1,https://whatever,https://that,https://this
# group2,https://whatever,https://that,https://this'
@NeilMasters
NeilMasters / benchmark-curl.sh
Created March 20, 2023 08:52
Benchmarking curl speed
!#/bin/bash
I=1
while [ $I -le 500 ]
do
echo $I
curl -I -S https://www.google.com
I=$(( $I + 1 ))
done