Skip to content

Instantly share code, notes, and snippets.

View AlexanderAllen's full-sized avatar
😸
Working from home @ Bushwick, NYC

AlexanderAllen AlexanderAllen

😸
Working from home @ Bushwick, NYC
View GitHub Profile
@AlexanderAllen
AlexanderAllen / commit-msg
Last active January 17, 2024 13:43
Drupal contrib commit msg hook
#!/usr/bin/php
# In .git/hooks/commit-msg
# Make sure to +x hook
# https://www.atlassian.com/git/tutorials/git-hooks
# See https://www.php.net/manual/en/function.exit.php
# https://www.php.net/manual/en/reserved.variables.argv.php
# https://www.php.net/manual/en/function.file-get-contents.php
# Regex: https://regex101.com/r/uQKPeu/1
@AlexanderAllen
AlexanderAllen / gpgIdentityRegex.md
Last active December 29, 2023 10:49
GPG Identity Regex

PCRE 2+

(?x)

# fingerprint and grip records only have about 12 fields,
# so the match can't be too strict with the number of mandatory fields.

^
(?
@AlexanderAllen
AlexanderAllen / ThemeManager.php
Created July 14, 2022 01:32
Drupal 8: Dump name of all templates processed to filesystem
# src/web/core/lib/Drupal/Core/Theme/ThemeManager.php, line 389
static $c = 1;
$filename = '/var/sys/RM26464.log';
if ($c == 1) {
$handle = fopen($filename, 'r+');
ftruncate($handle, 0);
rewind($handle);
// echo fread($handle, filesize($filename));
fclose($handle);
@AlexanderAllen
AlexanderAllen / launch.json
Created February 26, 2022 02:57
Rust for Windows Launch Config
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// C++ extension configuration.
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
@AlexanderAllen
AlexanderAllen / docker-compose.yml
Created February 1, 2020 16:33
Switching to unix socket with named volumes for PHP FPM and Nginx
# Staying on version 2.x for performance tuning cpu, memory resources.
# Ver. 3.x is meant for swarms and is not 100% backwards-compat.
# Secrets are available only on 3.x.
version: '3.7'
networks:
default:
external: true
name: localenv
services:
@AlexanderAllen
AlexanderAllen / Makefile
Created January 31, 2020 15:41
Docker workload excerpt
# The php files are mounted from the host so access is slow.
slow: pull www
docker run --rm --name symfony-demo -p 8080:8080 -v $(shell pwd)/www:/var/www djs55/symfony-demo
@AlexanderAllen
AlexanderAllen / docker-compose.yml
Created January 14, 2020 01:36
Forward logs to Nginx as non-root user, by using the tty parameter
nginx:
image: alexanderallen/nginx:1.17-alpine
tty: true
entrypoint: 'su-exec nobody /usr/sbin/nginx -g "daemon off;"'
ports:
- 80:8080
- 443:443
healthcheck:
test: curl --fail -s http://localhost:80 || exit 1
interval: 30s
@AlexanderAllen
AlexanderAllen / default.conf
Created January 4, 2020 18:20
Final nginx default conf
server {
listen 8080;
server_name localhost;
root /app/web; ## <-- Your only path reference.
location = /favicon.ico {
log_not_found off;
access_log off;
}
@AlexanderAllen
AlexanderAllen / composer.json
Created January 3, 2020 07:51
Drush 9 Composer Manifest
{
"name": "alexanderallen/php-cli.drush9",
"description": "Composer dependencies for Drupal 8.4+ development.",
"require": {
"drush/drush": "~9.0",
"symfony/yaml": "~3.0",
"pear/pear-core-minimal": "1.10.1"
}
}
@AlexanderAllen
AlexanderAllen / marie-kondo'd.Dockerfile
Created January 3, 2020 07:35
Optimized Dockerfile for Composer and Drush, moved optional tooling into new, optional build targets.
FROM alexanderallen/php7-fpm.core:alpine-3.11 as core
ENV \
SSH_PRIVATE_KEY="/root/.ssh/id_rsa" \
LANG="en_US.UTF-8" \
LC_ALL="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
TERM="xterm" \
# Register the COMPOSER_HOME environment variable.
COMPOSER_HOME=/composer \