Skip to content

Instantly share code, notes, and snippets.

View typhonius's full-sized avatar

Adam Malone typhonius

View GitHub Profile
@typhonius
typhonius / generic_puppet_install.sh
Last active September 10, 2015 03:50
Generic way to install puppet across whichever platform
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
function get_hostname() {
read -p "Enter hostname: " hostname
if [ -z "$hostname" ]; then
@typhonius
typhonius / more_ape_tests.patch
Last active August 29, 2015 14:08
further tests for ape
diff --git a/ape.test b/ape.test
index 756cfeb..f34a7fe 100644
--- a/ape.test
+++ b/ape.test
@@ -31,6 +31,7 @@ class ApeTestHelper extends DrupalWebTestCase {
$modules[] = 'path';
$modules[] = 'user';
$modules[] = 'common_test';
+ $modules[] = 'ape_redirect_test';
parent::setUp($modules);
@typhonius
typhonius / ghetto_load_detector.sh
Created August 8, 2014 07:49
Ultra dirty, super basic, nagios replacement.
#!/bin/bash
STLOAD=$(cat /proc/loadavg | awk '{print $1}')
while true; do
FINLOAD=$(cat /proc/loadavg | awk '{print $1}')
if (( $(echo "$STLOAD $FINLOAD" | awk '{ if ($1 >= 8 && $2 >= 8) print 1}') )); then
if [[ -z $TIME ]]; then
TIME=$(date +"%s")
fi
@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;
@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().
user_restrictions_create_form:
route_name: user_restrictions.create_form
title: 'Add rule'
appears_on:
- user_restrictions.list_form
@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
@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 / 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 / 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 {