Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@evandhoffman
evandhoffman / parsebind.pl
Created May 26, 2011 22:00
Parses bind query logs to determine queries per second.
#!/usr/bin/perl
#use Date::Parse;
use Time::ParseDate;
my $line_num = 0;
my $first_line = 0;
my $oldest_record = 0;
my $line = '';
my $date = 0;
@evandhoffman
evandhoffman / use_default_quota.ps1
Created May 27, 2011 13:35
Powershell to force set all user mailboxes to use the database quota defaults.
[PS] C:\Windows\system32>get-mailbox -filter { usedatabasequotadefaults -eq $false -AND recipientTypeDetails -eq 'usermailbox' } | set-mailbox -UseDatabaseQuotaDefaults $true
{
"_id" : ObjectId("4defd2713fce2e9bc35d09f0"),
"author" : "Bob",
"date" : ISODate("2011-06-08T19:49:48.809Z"),
"body" : "Is it hot in here?",
"votes" : 0,
"answers" : [
{
"author" : "evan",
"date" : ISODate("2011-06-08T19:48:54.388Z"),
@evandhoffman
evandhoffman / profile.sh
Created June 23, 2011 20:50
Mac .profile for non-retarded terminal behavior
#!/bin/bash
PS1='[\d \t \u@\h \# \W]\$ '
function settitle () {
export PREV_COMMAND=${@}
export CURR_CMD=${PREV_COMMAND}
echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~} : ${CURR_CMD}\007"
}
@evandhoffman
evandhoffman / aws-header-filter.pl
Created July 6, 2011 20:58
aws-header-filter.pl
#!/usr/bin/perl
use strict;
use warnings;
my @legal_headers = qw( Accept-Language Bcc Cc Comments Content-Type Content-Transfer-Encoding Content-ID Content-Description Content-Disposition Content-Language Date DKIM-Signature DomainKey-Signature From In-Reply-To Keywords List-Archive List-Help List-Id List-Owner List-Post List-Subscribe List-Unsubscribe Message-Id MIME-Version Received References Reply-To Return-Path Sender Subject Thread-Index Thread-Topic To User-Agent );
my %legal_headers;
@legal_headers{@legal_headers} = (1) x @legal_headers;
@evandhoffman
evandhoffman / san-backup.sh
Created July 12, 2011 21:32
Postgres/Compellent snapsho backup
#!/bin/bash
# Compellent CLI config
WAL_ARCHIVE_DIR=/mnt/isilon/wal-archive/
TIMESTAMP_FILE="$WAL_ARCHIVE_DIR/`date +%s`.lock"
JAVA=/usr/bin/java
CML_JAR=CompCU.jar
@evandhoffman
evandhoffman / evan-ses-send-email.pl
Created August 2, 2011 18:05
Amazon's ses-send-email.pl vs mine.
# Read message body from STDIN, replacing illegal headers with X-headers.
my @legal_headers = qw( Accept-Language Bcc Cc Comments Content-Type Content-Transfer-Encoding Content-ID Content-Description Content-Disposition Content-Language Date DKIM-Signature DomainKey-Signature From In-Reply-To Keywords List-Archive List-Help List-Id List-Owner List-Post List-Subscribe List-Unsubscribe Message-Id MIME-Version Received References Reply-To Return-Path Sender Subject Thread-Index Thread-Topic To User-Agent );
my %legal_headers;
@legal_headers{@legal_headers} = (1) x @legal_headers;
sub read_message {
my $in_header = 1;
my $in_body = 0;
@evandhoffman
evandhoffman / gen-zonefile.pl
Created September 23, 2011 21:57
Converts a spreadsheet of hostname->IP/hostname->hostnames to multiple zone files.
#!/usr/bin/perl
my %domains = ();
while(<>) {
chomp;
my @a = split(/\t/);
my ($host, $dom, $points_to,$unused,$crap) = map { s/^([\W\s]+)(.+)/$2/g ; $_; } @a;
#next if $unused;
@evandhoffman
evandhoffman / changeadpasswd.pl
Created October 6, 2011 19:39
Change Active Directory password from a web browser.
#!/usr/bin/perl
#
# Evan Hoffman (evanhoffman@evanhoffman.com)
# 13 January, 2010
#
# Base functionality from: http://search.cpan.org/~gbarr/perl-ldap/lib/Net/LDAP/FAQ.pod#..._in_MS_Active_Directory_?
print "Content-Type: text/html\n\n";
use Net::LDAP;
@evandhoffman
evandhoffman / dateparse-822.pl
Created October 27, 2011 17:45
Parse a date in RT format into RFC822
#!/usr/bin/perl
use DateTime;
my $date = '2009-02-13 15:43:14';
print "Original: $date\n";
print "Converted: ";