Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl
#
# memcached-tool:
# stats/management tool for memcached.
#
# Author:
# Brad Fitzpatrick <brad@danga.com>
#
# License:
# public domain. I give up all rights to this
@benclark
benclark / gist:70a802c015ce74d610e3
Created June 9, 2015 19:34
Run drush updb in parallel in groups of 5
#!/bin/sh
#
# Run `drush updb` in parallel in groups of 5.
#
# The for loop is populated by running `drush sa`, but this could also be a
# file with aliases on each line.
#
# The
i=0
program WAR;
uses crt,DispANS,TextCursor;
const
top = 1;
whichCards : array[2..14] of char =
('2','3','4','5','6','7','8','9','0','J','Q','K','A');
type setCards = array[2..14] of integer;
@benclark
benclark / gist:2dd1ad7f5092e4846fb9
Created October 29, 2014 19:49
Create random password for every Drupal user from uid 1 to uid 45
#
# Create random password for every Drupal user from uid 1 to uid 45
# @todo - variable user ID sequence?
#
for uid in $(seq 45); do uname=$(drush user-information $uid 2>/dev/null | grep -oP "(?<=User name \: ).+"); if [ -n "${uname}" ]; then drush user-password "$uname" --password=$(date | md5sum); fi done
for alias in `drush sa`; do echo $alias; drush @$alias updb -y; done
@benclark
benclark / basicauthtest.sh
Last active December 30, 2015 23:39
Test for basic auth on all Apache virtual host sites
#!/bin/bash
vhosts=/etc/apache2/sites-enabled/*
for f in $vhosts
do
servername=`grep ServerName $f | sed 's/\s*ServerName\s*//g' - | head -n1`
for s in $servername
do
url="http://$s https://$s"
for protocol in $url
@benclark
benclark / theme_D6MODULE_table_form.php
Last active December 18, 2015 16:09
Theme a series of form elements into a table (Drupal 6), with optional tabledrag.js support
<?php
/**
* Theme a series of form elements into a table (Drupal 6), with optional
* tabledrag.js support.
*/
function theme_D6MODULE_admin_table_form($form) {
$header = array();
$rows = array();
<?php
if ($order_id = db_result(db_query("SELECT order_id FROM {fundraiser_webform_order} WHERE sid = %d", $_GET['sid']))) {
$order = uc_order_load($order_id);
$order_total = isset($order->order_total) ? $order->order_total : 0;
}
?>
@benclark
benclark / wordcount.php
Last active December 17, 2015 23:28
Find out which words are most commonly used in song lyrics.
<?php
/**
* @file
* Find out which words are most commonly used in song lyrics.
*/
$wordcounts = array();
$lines = file('album/song.txt');
foreach ($lines as $line_num => $line) {
@benclark
benclark / .profile
Created June 1, 2013 01:37
My .profile
alias now='/bin/date +%s'
# Convert a timestamp
unixtime() {
php -r 'if (isset($argv[1]) && is_numeric($argv[1])) print date(DATE_RSS, $argv[1]) . "\n";' $1
}
# Local VM config
export localvmname="Debian32"