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 / 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;
}
@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 / 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 / find-submodules.sh
Created October 22, 2014 09:53
Find all modules with sub modules
cd /path/to/modules/contrib && for module in $(gfind -type d -maxdepth 1 | cut -d/ -f2); do gfind $module -name \*.info ! -name $module.info; done
@skwashd
skwashd / snippet.sh
Created April 30, 2015 06:33
Find out what is generating the front page of a #drupal site
drush eval 'drush_print_r(menu_get_item(variable_get("site_frontpage")));'
@skwashd
skwashd / my.module
Created May 26, 2015 23:43
Changing the title of the contact form in Drupal
<?php
/**
* Implements hook_menu_alter().
*/
function my_menu_alter(&$items) {
$items['contact']['title'] = 'Contact Me';
}
@skwashd
skwashd / example.patch
Created June 18, 2015 03:17
Example failing patch
From 4800290372e085a4d26bf961f19d27eb6bef9805 Mon Sep 17 00:00:00 2001
From: A User <a.user@example.com>
Date: Sun, 14 Jun 2015 22:05:23 +1000
Subject: [PATCH] Add label for 'old' entity to the diff data
---
modules/deploy_services/deploy_services.services.inc | 1 +
1 file changed, 1 insertion(+)
diff --git a/modules/deploy_services/deploy_services.services.inc b/modules/deploy_services/deploy_services.services.inc
@skwashd
skwashd / .gitignore
Last active August 29, 2015 14:23
My global .gitignore file
#
# Global .gitignore file.
#
# Created by Dave Hall (@skwashd) - http://davehall.com.au
#
# See https://help.github.com/articles/ignoring-files/#create-a-global-gitignore for installation instructions.
#
# Licensed under the terms of the WTFPL - http://www.wtfpl.net/txt/copying/
#
@skwashd
skwashd / index.sh
Created August 13, 2011 08:35
Index all of your articles
#!/bin/bash
#
# Add all of your Drupal nodes to the search index.
#
# NOTE:
# * This should work when you have around 10 000 nodes.
# * I assume you have set search to add 500 nodes per cron run.
# * There are better ways of doing this, but it does the job.
#