Feuerfest

Just the private blog of a Linux sysadmin

Why I don't accept connect/friendship requests from recruiters

Photo by Andrea Piacquadio: https://www.pexels.com/photo/cheerful-young-woman-screaming-into-megaphone-3761509/

When you work in IT you are in the privileged situation that people are actively offering you positions. If I wanted, I wouldn't have needed to search for a single one of my jobs. I got plenty of offerings on Xing or LinkedIn, via email or sometimes even through Twitter direct messages or Google Hangouts.

So, as the question just recently arised from a recruiter on Xing: "Why didn't I accept the request to become connected?"
Well, short answer: My starting page feed and too much clutter.

In fact, I did tend to accept those requests years ago. Quickly, this had a rather unpleasant side-effect: My feed was full of job advertisements for various positions in far too many industries. Jobs which were absolutely not relevant for me. For which I did have no skills, no training, no interest, no passion. And.. 99,9% of the time I'm not searching for a job. So why should I be forced to read job ad after job ad and - sorry for the wording - waste my time with it? Especially when it is not a one-time occurrence but a constant stream of non-interesting content.

Additionally, because of all that clutter, I sometimes didn't notice crucial personal updates from old colleagues & friends. As sadly nowadays it's the standard to just have one single feed where all postings show up. Not sorted into categories or whatever. Therefore I am more or less forced to read every article (and advertisement...) even if I'm not interested in it. Feel free to read my post The problem with social networks - and why I still miss Google+ if you want to know more.

Thais is the sole reason why I stopped doing that.
It is really nothing personal. It's just that 99,9% of the time your content is irrelevant to me - as I'm simply not on the lookout for a new challenge. And on top of that: In the short time frames when it is relevant to me, 99% of the content is - again - irrelevant to me - because the jobs don't fit what I'm searching for.

I like my feed/stream to be about stuff I'm interesting in. I don't like it when I constantly have to read stuff which is neither interesting nor relevant for me.

If, for example, LinkedIn changes the way their feed works, then my position could change. But until things stay as they are I sadly have to be a bit more rigid in who I accept as a contact.

Comments

What does "rc" and ".d" stand for in file-/directory names?

Photo by Tima Miroshnichenko: https://www.pexels.com/photo/close-up-view-of-system-hacking-in-a-monitor-5380664/

This was a question which came up recently and while I could have given the answer based on my experience where these two strings commonly occur, I never really researched the initial origin.

Turns out rc has quite a heritage. Quoting from the Indiana Universities Knowledge Base:

runcom (as in .cshrc or /etc/rc)

The rc command derives from the runcom facility from the MIT CTSS system, ca. 1965. From Brian Kernighan and Dennis Ritchie, as told to Vicki Brown:

"There was a facility that would execute a bunch of commands stored in a file; it was called runcom for "run commands", and the file began to be called "a runcom". rc in Unix is a fossil from that usage."

Note: The name of the shell from the Plan 9 operating system is also rc.

And then I learned about the Plan 9 OS of which I've never heard before: https://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs

For .d there is not a real distinctive answer. It seems the common consensus is that it originated from /etc/rc?.d as to have a directory for runcoms and to distinguish it from a normal daemon configuration file - as these are typically stored under /etc. And/or to prevent naming-problems, as files & folders can't share the same name under Unix/Linux the .d as indicator for a directory was added.

And from there this mechanism was used for other daemons as well. What seems to have started as /etc/rc1.d, /etc/rc2.d, etc. as a way to separate runcoms to be executed on different runlevels, became commonly used today for the configuration of daemons/services.

Today a something.d directory holds configurations files for the something daemon. The advantage is that you are able to split your configuration in different files. Making it, for example, easier to deploy only certain files to certain hosts via your configuration management tool of choice (Puppet, Ansible, Chef, etc.). Additionally it's easier to spot configuration errors in a relatively small than in one big "contains it all"-file.

Comments

Changing the default link target in Bludits TinyMCE

Photo by Monstera: https://www.pexels.com/photo/woman-holding-book-with-blank-pages-6373293/

When creating links in TinyMCE the link-plugin is configured to open links in the current window. As this is the default setting. However I don't like this and changed it every time. And when you change something every single time, you should just make it your new default.

Luckily TinyMCE has good documentation about every plugin. So we learn about the default_link_target parameter we can utilize to achieve exactly this.

We open the bludit-folder/bl-plugins/tinymce/plugin.php file and search for tinymce.init. Then we add the default_link_target: '_blank' parameter at the end of the list. Don't forget to add a semicolon behind the formerly last parameter.

In the end it looks like this:

        tinymce.init({
                selector: "#jseditor",
                auto_focus: "jseditor",
                element_format : "html",
                entity_encoding : "raw",
                skin: "oxide",
                schema: "html5",
                statusbar: false,
                menubar:false,
                branding: false,
                browser_spellcheck: true,
                pagebreak_separator: PAGE_BREAK,
                paste_as_text: true,
                remove_script_host: false,
                convert_urls: true,
                relative_urls: false,
                valid_elements: "*[*]",
                cache_suffix: "?version=$version",
                $document_base_url
                plugins: ["$plugins"],
                toolbar1: "$toolbar1",
                toolbar2: "$toolbar2",
                language: "$lang",
                content_css: "$content_css",
                codesample_languages: [$codesampleConfig],
                default_link_target: '_blank'
        });

And now generated links will per-default open in a new window.

Comments

Bludit and syntax highlighting

Photo by Pixabay: https://www.pexels.com/photo/computer-c-code-276452/

Bludit offers syntax highlighting via TinyMCE and it's codesample plugin, which you have to enable in the TinyMCE plugin settings first. But it offers only limited support. No Bash, no Puppet, no Perl and so on. Also I wanted line numbering when in code blocks for easier orientation. This is also not included.

The Prism.js library however offers support for many more languages and also some nice Plugins. For example for line-numbering.

To make everything work, the following tasks are necessary:

  1. Download & install the Bludit-Prism Plugin from here: https://plugins.bludit.com/plugin/prism
  2. Replace prism.js and prism.css files included in this Plugin with newer ones from https://prismjs.com/
    • As the one included in the Bludit Prism-Plugin only has support for: HTML/XML, JavaScript, CSS, PHP, Ruby, Python, Java, C, C#, C++
  3. Add our new languages to the codesamples config in the TinyMCE plugin config. This will add them in the dropdown-menu when inserting a code-sample block
  4. Edit the plugin.min.js file from the TinyMCE codesample plugin to automatically included the line-numbers plugin into the HTML pre-element.

For a general overview, and a little bit of background why the Prism plugin was created, see this link: https://forum.bludit.org/viewtopic.php?t=1818

As I'm somewhat new to Bludit I can't assess if this is the best approach. But for me it works. ;-)

  1. Download & install the Bludit-Prism Plugin from here: https://plugins.bludit.com/plugin/prism
    • Then activate it on the Bludit Plugins page
  2. Download prism.js and prism.css from https://prismjs.com/
    • Include all languages and plugins you need
    • Note: You need to use the JS and CSS-file from the same generation! You can't mix features or versions.
  3. Go to: bludit-folder/bl-plugins/prism and make a backup copy of the original files
    • mv js/prism.js js/prism.js.backup
      mv css/prism.css css/prism.css.backup
      
  4. Download new prism.js and prism.css and put into the correct folders
  5. Go to: Plugins -> TinyMCE -> Codesample languages and add your new languages, in my case:
    • Bash sh|RegEx regex|Puppet puppet|Perl perl|Python python|HTML/XML markup|JavaScript javascript|CSS css|PHP php|Ruby ruby
    • Unrelated side info: This will be written in the file bludit-folder/bl-content/databases/plugins/tinymce/db.php. I was just curious how/where this change is persisted.
  6. Now you will have syntax highlighting. But only in the generated HTML files, not in the TinyMCE code-blocks!
  7. To automatically include the line-numbers plugin from Prism.js we need to include the "line-numbers" class into the pre-element. This is done in the following way:
    • Open: bludit-folder/bl-plugins/tinymce/tinymce/plugins/codesample/plugin.min.js
    • Search for <pre and in the class property add line-numbers. It should now look like this: t.insertContent('<pre id="__new" class="language-'+a+' line-numbers">'+r+"</pre>")
    • A little after that pre you will also find t.dom.setAttrib(e,"class","language-"+a), add the line-numbers class in there too, it should look like this: t.dom.setAttrib(e,"class","line-numbers language-"+a)
    • Again, thanks to this comment on GitHub: https://github.com/tinymce/tinymce/issues/2771#issuecomment-232910444
  8. Keep in mind: As Bludit is a static file generator, your previously generated pages won't get this automatically. Here you will have to edit the pre-element manually.

If you are interested in some examples, have a look at this page: https://admin.brennt.net/syntax-highlighting-test with line-numbering and without, etc.

Comments

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