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

How to change the colours of directories and files

To change the colour of directories from dark blue to light blue (cyan):

    export LS_COLORS=$(echo $LS_COLORS|sed 's/di=01;34/di=01;36/')

See also

    man dircolors

and

    dircolors --print-database



...for a list of the colours.

System maintenance

There is a reason we have a process of change control. It has become a dirty word in some departments, but the bare minimum is:
  • making a change in the development environment
  • testing it, preferably by more than one person/team
  • packaging up the release and labeling it properly
  • making a formal request to deploy it, including roll-back instructions
In addition, a precedent should never be set to fix something that another department has broken!

Log4perl

    use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($ERROR);
    DEBUG "This doesn't go anywhere";
ERROR "This gets logged";

See stored procedures in MySQL

List them
mysql> show procedure status;

See the code of one
mysql> show create procedure [name];

Perl sprintf

        # Format number with up to 8 leading zeroes
$result = sprintf("%08d", $number);
        # Round number to 3 digits after decimal point
$rounded = sprintf("%.3f", $number);

Perl's sprintf permits the following universally-known conversions:

   %% a percent sign
%c a character with the given number
%s a string
%d a signed integer, in decimal
%u an unsigned integer, in decimal
%o an unsigned integer, in octal
%x an unsigned integer, in hexadecimal
%e a floating-point number, in scientific notation
%f a floating-point number, in fixed decimal notation
%g a floating-point number, in %e or %f notation