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

Jump to

Quick reference

How to build a CPAN module

Not really, this is just a few rough notes.

https://metacpan.org/pod/Dist::Zilla::Tutorial - shows the format of dist.ini

http://dzil.org/tutorial/start.html

Still use a cpanfile, and also Dist::Zilla::Plugin::Prereqs::FromCPANfile

With dzil you can choose whether you want to generate a Makefile.PL or Build.PL

Changes:

Thanks to Nelo & the team.

Test that all your module dependencies are listed in the cpanfile

Put this at xt/author/cpanfile.t: Thanks Anton & the team.

When Postgres allows any password

Problem: Postgres does not check my password, i.e. it accepts all passwords.

Solution: pg_hba.conf and change trust to md5. Restart postgres. That is all.

(source)

SSH tunnel using a jump host

Access a service on a remote machine via an intermediary

ssh -v -L 4444:app.example.com:5000 $USER@jump.example.com -nNT

Now you can access the service running on app.example.com:5000 by going to localhost:4444 in your browser.

Explanation of the command

  • from the host machine (where you are running the command)
  • connect to jump.example.com as user $USER
  • once there, access service app.example.com on port 5000
  • then make that service available on the host machine on port 4444

Advanced usage - Two jumps

ssh -J user@jump.example.com user@app.example.com -L 1111:database.example.com:3306 -nNT -vvv

Notes:
-J jumps to another host
-L makes a tunnel to a service that's already running

Now you can do:

mysql --protocol=tcp --host=127.0.0.1 --port=1111

Notes:
- you must specify protocol because of the tunnel
- specifying 127.0.0.1 (instead of "localhost") prevents MySQL trying to use a local socket and failing

Use a proxy on a remote machine via an intermediary

If there's a proxy you need to use: proxy.example.com:8888 -- but you can only access it from jump.example.com -- then set up a tunnel like this:

ssh -A -L 4444:proxy.example.com:8888 $USER@jump.example.com -nNTv

Now you can use http://localhost:4444 as your proxy server, instead of http://proxy.example.com:8888


Vim mappings for commands like JSON pretty-print and perltidy

imap :!python -m json.tool
map :%!perltidy

?
nmap :%!python -m json.tool

# AB
nmap :%!python -m json.tool
map :!perl -cW %
map :%!perltidy
map :resize +10