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

Jump to

Quick reference

Perl Tests: Better output when comparison fails

use Test::More;
use Test::Differences;

is_deeply($actual, $expected, 'foo') or eq_or_diff($actual, $expected, 'oof');

or

is_deeply($actual, $expected, 'foo') or diag explain $actual;

Use lighttpd as a proxy-pass server

$HTTP["host"] =~ "made.up.hostname" { # hostname you want to create
    $SERVER["socket"] == ":1234" { # port you want to create

        server.errorlog      = "/var/logs/madeup/lighttpd-error.log"
        accesslog.filename   = "/var/logs/madeup/lighttpd-access.log"

        proxy.server = ( "" =>
                           ( ( 
                               "host" => "123.456.789.012", # where you want to proxy to
                               "port" => 5678, # port you want to proxy to
                             ) ) 
                         )   
    }   
}

# Now go to http://made.up.hostname:1234 and you will get directed through to http://123.456.789.012:5678



smbclient commands on linux

# List all shares
smbclient -L '\\\\server-name' -U username -W DOMAIN

# Logs into server to type commands
smbclient '//server-name/sharename$' -U username -W DOMAIN

# Logs in, runs 'ls' command and disconnects

smbclient '//server-name/sharename$' -U username -W DOMAIN -c ls

# Other parameters:
-d99 = debug output
-D directory = start from directory

# Commands
get = just like FTP



See also smb2www (perl) and smb2www (c).


Configure CNTLM

0) Download cntlm
./configure
make
sudo make install

1) Generate the password hash
cntlm -u username -d DOMAIN -H

2) paste the output into the config file, and add this:
Auth NTLM

3) Run:
cntlm

4) export http_proxy=http://localhost:3128

5) You can now access web pages


See also Charles proxy

Set the date in linux

# date +%Y%m%d --set "2013-05-20"
# date +%H%M%S --set "15:30:00"