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

Git set upstream

git branch --set-upstream-to

Or in later versions:

git branch --set-upstream

Thanks

Automatically generated diagrams of Perl code


  • Use UML::Sequence to diagram your method calls - Looks cool but couldn't get the module's tests to pass.
  • Write your own code to produce a Graphviz spec file - Good choice if you want a data structure diagrammed, e.g. State transitions.
  • SchemaSpy works well for database tables.
Untried:
  • UML::Class::Simple - class diagrams, not methods?
  • Devel::Diagram - class diagrams, not methods?
  • Devel::DProfPP

How are my Perl modules being loaded?

Large legacy system?
Confused about how your modules are being loaded?
Getting errors because they are loaded in the wrong order?

Try Devel::TraceUse

Emacs for a vi user

In the past I've exclusively used vi, but now I want to use Emacs as I've heard it has some useful modes, for example 'font-lock-keywords' mode which is one way to easily highlight certain keywords in a program's console output. I don't want to mess around compiling specialised text highlighting programs, and they're not in my standard repos. Emacs is much more likely to already be available wherever I need it.

Emacs commands:
  • To exit: C-x C-c
  • Turn on syntax highlighting: M-x font-lock-mode

Key:
C = Ctrl
M = Meta (Alt)

Thanks to the rest of the web

UPDATE: It turns out font-lock-keywords can easily be implemented in a 3 line bash script. Call it "highlight":

    # Usage: tail -f error.log | highlight "error"
    RED="$(tput setaf 1)"
    RESET="$(tput setaf 7)"
    sed "s/$1/$RED$1$RESET/"

But I would still like to see the Perl debugger integrated into Emacs

Colouring terminal output


Thanks to StackOverflow

UPDATE: You can actually do this yourself with pretty much any programming language that has an ANSI colours library.

Drawing software diagrams

Alternatives:
  • Pencil and paper: Extremely easy to use, but no templates, and not online
  • GraphViz: Good for automatically generating a diagram from code, but you need to implement a script to do it. Bad (impossible) for free-form manual drawing.
  • Asciiflow: Good for quickly knocking up a rough drawing of boxes and lines. Bad for editing that drawing.
  • OpenOffice/LibreOffice Draw: Seems to be good for diagrams. Can export to PDF. How do you make the canvas bigger?
  • LucidChart: Free. Online only, but can export to PDF.
  • Dia: Free, but clunky. Dia by name, dire by nature. Exported images are messed up.
  • Visio: Microsoft. You must pay.
  • Omnigraffle: Mac only, but nice.
  • www.draw.io: Free, but not as intuitive as others.
  • Gliffy.com: Free trial. Online only. Quite good.
  • moqups.com: Good. One project per free account.
  • Creately
  • Diagramly?
  • Pencil project?