Skip to content

Instantly share code, notes, and snippets.

View swichers's full-sized avatar
👻
We must construct additional pylons!

Steven Wichers swichers

👻
We must construct additional pylons!
View GitHub Profile
@swichers
swichers / repman-sync-all.sh
Created March 14, 2024 23:11
Re-syncs all repositories under a repman organization
#!/bin/env bash
# Requires HTTPie and JQ
# Usage repman-sync-all.sh orgname apikey
# Check if jq and http exist
command -v jq >/dev/null 2>&1 || { echo >&2 "jq is required but it's not installed. Aborting."; exit 1; }
command -v http >/dev/null 2>&1 || { echo >&2 "http (HTTPie) is required but it's not installed. Aborting."; exit 1; }
# Function to display usage information
usage() {
@swichers
swichers / composer.json
Last active March 24, 2022 10:58
Capturing STDERR from interactive proc_open call
{
"name": "swichers/passthru_with_errors",
"description": "An enhanced passthru() command that includes error capturing.",
"license": "Apache-2.0",
"authors": [ { "name": "Steven Wichers", "role": "Developer" } ],
"require": {
"php": ">=5.3.0"
},
"autoload": {
"files": ["passthru_with_errors.php"]
@swichers
swichers / rebuild_field_map.d8.drush.inc
Created November 23, 2017 00:07
drush 8 command to rebuild Drupal 8 field mappings
<?php
/**
* @file
* Drush command implementation for rebuild-field-map.
*
* This will allow rebuilding the field mapping stored in the key value store
* for a given entity type. This is helpful when trying to repair a corrupted
* field map store without having to add and remove fields.
*/
@swichers
swichers / docker-compose.yml
Created September 21, 2021 01:27
Route specific SSH traffic through a Docker VPN
# This is useful to have an isolated VPN setup that lets you route SSH traffic
# without touching other traffic on the host.
#
# SETUP:
# mkdir ./config
# cat ~/.ssh/id_rsa.pub > config/bastion_keys
# cp path/to/your.ovpn config/
# chmod 0700 config
# chmod 0400 config/bastion_keys
# chown -R 4096:4096 config
@swichers
swichers / d8-behat-iSelectFirstAutocomplete.php
Last active August 6, 2021 11:59 — forked from IslandUsurper/gist:12723643dddc9315ff71
Behat Step to select the first autocomplete suggestion
<?php
use Behat\Mink\Extension\ElementNotFoundException;
use Drupal\DrupalExtension\Context\DrupalContext;
class FeatureContext extends DrupalContext {
/**
* Gives us acess to the other contexts so we can access their properties.
*
@swichers
swichers / frontend-reqs.sh
Created July 24, 2018 06:04
BLT frontend-reqs script for multiple themes
#!/usr/bin/env bash
set -e
THEME_PATH=../../docroot/themes/custom
for THEME_FOLDER in "${THEME_PATH}"/*; do
if [ -d "${THEME_FOLDER}/npm" ]; then
THEME=${THEME_FOLDER%*/}
THEME=${THEME##*/}
@swichers
swichers / jsonapi.vcl
Created August 1, 2018 22:22
Varnish VCL for checking authorization against a different page and then forcing a cached response.
vcl 4.0;
# !!Important!! Do not use this if your authenticated response can vary
# between users or roles.
# Note: This is only useful if the following things are true:
# * Access to the jsonapi endpoints is restricted to authorized users only.
# * jsonapi request results will be the same for all authorized users. No
# customized or filtered results based on role or other access checks.
@swichers
swichers / cli.sh
Created September 26, 2014 01:17
Scan directory for large images and size them down
# Command to run on a bash shell
# Adjust as necessary to increase/decrease size of files matched, extensions, exclusions, etc.
# Will find images larger than 500k and not in the styles directory.
find . -regex ".*\.\(jpg\|gif\|png\|JPG\|PNG\|jpeg\)" -type f -size +500k -not -path "./styles/*" -exec image-resize.sh "{}" \;
@swichers
swichers / write-to-acquia-log-stream.sh
Created December 16, 2020 23:40
Write log lines to the syslog in a way that the Acquia log streamer will show them.
#!/usr/bin/env bash
# Write log lines to the syslog in a way that the Acquia log streamer
# will show them.
WATCHDOG_NAME='Logging Example'
# General logging to syslog.
log() {
(>&2 echo "${1}")
if [[ ! -z "${AH_SITE_NAME}" ]]; then
@swichers
swichers / d8-bundle-autocomplete.patch
Created April 5, 2018 22:03
Adding the entity bundle to the autocomplete results
diff --git a/docroot/modules/custom/custom_utils/custom_utils.services.yml b/docroot/modules/custom/custom_utils/custom_utils.services.yml
index 006b5d51..98868011 100644
--- a/docroot/modules/custom/custom_utils/custom_utils.services.yml
+++ b/docroot/modules/custom/custom_utils/custom_utils.services.yml
@@ -1,3 +1,11 @@
services:
custom_utils.controller.fieldscontroller:
- class: Drupal\custom_utils\Controller\FieldsController
\ No newline at end of file
+ class: Drupal\custom_utils\Controller\FieldsController