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
cleartext

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:

coloredlogs.install(isatty=True)

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 | http://ppa.launchpad.net/git-core/ppa/ubuntu/ trusty/main amd64 Packages
git | 1:1.9.1-1ubuntu0.3 | http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
git | 1:1.9.1-1ubuntu0.3 | http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
git | 1:1.9.1-1 | http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
git | 1:1.9.1-1 | http://us.archive.ubuntu.com/ubuntu/ trusty/main Sources
git | 1:1.9.1-1ubuntu0.3 | http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main Sources
git | 1:1.9.1-1ubuntu0.3 | http://security.ubuntu.com/ubuntu/ trusty-security/main Sources

In all likelihood this will work under Debian, too.

Disabling the Touchscreen under Linux/X11

I am specifically using Ubuntu, but it does not matter as long as you have the xinput tool installed.

At the command-line, run xinput --list to list all of your HID devices:

$ xinput --list
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=13   [slave  pointer  (2)]
⎜   ↳ eGalax Inc. eGalaxTouch EXC7910-1026-13.00.00 id=10   [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Sleep Button                              id=8    [slave  keyboard (3)]
    ↳ Lenovo EasyCamera                         id=9    [slave  keyboard (3)]
    ↳ Ideapad extra buttons                     id=11   [slave  keyboard (3)]

Identify the ID of the one that corresponds to your screen. Disable it:

$ sudo xinput disable 10
[sudo] password for dustin: 

To make the change permanent, add the second command to a script in /etc/X11/Xsession.d (e.g. “98disablexinput”):

#!/usr/bin/bash

xinput disable 10