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 →