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

Comparison of private image hosting

  • Facebook - Private albums, but I never quite trust them with my privacy. Interface is tedious and buggy to use. Not geared towards organising lots of images. Upload limit not advertised.
  • Photobucket - Private or password protected albums. Interface is not great as it squashes your thumbnails, has adverts and only shows a few images each page (mobile). 10Gb free, $30/year for 20Gb, more storage available.
  • Flickr - 1Tb free. Pictures can be private, or shared with family. For pictures, this is very good. Uploaded video quality can be poor. Interface is great for uploading and organising many thousands of photos and video.
  • SmugMug - $40/year for unlimited uploads. Advanced privacy/sharing system. They've put a lot of effort into it.
I recommend Flickr.

Fix home and end keys in remote shell

$ od -c

<home key pressed>   ^[[7~
<end key pressed>    ^[[8~

Then put in /etc/inputrc or ~/.inputrc:

"\e[7~": beginning-of-line
"\e[8~": end-of-line

An actual example:

"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[3~": delete-char

(source)

Android: Don't refresh page when no signal

chrome://flags/#enable-offline-mode

and

chrome://flags/#enable-offline-load-stale-cache

Unfortunately this doesn't work anymore - those flags were experimental.
In fact I've switched to Firefox (which is also much faster on Android) because Chrome tabs kept annoyingly reloading when the phone had no signal.

Perl: Disable control-C and control-Z

$SIG{'INT'} = 'IGNORE'; # Ctrl-C
$SIG{'TSTP'} = 'IGNORE'; # Ctrl-Z

Bash script must run as root

# This script must be run as root

if [ "$(id -u)" != "0" ]; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

svn basics, for git users

How to do stuff in subversion, when you're used to git:

# create a new branch
svn copy -m "Branching trunk" https://www.example.com/svn/repos/project/trunk https://www.example.com/svn/repos/project/branches/new_branch_name

# check out new branch
svn checkout https://www.example.com/svn/repos/project/branches/new_branch_name

# check status/diffs of working directory
svn status
svn diff

# show a specific commit
svn diff -c63197
svn diff -c63197 | vim -R -
svn diff -r63196:63197
svn diff -c63197 db/src/securesite/

# commit files
svn commit -m'Commit message' filename.ext

# see your changes after committing
svn update

# find where a branch was cut from trunk (svn equivalent of git mergebase)
# The last commit will be the first one in this branch after it was cut from trunk:
svn log -v --stop-on-copy

# cherry pick
svn merge -cXXXX trunk branch

# revert a commit
svn merge -c -REV .

Perl telnet script OR netcat

When you need to test using telnet, but don't have telnet installed, and you do have Perl:

use strict;
use warnings;

my $usage = "usage: $0 host port\n";

my $host = $ARGV[0] or die $usage;
my $port = $ARGV[1] or die $usage;

use Net::Telnet ();
my $t = new Net::Telnet (
        Port    => $port,
        Timeout => 5,
);
$t->open($host);

my $print_success = $t->print("GET / HTTP/1.0\n");
print "sent command: $print_success\n";

my @lines = $t->getlines(Timeout => 2);

print @lines;

OR an even easier way with netcat:

fprint "GET / HTTP/1.0\n\n" | nc host port

sudo doesn't list files properly

Problem:

You can list a directory using sudo:
$ sudo ls /var/log/apache/
access_log  error_log

But you can't list files with a wildcard using sudo:
$ sudo ls /var/log/apache/*_log
ls: cannot access /var/log/apache/*_log: No such file or directory

Solution:

Ensure parameter expansion happens in the shell run by sudo, not in the user's shell:
$ sudo bash -c 'ls /var/log/apache/*_log'

(source)

Test Kerberos authentication

vi /etc/krb5.conf
/opt/mitk5/bin/kinit [username]