Skip to content

Instantly share code, notes, and snippets.

View typhonius's full-sized avatar

Adam Malone typhonius

View GitHub Profile
@typhonius
typhonius / acquia.inc
Last active May 9, 2017 18:18
An include file for the Acquia Cloud to be placed at the docroot/sites/acquia.inc location. May be optionally called from the site's settings.php with further details found on the Acquia Knowledgebase article.
<?php
/**
* @file
* Utilities for use in protecting an environment via basic auth or IP whitelist.
*/
function ac_protect_this_site() {
global $conf;
@typhonius
typhonius / domain_fix.sh
Created November 21, 2013 22:10
Allows domains from domain access module to be updated when copying the db between environments on the Acquia Cloud. This file should exist in /hooks/common/post-db-copy.
#!/usr/bin/env php
<?php
/**
* @file domain_fix cloud hook for the Acquia Cloud
* @author Adam Malone <[email protected]>
*
* This file should be placed in /hooks/common/post-db-copy
* and will allow domains in domain_access module to be updated
* following database copy. This ensures no manual updates to
@typhonius
typhonius / seed_derivatives.drush.inc
Last active January 27, 2021 10:01
This script can generate image derivatives for Drupal for warming up the filesystem prior to going live. Image derivative generation puts an amount of load on the servers so it images have been migrated from another server with no derivatives, it may be useful to pre-generate using this script.
<?php
/**
* Implements hook_drush_command().
*/
function seed_derivatives_drush_command() {
$items = array();
$items['seed_derivatives'] = array(
'description' => "Create image derivatives",
@typhonius
typhonius / cache_plotter.php
Created February 4, 2014 06:09
Memcache by default will not accept objects larger than 1M. This script looks through all the Drupal cache tables (provided they're named correctly) and discovers any objects that would blow this requirement. Table names cannot be prepared as these are not variables that cannot be altered at runtime without changing the meaning of the query. It …
<?php
$user = '';
$pass = '';
$database = '';
$limit = 1000000;
$dsn = 'mysql:dbname=' . $database . ';unix_socket=/var/run/mysqld/mysqld.sock';
try {
@typhonius
typhonius / nginx_top_forwards
Created February 9, 2014 10:45
Will split all forwarded for IPs and count how many there are.
watch 'grep -o "forwarded_for=\".*\" " nginx.log | cut -d= -f2 | sed -e "s/\"//g" | tr "," "\n" | tr -d " " | sort -n | uniq -c | sort -nr | head -n20'
@typhonius
typhonius / newmac
Created February 22, 2014 23:02
Sets a new mac address
newmac() {
MAC=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
echo "Setting MAC address to $MAC"
sudo ifconfig en0 ether $MAC
}
@typhonius
typhonius / pound.cfg
Created February 23, 2014 07:52
pound configuration file
User "apache"
Group "apache"
#RootJail "/var/pound/jail"
#Alive 60
ListenHTTPS
HeadRemove "X-Forwarded-Proto"
AddHeader "X-Forwarded-Proto: https"
Address 0.0.0.0
Port 443
user_restrictions_create_form:
route_name: user_restrictions.create_form
title: 'Add rule'
appears_on:
- user_restrictions.list_form
@typhonius
typhonius / cacheplotter.drush.inc
Created April 30, 2014 09:51
I feel dirty putting the Drupal 6.x integration in there but it's still a supported API version so w/e. This checks your db cache tables for sizes of values. Useful if you're using memcache and are worried about exceeding the max page size.
<?php
/**
* @file
* Drush command to check for overly large items in DB cache tables that will
* not work with memcache.
*/
/**
* Implements hook_drush_command().
@typhonius
typhonius / what_should_i_port.pl
Last active March 22, 2016 03:56
Super delicious perl script to get a list of modules from d.o and select one at random for the user to port to Drupal 8. Also it's perlcritic brutal approved!
#!/usr/bin/env perl
use strict;
use warnings;
use LWP::Simple;
use Scalar::Util qw(looks_like_number);
our $VERSION = 1.337;