Skip to content

Instantly share code, notes, and snippets.

@kerasai
kerasai / .lando.yml
Created July 16, 2021 16:06
Example Lando File
name: example-site
recipe: drupal8
config:
php: '7.4'
webroot: web
xdebug: true
tooling:
behat:
service: appserver
cmd:
@kerasai
kerasai / archive.sh
Created May 24, 2021 20:58
Static Site Archive
// Before you can do this, get http://brew.sh/
// Then get wget: brew install wget
//
// Grab an entire static archive of a site. (This might take a while)
wget -mkEpnp http://sitename.com
@kerasai
kerasai / backup_files.sh
Created April 26, 2021 22:31
TAR Files Backup
#!/bin/sh
# Run from /sites/default, etc.
tar \
--exclude='files/private/backup_migrate'\
--exclude='files/css' \
--exclude='files/js' \
--exclude='files/styles' \
-zcvf files.tar.gz files/
@kerasai
kerasai / commit-msg
Created November 4, 2020 23:16
Commit message validation for JIRA ticket number.
#!/bin/sh
MSG=$(head -n 1 $1)
PATTERN='[A-Z]+-[0-9]+: .'
# Allows us to read user input below, assigns stdin to keyboard
exec < /dev/tty
if [[ ! $MSG =~ $PATTERN ]]; then
echo 'Commit message does not match the format "ABC-123: i did some stuff".'
@kerasai
kerasai / prepare-commit-msg
Last active November 4, 2020 22:44
Script for Git Prepare Commit Message Hook - Attempts to prefix with JIRA issue number
#!/bin/bash
# Looks for a JIRA style ticket name in the branch name, and prefixes the
# commit message with the ticket, if found.
#
# If you're using the `git commit -m` style commit command, the issue number
# will be prefixed without notice.
#
# If you use the standard `git commit` command where you're sent to an editor,
# the issue number will appear as the default commit message in the editor.
@kerasai
kerasai / behat.yml
Created October 21, 2020 19:25
Behat w/Self Signed Certs
default:
extensions:
Behat\MinkExtension:
base_url: https://mysite.local
goutte:
guzzle_parameters:
verify: false
@kerasai
kerasai / git_delete_merged.sh
Last active February 16, 2021 15:39
Delete merged git branches
# Delete local branches.
git branch --merged main | grep -v "\* main" | xargs -n 1 git branch -d
# Delete local branches (seems to remove only some).
git remote prune origin
# Delete remote branches (dry run).
git branch -r --merged origin/main | grep -v 'origin/main' | sed -E 's/(origin\/)//'
# Delete remote branches (for real).
git branch -r --merged origin/main | grep -v 'origin/main' | sed -E 's/(origin\/)//' | xargs -n 1 -I % git push origin :%
@kerasai
kerasai / docker-compose-health.sh
Last active September 28, 2020 14:12
Waits until services report as healthy, all services must have a health check defined.
#!/bin/bash
set -e
# Grab args, shift first off as the timeout.
END=$((SECONDS+$1))
shift
SERVICES=( $@ )
# Wait for the services to report as healthy.
@kerasai
kerasai / git_clean.sh
Created June 4, 2020 14:52
Clean Git type files from dependencies, when they've got to be committed (barf)
#!/usr/bin/env bash
DEPENDENCY_LOCATIONS=("./drush/Commands/contrib")
DEPENDENCY_LOCATIONS+=("./vendor")
DEPENDENCY_LOCATIONS+=("./web/libraries")
DEPENDENCY_LOCATIONS+=("./web/modules/contrib")
DEPENDENCY_LOCATIONS+=("./web/profiles/contrib")
DEPENDENCY_LOCATIONS+=("./web/themes/contrib")
for DEPENDENCY_LOCATION in "${DEPENDENCY_LOCATIONS[@]}"
@kerasai
kerasai / driver.js
Created April 15, 2020 19:12
Set cookie on lighthouse - ugly hack
// Set request blocking before any network activity
// No "clearing" is done at the end of the pass since blockUrlPatterns([]) will unset all if
// neccessary at the beginning of the next pass.
await passContext.driver.blockUrlPatterns(blockedUrls);
await passContext.driver.setExtraHTTPHeaders(passContext.settings.extraHeaders);
// Add this call for setting the cookie.
await passContext.driver.setCookie();