Skip to content

Instantly share code, notes, and snippets.

View deekayen's full-sized avatar
🏡
Working from home

David Norman deekayen

🏡
Working from home
View GitHub Profile
@deekayen
deekayen / unlimited_node_access_rebuild_time.patch
Created December 2, 2014 23:30
Remove the time limit imposed by Drupal 7's node_access_rebuild function by hacking core.
diff --git a/modules/node/node.module b/modules/node/node.module
index dbb1a65..a750cf9 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -3634,7 +3634,7 @@ function node_access_rebuild($batch_mode = FALSE) {
}
else {
// Try to allocate enough time to rebuild node grants
- drupal_set_time_limit(240);
+ drupal_set_time_limit(0);
@deekayen
deekayen / dnar.drush.inc
Created December 3, 2014 23:47
Rebuild node access permissions in Drupal 6 using drush.
<?php
/**
* @file
* Drush code to rebuild node access.
*/
/**
* Implementation of hook_drush_command().
*/
@deekayen
deekayen / dcs.sh
Created February 5, 2015 18:27
Code review of Drupal features files using phpcs
#!/bin/sh
which dcs
# Output:
# dcs: aliased to phpcs --standard=Drupal,DrupalPractice --extensions='php,module,inc,install,test,profile,theme,js,css,info,txt' --ignore='*.features.*.inc'
@deekayen
deekayen / fputcsv_outfile_benchmark.php
Created February 10, 2015 21:17
Compare MySQLi/fputcsv against MySQL's native OUTFILE against a 500M, 1,400,000 row table. fputcsv() is 2.5-3x slower.
<?php
/**
* @file
* Test fputcsv vs MySQL OUTFILE.
*/
class Timer {
protected $last, $timers = array(), $length = 10;
@deekayen
deekayen / main.cf
Last active August 29, 2015 14:22
The main Postfix configuration for my Debian 8 server which is decent at filtering most spam.
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# 100M
message_size_limit = 102400000
# appending .domain is the MUA's job.
append_dot_mydomain = no
readme_directory = no
@deekayen
deekayen / authy-ssh.install
Created June 1, 2015 19:20
Authy-ssh install instructions
Generating initial config on /usr/local/bin/authy-ssh.conf...
Adding 'ForceCommand /usr/local/bin/authy-ssh login' to /etc/ssh/sshd_config
MAKE SURE YOU DO NOT MOVE/REMOVE /usr/local/bin/authy-ssh BEFORE UNINSTALLIN
G AUTHY SSH
To enable two-factor authentication on your account type the following command:
sudo /usr/local/bin/authy-ssh enable root <your-email> <your-numeric-country-
code> <your-cellphone>
@deekayen
deekayen / crontab.txt
Created September 22, 2015 00:36
crontab on the Drobo 5N to update DNS-O-MATIC
35 */3 * * * /bin/wget --no-check-certificate --user deekayen@example.com --password PasswordHere https://updates.dnsomatic.com/nic/update > /dev/null 2>&1
@deekayen
deekayen / df.sh
Created July 18, 2012 19:10
Disk space cron monitor for Ubuntu 8.04
#!/bin/bash
ADMIN="help@example.com"
ALERT=95
df -H | grep -vE '^Filesystem|tmpfs|cdrom|varrun|varlock|udev|devshm|boot' | awk '{ print $3 " " $4 " " $5 }' | while read output;
do
usep=$(echo $output | awk '{ print $2}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $3 }' )
free=$(echo $output | awk '{ print $1 }' )
if [[ $usep -ge $ALERT ]]; then
echo "Running out of space $partition ($usep% used, $free avail)
@deekayen
deekayen / ddos.pl
Created August 20, 2012 00:27
Distributed denial of service amplification monitor by Jeff Taylor (Shdwdrgn). Written for hosts of OpenNIC DNS servers.
#!/usr/bin/perl
$| = 1;
# ddos.pl 2012.06.29
# by Jeff Taylor (Shdwdrgn)
#--- REQUIRED PERL LIBRARIES ---#
# Net::Pcap (debian: libnet-pcap-perl)
# IPTables::ChainMgr (debian: libiptables-chainmgr-perl)
@deekayen
deekayen / aws_penetration_test_request_list.txt
Last active November 23, 2015 03:03
Amazon CLI query to get information from a specific region for copy/pasting into the AWS Vulnerability / Penetration Testing Request Form
aws ec2 describe-instances --region us-west-2 --profile default --filters "Name=instance-type,Values=t2.micro,t2.small,*.medium,*large" "Name=instance-state-name,Values=running" --query Reservations[*].Instances[*].[InstanceId,PrivateIpAddress] --output text