Skip to content

Instantly share code, notes, and snippets.

@chris-allen
chris-allen / ssmcmd-ps & ssmcdm-sh
Last active May 20, 2024 18:57
Aliases to easily run script on linux / windows EC2 instance
_ssmcmd() {
# Ensure jq is installed
if ! command -v "jq" &> /dev/null; then
echo -e "Missing required command: jq"
exit
fi
echo -n "Running command..."
local CMD_ID=$(aws ssm send-command \
--targets "Key=instanceids,Values=$2" \
@chris-allen
chris-allen / pr-only-branch-overrides.sh
Created April 15, 2024 11:22
Set CircleCI pr-only-branch-overrides
curl -X PUT -H "Circle-Token: <token>" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
--data '{"feature_flags":{"pr-only-branch-overrides": "prod, dev, staging"}}' \
"https://circleci.com/api/v1.1/project/<vcs_type>/<org_slug>/<repo_name>/settings"
@chris-allen
chris-allen / CustomMigrateCommands.php
Created June 28, 2023 17:59
Custom drush command to delay search reindexing until migrations complete
<?php
namespace Drupal\my_migrate\Commands;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\migrate_tools\Commands\MigrateToolsCommands;
use Drupal\migrate_tools\MigrateTools;
use Drupal\search_api\IndexBatchHelper;
@chris-allen
chris-allen / ecssh
Last active May 8, 2024 18:49
Alias for easy SSH in to ECS task
_ecssh() {
aws ecs execute-command \
--cluster $1 \
--task $2 \
--command "/bin/bash -c \"[ -f \"/entrypoint.sh\" ] && source /entrypoint.sh\" && /bin/bash" \
--interactive
}
alias ecssh='_ecssh'
@chris-allen
chris-allen / mfaws
Last active July 13, 2023 11:20
Assists in using MFA with the AWS v2 CLI
#!/bin/bash
RED='\033[0;31m'
BLUE='\033[0;34m'
GREEN='\033[0;32m'
NC='\033[0m'
sed_cmd="sed -i"
if man sed | grep -q BSD; then
sed_cmd="sed -i ''"
@chris-allen
chris-allen / ContextualThumbnailAltText.php
Last active May 6, 2022 18:00
Custom search_api field processors to index media URLs / alt text based on context
<?php
namespace Drupal\my_module\Plugin\search_api\processor;
use Drupal\search_api\Datasource\DatasourceInterface;
use Drupal\search_api\Item\ItemInterface;
use Drupal\search_api\Processor\ProcessorPluginBase;
use Drupal\search_api\Processor\ProcessorProperty;
/**
@chris-allen
chris-allen / markup-styleguide.md
Created May 11, 2021 13:04
Markup Styleguide
<input class="single-prop-self-closing" />

<img
  src="/img/test.png"
  class="multiple-props-self-closing"
/>

<span class="single-prop-no-content"></span>
@chris-allen
chris-allen / cleanup-remote.sh
Last active September 26, 2025 15:12
Easy way of cleaning up local branches that have since been deleted from the specified remote. `cleanup-remote origin`
_cleanupRemote() {
if [ -n "$1" ]; then
branches=$(git remote prune "$1" -n | grep -oP ".*would prune\] $1/\K(.+)")
if [ -n "$branches" ]; then
echo "The following branches will be pruned and any local copies deleted:"
echo
echo "$branches"
echo
#!/bin/bash
mydir=/tmp/certs
mkdir $mydir
truststore=${mydir}/rds-truststore.jks
storepassword=changeit
curl -sS "https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem" > ${mydir}/rds-combined-ca-bundle.pem
awk 'split_after == 1 {n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1}{print > "rds-ca-" n ".pem"}' < ${mydir}/rds-combined-ca-bundle.pem
@chris-allen
chris-allen / locker.sh
Created February 6, 2020 15:50
Personal encrypted locker commands
lockup() {
tmp_dir=$(mktemp -d -t locker-XXXXXXX)
(
set -e
locker=$1
files=${@:2}
if [ -z "$locker" ]; then
echo "Must specify a locker name"