cat and next line continuation ‘\’

This one, gave me one, huge, headache.

> cat
cat file \
 | sed "s|aa|bb|g"

> touch file
> ./
cat:  : No such file or directory
./ line 3: syntax error near unexpected token `|'
./ line 3: ` | sed "s|aa|bb|g"'

Yes, you are right, there is an extra space at the end of line cat file \ .

macOS + VIM + Modifer Keys… – make life easier

yank the line

Whenever you need that line – without leading spaces, and without new line character: ^y$.


> svn merge -r HEAD:some_revision_back_in_time .


> indent -npsl -bli0 -brs -br -brf -bs -cdw -ce -cs -i2


# This one works for macOS

> tar zxf archive.xz

macOS – disable notifications

I am not sure who’s idea was it to force people to use notifications. The first thing I always do (after installing macOS) is going to System Preferences -> Notifications -> Turn on Do Not Disturb. There is no other way, unless you want to be disturbed every, freaking, minute :)

/dev/ufs/ no such file or directory

I was struggling for quite some time with my USB backup drive attached to NAS server based on FreeBSD. From time to time, during boot time, I was getting error

/dev/ufs/usbstorage no such file or directory

and machine was going into single user mode. It turned out, that adding late inside /etc/fstab was enough to solve the issue.

/dev/ufs/usbstorage   /media/usbstorage   ufs   rw,late   0   0

It solved the problem of missing location during the boot time.

NetBeans – make macOS installer beautiful again

It’s fairly easy to make macOS like Application based on zip file distributed by Apache. All you need to do is to create structure like this:
|-- Contents
|   |-- Info.plist
|   |-- MacOS
|   |   `-- NetBeans
|   `-- netbeans.content
`-- Icon\r

and make sure to run actual application inside NetBeans wrapper script

#!/usr/bin/env bash

ABSPATH=$(cd "$(dirname "$0")"; pwd)


Then, you need just a little bit of this, a little bit of that, and you can end up with something like this :)

vsftpd and nasty ‘vsftpd failed – probably invalid config.’ error

If you have encountered this sort of issue

 * Starting FTP server vsftpd
 * vsftpd failed - probably invalid config.

try this one. Inside /etc/init.d/vsftpd replace these lines

  start-stop-daemon --start --background -m ...

  while [ ${n} -le 5 ]

with this one

  start-stop-daemon --start --background -m ...

  sleep 1  # this one, will remove race condition

  while [ ${n} -le 5 ]

I have spent few hours to resolve this one ;)

NetCAT – NetBeans 10 and testing FTP connections
– Docker based

That’s yet another post about making live easier through Docker. This time, I am focusing on FTP.

Testing FTP features in PHP based project requires running FTP server. And, let’s be honest, this is a place where you can face some issues. First of all, you have to have FTP server running, you have to convince your FTP server admin to give you some space there, and you have to convince him to allow you to play with WWW storage :) I guess, you can call it a challange.

Another approach is to set up your own machine – doable.

And yet another approach is to use specially crafted Docker image. Brought to you as a dedicated solution for all your NetCAT testing related troubles ;)

> git clone

That’s almost everything you need to do. There are just few more steps to go. Simply build it, run it and let it go.

You can run container with one of three, available, flavors: implicit_ssl, explicit_ssl, or no_ssl.

> docker build -t ftptest .

> docker run -i -t \
  -p 80:80 \
  -p 2020:20 \
  -p 2021:21 \
  -p 990:990 \
  -p 21100-21110:21100-21110 \
  ftptest /bin/ no_ssl

After it is successfully started you will be able to read




        NetCAT FTP testing server
        - FTP User: html
        - FTP Password: html

That’s it. We have server running. And, it’s not just a FTP server. We have apache2 on board as well.

To get it running inside NetBeans, we simply have to configure PHP Application from Remote Server. Once you are there, make sure to use proper settings for the project

and location of the server (make sure to clear Upload Directory) field.

While setting up FTP connection, you can choose Pure FTP when you have started container with nossl option, or you can use Explicit FTP using TLS when you have started container with ssl option.

That’s it. You have your own, remote, PHP project ready for development


CLI, diff, and something like meld

If you work with remote machines, and you need to take a brief look at some changes in files it might be really painful.

If need a quick glimpse into differences between two files, you can always use diff.

diff file_a.txt file_b.txt
< It's alive!
> And his name will be forty and four.

you can even get some context, together with difference

diff -u file_a.txt file_b.txt
--- file_a.txt	2018-10-26 11:28:40.000000000 +0200
+++ file_b.txt	2018-10-26 11:28:40.000000000 +0200
@@ -1,3 +1,3 @@
 Hello world!

-It's alive!
+And his name will be forty and four.

But, let’s be honest, that’s not what regular developers want to see. I know there are people who are extraordinary.

– I wanna tell you my secret now
– OK
– I see dead people

However, for most of us, seeing things as they are, visually, where you can actually see the difference served on the plate in front of you, is a sort of warm place where we feel comforted. And, what’s more important, you can have it, while working with CLI.

First of all, you can always resort to Vim. Yes, old good Vim can provide you with visualization of differences.

> vim -d file_a.txt file_b.txt

Second approach, is to use dedicated tool called: ydiff

All you have to do, is to download it from GitHub.

> curl -ksSL > ~/bin/ydiff
> chmod +x ~/bin/ydiff

and pass outcome of diff directly to ydiff.

> diff -u file_a.txt file_b.txt | ~/bin/ydiff -s

And what is your preferred way of checking differences while working with CLI?

NetBeans – profiler test pack (Docker based)

If you want to test remote profiler in NetBeans, it might be quite a struggle. Main source of the problem lays in the fact, you need remote code running. You have few options here: locally started code (you can access it via localhost), Virtual Machine with all the components (JDK, source code, profiler pack), dedicated bare metal based solution (but you need a machine to spare). Anyway, in all cases you have to copy files back and forth, that’s a little struggle. Not to mention time required to setup environment on target machine.

There is, however, yet another way. It simplifies the whole process quite heavily. You can use Docker.

First of all, you need a Docker. But I assume that you either have it somewhere or you know how to install it: Docker.

Then, you need to create Remote profiling pack.

Let’s say, you have saved it here: /tmp/ At the moment, Docker based solution supports only Linux (Intel/AMD) 64bit JVM.

All you have to do, is to build Docker image. Unfortunately, must be at the same level as Dockerfile. You have to pass just one argument – location of JDK you want to install inside Docker container (jdk_location).

> git clone
> cd ProfilerDocker
> cp /tmp/ ./
> docker build -t profiler \
--build-arg jdk_location=\
"" \

Once you have image created, you can run it: docker run -p 5140:5140 profiler.

As you can see, Java is waiting for a profiler to connect on port 5140. All we have to do is to press Attach inside NetBeans.

That’s it! Profiled code starts to roll, and you can observe results inside NetBeans.

Note 1: In case you are running on macOS make sure to set memory to some reasonable size. Otherwise, your Java code will fail with java.lang.OutOfMemoryError. Take a look here: Docker and memory settings

Note 2: Sometimes, it’s good to clean Docker images so you don’t run out of disk sapce. Take a look here: Cleaning Docker images.


NetBeans and arbitrary JDK version in macOS

By default, macOS picks up Java version based on highest number that is located here /Library/Java/JavaVirtualMachines. This is quite painful in case you have multiple versions of Java and willing to switch back and forth. You can, of course, export JAVA_HOME like this

> export JAVA_HOME=$(/usr/libexec/java_home -v 11)
> export PATH=${JAVA_HOME}/bin:${PATH}

You can disable Java versions by moving file /Library/Java/JavaVirtualMachines/jdk-##.jdk/Contents/Info.plist to “backup” – Info.plist~. If there is no Info.plist file, this particular version of Java is not taken into account.

Fortunately, in NetBeans, you can pass location of JDK (one that will be used by NetBeans) via --jdkhome argument.

# If you have JDK 11 installed, but you want to run NetBeans 
# with version 1.8 simply point to this particular version
# by passing it's location with --jdkhome argument
> ./netbeans --jdkhome \

That’s it.

Alternatively, you can modify file etc/netbeans.conf and set value of netbeans_jdkhome=”/path/to/jdk” to location you want to use.

Thunderbird – calendar times are mixed up (Lightning add-on)

I was struggling with Lightning plugin for quite some time. The reason was that I was getting invitations with mixed up times. Sometimes, they were correct, sometimes, completely crazy.

Eventually, it turned out that Thunderbird has it’s own time zone settings. Who would have guessed?

If you fix this one, all the meetings will start appear with correct date/time settings.

JAR files without version in file name

are so painful. The pain comes from the fact that you have to extract MANIFEST.MF to learn what’s inside.

> unzip -qc log4j.jar META-INF/MANIFEST.MF


> unzip -p log4j.jar META-INF/MANIFEST.MF


> vi log4j.jar 

Parsing for size with prefixes in C

At some point, I have decided to pass size of the log file created by stdroller.

I thought it will be hard as hell to pass SI prefixes. I was all wrong. It’s a piece of cake to parse the value with format like: ./stdroller --limit=10G or ./stdroller --limit=1k, etc.

All you have to do is to use strtoull function. It returns location of first character that is not a part of your positional system (I am using system with base 10). So, you get index of SI prefix for free. Isn’t that cool?

limit = strtoull( optarg, &next_idx, 10 );

if( *next_idx != '\0' ) {
  if( *(next_idx + 1) != '\0') {
    printf("Ups. You have passed incorrect number\n");
  } else {
    switch( *next_idx ) {
      case 'K':
      case 'k': 
        limit *= pow(10,3);
      case 'M':
      case 'm':
        limit *= pow(10,6);
      // you can put additional cases here for G/g, T/t, P/p, etc.
        printf("Ups. Incorrect SI prefix\n");

Just for the record, one can use CLI to create big files

If you need a huge file, and you need it fast

# macOS/linux
dd if=/dev/zero of=bigfile bs=1024 count=1048576

# macOS
mkfile 1G bigfile

# linux
truncate -s 1G bigfile

# linux
fallocate -l 1G bigfile

NetBeans 10 on macOS

At the moment, you can’t get nice looking, full-blown installer of NetBeans for macOS, yet. However, running it is fairly easy. Just make sure you have recent JDK installed – just get it from here: JDK 11

Note! Please, make sure you can survive with new licensing model preparred by Oracle. It’s quite different comparing to what it was in the past: Java SE license. It might be more suitable for you to stick to GPL based version of JDK: OpenJDK.

I, personally, decided to use Open JDK. Just download tar.gz, put it inside ~/opt and make sure to export system variables

> mkdir ~/opt
> cd ~/opt
> curl -O
> tar zxf openjdk-11_osx-x64_bin.tar.gz
> export JAVA_HOME=$HOME/opt/jdk-11.jdk/Contents/Home/
> export PATH=${JAVA_HOME}/bin:${PATH}
> java -version
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

# If you want to make sure OpenJDK is visible system wide, make sure
# to copy whole structure here

> cd /Library/Java/JavaVirtualMachines/
> sudo cp -r ~/opt/jdk-11.jdk .

# you can also modify your ~/.profile and add following line there
# export JAVA_HOME=$(/usr/libexec/java_home -v 11)

once you have done it, make sure to download NetBeans nightly build. You can find it here: (all files in zip).

You will get huge zip file and inside, you will have something like this

`-- nbbuild
    |-- build
    |-- nbms
    |   |-- apisupport
    |   |-- ergonomics
    |   |-- extide
    |   |-- groovy
    |   |-- harness
    |   |-- ide
    |   |-- java
    |   |-- javafx
    |   |-- licenses
    |   |-- nb
    |   |-- php
    |   |-- platform
    |   |-- profiler
    |   |-- webcommon
    |   `-- websvccommon
    `-- netbeans
        |-- apisupport
        |-- bin
        |-- cnd
        |-- cndext
        |-- dlight
        |-- ergonomics
        |-- etc
        |-- extide
        |-- groovy
        |-- harness
        |-- ide
        |-- java
        |-- javafx
        |-- licenses
        |-- nb
        |-- php
        |-- platform
        |-- profiler
        |-- webcommon
        `-- websvccommon

you are interested in this location

> cd archive/nbbuild/netbeans/bin

# make sure to use version you really want to use
> ./netbeans --jdkhome ${JAVA_HOME}

and, that’s it :) You can start working with NetBeans 10.

NetCAT 10.0 – it’s already rolling

In case you haven’t heard about NetCAT program, yet, take a look here: NetCAT 10.0. NetCAT is a community acceptance testing initiative targeting NetBeans. If you work with NetBeans a lot, I guess this is the best place to support the team behind the product, and (as well) it’s the best place to get the glimpse of what’s coming with the next release.