Feuerfest

Just the private blog of a Linux sysadmin

Syntax Highlighting Test

Photo by Ylanite Koppens: https://www.pexels.com/photo/used-pens-on-white-surface-1152665/

Bash:tst

#!/bin/bash
# vim: set tabstop=2 smarttab shiftwidth=2 softtabstop=2 expandtab foldmethod=syntax :
#
#
ICINGA2_API_USER="icinga2apitest"
ICINGA2_API_PASSWORD="notarealpassword"
ICINGA2_API_HOST="somehost"
ICINGA2_API_PORT="5665"

SCRIPT="$(basename "$0")"
JSON_PP="$(which json_pp)"
CURL="$(which curl)"

# Test if curl is present and executeable
if [ ! -x "$CURL" ]; then
  echo "This script requires curl for sending HTTP(S)-Requests to the API"
  exit 3;
fi

# Test if json_pp is present and executeable
if [ ! -x "$JSON_PP" ]; then
  echo "This script requires json_pp (pretty-print JSON) to display the retrieved results in a nice JSON-formatted syntax."
  exit 4;
fi

function HELP {
  echo "$SCRIPT: Query the Icinga2-API for latest check results"
  echo "Usage: $SCRIPT FQDN Servicename"
  echo ""
  echo "Both FQDN & Servicename can specified as RegEx."
  echo "Provide only FQDN to list all Services of this host."
}

# For later version where it's possible to specify what results to retrieve from the API
ONLY_ERRORS="&& !match(\"0\",service.state)"
HOSTFILTER="\"filter\": \"match(\"'$HOST'\",host.name)"
SERVICEFILTER="\"filter\": \"regex(pattern, service.name)\", \"filter_vars\": { \"pattern\": \"'$SERVICENAME'\" }"

HTML:

<html>
<head>
  <title>Test</title>
</head>
<body>
Bla!
</body>
</html>

Ruby:

def sum_eq_n?(arr, n)
  return true if arr.empty? && n == 0
  arr.product(arr).reject { |a,b| a == b }.any? { |a,b| a + b == n }
end

Puppet:

class java (
  String                                                    $distribution           = 'jdk',
  Pattern[/present|installed|latest|^[.+_0-9a-zA-Z:~-]+$/]  $version                = 'present',
  Optional[String]                                          $package                = undef,
  Optional[Array]                                           $package_options        = undef,
  Optional[String]                                          $java_alternative       = undef,
  Optional[String]                                          $java_alternative_path  = undef,
  Optional[String]                                          $java_home              = undef
) {
  contain java::params

}

Python:

# Python program to check
# if a string is binary or not
 
# function for checking the
# string is accepted or not
 
 
def check(string):
 
    # set function convert string
    # into set of characters .
    p = set(string)
 
    # declare set of '0', '1' .
    s = {'0', '1'}
 
    # check set p is same as set s
    # or set p contains only '0'
    # or set p contains only '1'
    # or not, if any one condition
    # is true then string is accepted
    # otherwise not .
    if s == p or p == {'0'} or p == {'1'}:
        print("Yes")
    else:
        print("No")
 
 
# driver code
if __name__ == "__main__":
 
    string = "101010000111"
 
    # function calling
    check(string)

RegEx:

$ grep --version
grep (GNU grep) 2.7
$ grep -E '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?(\.|$)){4}\b' <<< 192.168.1.1
192.168.1.1
$ grep -E '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?(\.|$)){4}\b' <<< 192.168.1.255
192.168.1.255
$ grep -E '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?(\.|$)){4}\b' <<< 192.168.255.255
$ grep -E '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?(\.|$)){4}\b' <<< 192.168.1.2555
192.168.1.2555
Comments

Admin Bar plugin

Photo by Steve Johnson from Pexels: https://www.pexels.com/photo/four-white-travel-adapters-1694830/

If you run Bludit you might want to give the Admin Bar Plugin a try. It adds a admin bar on top or bottom (configureable) which gives you this neat & handy "Edit post" button when you are logged in. Also quicklinks to all relevant sections (Content, Categories, General, Settings, etc.) and a "New post" button.

Handy.

My recommendation:

  • Show site name: Enabled
    • Name of your site with link to it. Useful if you need to get to the front page quickly
  • Show extended menu: Enabled (Default)
  • Show site settings: Disabled (Default)
  • Position of admin bar: Bottom (Default)
    • Else it will overlap with your static sites and search bar
Comments

Terminal fonts

Photo by Pixabay from Pexels: https://www.pexels.com/photo/blur-bright-business-codes-207580/

Most fonts, especially the standard ones coming with Windows/Linux are awful for usage in terminal applications like PuTTY, xterm, etc. Or the reading of technical output at all. Most of them aren't optimized to allow the easy recognition of characters and symbols you rarely encounter in a written document. But do so even more in a technical environment.

I mean, when did you ever read a newspaper which had all of these characters printed in one single article?

, ; . : | * ~ ' # < > ` ´ ^ [ ] { }

Additionally, many standard fonts aren't monospaced. This means: Each single character takes the same width. No matter if letter (upper- or lowercase), number or special character. Which gives such a HUGE boost to readability (and therefore performance) that I can't stress this point enough. Comparing output/logfile lines or just spotting anomalies gets significantly easier.

Usually "Which font do you use?" is a good conversation starter (or interview question ;-) ) when your counterpart is a seasoned sysadmin or developer.

So which ones do I use?

Currently I use the INPUT font in monospaced from David Jonathan Ross.

You can get a preview here: https://input.djr.com/preview/ and play around with all the options. Then, choose the one you like and import it into your systems font catalogue.

Sadly I can't use it for this blog. As web usage isn't free. And the offered rates/prices are way too overpriced for a little blog like this. (The cheapest is literally 1000 US-$ per month. Which is absolutely no price range for personal projects..)

Before that I used the Roboto Mono font, but I found some special characters rather hard to read or indistinguishable from another. So I asked around and was recommend the INPUT font, which I now use for some years.

Other fonts I got recommended were:

Comments

Embedding Youtube videos in Bludit

Photo by freestocks.org: https://www.pexels.com/photo/person-holding-space-gray-iphone-5-34407/

  1. Make sure your Content-Security-Policy header allows it. This should be enough to see the thumbnail and play the video:
    • In your CSP configuration:
      • frame-src youtube-nocookie.com www.youtube-nocookie.com youtube.com www.youtube.com;
      • img-src 'self' data: https://i.ytimg.com;
      • youtube-nocookie.com is the domain if you choose the privacy option when generating shared links
      • i.ytimg.com is needed for the preview thumbnails
    • If you want CSS, etc. you may need to configure additional headers
    • If you omit this step and you DO have a CSP in place, your browser will just show a "This content has been blocked by a policy"-message or similar. Open your browsers developer console to check for CSP related errors.
  2. In Bludit, go to: Plugins -> TinyMCE -> Settings
  3. Add media to the "Toolbar top" and "Plugins" fields. Now the button for easier embedding of videos will show up.
    • Of course you can also copy&paste the iFrame-code from the Youtube-Share link and use the source code view (<> Button) to insert it manually.
  4. Profit!
Comments

Windows tools I use

Photo by Nothing Ahead: https://www.pexels.com/photo/close-up-of-a-keyboard-4567339/

As an IT consultant in 99,5% of all cases I'm provided a notebook with Windows as operating system. As this is (sadly) still the standard, even when you do your work only on Linux machines.. Therefore I do have to use many separate Windows tools..

SSH/RDP (Remote/terminal access):

  • PuTTY & pageant as agent for automatic key based authentication
  • Alternatively SuperPutty works fine if you need to split windows next to each other or have all Putty windows in one application window
  • mRemoteNG also works fine for SSH & RDP as more often than not I also need to connect to servers via RDP too
  • If you only need RDP, have a look at the Remote Desktop Connection Manager from the lovely Sysinternals folks at Microsoft

Texteditor:

  • Notepad++ has syntax highlighting, proper support for all kind charsets AND per-default it saves even the text in windows you haven't explicitly saved. (Useful if you're in a hurry..)
  • Alternative: PSPad

Credentials/Secrets/Passcodes

  • KeePass: The neat thing is, so far it always came pre-installed.

Diffing files/finding differences:

  • Meld (That one is also available for Linux if you need a GUI)
Comments