Skip to content

Instantly share code, notes, and snippets.

View typhonius's full-sized avatar

Adam Malone typhonius

View GitHub Profile
typhonius / pagespeed.php
Created August 18, 2013 03:58
A PHP script to look up and parse google pagespeed results.
$url = 'URL GOES HERE';
$key = 'KEY GOES HERE';
// View to get a key
$data = json_decode(file_get_contents("$url&key=$key"));
$dat = $data->formattedResults->ruleResults;
foreach($dat as $d) {
$name = $d->localizedRuleName;
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
typhonius /
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.
* Implements hook_drush_command().
function seed_derivatives_drush_command() {
$items = array();
$items['seed_derivatives'] = array(
'description' => "Create image derivatives",
typhonius / worker-purger.js
Last active August 26, 2020 00:47
Purge selected files depending on publish or update webhook action with Ghost and Cloudflare
/* eslint-disable no-undef */
const url = require('url');
function generateSimpleResponse(httpCode, strMessage) {
return new Response(JSON.stringify({ result: strMessage }), {
status: httpCode,
headers: {
'Content-Type': 'application/json',
typhonius / greentext.module
Last active February 11, 2019 08:23
A filter format for applying greentext correctly to Drupal text. The snippet will provide any filter format with the ability to change any line starting with '>' into a greentext line. >Implying anyone will use it
function greentext_filter_info() {
$filters['greentext'] = array(
'title' => t('Implying greentext'),
'description' => t('Allows you to alter any lines input starting with \'>\' to appear as greentext.'),
'process callback' => '_greentext_greentext',
'tips callback' => '_greentext_greentext_tips',
return $filters;
typhonius /
Last active May 9, 2017 18:18
An include file for the Acquia Cloud to be placed at the docroot/sites/ location. May be optionally called from the site's settings.php with further details found on the Acquia Knowledgebase article.
* @file
* Utilities for use in protecting an environment via basic auth or IP whitelist.
function ac_protect_this_site() {
global $conf;
$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';
typhonius /
Last active March 25, 2016 14:12
Real simple script to get my now playing from for chat
#!/usr/bin/env perl
use strict;
use warnings;
use HTTP::Request;
use LWP::UserAgent;
use JSON;
use utf8;
binmode(STDOUT, ":utf8");
typhonius /
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;
$adam = array(
'remote-host' => '',
'root' => '/var/www/html/adammalone/docroot',
'uri' => '',
'strict' => 0,
'path-aliases' => array(
'%dump-dir' => '/home/adammalone/.drush/dumps',
'%files' => 'sites/default/files',