Skip to content

Instantly share code, notes, and snippets.

View jonpugh's full-sized avatar

Jon Pugh jonpugh

View GitHub Profile
@jonpugh
jonpugh / access.feature
Last active September 15, 2015 17:01
A big test for access control
Feature: MyEngageNY: Community Content
Background:
Given users:
| name | mail | status | roles |
| group_owner | [email protected] | 1 | local test user |
| non_member | [email protected] | 1 | local test user |
| member_user | [email protected] | 1 | local test user |
| moderator | [email protected] | 1 | local test user |
| contentadmin| [email protected] | 1 | local test user, content administrator |
@jonpugh
jonpugh / http_passwords.drush.inc
Created September 24, 2015 15:40
This drush file adds to aegir apache config, when a site is protected by http basic authentication, it grants access to the site's files folder without a password.
<?php
/*
* Implementation of hook_provision_apache_vhost_config()
*/
function http_passwords_provision_apache_vhost_config($uri, $data) {
$lines = array();
$user = d()->http_basic_auth_username;
$pass = d()->http_basic_auth_password;
@jonpugh
jonpugh / Breadcrumbs.php
Created May 5, 2016 00:28
Add Taxonomy Term to a Node's Breadcrumb in Drupal 8
<?php
// src/Breadcrumbs.php
namespace Drupal\modulename;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Link;
@jonpugh
jonpugh / ABSTRACT.md
Last active January 25, 2018 03:05
DrupalCon Nashville 2018 Session Submission: Host Your Own Drupal with Open Source

Host Your Own Drupal with Open Source

Why Host your Own Drupal? With so many amazing hosting providers available to you, why in the world would anyone want to "self-host" in 2018?

Well, perhaps:

  1. Your organization has already invested in IT. Your data infrastructure and human resources should be put to use!
  2. Your app has special security, technology or location needs that just aren't fulfilled by hosting services.
  3. You want to get the most out of every server and every dollar, with entirely open source software.
@jonpugh
jonpugh / apache-SA-CORE-2018-002.conf
Last active April 13, 2018 20:40
Web server configuration to mitigate Drupal SA-CORE-2018-002. Written by trusted sources. Patch your sites!!
# Apache configuration to block attempts to exploit the SA
# If using Aegir, you can put this file in /var/aegir/config/server_master/apache/post.d/SA-CORE-2018-002.conf
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} (.*)(23value|23default_value|element_parents=%23)(.*) [NC]
RewriteCond %{REQUEST_METHOD} POST [NC]
RewriteRule ^.*$ - [R=403,L]
</IfModule>
@jonpugh
jonpugh / docker-compose.yml
Created May 18, 2018 15:49
HTTP Router & Encryptor
# This file containers the "ingress" point: the "nginx" container binds to 80 and 443 on the host.
# The `nginx-proxy` network must exist before `docker-compose up` is called.
version: "2"
services:
nginx:
restart: always
image: nginx
container_name: nginx
# Adapted from http://kb.pulsesecure.net/articles/Pulse_Secure_Article/KB40126 and http://adam-perkins.com/post/pulse-secure-ubuntu-1704
# Not yet tested.
apt install \
libc6-i386 \
lib32z1 \
lib32stdc++6 \
libwebkitgtk-1.0-0:i386
libc6-i386 \
webkit2gtk-driver \
libproxy1v5 \
@jonpugh
jonpugh / tenyears.patch
Created February 13, 2019 12:04
git diff 5.x-0.1 7.x-3.x
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4a07b38
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+themes/*
+modules/*
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
@jonpugh
jonpugh / docker-compose.yml
Created August 13, 2019 19:00
Grafana/Graphite/Icinga/StatsD/Rancher/Prometheus Stack
version: "2"
volumes:
grafana-data:
prometheus-data:
graphite-data:
services:
nginx:
restart: always
image: nginx
@jonpugh
jonpugh / gist:6455d67d065c369a1f441a77b7ba180d
Created October 16, 2019 23:55
Manual workaround for database dumps "DEFINER" issue.
# Because of these issues:
# - https://stackoverflow.com/a/44015870/292408
# - https://www.drupal.org/project/workflow_participants/issues/3073354
# A second time because the export has the issue too.
- name: Add this function to /var/aegir/.drush/va.drush.inc
function drush_va_post_sql_dump() {
// BACKEND_RESULT is the full path to the file.
$file_ext_gz = drush_get_context('BACKEND_RESULT');
shell_exec("gunzip $file_ext_gz");
$file_ext_sql = str_replace('.gz', '', $file_ext_gz);