For that coworker who won’t stop “optimizing” his or her code, I give you my rules of optimization:

  1. Don’t optimize
  2. Don’t optimize, I’m serious
  3. Don’t optimize without benchmarking first
  4. Don’t benchmark without profiling first
  5. See rule #1

Edit: A co-worker suggested a step 4.5 of “Take a coffee break”. I don’t like coffee, but I like the spirit of the suggestion.

At work we have some git repos that were converted from CVS originally created back in 2002 or so. A lot of the things in these repos is cruft and could be deleted. I wrote a little git command to report the most recent commit date for each thing in the current directory.

#!/usr/bin/env perl

use strict;
use warnings;

use DateTime;

my %age;
for my $thing ( glob '*' ) {
    next if $thing =~ /^\.\.?$/;

    my $epoch = `git log -1 --format="%at" $thing`;
    chomp $epoch;

    $thing .= '/' if -d $thing;
    push @{ $age{$epoch} }, $thing;

for my $epoch ( reverse sort keys %age ) {
    my $dt = DateTime->from_epoch( epoch => $epoch );

    print $dt->date(), "\n";
    print "  - $_\n" for @{ $age{$epoch} };
    print "\n";