Archive

Author Archive

Work on profit-maximizing IT systems – No thanks

July 24, 2017 Leave a comment

Recently I was contacted by a well-meaning IT recruiter (name omitted for privacy reasons) and explained why I don’t work on financial trading systems anymore:

The request

Hi Oliver,

I came across your profile in my connections this morning and I was keen to reach out to you.

I can see your current experience working with Java, I am currently working on some Core Java opportunities working on the new development of a real-time trading platform.

This opportunity would allow you to work with the latest Java technologies as well as giving the opportunity to learn Scala.

Please let me know when the best date and time to get hold of you would be so we can discuss?

Kind regards,
XXXX

The response

Hello XXXX,

Is it a trading platform in the financial services sector (i.e. banking)?

If so then I have to politely decline. I have worked on trading systems for a large investment bank in the past. My role was Senior Developer / Technical Lead.

But I decided that I didn’t want to spend my limited life-time helping Wall Street traders or other folks whose only business is to make more money for themselves and their (usually already wealthy) investors.

I currently work on systems that support the Canadian Search & Rescue helicopter fleet. Rescuing people’s lives or health is a cause I feel good about and that motivates me.

Please feel free to contact me again if you come across job openings that contribute to the common good.

Thanks
Oliver Doepner

Categories: coding, opinion Tags: , ,

The works of Edgar Allen Poe (5 epub files)

July 22, 2017 Leave a comment

It is nice that copyright does not last forever and Project Gutenberg exists.

I just downloaded “The Works of Edgar Allan Poe“, volumes 1 – 5, from gutenberg.org as free ebooks (epub files).

Volume 1Volume 2Volume 3Volume 4Volume 5

I copied them to my Kobo eReader and look forward to days of reading.

Of course I could have borrowed the books for free from Halifax Public Libraries as well.

Testing HTML5 / CSS3 editor BlueGriffon

July 21, 2017 Leave a comment

I used to use the now-outdated Mozilla based editor Kompozer, which was a bug-fix fork of Nvu.

Today I realized that in the meantime (since 2015) the Nvu author Daniel Glazman has developed BlueGriffon, an Open Source next-generation Web Editor based on the current rendering engine of Firefox.

I just installed it on Windows at work and my Debian laptop at home and plan to give it a try.

If it is easy to use and generates clean standards-compliant code, I might use it for Web UI mock-ups and other prototyping. :)

Categories: apps, coding, css, firefox, gui, html Tags: ,

Trigger Camel route from command line

July 17, 2017 Leave a comment

Let’s say we have an Apache Camel route with an entry point like this:

from("direct:start")
    // other route steps 

How to trigger “direct:start” from the command line?

Use JMX

The JMX instrumentation agent is enabled in Camel by default.
In Camel 2.9+ no special jars are required for JMX.
For details, see the Camel JMX documentation.

  • Determine the process id of your Camel Java process.
  • Determine which user id your Camel process is running as.
  • Download or build the jmxterm tool. You need the “uber” jar.

On the same computer and as the same user, execute jmxterm like this:

java -jar jmxterm-*-uber.jar -l ${pid} -i jmxterm-script.txt

With a file jmxterm-script.txt like this:

bean org.apache.camel:context=camel-1,name="camel-1",type=context
run sendStringBody "direct:start" ""

This calls sendStringBody(..) on the ManagedCamelContext and triggers the route for you.

Categories: coding, java Tags: , ,

Nagios NRPE wrapper to encode meta-characters

April 23, 2017 Leave a comment

The Nagios Remote Plugin Executor allows remote execution of Nagios check commands, which is a powerful tool for monitoring the health of the machines and services on your network.

If your remote commands take command line parameters, you might run into trouble regarding special characters, typically required in regular expressions and other values you might want to send across. To actually see the error on the target machine, you need to Create a Log File for NRPE.

If your command fails due to this kind of error, then read on:

Apr 6 18:06:58 somehost nrpe[somepid]: Error: Request contained illegal metachars!
Apr 6 18:06:58 somehost nrpe[somepid]: Client request was invalid, bailing out...

NRPE inspects the arguments for characters that have special meaning for typical Unix shells to prevent shell command injection. If it encounters any charcaters deemed unsafe the command execution is rejected and you will see the error message above.

Unfortunately NRPE does not provide a way to safely encode and decode the parameter values.

To work around this, I created a wrapper script for the check_nrpe command, let’s call it check_nrpe_urlencoded.sh. I chose url-encoding for its simplicity and familiarity. The goal is to be able to create Nagios command definitions like this:

$USER1$/custom_scripts/check_nrpe_urlencoded.sh -H $HOSTADDRESS$ -c my_remote_command -a '$ARG1$' '$ARG2$'

And the remote command would bedefined in /etc/nagios/nrpe.cfg or under in a custom file under /etc/nrpe.d/, depending on your Linux distribtion:

command[my_remote_command]=/path_to_my_custom_nrpe_plugins/my_remote_command.sh '$ARG1$' '$ARG2$'

Here is a possible implementation of check_nrpe_urlencoded.sh:

#! /bin/bash

command='/usr/lib/nagios/plugins/check_nrpe'
args='no'

urlencode() {
    old_lc_collate=$LC_COLLATE
    LC_COLLATE=C

    local length="${#1}"
    for (( i = 0; i < length; i++ )); do
        local c="${1:i:1}"
        case ${c} in
            [a-zA-Z0-9.~_-]) printf "$c" ;;
            *) printf '%%%02X' "'$c" ;;
        esac
    done

    LC_COLLATE=${old_lc_collate}
}

for x in "$@"; do
  if [ ${x} = '-a' ]; then
    args='yes';
  else
    if [ ${args} = 'yes' ]; then
       x=$(urlencode ${x})
    fi
  fi
  command="${command} ${x}"
done

# execute the check_nrpe with the encoded args:
${command}

In the remote shell script like my_remote_command.sh, you would then decode the arguments like this:

function urldecode() {
  local url_encoded="${1//+/ }"
  printf '%b' "${url_encoded//%/\\x}"
}
arg1="$(urldecode $1)"
arg2="$(urldecode $2)"

And then use the decoded arguments as before.

Categories: bash, coding Tags: ,

Summing up numeric values using bash

March 22, 2017 Leave a comment

For example to add up the disk usage at several disjoint locations:

numfmt --to=iec $[$(du -s /home/*/docs | cut -f 1 | paste -sd+)]
101K

The $[..] is for arithmetic evaluation in bash.
Alternatively pipe to the bc command.

Categories: bash, coding

Simplest Dependency Injection

January 17, 2017 Leave a comment

diy

Note to self: If you create a Java application and think you need DI but not AOP, then do not automatically reach for containers like Spring, CDI, Guice. Just do all construction and wiring in the standard main method.

Example: https://github.com/odoepner/bagh-chal/blob/master/src/main/java/net/doepner/baghchal/Main.java