Skip to content

Instantly share code, notes, and snippets.

View memcached-tool
#!/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 Jun 9, 2015
Run drush updb in parallel in groups of 5
View gist:70a802c015ce74d610e3
#!/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
View war.pas
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 Oct 29, 2014
Create random password for every Drupal user from uid 1 to uid 45
View gist:2dd1ad7f5092e4846fb9
#
# 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
View gist:b0c7cb8cc1bba905f804
for alias in `drush sa`; do echo $alias; drush @$alias updb -y; done
@benclark
benclark / basicauthtest.sh
Last active Dec 30, 2015
Test for basic auth on all Apache virtual host sites
View basicauthtest.sh
#!/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 Dec 18, 2015
Theme a series of form elements into a table (Drupal 6), with optional tabledrag.js support
View theme_D6MODULE_table_form.php
<?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();
View gist:5706405
<?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 Dec 17, 2015
Find out which words are most commonly used in song lyrics.
View wordcount.php
<?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) {
View .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"