Skip to content

Instantly share code, notes, and snippets.

@evandhoffman
evandhoffman / parsebind.pl
Created May 26, 2011
Parses bind query logs to determine queries per second.
View parsebind.pl
#!/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
Powershell to force set all user mailboxes to use the database quota defaults.
View use_default_quota.ps1
[PS] C:\Windows\system32>get-mailbox -filter { usedatabasequotadefaults -eq $false -AND recipientTypeDetails -eq 'usermailbox' } | set-mailbox -UseDatabaseQuotaDefaults $true
View gist:1015230
{
"_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 Jun 23, 2011
Mac .profile for non-retarded terminal behavior
View profile.sh
#!/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"
}
View 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 Jul 12, 2011
Postgres/Compellent snapsho backup
View san-backup.sh
#!/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 Aug 2, 2011
Amazon's ses-send-email.pl vs mine.
View evan-ses-send-email.pl
# 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 Sep 23, 2011
Converts a spreadsheet of hostname->IP/hostname->hostnames to multiple zone files.
View gen-zonefile.pl
#!/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 Oct 6, 2011
Change Active Directory password from a web browser.
View changeadpasswd.pl
#!/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 Oct 27, 2011
Parse a date in RT format into RFC822
View dateparse-822.pl
#!/usr/bin/perl
use DateTime;
my $date = '2009-02-13 15:43:14';
print "Original: $date\n";
print "Converted: ";
You can’t perform that action at this time.