Skip to content

Instantly share code, notes, and snippets.

@alanmackenzie
alanmackenzie / execute-as-initial.sh
Created November 28, 2011 17:41
A bash function that executes a command as the original user account that you initially logged in with. Useful in conjunction with su and sudo.
# This function will execute a command as the original account
# that a user logged in with. This is useful in conjunction with
# su and sudo.
#
# e.g.
# If you su to root ${HOME} will be /root rather than the home
# of the account you initially logged in with.
#
# execute-as-login COMMAND [VARIABLE]
#
@alanmackenzie
alanmackenzie / atomic-symlink-create-or-update.sh
Created January 12, 2012 14:02
Atomically update the target of a symlink.
@alanmackenzie
alanmackenzie / default.c
Created May 28, 2012 16:52 — forked from jelder/newrelic.h
Add X-Request-Start header so we can track queue times in New Relic RPM beginning at Varnish. - Fixed for Varnish 3.0.2-1 on Ubuntu.
/*
* In varnish 3.0 the includes must be outside a subroutine.
*/
C{
#include <stddef.h>
#include <sys/time.h>
}C
@alanmackenzie
alanmackenzie / acquia_fix.drush.inc
Created August 30, 2012 09:59
Fixes your Acquia Solr Search configuration after the down time on 28th Aug 2012.
<?php
/**
* @file
* This file contains a drush command to fix acquia solr service issues on
* the 28th Aug 2012.
* @see http://status.acquia.com/node/31
*/
/**
* Implements hook_drush_command().
@alanmackenzie
alanmackenzie / acquia-connector-behind-proxy-config.php
Created January 14, 2013 11:23
Drupal configuration to get the acquia connector to function correctly behind a proxy.
<?php
// Place the following in your settings.php.
$conf['proxy_server'] = 'www-cache.my.proxy.com';
$conf['proxy_port'] = '80';
define('ACQUIA_DEVELOPMENT_NOSSL', TRUE);
@alanmackenzie
alanmackenzie / search-api-example.php
Created November 14, 2013 15:26
Drupal Search Api Custom Search Example
<?php
$server = search_api_server_load('acquia_search_solr_server');
$index = search_api_index_load('node_index');
$query = new SearchApiQuery($index);
$query->condition('type', 'article');
$results = $query->execute();
@alanmackenzie
alanmackenzie / info-str-replace.sh
Created December 11, 2013 15:12
Drupal info file string replace.
for i in $(find . -name *.info); do sed -i 's/target/replace/g' $i; done
@alanmackenzie
alanmackenzie / drupal-theme-registry-template-search.sh
Last active December 31, 2015 03:49
Search a Drupal installations theme registry for matching template files
drush php-eval "print_r(theme_get_registry());" | grep "${TEMPLATE_SEARCH_MATCH}"
@alanmackenzie
alanmackenzie / drupal-user-support-query.sql
Last active August 29, 2015 14:05
Editorial friendly user support SQL query for the standard Drupal 7 database schema.
SELECT
uid,
name,
mail,
FROM_UNIXTIME(created) AS 'account created',
FROM_UNIXTIME(access) AS 'last access',
FROM_UNIXTIME(login) AS 'last login'
FROM users
WHERE mail = 'example@example.com'\G
@alanmackenzie
alanmackenzie / delete-git-branch-and-tags.sh
Last active August 29, 2015 14:05
Delete git branches or tags based on string matching.
# Example: ./delete-git-branch-and-tags.sh sprint
# @TODO: Handle multiple remote repositorys.
SEARCH="${1}"
for i in $(git tag | grep "${SEARCH}");
do
git tag -d "${i}"
git push origin ":refs/tags/${i}"
done