Skip to content

Instantly share code, notes, and snippets.

@schnippy
schnippy / github-multiple-deploy.md
Last active December 18, 2018 20:36
Managing multiple Github projects with multiple deploy keys on a single server

Managing multiple Github projects with multiple deploy keys on a single server

I have a number of projects on a single server that all have their own git repos on Github. My problem is that I need to create a separate deploy key for each one of these but I have to keep adding and re-adding the ssh-keys when I am doing deployments, ex:

eval "$(ssh-agent -s)"
ssh-add id_site1

I figured that there had to be a way to simplify this using SSH config but ended up with something like this which did not work, it always assumed the first entry in the list.

Beyond module security updates: How to craft a holistic security strategy

This past year, Drupal site maintainers raced to patch their sites to address back-to-back critical security issues in Drupal 7/8, with exploits being detected in the wild within hours after the patches were released. These updates, while not out of the ordinary for open source software, occurred in an an increasingly complex security environment that is seeing a greater range of hostile actors executing more sophisticated, targeted, and damaging website attacks.

As a site owner, how worried should I be about these threats? What can I do besides keeping my modules patched? Are there other best practices for protecting my site from common attacks? How can I approach web security more holistically?

In this session, we will introduce a framework for understanding Drupal website security and how to assess possible solutions. This will include:

  • Understanding the nature of the current threat;
  • Discussion of common Drupal site vulnera
@schnippy
schnippy / module_schema_query.md
Last active October 24, 2018 19:51
TIL: Checking module schema in database to confirm whether module updates have run

TIL: How to check module schema in database to confirm whether module updates have run

If I’m running database updates on a Drupal site and there is some question about whether or not the update fired, I can check this in the database itself from the command line.

Every module that has database updates will define these in their install file, ex. ctools.install and that file will have a number of install hooks that reference the schema number, ex:

/**
 * Revert the length of the ctools_object_cache.name column back to 128.
 */
@schnippy
schnippy / export_query_csv.md
Last active September 6, 2019 23:00
TIL: How to export a MySQL query directly to CSV

TIL: How to export a MySQL query directly to CSV

I'm often running a single query that produces a set of results that I would like to export into a CSV.

For example, in a query against the url_alias table, I will want to grab the following and have it export into a spreadsheet rather than

mysql> SELECT source,alias FROM url_alias WHERE alias LIKE "library%";
+-----------+----------------------------------------------------------------+
| source    | alias                                                          |
+-----------+----------------------------------------------------------------+
@schnippy
schnippy / TermReferenceBoost.php
Created August 10, 2018 22:13
Drupal 8.x Search API processor plugin for boosting search items by term reference field
<?php
// This plugin allows the administrator to boost items in an index based on a taxonomy term.
//
// Drop into an existing plugin module or create a new one, ex. create an info.yml file as
// modules/custom/search_api_boost_term_reference/search_api_boost_term_reference.info.yml
//
// name: 'Search API Boost by Term Reference'
// description: 'Define custom boost priority in Search API index by term reference field'
// core: 8.x
@schnippy
schnippy / fontawesome_flags.md
Last active October 31, 2018 03:25
Using FontAwesome icons with On/Off states with Drupal 8 flags module
@schnippy
schnippy / Drupal7RandomNode.md
Last active September 23, 2019 18:31
Drupal 7: Create menu_hook to load random node of approved content types for more efficient debugging and testing

Drupal 7: Create menu_hook to load random node by type

On many projects, I often have a need to be able to see a random node of a particular content type for debugging or load testing. I use this function on Drupal 7 sites in my core module / feature to add a hook of:

http://mysite/random/my-content-type

(I use this instead of a view sorted by random because I want to be redirected to the full path of the node.)

Leaving off the content-type will use a random type from the array of valid content types I have provided. Providing an invalid content type will redirect it to an item from my core (or default) content-type.