A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Trace the execution of subroutines under mod_perl

1) First try one of these to trace every line (doesn't actually capture subroutine names):

Debug::Trace, Debug::LTrace, Devel::Trace, or others.

2) Then if you want to filter the list, try:

perl PERL5DB='sub DB::DB {my @c=caller;return if $c[1] =~ m|/opt/foo/bar| || $c[1] =~ m|/qux/| || $c[1] =~ m|Useless|; print STDERR qq|@c[1,2] ${"::_<$c[1]"}[$c[2]]|}' perl -d path/to/test/file.t

(thanks Brian)

3) Here's one I came up with using Moose:

use Moose;
use Scalar::Util;
use Data::Dumper;
for my $func qw(list all the subroutine names here) {
    around $func => sub {
        my $orig = shift;
        my $self = shift;
        warn "Running __PACKAGE__::${func} with:\n";
        my $i = 0;
        foreach my $param (@_) {
            $i++;
            # don't display class it$self
            next if blessed $param and $param->isa(__PACKAGE__);
            if (blessed $param) {
                # try not to dump out huge objects
                warn "\t$i = $param\n";
            } else {
                warn "\t$i = ".Dumper($param);
            }
        }
        # call the original sub
        $self->$orig(@_);
    }
}

4) Simple way to log all parameters:

my $r=\@_; $logger->debug('entering ', sub { $logger->dump(args => $r) });

5) Simple way to log method name only, without potentially verbose parameters:

$logger->info("entering ".( caller(0) )[3]);

6) Log4perl configuration

Use %M to log the method name, then just log anything, e.g. "entering".



Open files from the command line in Ubuntu

Either:
evince [filename] (for document viewer, e.g. pdfs)
or:
gnome-open [filename] (for any file)

http://ubuntuforums.org/showthread.php?t=446766

How to install subversion on your linux shared hosting account

  1. Find out which linux distro your web host is running
  2. Download a set of subversion binaries for that linux distro
    1. or install that linux distro on a VM and compile into a PREFIX directory
  3. Copy bin/svn and require libs onto your web host (see list below for svn 1.6.16)
  4. Voila!


List of libs required for svn client:
svntest/lib/libsvn_ra-1.so.0
svntest/lib/libssl.so.0.9.8
svntest/lib/libsvn_diff-1.so.0
svntest/lib/libneon.so.27
svntest/lib/libsvn_ra_neon-1.so.0
svntest/lib/libsvn_subr-1.so.0
svntest/lib/libsvn_ra_local-1.so.0
svntest/lib/libsvn_wc-1.so.0
svntest/lib/libsvn_ra_svn-1.so.0
svntest/lib/liblber-2.4.so.2
svntest/lib/libsvn_fs_util-1.so.0
svntest/lib/libsvn_delta-1.so.0
svntest/lib/libldap-2.4.so.2
svntest/lib/libcrypto.so.0.9.8
svntest/lib/libsvn_fs_fs-1.so.0
svntest/lib/libsvn_fs-1.so.0
svntest/lib/libapr-1.so.0
svntest/lib/libserf-0.so.0
svntest/lib/libaprutil-1.so.0
svntest/lib/libgdbm.so.3
svntest/lib/libsvn_ra_serf-1.so.0
svntest/lib/libsvn_client-1.so.0
svntest/lib/libsvn_repos-1.so.0

You can do 'OR' searches in FogBugz

See instructions here:
https://fogbugz.lovefilm.com/help/topics/basics/Searchingforcases.html

Real IE6 on Ubuntu

  • Download the Internet Explorer Application Compatibility VPC Image from Microsoft
  • It is an .exe file. In Windows, run it to extract the files. You will get IE6Compat.vhd and some text files.
  • In Ubuntu, install VirtualBox 1.4.x
  • Type: vboxmanage clonehd IE6Compat.vhd WindowsXP_IE6_VirutalBox.vdi --format vdi
  • Create a new VirtualBox VM and load WindowsXP_IE6_VirutalBox.vdi into it
  • It will not log in because it says it's not registered.