Skip to content

Instantly share code, notes, and snippets.

View emsearcy's full-sized avatar

Eric Searcy emsearcy

  • 20:06 (UTC -07:00)
View GitHub Profile
@emsearcy
emsearcy / array_merge.yaml
Created January 5, 2024 21:38
Lowdefy Snippet for Merging Object Arrays
#
# Array merge takes a source array of objects and merges into into a
# destination array of objects, while looking up an defined attribute from each
# object (in both arrays) to de-duplicate the final array.
#
# So if you call with:
# _ref:
# path: path/to/array_merge.yaml
# vars:
# from: [ {"id": 1, name: "Alice"}, {"id": 2, name: "Bob"} ]
@emsearcy
emsearcy / ldap_snippet.go
Last active April 5, 2021 20:28
go-ldap LDAP connection management
type ldapConnResult struct {
Conn *ldap.Conn
Error error
}
type userLdapPool struct {
// maintain two "pool" connections managed through channels
// one for read/write operations and another for authentication (re-binding)
rwConn chan ldapConnResult
rwConnReset chan bool
@emsearcy
emsearcy / linecompare.pl
Created July 9, 2019 21:09
compare lines
#!/usr/bin/perl -W
open FILE_A, "<", $ARGV[0];
open FILE_B, "<", $ARGV[1];
my %a_lines = ();
my %b_lines = ();
my %a_only_lines = ();
my %b_only_lines = ();
my $both_lines = 0;
@emsearcy
emsearcy / set_dmarc.py
Last active March 26, 2018 20:36
Set DMARC mitigation for all Mailman 2 lists
#!/usr/bin/python
#
# Eric Searcy
# github.com/emsearcy
"""Ensure all mailing lists have DMARC mitigation enabled
Set 'DEFAULT_DMARC_MODERATION_ACTION = 1' in mm_cfg.py to set policy for future
changes.
@emsearcy
emsearcy / newrelic-goji-middleware.go
Created March 22, 2018 22:48
Goji.io middleware for New Relic golang-agent transaction instrumentation
// This is an independent work and is not sponsored or
// affiliated with New Relic.
//
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package main
import (
"fmt"
@emsearcy
emsearcy / Makefile
Last active December 1, 2017 17:29
Makefile for Terraform with local build of patched DNS Made Easy provider
# Terraform Makefile
#
# Automates management of secrets from pass.
# pass variable for DNS Made Easy
#export TF_VAR_dme_skey := $(shell pass show services/dns/dme)
.PHONY: error init plan apply clean
error:
@emsearcy
emsearcy / mm3_to_groupsio.py
Created September 29, 2017 20:00
Export mailman3 subscribers for groups.io
# Django script to export member lists from Mailman 3 to Groups.io
# Includes a suffix "nomail", "digest", or "summary" as needed
#
# Sample command:
# /opt/mailman3-web/virtualenv/bin/python ./manage.py runscript mm3_to_groupsio --script-args lists.example.com
import codecs
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
@emsearcy
emsearcy / README.md
Last active June 8, 2022 02:50
Ansible role to install certbot in a virtualenv + non-root user

certbot

This role installs certbot in a virtualenv with automated certificate renewal.

Running certbot as a non-root user and in a virtualenv provides extra security.

Web server configuration

@emsearcy
emsearcy / menu-no-rebuild-recurse.patch
Created August 17, 2016 17:53
No menu_rebuild recurse
diff --git a/includes/menu.inc b/includes/menu.inc
index ab97722..7181768 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -2767,7 +2767,14 @@ function menu_rebuild() {
// If we get here and menu_masks was not set, then it is possible a menu
// is being reloaded, or that the process rebuilding the menu was unable
// to complete successfully. A missing menu_masks variable could result
- // in a 404, so re-run the function.
+ // in a 404, so we cannot proceed without completing the rebuild.
@emsearcy
emsearcy / maintenance.patch
Created June 3, 2016 20:33
Don't cache maintenance pages
diff --git a/includes/common.inc b/includes/common.inc
index ceac115..f3ada95 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -2711,6 +2711,7 @@ function drupal_deliver_html_page($page_callback_result) {
// Print a 503 page.
drupal_maintenance_theme();
drupal_add_http_header('Status', '503 Service unavailable');
+ drupal_add_http_header('Cache-Control', 'no-cache, must-revalidate, post-check=0, pre-check=0');
drupal_set_title(t('Site under maintenance'));