Macros in Vim

I don’t know how to quit vim so I am destined to use it forever. Let’s make the usage a little less painful.
Read more →

Git - Pushing Code to a Remote Computer

I needed to set up git for pushing into a non bare repo with a checked-out branch. Here is how I did it:
Read more →

Handling API Errors in Angular

This is a brief howto on handling error responses from your API with an Interceptor and Angular Material Dialogs
Read more →

Strippr - A Comic Strip Compositor

I like to create simple comic strips for fun. They all look similar, so I had an idea to create a small application that would swallow a JSON with ‘script’ and spit out a comic strip.
Read more →

A Quick Reflection About Java Reflection

I was asked a question:“What do you know about reflection in Java?” I wasn’t really confident while answering that question, so let’s get a bit wiser and polish my rusty knowledge.
Read more →

Don’t hate HATEOAS

A brief intro to HATEOAS
Read more →

Reading Command Line Arguments in NodeJS

Accessing command line arguments in NodeJS is easy. For simple applications, access the process.argv array directly. For more sophisticated ones, use one of argument parsers.
Read more →

Nested Classes in Java

I have recently tried one Java quiz and there was a question about class nesting. I didn’t answer correclty since I hardly ever use this language feature and when use nested classes, I use them intuitively. Let’s refresh this piece of knowledge and add some remarks.
Read more →

Hello Docker

How to dockerize a simple NodeJS app
Read more →

Use q For High IQ

"q" is a nifty command line tool if you would like to do some text file processing and lookups. So what is it? Basically SQL for csv/tsv (and other tabelated) files. It supports most of the basic queries and also allows to perform them over multiple files (supports joining). How does it work? You can imagine a file with tabelated data as a single table of a database. Just type in the command prompt:
Read more →

Hugo, Asciidoctor & PlantUML

PlantUML is a great markup language for creating (not only) UML diagrams. Let’s try and make this tool work with Hugo + Asciidoc. Asciidoctor has an asciidoctor-diagram package in its toolset. This package should add support not only for PlantUML but also for GraphViz and other graphing markups. Cool. Asciidoctor-diagram was installed when setting up the platform, covered in the previous article If you try to add a simple PlantUML diagram now, you will probably get an empty picture.
Read more →

Beauty of Lambdas

I came across an interesting kata on Codewars. Let’s discuss the solution a little bit.
Read more →

Autowiring a Spring Bean from External JAR

About importing an external library containing a Spring Bean into a project
Read more →

Sudo su vs sudo -i

If you ever wondered, sudo su and sudo -i are not exactly the same. sudo suCalls sudo with command su, i.e. Bash is called as interactive non-login shell. It executes only .bashrc and you remain in the same directory.sudo su -Logs in as super user, i.e. /etc/profile, .profile and ``.bashrc`are executed and you are logged in to root’s home directory with root’s environment.sudo -i-i = simulate initial login. The manpage for sudo says:
Read more →

Silent pushd and popd in Bash Scripts

I have several shell scripts that use pushd and popd extensively. These commands output the paths to stdout which may overwhelm the console output with lots of unwanted text. Unfortunately, neither pushd nor popd have any silent option according to their man pages. A simple solution is to redirect the stdout to /dev/null. pushd $PWD > /dev/null Is it favourable to explicitly redirect to /dev/null everytime I call pushd/popd in the script?
Read more →

Find All Directories

I needed to go through a directory structure and do a git-fetch if there was a .git repository inside. Finding all directories containing the .git is quite easy with find command. find $root-directory -regex '^.*/.git$' -printf '%h\n' | sort -d This is nice but it also prints unneccesary data. It does not only print the leaf directories but also all the partial paths to them. The original project structure is something like:
Read more →

Why We Should Avoid Side Effects

I have recently come across a very bad piece of code. Here is the idea. It is a service that basically takes camera stream configuration, takes snapshot and saves the stream + snapshot + some additional info for further use. This service is called every time a new stream is added or when the stream needs to be updated. Here is the roughly sketched idea. CameraService @Service public class CameraService() { @Autowired private CameraRepository cameraRepository; @Autowired private SnapshotService snapshotService; public Camera updateCamera(CameraConfiguration configuration) { Camera updatedCamera = cameraRepository.
Read more →

Asciidoctor Hugo

Hugo has great support for Markdown. It works out-of-the-box altogether. However, I like Asciidoc more so I tried to set up the platform for writing pages with lots of source code listings. It became a task for masochists. If you are okay with Markdown, you should probably stay in that realm and enjoy simplicity. I tried several approaches. None of them seemed to work for me. External CSS according to Rgielen.
Read more →

Spring (Boot) application.properties and Variables

Define an environment variable in environment export my_config=1337 To make a default value if the environment variable is not defined. application.properties 1 # Default value 2 my_config=666 3 4 # Take either a value from system environment or the default value. 5 my.config=${my_config} Consume the variable somewhere in the application. MyClass.java 1 @Component 2 public class MyClass { 3 @Value("${my.config}") 4 private int myValue; 5 6 // Consume myValue ad libitum 7 } Careful with the naming, it happened several times that I defined the default configuration with dot-notation and then the application did not work.
Read more →

Bash Autocomplete

MotivationI have inherited several Bash installation scripts for our software developed in CertiCon. What a user could do was to call the following command in the terminal and the application behaved as requested. $ myApp start|stop|restart The magic was hidden in the keyword complete in a file called autocomplete_app.sh. autocomplete_app.sh complete -o nospace -F _myApp_autocomplete myApp complete -o nospace -F _myApp_autocomplete /opt/myApp/compose.sh AutocompletionBash auto completion is quite a well-known feature from user point of view.
Read more →

Files and Directories

Check if directory is emptyBecause having something like Directory.isEmpty() would be too obvious. File dir = new File("path/to/my/file"); boolean isEmpty = file.isDirectory() && file.list().length == 0 Create a Path to Nonexistent Temporary fileThis is an interesting task. I needed to create a path to a temporary zip archive that did not exist yet so that I could use a zip4j library. It is easy to create a temporary file. 1 File tempFile = File.
Read more →