Chrome at the Command-Line to Dump Website Structure

You can use Chrome to dump the DOM, PDF, or screenshot of a webpage, or do a number of other cool things:

Open a website in a Chrome process headless-mode, which you can then query from a client process or another browser:

$ chrome --headless --disable-gpu --remote-debugging-port=9222

Print the site HTML:

$ chrome --headless --disable-gpu --dump-dom

Capture a PDF:

$ chrome --headless --disable-gpu --print-to-pdf

Capture a PNG screenshot:

$ chrome --headless --disable-gpu --screenshot

Open a REPL console in which to run JavaScript expressions against the DOM:

$ chrome --headless --disable-gpu --repl

Use GPG to Quickly Encrypt at the Command-Line

$ echo "cleartext" | gpg --passphrase "some-passphrase" -c --no-use-agent > text.encrypted
$ cat text.encrypted | gpg --passphrase "passphrase" --no-use-agent 2>/dev/null
$ cat text.encrypted | gpg --passphrase "some-passphrase" --no-use-agent 2>/dev/null

Without “–no-use-agent”, you might very well be prompted by some system keyring/agent every time.

Colored Logging in Python Under Jenkins

Setting-up the coloredlogs package is easy. Just install the coloredlogs package from PIP, import coloredlogs, and initialize like the following:


Note the isatty parameter. By default, coloredlogs detects whether or not you’re in a terminal and enabled ANSI output accordingly. This means that you won’t see ANSI output in Jenkins unless you explicitly pass True.

Make sure to check “Color ANSI Console Output” in your job config. Using “xterm” for “ANSI color map” worked fine for me.

As this will add another handler to the logging, you may see duplicate logging if you have any other handlers.

For more information on configuration, see the documentation.

Listing Available Package Versions in Ubuntu: The “Madison” Subcommand

There is an unlisted subcommand to apt-cache called “madison”. This will simply list all available versions:

$ apt-cache madison git
git | 1:2.11.0-2~ppa0~ubuntu14.04.1 | trusty/main amd64 Packages
git | 1:1.9.1-1ubuntu0.3 | trusty-updates/main amd64 Packages
git | 1:1.9.1-1ubuntu0.3 | trusty-security/main amd64 Packages
git | 1:1.9.1-1 | trusty/main amd64 Packages
git | 1:1.9.1-1 | trusty/main Sources
git | 1:1.9.1-1ubuntu0.3 | trusty-updates/main Sources
git | 1:1.9.1-1ubuntu0.3 | trusty-security/main Sources

In all likelihood this will work under Debian, too.