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 / SA-CORE-2014-005.patch
Created October 15, 2014 16:03
SA-CORE-2014-005
From 26a7752c34321fd9cb889308f507ca6bdb777f08 Mon Sep 17 00:00:00 2001
From: David Rothstein
Date: Wed, 15 Oct 2014 14:31:54 +0000
Subject: SA-CORE-2014-005 by Stefan Horst, greggles, larowlan, David_Rothstein, klausi: Fixed SQL injection vulnerability
---
diff --git a/includes/database/database.inc b/includes/database/database.inc
index f78098b..01b6385 100644
--- a/includes/database/database.inc
+++ b/includes/database/database.inc
@skwashd
skwashd / console.js
Created June 12, 2014 08:15
console.log() for IE
// Lifted from https://stackoverflow.com/a/22103222
if (typeof console === "undefined" || typeof console.log === "undefined") {
console.log = function(msg) {
alert(msg);
};
}
@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;
}
@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 / 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 / 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 / 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 / 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 / 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 / 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://new@sdf.org">click me</a></p>
</body>
</html>