more or less useless tips and tricks 3

more or less useless tips and tricks 3

  • Written by
    Walter Doekes
  • Published on

More or less useless/useful tips and tricks, bundled together. They weren’t worthy of a box div on their own. I gave them only a li each.

  • gsettings set org.gnome.desktop.calendar show-weekdate true — to enable week numbers in the gnome-shell datetime calendar popup. (You may need to set LC_TIME to en_GB so the week starts on a Monday instead of, American style, on a Sunday. You’ll probably have set LC_PAPER too already, to get A4 paper size printing defaults.)

  • prlimit --nofile=2048:2048 -p $PID — to change resource limits of a running process. If you ever run into the problem that a long-running application has too few open files or has a 0-byte core-file limit, prlimit will use the prlimit(2) system call to change limits on the fly:

    $ ulimit  -c
    0
    $ prlimit --core=unlimited -p $$
    $ ulimit  -c
    unlimited
    
  • wcheckrestart -sd | xargs systemctl restart — taking advantage of the fact that systemctl will find service files by running pid (systemctl status $PID), this sequence will restart processes that reference updated shared libraries. See: wcheckrestart -sd

  • Escaping $1 in zabbix_agent2 UserParameter= — if you’re using zabbix_agent2 you may notice it’s fairly compatible with the v1 version. However, to escape the UserParameter dollar signs, you cannot use the double-dollar. Luckily, you can generally use shell quoting instead. The following works for both zabbix_agent and zabbix_agent2:

     # 'dpkg -l foobar' lists: "ii  foobar  1.2-1  Foobar is a bar baz package"
     # So dpkg.version[foobar] yields "1.2-1"
    -UserParameter=dpkg.version[*], dpkg -l '$1' | awk '/^ii/{print $$3}'
    +UserParameter=dpkg.version[*], dpkg -l '$1' | awk '/^ii/{print $''3}'
    
  • Converting an image to a full size A4 PDF:

    convert INPUT.jpg -resize 1240x1750 -background white -gravity north \
        -extent 1240x1750 -units PixelsPerInch -density 150 OUTPUT.pdf
    

    (If you run into convert-im6.q16: not authorized, you may need to edit /etc/ImageMagick-6/policy.xml.)


Back to overview Newer post: gitlab / securing public repositories Older post: encryption decryption speed / gnupg / openssl