apes strong together = stackoverflow

tl;dr; Roadmap of skills to develop, pls contribute on gitlab or github

I’ve always felt there is a missing element on what you need to learn next to progress in your skill set. Sure there are books, blogs, awesome-X pages.

Books get out of date quickly, blogs are usually managed by one person, awesome-X are often spammed with ads of technologies, aren’t skill agnostic…

and it all lacks progression roadmaps.

So I made one with Hugo. It’s pretty much empty now, I’ve only populated Java and Flutter section and it’s still opinionated how I see these technologies, so you might not agree with my opinion.

That’s even better, because I would like this to be a community managed page!

Developed with GitLab, Hugo and your support, we could build a list of topics a person needs to learn to be considered beginner or expert in their technology.

It’s pretty much a like a simple to-do list, but community managed, so you can take and give what you want. I don’t mean this to contain tutorials or learning material, rather links to good quality content. It’s for a person to read the list and notice:

“Oh, in my company we don’t do X. I’ve never done X, I should learn X!”

Or maybe you’re a mentor and want to set goals for your students? That will work too.

A link to GitLab repo and the generated pages are here.

It’s been nearly 3 years since my last post, so I don’t expect people to be here any longer.

If anybody is here, I wanted to share with you my recent development.

I wrote a simple CRUD page for storing links about topics that are of interest to me. I read the link (90% I read it, I promise), found it good quality, interesting, refreshing knowledge and I want to share this link with you, so you can gain some knowledge too!

You will find there topics like: Java, Spring, JVM, tools, Dart and Flutter, Go and Rust maybe?, SQL and Postgres, other databases too, Docker, k8s, k3s and any other container related technologies, interesting open-source projects, IT and computer science learning materials, good manufacturing practices of software architecture, and probably more, whatever I found interesting to read. Soft skills tips too!

It used to act as a wykop.pl bot, but since they (wykop) changed their API completely, I decided to wider my audience and rewrote the bot to post on Twitter as @interfa64424182.

You can see there is already a bit of history, and more to come daily!

tomcat

I assume you know what Tomcat and Docker are. Tomcat image by default has no user and no application deployed. It was designed to fork the image and use it with your own configuration. I couldn’t find any introduction which shows how to deploy your own Tomcat with user management enabled for your side projects. Everything was either too complex for my needs or did not answer the question “how to deploy Tomcat to play with it, deploy in it, destroy it”.

So, here I wrote a simple snippet that builds a local Tomcat docker image with your username and password and enables you to run Spring-Boot project, login from remote IP address (by default you can login only from IP Tomcat is running on).

  1. You need your own Dockerfile which forks Tomcat
  2. tomcat-users.xml file which contains roles, username and password
  3. context.xml file which enables you to login to Tomcat instance from remote IP

You can clone my Tomcat repository from GitLab, modify tomcat-users.xml with your own username and password and built it locally, but here you can see all the source code I used in the repository.

Source for the Dockerfile the image forks tomcat:8.0-jre8, copies local user management file and context to the image. Of course it has to expose port 8080 where Tomcat will be listening for connections:

FROM tomcat:8.0-jre8
MAINTAINER info@agilob.net
COPY tomcat-users.xml /usr/local/tomcat/conf/tomcat-users.xml
COPY context.xml /usr/local/tomcat/webapps/manager/META-INF/context.xml
EXPOSE 8080/tcp

tomcat-users.xml contains list of users, their roles and passwords, it’s simple as that:

<!--?xml version="1.0" encoding="UTF-8"?-->
<tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0">
  <user username="user" password="password" roles="admin-gui,admin-script,manager-gui,manager-script,manager-status,manager-jmx">
</user></tomcat-users>

The next one is context.xml which allows you to login to a remote server using your home IP (I deploy Tomcat on my dedicated server and connect to it from home):

<!--?xml version="1.0" encoding="UTF-8"?-->
<context antiresourcelocking="false" privileged="true">
    <!--
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
    -->
</context>

The last part of my setup is to automate the build process. I want to build the image and automatically deploy it in local Docker:

#!/bin/bash -e
docker build . | tee .log.txt
TAG=`cat .log.txt | tail -n1 | awk 'NF&gt;1{printf $NF}'`
docker run --restart=always -it -p 8080:8080 $TAG

Now, when you run bash ./build.sh as root, it will automatically build the image for you and start it.

GitLab.com offers free git repositories and similarly to GitHub, free CI which comes by default in your repository. GitLabCI can automatically generate badges for your project like build status and test coverage.

To start using GitLabCI without a hassle, GitLab repository manager offers .gitlabci.yml templates for your projects. For a Golang project, edit the default template, find the line that starts with go test -race and append -coverprofile .testCoverage.txt, so it looks like the one below:

- go test -race $(go list ./... | grep -v /vendor/) -v -coverprofile .testCoverage.txt

Go to Settings -> CI / CD, expand section General pipelines settings and add this regular expression  ^coverage:\s(\d+(?:\.\d+)?%) to Test coverage parsing

Next time you run your pipelines, test stage will contain something like:

PASS
coverage: 83.9% of statements

It will generate badges with build status and test coverage:

pipeline status coverage report

There are plenty of online tutorials showing how to create database-based authentication for Spring. Some of them use SQL query to authenticate user and retrieve its roles, some use DAO… but none of them worked well for me and all of them had some major problems, even like SQL Injection. So, in this post I will explain my approach and present final solution with a database (MySQL), User and Role class and UserDetailsService implementation.

The goal is to create basic webpage with login form and signup form (which includes fields validation) that handles different roles. Then, you and me can use it as a template project.

This tutorial doesn’t include steps how to setup your IDE and build environment. We’re going straight to code, and I will try to avoid as much boilterplate as possible, so the code won’t include getters and setters. If you still write them by hand, time to learn about Lombok project (which I use here) or any other code generator.

Continue reading

Everyone knows it’s important to keep dependencies up to date. The risks of not updating them are very often high: you risk losing your data or data of your customers, being part of a botnet or simply getting hacked by script kiddies replacing your frontpage with something shameful.
Not everyone knows how easy it is to keep your dependencies up to date with gradle. Both gradle and maven have plugins to check for updates in your list of dependencies.

Continue reading

To be able to access two databases in SpringBoot you must define two data sources. In my case I had one database for identity details of users, like username, name, email, address etc. and second database for everything else.

You have to define one @Configuration class for each database and each class will wired its own datasource to services (like JpaRepository or CrudRepository) to defined packages.

Continue reading

unix logo

I found that there are some people on GitHub that collect source codes from early UNIX ages, like first compilers, first shells, or PDP7-UNIX. Just to made them available in one place (slightly decentralize access to them) – I decided to create gitlab.com account `UNIX-history` for them.

You can find there source codes from 1970, nicely commented and manually formatted, before this all happened.

Also, enjoy this presentation about future of programming:

Sudo has an easter-egg that’s disabled by default. It can insult you each time you provide incorrect password. Just like that:

[sudo] password for agilob: 
You can't come in. Our tiger has got flu

[sudo] password for agilob: 
You do that again and see what happens...

[sudo] password for agilob: 
You can't get the wood, you know.

[sudo] password for agilob: 
Speak English you fool --- there are no subtitles in this scene.

[sudo] password for agilob: 
I think ... err ... I think ... I think I'll go home

[sudo] password for agilob: 
Where did you learn to type?

[sudo] password for agilob: 
stty: unknown mode: doofus

[sudo] password for agilob: 
Listen, burrito brains, I don't have time to listen to this trash.

[sudo] password for agilob: 
sudo: 3 incorrect password attempts

Continue reading

A lot of people, websites and communities encourage you to run your Tor node – middle node or bridge, not exit node, but none of them tell you about real consequences of keeping a Tor node active for a long time. So, here I’m going to share with you my experience of running middle node on VPS/dedicated server and home router. This post is divided into parts, one shortly describes problems when running Tor on your home IP, and the second section is about running it on your server. It describes my experience, so not all of it applies to you.

This post is meant as a warning for you, because a lot of portals and people will tell you to help Tor by hosting a node, as it doesn’t cost anything… but they don’t tell you what are the costs not in terms of money.
Continue reading