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

Always get a stack trace when Perl dies

Always get a stack trace when Perl dies or warns:

use Carp::Always;
or

perl -MCarp::Always -e'die "argh"'


Easily switch communication devices in Windows 7

http://coastalrocket.blogspot.co.uk/2009/12/switching-audio-devices-in-windows-7.html

Get unique values from an array in Perl

# Unique an array

@unique_list = keys %{{ map { $_ => 1 } @big_list }}; # aka dedupe a list

# Unique a hash on a specified key 'id'

@unique_list = values %{{ map { $_->{id} => $_ } %big_hash }};




Explanation

Extract an RPM file

How to see what's in an RPM file:


rpm2cpio /path/to/file.rpm | cpio -i --make-directories


Thanks to askubuntu.com

View current queries in postgres

Edit config

sudo vim /var/lib/pgsql/9.0/data/postgresql.conf


Add this line:

stats_command_string = true


Restart

pg_ctl reload


Then

SELECT datname,procpid,current_query FROM pg_stat_activity


Thanks

Sublime text editor tricks

Sublime is not a bad text editor for Linux:

Mount a remote directory:  sshfs username@hostname:/remote/path /local/path

Put a vertical line after 80 characters: Preferences > Settings - User > ... add an entry: "rulers": [80]

Change syntax highlighting coloursPreferences > Browse Packages > Color Scheme - Default > ... edit the Color Scheme file you are using.

{
"color_scheme": "Packages/Color Scheme - Default/All Hallow's Eve.tmTheme",
"font_size": 10,
    "rulers": [80],
    "auto_complete": false
}


Shortcuts:

  • Shift-F11 = Enter "concentration" mode AKA "distraction free" mode