Skip to content

Instantly share code, notes, and snippets.

@phenaproxima
phenaproxima / apply-a-recipe.php
Last active February 12, 2025 17:04
How to programmatically apply a Drupal recipe (works in 10.3 and later)
<?php
use Drupal\Core\Batch\BatchBuilder;
use Drupal\Core\Recipe\Recipe;
use Drupal\Core\Recipe\RecipeRunner;
// There are two ways to apply a recipe programmatically: immediately, or as a batch job.
// The batch job is generally the safer option, since more complex recipes could risk
// timing out if they try to do too much at once.
alias mrn='curl "https://api.drupal-mrn.dev/changelog?project=${PWD##*/}&to=`git tag --sort=committerdate | tail -1`&from=`git tag --sort=committerdate | tail -2 | head -1`&format=html"'
@chx
chx / PauseRedirectRequestSubscriber.php
Created September 17, 2022 20:14
Pause redirect module
<?php
namespace Drupal\pause_redirect\EventSubscriber;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\pause_redirect\Form\PauseRedirectSettingsForm;
use Drupal\redirect\EventSubscriber\RedirectRequestSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\RequestEvent;
#!/usr/bin/env rc
# Assume all packages given are already installed
if(test $#* -lt 2) exit 1
module=$1
shift
for(pkg in $*) {
# Get all go binaries by checking for 'Go BuildID='
for(bin in `{apk info -q -L $pkg \
| grep -v '^usr/share' \
@andypost
andypost / Makefile
Created September 1, 2021 13:18
Alpinelinux docker CI images for each arch
.PHONY: run
all: x86_64
IMAGE_ALP=alpinelinux/alpine-gitlab-ci:latest-
builder = docker run --rm -it --network host \
--cap-add=SYS_PTRACE --privileged \
--platform=linux/$(or ${2}, ${1}) \
-v $(shell pwd):/mnt -e APORTSDIR=/mnt -w /mnt \
@andypost
andypost / docker-compose.yaml
Last active August 8, 2022 05:49
Drupal 8 template for core dev + chromium
version: "2.1"
services:
php:
image: skilldlabs/php:8-fpm
container_name: core8
restart: always
working_dir: /var/www/html/web
volumes:
@LionsAd
LionsAd / CFAwareApcuBackend.php
Last active November 21, 2018 20:37
CFAwareApcuBackend -- ChainedFastAware APCu Cache backend
<?php
namespace Drupal\Core\Cache;
use Drupal\Component\Assertion\Inspector;
/**
* Stores cache items in the Alternative PHP Cache User Cache (APCu).
*/
class CFAwareApcuBackend extends ApcuBackend {
@andypost
andypost / Makefile
Last active December 17, 2023 18:43
drupal 10 core contributor docker kickstarter
.PHONY: up upx log down exec exec0 h t
CUID := $(shell id -u)
CGID := $(shell id -g)
IMAGEPHP := skilldlabs/php:8
all: | exec
up:
docker run --rm --name core9 \
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active January 9, 2025 12:22
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files: