Skip to content

Instantly share code, notes, and snippets.

@pbuyle
pbuyle / MODULE.module.php
Last active April 5, 2017 18:40
Integration of Pantheon with the Cache Expiration (expire) module on Drupal
<?php
/**
* Implements hook_init().
*/
function MODULE_init() {
// Add Surrogate-Key headers based on path segments.
// E.g. if the current path is product/some-category/product-name
// we should end up with the following Surrogate-Keys:
// product product/some-category product/some-category/product-name
@pbuyle
pbuyle / keybase.md
Created October 16, 2017 13:36
keybase.md

Keybase proof

I hereby claim:

  • I am pbuyle on github.
  • I am pbuyle (https://keybase.io/pbuyle) on keybase.
  • I have a public key ASB9qdFh6waGTWDNPznaOoUIM--VNmb7fIDmlUEkGaEfIAo

To claim this, I am signing this object:

@pbuyle
pbuyle / RoboFile.php
Last active March 21, 2018 16:51
Deploy to Pantheon with Robo
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks {
use terminusLoadTasks;
@pbuyle
pbuyle / composer.json
Last active June 30, 2018 17:03
[Drupal] Redirects in settings.php with nikic/fast-route
{
...
"require": {
...
"nikic/fast-route": "^1.0"
...
}
...
}
@pbuyle
pbuyle / branches.groovy
Last active October 8, 2018 14:50
Groovy script to get a list of Git branches for a GitLab managed repository, usable with Jenkins Extensible Choice plugin.
project_id = 1
private_token = "XXXXXXXXXXXXXXXXXXXX"
return new groovy.json.JsonSlurper().parseText(new URL("https://git.pheromone.ca/api/v3/projects/"+project_id+"/repository/branches?private_token="+private_token).text).name
Verifying my Blockstack ID is secured with the address 1NgvMCTCjVWieFSw47dNskw7HePTe7PNiY https://explorer.blockstack.org/address/1NgvMCTCjVWieFSw47dNskw7HePTe7PNiY
@pbuyle
pbuyle / AsyncStreamHelpers.scala
Last active September 2, 2021 13:54
Untested Scala code to group com.twitter.concurrent.AsyncStream elements toghether. I wrote it thinking I needed it but was wrong. Manbe I will eventually need it. Maybe not. Maybe I will not remember this gist when I do. Maybe I got it all wrong.
import com.twitter.concurrent.AsyncStream
object AsyncStreamHelpers {
implicit class RichAsyncStream[T](val stream: AsyncStream[T]) {
/**
* Partitions this stream into sequences of adjacent elements grouped according to some discriminator function.
*
* This method will evaluation of this stream until its first element not belonging to the first group (ie. if the
* first element of the returned stream is a size of `n` then `n + 1` first element of this stream will be
* evaluated). Accessing each subsequent element of the resulting stream will evaluate another group of elements
@pbuyle
pbuyle / MODULE.install.php
Last active November 9, 2022 18:19
Drupal - Migrate existing field content from language "undefined" to entity language in a single hook_update_N() implementation.
<?php
/**
* Migrate existing field content from language "undefined" to entity language.
*/
function MODULE_update_N(&$sandbox) {
// Number of entities to be processed for each step.
$messages = array();
if (!isset($sandbox['fields'])) {
// Initialize the array of field to process.
@pbuyle
pbuyle / FeatureContext.php
Last active January 25, 2024 23:25
Behat step-definition to verify visibility (not just presence) of Drupal form elements.
<?php
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
/**