Thymeleaf provides a powerful and easy to use template engine that is effortlessly integrated in Spring and Spring Boot projects.
In this example we look at how to send HTML emails with attachments using a Thymeleaf template from a Spring Boot 2 project.
First of all these are the imports we need to add:
org.springframework.boot:spring-boot-starter-mail
org.springframework.boot:spring-boot-starter-thymeleaf
27/04/2019
18/03/2019
[Ubuntu] Install Microsoft fonts
Most of the world uses Microsoft Windows and Office, therefore it might be sometimes necessary to generate documents using Microsoft fonts, which of course are only available on Windows.
For Ubuntu, the ttf-mscorefonts-installer package contains SOME of those fonts, simply install it and you can start using them AFTER regenerating the font cache with fc-cache
[Linux] Bind special key press to ALSA control action
If using ALSA, it's possible to bind special keyboard keys to action controls with a few configuration lines.
First of all, to find the available action controls, run in a terminal: amixer scontrols
Then, find the key event we need to bind to the desired action, and add it as an event,action pair in a new configuration file under /etc/acpi/events for example:
event=button/mute MUTE 00000080 00000000 K
action=/usr/bin/amixer sset 'Master',0 toggle
event=ibm/hotkey HKEY 00000080 00001009
action=/etc/acpi/undock.sh
First of all, to find the available action controls, run in a terminal: amixer scontrols
Then, find the key event we need to bind to the desired action, and add it as an event,action pair in a new configuration file under /etc/acpi/events for example:
event=button/mute MUTE 00000080 00000000 K
action=/usr/bin/amixer sset 'Master',0 toggle
which in this case for my lapotop binds the mute button to the mute action. It is also possible to execute a script instead, for example:
action=/etc/acpi/undock.sh
which runs some actions when the laptop is undocked.
[Linux] Find which event is generated on special keypress
To determine which ACPI event is generated when a special key is pressed, simply open a terminal and run: acpi_listen
Then press any special key (media keys and such, normal keys won't generate an event) and you will see the output eg:
button/volumedown VOLDN 00000080 00000000 K
button/mute MUTE 00000080 00000000 K
button/volumeup VOLUP 00000080 00000000 K
Then press any special key (media keys and such, normal keys won't generate an event) and you will see the output eg:
button/volumedown VOLDN 00000080 00000000 K
button/mute MUTE 00000080 00000000 K
button/volumeup VOLUP 00000080 00000000 K
05/03/2019
[Ubuntu] Boot USB after error mmx64.efi not found
UEFI, great leap into the future and also great pain.
There is a funny error that can happen after creating a UEFI bootable USB to install a linux distro for example. If the installation is not completed immediately and the system is restarted, some files are left in some area of the EFI partition (I guess) and subsequent attempts to boot the exact same device will fail with an error:
Failed to open \EFI\BOOT\mmx64.efi - Not Found
Failed to load image \EFI\BOOT\mmx64.efi: Not Found
Failed to start MokManager: Not Fond
Something has gone seriously wrong: import_mok_state() failed
The easiest fix, is to simply browse the USB drive and go into the efi/boot folder, then copy the grubx64.efi file and rename it to mmx64.efi
The next boot will work again as intended. Magic of the machines
There is a funny error that can happen after creating a UEFI bootable USB to install a linux distro for example. If the installation is not completed immediately and the system is restarted, some files are left in some area of the EFI partition (I guess) and subsequent attempts to boot the exact same device will fail with an error:
Failed to open \EFI\BOOT\mmx64.efi - Not Found
Failed to load image \EFI\BOOT\mmx64.efi: Not Found
Failed to start MokManager: Not Fond
Something has gone seriously wrong: import_mok_state() failed
The easiest fix, is to simply browse the USB drive and go into the efi/boot folder, then copy the grubx64.efi file and rename it to mmx64.efi
The next boot will work again as intended. Magic of the machines
26/08/2018
[Java] Useful keytool commands
Keytool is a tool to manage Java keystores. Here are some useful commands to:
- generate a new key and place it in a keystore:
- verify the content of a keystore:
- export the public key:
- delete a key:
- add a private key:
- add a public key:
15/08/2018
[Ubuntu] Revert kernel back to older version
Intro story: So much luck in a single day.
I always keep only 2 kernel versions after every update, so that I can boot back if something goes wrong. This usually helps, except today I decided to upgrade my Ubuntu from 16.04 to 18.04 since I like spending my nights fixing stuff after unnecessary upgrades, but hey, the future is there.
So I first fully updated my current installation (1st kernel bump), then migrated to the new one (2nd kernel bump) and it turns out I got two 4.15 kernels, with only different minor version.
Double interesting, my wireless card:
02:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8821AE 802.11ac PCIe Wireless Network Adapter
apparently has issues (read: bug) with kernel 4.15 preventing it from working at all (not even connected to the router), and even more interesting, on one version it can actually only connect to websites under google.com domain..
Anyway, quick fix was to revert back my kernel, here is how for future me to remember:
I always keep only 2 kernel versions after every update, so that I can boot back if something goes wrong. This usually helps, except today I decided to upgrade my Ubuntu from 16.04 to 18.04 since I like spending my nights fixing stuff after unnecessary upgrades, but hey, the future is there.
So I first fully updated my current installation (1st kernel bump), then migrated to the new one (2nd kernel bump) and it turns out I got two 4.15 kernels, with only different minor version.
Double interesting, my wireless card:
02:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8821AE 802.11ac PCIe Wireless Network Adapter
apparently has issues (read: bug) with kernel 4.15 preventing it from working at all (not even connected to the router), and even more interesting, on one version it can actually only connect to websites under google.com domain..
Anyway, quick fix was to revert back my kernel, here is how for future me to remember:
- go to http://kernel.ubuntu.com/~kernel-ppa/mainline/ and download in the same folder: linux-headers-VERSION-generic-XXX_SYSTEM.deb, linux-headers-VERSION_all.deb, linux-image-VERSION-generic-XXX_SYSTEM.deb for your system, eg I have 64 bit system and got amd64 files
- install them by going into the folder where you downloaded them, make sure there are only those three .deb files and run: sudo dpkg -i *.deb
- restart the system, then press SHIFT at boot to enter the GRUB choices, then check from the top line (number 0) to the line of your kernel version. If your installation has the "Advanced" menu entry and does not display all kernels, go there and do the same counting. We need this to set a default GRUB entry to always boot in this kernel
- edit /etc/default/grub and change the value of GRUB_DEFAULT to the number you counted OR to (exactly as shown) "1>N" if you have the "Advanced" menu option. This means you want to boot into the Nth entry (starting from 0) under the "Advanced" menu. Also set GRUB_TIMEOUT to some value in seconds that's more than 1, to have some time to block the boot process in case of mistakes
- run sudo update-grub and you are set
Subscribe to:
Posts (Atom)