Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
SOURCE_REPO="/local/path/to/source/repo"
REMOTE_NAME="github"
REMOTE_PATH="https://github.com/username/repo.git"
REMOTE_BRANCH="master"
# Prepare source repo.
cd ${SOURCE_REPO}
find . -not \( -name .git -prune \) -exec git rm -r {} \;
<?php
function menu_children_alphabetical_reorder($plid) {
if ($children = db_query("SELECT mlid, link_title FROM {menu_links} WHERE plid = :plid", array(':plid' => $mlid))->fetchAllAssoc()) {
natcasesort($children);
$weight = 0;
foreach (array_keys($children) as $mlid) {
db_update('menu_links')
->fields(array('weight' => $weight++))
->condition('mlid' => $mlid)
<?php
// Load a drushrc.php file from the 'drush' folder at the root of the current
// git repository.
if ($repo_root = _drushrc_find_repo_root()) {
drush_set_context('DRUSH_REPO_ROOT', $repo_root);
if (is_dir($repo_root . '/drush')) {
if (is_file($repo_root . '/drush/drushrc.php')) {
$options['config'] = $repo_root . '/drush/drushrc.php';
@davereid
davereid / gist:5be00cb29c509ee3e64e
Created July 1, 2014 20:06
Getting Acquia to load the /drush/drushrc.php for site checkouts.
<?php
// ~/.drush/drushrc.php
if ($root = drush_get_option('root')) {
$drush_dir = str_replace('/docroot', '/drush', $root);
if (is_file($drush_dir . '/drushrc.php')) {
$options['config'] = $drush_dir . '/drushrc.php';
}
}

Problem:

  • I want to render an entity using an entity_reference field formatter. This entity is independent and not a field value, so it doesn't have any parent. I want to give the end user the options of formatters to pick from and be able to fill in options.
  • If it helps think of it as you have a file entity and you want to render it using the file_generic formatter.

Context:

  • Rendering an entity embedded in filtered text (hence rendering is done in Filter plugins).
/**
* Implements hook_page_alter().
*/
function batch_yakety_sax_page_alter(&$page) {
if (current_path() == 'batch' && isset($_REQUEST['id']) && batch_load($_REQUEST['id'])) {
$page['content']['system_main']['yakety']['#markup'] = '<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/28530082&amp;color=0066cc&amp;auto_play=true&amp;hide_related=false&amp;show_artwork=true"></iframe>';
}
}
@davereid
davereid / keybase.md
Last active August 29, 2015 13:57
Keybase proof

Keybase proof

I hereby claim:

  • I am davereid on github.
  • I am davereid (https://keybase.io/davereid) on keybase.
  • I have a public key whose fingerprint is 8089 8106 BAB6 873B 5406 4585 0E47 507B 7D69 8DD9

To claim this, I am signing this object:

<?php
/**
* Implements_drush_help_alter().
*/
function multisite_sql_drush_help_alter(&$command) {
if ($command['command'] == 'sql-drop') {
$command['options']['ignore-prefix'] = 'Ignore database prefixing if found.';
}
}
name = Debug
description = Helps debug a corrupted module_implements cache
core = 7.x