Skip to content

Instantly share code, notes, and snippets.

@rocketeerbkw
rocketeerbkw / example.php
Last active June 23, 2023 18:42
How to migrate multi-value link field in Drupal 8
<?php
class Example extends SourcePluginBase {
public function prepareRow(Row $row) {
parent::prepareRow($row);
// I do some data manipulation to end up with an array that looks like this,
// which I want to import into multi-value link field.
$links = [
@aaronbauman
aaronbauman / p-connect.sh
Last active June 10, 2020 09:28
Connect to a Pantheon database in Sequel Pro
#!/bin/sh
# exit on any errors:
set -e
if [ $# -lt 1 ]
then
echo "Usage: $0 @pantheon-alias"
exit 1
fi
@maban
maban / Event Notes.md
Last active March 9, 2020 19:28
Event Notes

Event Notes

  • Event Name:
  • Location:
  • Date:
  • Conference format: (number of days, tracks, and speakers)

Talk

@agarzon
agarzon / DbHelper.php
Last active February 18, 2025 05:42
Codeception DB helper to extend database functionalities (update & delete)
<?php
namespace Codeception\Module;
/**
* Additional methods for DB module
*
* Save this file as DbHelper.php in _support folder
* Enable DbHelper in your suite.yml file
* Execute `codeception build` to integrate this class in your codeception
*/
@jgraham909
jgraham909 / image_link_update.php
Created March 6, 2013 21:43
Update content after Drupal 7.20 update to account for image cache tokens
@davereid
davereid / gist:4639015
Last active December 11, 2015 18:08
Entity operation automation
<?php
function entity_get_operation_links($entity_type, $entity, $base_path = NULL) {
$build = array(
'#theme' => 'links__operations__' . $entity_type,
'#links' => array(),
'#attributes' => array('class' => array('links inline')),
);
list($entity_id) = entity_extract_ids($entity_type, $entity);
anonymous
anonymous / gist:4357636
Created December 22, 2012 05:37
SELECT n.nid, n.title, fc.count
FROM node n
INNER JOIN flag_counts fc ON fc.content_id = n.nid
ORDER BY fc.count DESC
LIMIT 20;
691078 Field tokens 350
1499460 [meta] New theme system 221
494100 State of the multigroup module 218
@nathansmith
nathansmith / gist:4354237
Last active December 10, 2015 00:49
Utility function for checking if something exists.
// Check existence
function exists(thing) {
return (!isNaN(thing) && typeof thing !== 'undefined' && thing !== null) ? thing : undefined;
}
// Or, more tersely
function exists(thing) {
// != checks `null` and `undefined`
return thing != null ? thing : undefined;
}
@MrMaksimize
MrMaksimize / commit-msg.sh
Created September 22, 2012 00:27
Commit message hook that appends story id
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: