Skip to content

Instantly share code, notes, and snippets.

View skwashd's full-sized avatar
👨‍💻
planning, coding, reviewing

Dave Hall skwashd

👨‍💻
planning, coding, reviewing
View GitHub Profile
@skwashd
skwashd / mymodule.module
Created July 7, 2013 14:14
Extract a list of all Organic Groups groups with their names. Works with OG 7.x-2.x - tested with 7.x-2.2.
<?php
/**
* Extract a list of all available Organic Groups.
*
* This is ugly and inefficient, but it is the only way
* I could figure out how to do it, but hey it works.
*
* This is designed to work with OG 7.x-2.x
*
@skwashd
skwashd / deploy_sevices_client.module
Last active December 21, 2015 14:18
Example deploy_services diff logic. Most of the hacks needed to make this work have been documented. This is a PoC, not production ready.
<?php
/**
* Implements hook_menu().
*/
function deploy_services_client_menu() {
$items = array();
//$items['job/%wf_job/diff/entities'] = array(
// dev hack
$items['job/123/diff/entities'] = array(
@skwashd
skwashd / index.html
Created October 2, 2013 11:03
Test SSH links on various browsers/OSes.
<!DOCTYPE HTML>
<html>
<head>
<title>SSH Link Test</title>
<meta charset="UTF-8">
</head>
<body>
<p><a href="ssh://[email protected]">click me</a></p>
</body>
</html>
@skwashd
skwashd / settings.php
Created October 4, 2013 03:12
It is very useful to have different Drupal configurations in different environments. The easiest way to do this is via setting values in the $conf array in settings.php. For my site builds I generally create a sites/default/config directory that contains the per environment settings. When working with Acquia Cloud and Pantheon the db credentials…
<?php
/**
* Example settings.php which supports per environment configs on different hosting platforms.
*/
$include = '';
// Pantheon
if (isset($_SERVER['PANTHEON_ENVIRONMENT'])) {
$include = __DIR__ . "/config/settings.{$_SERVER['PANTHEON_ENVIRONMENT']}.php";
}
@skwashd
skwashd / fix-bean-deploy_manager_entities.sql
Created October 13, 2013 12:29
Want to fix deploy_manager_entities data for the bean module after upgrading to 1.2 or 1.4? Try this query.
UPDATE deploy_manager_entities dme
JOIN (
SELECT br.bid, MAX(br.vid) max_vid
FROM bean_revision br
INNER JOIN deploy_manager_entities dme
ON br.bid = dme.entity_id
GROUP BY br.bid
) b
ON b.bid = dme.entity_id
SET dme.revision_id = b.max_vid
@skwashd
skwashd / pre-commit
Last active January 4, 2016 04:59
Git pre-commit hook for checking files with coder-review and php lint. This prevents developers committing broken PHP or code that doesn't comply with the Drupal coding standards.Add this file to .git/hooks/pre-commit in the root of your doc repo and make it executable (chmod +x .git/hooks/pre-commit).You must have the coder module in ~/.drush/T…
#!/bin/bash
#
# Git pre-commit hook for Drupal projects.
# Created by Dave Hall - http://davehall.com.au
# Distributed under the terms of the WTFPL - http://www.wtfpl.net/
#
set -e
@skwashd
skwashd / pre-commit
Last active February 28, 2024 11:11
Git pre-commit hook that blocks commits for files that contain swear words.
#!/bin/bash -e
#
# Git pre-commit hook that blocks commits for files that contain swear words.
#
# Created by Dave Hall - http://davehall.com.au
# Distributed under the terms of the WTFPL - http://www.wtfpl.net/
#
# Please don't use this fucking script, it is shit!
#
@skwashd
skwashd / settings.php
Created February 15, 2014 04:46
Example drupal settings.php entries for automatically configuring composer-manager on Acquia Cloud.
if (!empty($_ENV['AH_SITE_ENVIRONMENT'])) {
$conf['composer_manager_file_dir'] = "/var/www/html/{$_ENV['AH_SITE_GROUP']}.{$_ENV['AH_SITE_ENVIRONMENT']}/docroot/sites/default/files/composer";
$conf['composer_manager_vendor_dir'] = "{$conf['composer_manager_file_dir']}/vendor";
}
@skwashd
skwashd / my_module.install
Created March 26, 2014 09:02
Enable media module and process all the files in 1 step.
<?php
/*
If you have a large number of existing files then you will want
to implement batch in hook_update_N(). I didn't need that so it
isn't implemented here. If you need it read this article
http://bleen.net/blog/running-batch-processes-update-hook-bed
*/
/**
@skwashd
skwashd / clean-rules.php
Created March 29, 2014 08:19
Delete old rules that are in the database. Best used in a hook_update_N() implementation.
<?php
$type = 'rules_config';
$query = new EntityFieldQuery();
$rules = $query->entityCondition('entity_type', $type)
->execute();
if (!$rules) {
return;
}