Skip to content

Instantly share code, notes, and snippets.

View typhonius's full-sized avatar

Adam Malone typhonius

View GitHub Profile
@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 / 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 / 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 / hashy.sh
Created October 29, 2013 11:08
Super simple password hashing on the command line.
#!/bin/bash
SALT=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-10};echo;`
PW=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-18};echo;`
HASH=`openssl passwd -1 -salt $SALT $PW`
echo "Automatically generated password of $PW salted against $SALT gets hashed as $HASH"
@typhonius
typhonius / lastfm.pl
Last active March 25, 2016 14:12
Real simple script to get my now playing from last.fm for chat
#!/usr/bin/env perl
use strict;
use warnings;
use HTTP::Request;
use LWP::UserAgent;
use JSON;
use utf8;
binmode(STDOUT, ":utf8");
<?php
$options['shell-aliases']['offline'] = 'variable-set -y --always-set maintenance_mode 1';
$options['shell-aliases']['online'] = 'variable-delete -y --exact maintenance_mode';
$options['shell-aliases']['sync-dbs'] = '!drush sql-sync --structure-tables-key=common --no-cache {{#prod}} {{@target}}';
$options['shell-aliases']['sync-files'] = '!drush rsync {{#prod}}:%files {{@target}}:%files';
$options['structure-tables']['common'] = array('cache', 'cache_filter', 'cache_menu', 'cache_page', 'history', 'sessions', 'watchdog');
$options['shell-aliases']['sync-fsdb'] = '!drush sql-sync {{#prod}} {{@target}} && drush rsync {{#prod}}:%files {{@target}}:%files';
<?php
$adam = array(
'remote-host' => 'adammalone.net',
'root' => '/var/www/html/adammalone/docroot',
'uri' => 'adammalone.net',
'strict' => 0,
'path-aliases' => array(
'%dump-dir' => '/home/adammalone/.drush/dumps',
'%files' => 'sites/default/files',
@typhonius
typhonius / pagespeed.php
Created August 18, 2013 03:58
A PHP script to look up and parse google pagespeed results.
<?php
$url = 'URL GOES HERE';
$key = 'KEY GOES HERE';
// View https://developers.google.com/speed/docs/insights/v1/getting_started#before_starting to get a key
$data = json_decode(file_get_contents("https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url=$url&key=$key"));
$dat = $data->formattedResults->ruleResults;
foreach($dat as $d) {
$name = $d->localizedRuleName;
@typhonius
typhonius / badger_dns_update.pl
Created August 17, 2013 06:37
A small script that gets the current IP and updates a domain using the API for badger.com Currently the domain ID is hard coded although work will be done to allow iteration and ID lookup
use strict;
use warnings;
use HTTP::Request;
use LWP::UserAgent;
use Regexp::Common qw /net/;
use JSON;
my $email = 'FILLME';
my $password = 'FILLME';
my $badger = 'https://api.badger.com';
<?php
# Memcache
print "Memcache API\n";
$conf['cache_backends'][] = './sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
bench_it();
#Memcache Storage
print "Memcache Storage\n";