Youtube Download
A quick tips on how to download stuff from Youtube, using yt-dlp.
First Principles Thinking
A quick tips on how to download stuff from Youtube, using yt-dlp.
I’ll compare Parallels 1.9.4 AppStore Edition vs UTM 4.5.4 (100). Time of writing of this blog post: 8. Oct. 2024.
Many people think they understand thread programming, but unfortunately only a handful of people really do. If you think you can write thread-safe program, you can’t.
SOLID is a way to develop your programs. I am not a huge fan, and now Prime put my thoughts into words very eloquently.
minikube is an excellent way to have a Kubernetes server up-and-running in no time on your Ubuntu machine. In this article we’re going to have the vaadin-boot-example-maven app running in Kubernetes. That will require the following steps:
When a project defines no @WebServlet
, how come that VaadinServlet
gets loaded automatically?
Without automatic loading of VaadinServlet
there would be no servlet to handle
requests, and Jetty/Tomcat would simply return 404 NOT FOUND.
Let’s take a look, both on standard servlet project and on a Spring-Boot project, how
the automatic loading works.
There are many JDBC frameworks, both Java and Kotlin. However, some of the frameworks lack certain functionality which prevents them to be used with Vaadin and the traditional way of Vaadin CRUD via the Binder, including the JSR 303 Bean Validation.
To add right-click (or context-click) listener to any component in Vaadin 23+:
The goal is to setup 2 Vaadin apps on one Ubuntu machine:
Because we all need to go to the toilet sometimes.
I have an Android Tablet for kids, with VLC and a bunch of movies installed. Recently I needed to copy over some new movies from MacBook, and it just wouldn’t work.
Intellij IDEA now runs on Wayland, and it runs surprisingly well! What’s even better, IDEA running on Wayland is now compatible with UTM, meaning that you can finally set up a perfect dev env in Ubuntu running in UTM! IDEA runs buttery-smooth, no hiccups; if I’d have to guess it’s partly because of JVM 21 and partly because of dropping X baggage.
Even though RPI Zero 2W is quite limited and 32bit OS would work much better, Ubuntu 24.04+ only ships as arm64 so there’s nothing you can do. Flash a SD Card with arm64 Ubuntu and choose the “Server” option.
I want to avoid installing custom binaries provided by the VPN providers. I usually tend to use the VPN provider which either uses wireguard or openvpn:
Say you want to expose Jenkins at /jenkins
via nginx (which also unwraps https).
You try to define the standard proxy_pass http://localhost:8080/;
rule, and nothing works.
If you’re using one of the Vaadin Paid components (e.g. Components marked with $
or Classic Components and you want to run UI tests in your CI/CD env,
you need to pass the Vaadin server license key to
the build JVM. The easiest way is to use the VAADIN_OFFLINE_KEY
environment variable.
If you’re using one of the Vaadin Paid components (e.g. Components marked with $ or Classic Components and you want to run UI tests in your CI/CD env, the server offline license won’t work unless you enable Vaadin production mode. Luckily it’s easy.
The easiest way is to use karibu-tools built-in support but that requires Kotlin. Here’s the Java class (quick’n’dirty, no javadoc):
The Vaadin Documentation on In-Project Web Component is rather outdated, so here’s a more up-to-date example. Also don’t forget to consult Lit Documentation whenever needed.
To enable session persistence, set the server.servlet.session.persistent=true
setting in your Spring Boot application.properties
The property value is false
by default; however, it is overwritten by spring-devtools, which sets it to true.
It’s quite convenient since you remain logged in over redeploys without any special configuration.
Summarizing ways to style both Vaadin and non-Vaadin components here. Important: The @CssImport
annotation
only works with web components implementing the ThemableMixin
(so, in general, only with Vaadin components)
AND/OR web components correctly defining parts in their ShadowDOM.
@CssImport
can not be used with other web components - it will simply get ignored and will do nothing.
I’m working with Linux in VM/Parallels on a daily basis, and it’s impossible for me to constantly switch between two very different layouts. Therefore, I’ve decided to try and modify Linux to work as much as MacOS.
I’m working with Linux in VM/Parallels on a daily basis, and it’s impossible for me to constantly switch between two very different layouts. Therefore, I’ve decided to try and modify Linux to work as much as MacOS.
The general advice is to bite the bullet and learn Mac keyboard shortcuts. That doesn’t help in my case though: I’m working with Linux in VM/Parallels on a daily basis, and it’s impossible for me to constantly switch between two very different layouts. Therefore, I’ve decided to try and modify Mac to work as much as Linux. That means that, for example, Ctrl+Q closes app (and not ⌘Q), Ctrl+Home moves the cursor to the top. I’ve also avoided installing all third-party apps on Mac, and only using Input Remapper which is available in official Ubuntu repository for both Ubuntu 22.04 and 24.04, so this method is future-proof.
I need to setup new machine from time to time, and I always forget all the things that need to be set up. So, here it goes.
I need to setup new machine from time to time, and I always forget all the things that need to be set up. So, here it goes. I won’t setup any encryption since I expect MacBook disk itself to be already encrypted.
The Vaadin Navigation Lifecycle documents in great depth what happens when there’s a navigation from one view to another. However, it leaves out one important corner-case: what exactly happens when there’s a navigation from a view onto itself. There’s a Request for clarification 3265, but let’s go through what actually happens in Vaadin 24.3.6.
When working for the customer, I’ve found out that the best way is to setup a dedicated VM. That way, it’s easy to install anything that the customer uses, without polluting your main OS. The question is, how does IDEA perform in a VM?
If Vaadin is failing with “Invalid JSON from server: 1|X”, read on.
The problem is that Vaadin expects an UIDL JSON message over the websocket pipe and can’t parse 1|X
. Where did 1|X
came from?
I’ve tested two VMs: UTM and Parallels. Testing hardware is an old MacBook Air 2015 x86-64.
UnexpectedTypeException: HV000030: No validator could be found for constraint ‘javax.validation.constraints.NotBlank’ validating type ‘java.lang.String’.
The documentation for Gradle Overlapping Outputs is a bit misleading: it explicitly states that you need two tasks, overwriting each other outputs. However, the overlapping outputs behavior can easily be reproduced with just one task.
The documentation for Gradle Build Cache is great and goes in depth but it lacks a quick “getting started” examples. Let me therefore explain the difference between UP-TO-DATE and FROM-CACHE, and reach out to the official documentation if you have any further questions.
You can use the following methods to retrieve the current view, location or the browser URL:
You’re having ConcurrentModificationException
s that occur randomly and can not be
reproduced at will. The stacktrace doesn’t help much since it simply points into VerticalLayout.add()
or similar, and everything looks okay.
This kind of exception happens when a Vaadin code is accessed from a background thread.
But it’s definitely not easy to figure out, exactly who is calling Vaadin code without ui.access()
.
You can call ui.getInternals().getPushConnection().isConnected()
to figure out whether Atmosphere websocket pipe is connected. The question is,
is the pipe actually alive and healthy?
The UTM VM is just brilliant. I’m testing it on an old x86 MacBook Air. When using QEMU hypervisor, the CPU speed is almost native. Installing Ubuntu from ISO is very easy.
I’ve bought an old 2015 x86 MacBook Air, to get a taste of the Apple experience, and to see whether it might be my daily driver. Currently, I’m quite happy with Ubuntu, but I’m always hesitant to suspend the machine - it never worked properly in the past. Also the Nvidia+Wayland support is just strange; IDEA also had a couple of GNOME Shell-related issues in the past. I wanted to see whether things work better on Apple machines.
If you have been bitten by Vaadin’s
IllegalStateException: Can't move a node from one state tree to another. If this is intentional, first remove the node from its current state tree by calling removeFromTree
,
read on.
As Brian Goetz mentioned:
Optional is intended to provide a limited mechanism for library method return types
where there is a clear need to represent “no result,” and where using null
for
that is overwhelmingly likely to cause errors.
What I learned when reading the rethinking productivity in software engineering book:
In Vaadin 8, it was possible to use ConnectorBundleLoaderFactory
to defer loading of
certain components, to speed up the rendering of the initial view, usually the login view.
You can read more about this in the Optimizing the widget set
Vaadin 8 documentation page. What’s the replacement in Vaadin 24?
It’s possible to increase the root filesystem size of the Linux VM machine, quite easily.
An example code to use Gson with http4k. See beverage-buddy-jooq to see this code in action.
An example code to use the built-in JDK HttpClient directly, with a bit of Kotlin.
Since Ubuntu 22.10, PipeWire replaced PulseAudio as the default sound server.
On my servers, I like to have two things:
This article lists a couple of tips to try out. First, let’s talk about GRUB since it’s responsible for booting up your Linux. These tips apply to Ubuntu 22.04 and higher.
The default Growatt Dashboard is slowly refreshed, often behind the real data by half a hour or more. The mobile Growatt app is horrible, it frequently requires you to re-login, and then shows obsolete data. The solution is to grab the data from Growatt Inverter ourselves and visualize them using Grafana.
okhttp was my go-to library when writing a http client code
for JVM. However, since Java 9 there’s a built-in java.net.http.HttpClient
.
Feature-wise and API-wise it compares very well against okhttp - it’s really usable, supports async
out-of-the-box and is baked-in in JVM by default, as opposed to okhttp (which also brings in additional dependency on okio).
Recently I need to change
the clocksource on Ubuntu 22.04 running on RISC-V LicheeRV Dock to something else,
since the default timer
was unreliable. The question is, how to make a change to
/sys/devices
permanent?
The .local
top-level-domain (TLD) is reserved to be used for your LAN. Every machine
has its own hostname, and if configured properly, it is accessible on your LAN by
the name of hostname.local
.
Getting this device up and running is almost impossible for the uninitiated, but finally I managed to get this bloody device up-and-running WITHOUT having to connect to UART-TTL. The Starfive VisionFive2 homepage.
Python has had a concept of generators for a long time. In short,
you generate sequence by calling yield
repeatedly in a block, instead of splitting your code into a nasty state machine.
Kotlin implemented the generators via coroutines, see Kotlin Sequences: Chunks
for more detail. And now that we have virtual threads, we can do the same thing in Java.
RISC-V architecture is on the rise, along with the ARM architecture. RISC-V is OSS and royalty-free as opposed to ARM and x86. There are compelling machines being introduced as we speak. Recently, Ubuntu created a new Ubuntu Download page for RISC-V where you can download images for your RISC-V machine. We’re going to install Ubuntu and Java on three RISC-V machines, and we’ll run a very simple Vaadin example app on those.
Pampered by the generally awesome hardware support straight by the vanilla linux kernel, I gave a couple of WiFi WiFi USB dongles a go, unfortunately the result is a bit of a mixed bag. I’m using Ubuntu 23.04 with kernel 6.2.0.
Over the years I’ve come up with a set of rules for any programming language that really suit my programming style. It goes without saying that every person has their own preferences and/or tasks: you may prefer dynamically-typed languages, or you may have to develop a Linux kernel driver, and then you should not follow these rules. I would personally miss the benefits of a statically-typed language such as 100% auto-completion and automatic type checking, however you may not miss those things and instead appreciate other things offered by dynamically-typed languages. Please take this article as a highly subjective personalized rambling of one old man.
We’ll build on the 2 Vaadin Apps 1 Kubernetes article; this time we’ll add a persistent database PostgreSQL to the mix. We’ll deploy the jdbi-orm-vaadin-crud-demo app which has the capability of running with either in-memory H2, or a remote PostgreSQL database. We’ll learn how services talk to each other by the help of the DNS plugin, and how to make PostgreSQL database files persistent using the hostpath-storage plugin.
I wanted to write a small command-line utility (no UI), to run on a Raspberry PI 3, which is an Ubuntu-based ARM64 machine. (Yup, I’ve installed the Ubuntu 64-bit over Raspbian). Here are some lessons learned.
The more you try to avoid coding, the more ridiculous the result will be. Prime examples: no-code, BDD.
Tried out golang, and I personally don’t like the language at all. Thoughts:
When developing a small command-line app, I’ve tried to develop it in Dart, to get the feel of the language and its ecosystem. I liked Dart quite much - it’s very close to Kotlin in focusing on usability and producing readable code, and not bringing every fancy feature just because. The library ecosystem is also very rich, you can find library for anything. The library may be 0.0.2 created by some unknown dude, but it will work.
If Kubernetes Ingress routing controller is misconfigured, it can provide surprising results. This guide lists all the points to take a look at. Works with Microk8s but should apply to any Kubernetes system.
Vaadin does officially support the Material theme, however it’s not actively developed and not recommended for new projects. The situation differs for Vaadin 14 and Vaadin 23+.
Sometimes the serialized class suddenly references a completely unexpected class by accident
(maybe some class is an inner class or such). However,
by default the NotSerializableException
prints only the offending class that’s not serializable, but it doesn’t
print the ‘field path’ how the serialization got there.
The basic principle of Java packaging is to package by feature. Let me repeat the advantages here:
This builds on 2 Vaadin Apps 1 Nginx but wraps everything in Kubernetes (namely, microk8s).
Let’s Encrypt is an excellent way to have https for free. The tutorial at Microk8s addon: Cert Manager lists all the steps but doesn’t explain much. Here’s what I learned.
microk8s is an excellent way to have a Kubernetes server up-and-running in no time on your Ubuntu machine. In this article we’ll deploy a container with nginx serving a simple static page, and we’ll configure ingress to perform reverse proxy for us.
If you’re looking for a self-hosted OSS free CI, this may give you some tips.
The goal is to setup 2 Vaadin apps on one Ubuntu machine:
DON’T. Session-scoping a route is very dangerous since if the user opens two tabs, that route instance will be shared between the two tabs, leading to unpredictable errors.
The easiest way to add REST server to your vaadin app is to use Javalin in the standalone mode. By default, Javalin runs its own Jetty server. However, your Vaadin app is already running in a servlet container. We can simply exclude Jetty from Javalin dependencies and use Javalin via the regular Servlet API.
I love the Frameworkless Movement, and, most importantly, the Frameworkless Manifesto. The movement ideas could be misunderstood rather easily; here are a bunch of thoughts to clear things up.
A blocking dialog is a dialog which blocks the code execution until an answer is obtained from the user. For example, in Swing, it is possible to write a code block which shows a confirm dialog, waits until the user clicked the “Yes” or “No” button, then resumes its execution on confirmation and finishes afterwards. Something akin to the following:
Vaadin (actually every web framework) runs two UI loops:
I love this old DOS/Windows game, and the brilliant OpenTTD project allows you to install and run the game easily, in any major OS. It bundles with a new open music, graphics data and everything, in order for you to run and play the game.
The DNS Relay functionality on the Arris Cable Modem/Router/whatever is a fucking disaster - it’s slow as hell and randomly stops working. I therefore set up my own DNS relay server on my LAN.
To disable NetworkManager and control your network configuration from command-line only, even
on Ubuntu Desktop, use netplan, edit files in /etc/netplan/
and change the renderer
from NetworkManager
to networkd
.
Vaadin components are partly build in javascript, to make the components work in the client-side (in the browser). That javascript code needs to be downloaded from somewhere, built, then distributed to the browser. For that we’re using the JavaScript toolchain. Without going into details, think Maven for JavaScript - it’s called npm. There’s also “webpack” which takes stuff downloaded by npm, and creates one huge javascript file out of that. That’s all you need to know about JavaScript part of Vaadin. Now, back to the point.
Having excellent language (Kotlin) with a proper full-blown garbage collector (not just reference counting) compiled to native binary which starts up insanely fast is a god-send. That being said, a language is almost useless without a set of libraries; and this is where Kotlin Native lacks severely, especially on ARMs.
Vaadin supports many additional scopes (think objects that are bound to e.g. session; when the session terminates, the objects are garbage-collected).
These steps are so annoying and error-prone, I am creating a documentation for myself, should I have to deal with this piece of shit ever again.
Running TestBench on Ubuntu is a nightmare. The ChromeDriver will block endlessly and won’t work, while FirefoxDriver will either segfault snap or fail with some other crazy error. On top of that, Selenium has problems with Chromium and Firefox installed as snap.
It came as quite a surprise to me that many people are using Spring Boot just to
avoid having to launch their apps as WAR files in Tomcat. But then again, it makes sense:
simply running a main()
function is far simpler than having to fiddle with WAR and Tomcat
deployment in your IDE, hoping that debugging would just work.
The best way that worked for me was a simple SOA architecture, no Spring, no JPA, no DI. Only use what you really need. DIY.
The newest Linux/Ubuntu 22.04+ DNS resolve stack is a fucking spaghetti of resolvconf, systemd-resolved, Network Manager
and 34724 other cryptic shit. In the good old days you would add nameserver
to /etc/resolv.conf
and be
done with it. Now you can’t even edit the file since it’s a symlink to ../run/resolvconf/resolv.conf
with nameserver 127.0.0.53
which is a DNS server running locally on your machine by systemd-resolved.
Keywords: Vaadin Initialization. Quoting Javadoc, “Lookup Provides a way to discover services used by Flow (SPI). Dependency injection frameworks can provide an implementation that manages instances according to the conventions of that framework. This is similar to the Instantiator class but a Lookup instance is available even before a VaadinService instance is created (and as a consequence there is no yet an Instantiator instance).”
The postgresql docker docs are pretty good. For experimenting, you can run PostgreSQL in a docker container. Note that once you hit CTRL+C, the database is gone:
The I18nProvider
class handles the duty of performing localization in Vaadin apps.
You can invoke it either directly via VaadinService.getCurrent().getInstantiator().getI18NProvider().getTranslation("key", UI.getCurrent().getLocale());
or via Component.getTranslation()
. The latter is much shorter, but you may not have a component
always around to perform the translation. Therefore, I recommend to create a simple class
You may already have encountered a funny “bug” when using Vaadin Grid:
T14s is a great laptop on paper: powerful AMD processor, portable 14” body, lovely piece of art. A complete garbage underneath. This is literally the worst machine I ever owned.
After VirtualBox 6.1.34 stopped working with kernel 5.15.0.47, I decided it was time to ditch the VirtualBox kernel-tainting VM modules and move to virt-manager (gnome-boxes offered almost zero configuration options and its UI performance was horrible). Pretty happy so far with my Linux-in-Linux setup:
The Custom Instantiator Official Vaadin documentation is now available, check it out. I’m keeping this text for historic reasons mostly.
To extend the VaadinService
class you need to override VaadinServlet.createServletService()
method which is done by introducing your own VaadinServlet
into the app.
Your new servlet will automatically take precedence over the old VaadinServlet
.
The official Vaadin documentation on configuration properties
is quite well hidden, therefore I’ll repost it here.
In order to change DeploymentConfiguration
properties, pass them as a servlet init parameter.
Simply define your own servlet which extends VaadinServlet:
The Vaadin documentation at Application Lifecycle: UI Expiration is not very clear. The Stack Overflow: Session Stays Open Indefinitely Answer by Erik Lumme is much clearer.
Garbage Collector is a big thing, even though it doesn’t receive much spotlight in the news. Do you remember the feeling of relief when you moved to a language with garbage collector? Suddenly you didn’t had to remember all the time who’s responsible for memory allocation and freeing - is it the caller? Or the callee? This for even the most basic things like strings.
Vaadin 14+ can be used two ways: writing as much code as possible in JavaScript, and writing as much code as possible in Java. I’ll focus on the Java way.
To use custom icons with Vaadin 14+, please see How to use Material icons in Vaadin Flow (14.6). To embed SVGs as icons into your app, see Images and Icons.
Grid background may be tricky, and the approach differs for Lumo and for the Material theme.
The best way to achieve that is to use the Vaadin Anchor
component, setting href
to
appropriate StreamResource
. That way, the browser will correctly open the download dialog by default,
working as expected. Tags: FileDownloader
.
Random thoughts on having the Ubuntu Server 21.10 running on top of Raspberry PI 3, and 23.04 running on Raspberry PI Zero 2 W.
A list of frequently asked questions regarding the Gradle plugin.
This could be tricky: not only you need a Maven repository proxy/cache which will allow Maven to access and download Vaadin jars (and transitive dependency jars), you also need a (p)npm proxy/cache which will allow (p)npm to access and download JavaScript client-side stuff used by Vaadin.
For example you may want to log the Vaadin version to the server log at start time, or you want to see whether the vaadin version v-bump has been taken into effect in your project.
To create a zip with the project jar, all transitive dependencies and a bunch of scripts,
just paste this into your build.gradle
:
No.
EDIT: There’s a project in Github listing all API replacements now: the karibu-migration. I’m keeping this blogpost for historic reasons only.
Awesome blogpost by Chris Kiehl: Software development topics I’ve changed my mind on after 6 years in the industry. Excellent thoughts, and I agree with almost everything. A couple of thoughts from me below.
A quote from Steve Jobs first.
A bit of a clickbait title there; sure, there has been countless articles in this regard (die/won’t die/blah). I’m not interested in when or how; here I’ll talk about the why. In my Java Is Not Dead, Java Is Obsolete article I touched the subject from an evolutionary point of view (think of Java as a meme - it is alive only when there are Java practitioners around. Since the stream of new practitioners shrinks every year because there are more lively memes, the “Java” meme will shrink and die as the pool of its hosts will shrink). Here, I’ll touch other topics.
Building on How to Enable HTTP and HTTPS in Spring Boot which is a bit outdated nowadays.
Vaadin 8 used to have the ComboBox.setNullSelectionAllowed(true)
function which enabled
the user to select an empty item in the ComboBox. Vaadin 14 does not seem to
have the same function, so what to do next?
Covering large area with a reliable WiFi signal may be tricky. The idea is to simply add more access points to different parts of your house, essentially creating a network which together covers the entire house. All of the APs (acronym for Access Point) share the same SSID; the client (your laptop or mobile phone) then knows that it can connect to any of those APs to obtain the access to the internet. As you move the device within your house, the device will eventually lose connection to the original AP and needs to reconnect to a different AP. The promise here is that the device is free to reconnect (this is called “Roaming”) to any other AP without having to obtain a new IP or reconfigure its networking much - this way the device can keep the TCP/IP connections open and continue communication. In order to keep this promise, all APs must be connected to the same LAN network, sharing the same netmask and gateway.
Simply create the following Servlet Filter which will start the transaction and will commit/rollback after the request has been handled:
Grid is the most complex component in Vaadin, and it’s not easy to figure out what to do when it starts behaving slow. However, here are couple of tips to try. Try these tips out regardless of whether you’re using Vaadin 8 or Vaadin 14.
TODO this is old tutorial and will be replaced in the future.
A quick tip on how to add a (Vaadin) session init listener: first,
create a VaadinServiceInitListener
as documented at VaadinServiceInitListener tutorial.
There are two main entrypoints of error handling in Vaadin:
Vaadin 14 kinda supports IE11, but there are limitations. The performance hit is substantial, for example vaadin-grid may perform 5x-10x slower in IE11 than in Chrome or Firefox, on the same machine. This performance hit will not be fixed (it can not be fixed) - if you need a performant site for IE11 then Vaadin 8 is the best choice.
In today’s highly unscientific test, I’m going to compare two projects:
After months of development and testing, the Vaadin Gradle Plugin is now official, hooray! :-D
If you need to preserve the state of certain route during the duration of user’s session (e.g. to preserve a half-filled form so that the user can return to the form and fill it afterwards, or to create a multi-route wizard with a back+forward navigation), you may use the following code to cache the route components in your session.
After Linux is installed on your SSD, don’t forget to enable the Discard operation, to let your SSD know which blocks are free to be reclaimed.
So apparently the tablet needs to support something called Widevine in order to play Netflix/Amazon Prime Video in Full HD. At first I thought it’s not such a big issue to watch movies in 720p, but there’s a big but:
According to Bintray blogpost, Bintray and JCenter are dead effective May 2021. That’s too bad - I’ve been using Bintray to avoid Maven Central ridiculously complex deployment process. Looks like that can not be avoided anymore.
The only way humans really learn is by their own mistakes. Make a programming mistake, live with it, maintain it, fix it, then move on. That is the only way to grow as a developer. That implies that if you’re not also the maintainer of your own code, you can not grow as a developer: there is no other way to learn from one’s mistakes than by becoming a maintainer of your own code.
Complexity appeals to stupid people, and it’s pointless to argue with stupid people.
If you ever used a component-oriented framework such as Java’s Swing or Vaadin, then you’re familiar with components such as buttons and checkboxes. It goes like this:
Have you ever found yourself using certain library or approach, but instead of feeling empowered by it, you constantly have to fight back, go against the flow and bend the rules in order to achieve things? Congratulations, you’ve found your personal anti-pattern.
The Model-View-Controller, Model-View-Presenter and related patterns are very popular with page-oriented frameworks such as Ruby on Rails, Groovy on Grails and Python Django. There is typically a lot of things going on in the page, and the MVC pattern helps keeping the code separated into smaller, more easily digestable packages.
I hate complexity. I can’t stand it, I can’t handle it, and most importantly: I don’t want to handle it. I hate frameworks that expose me to great complexity just in order to achieve something simple, ultimately producing stacktraces 200 lines deep into some dynamic proxy crap I’m not possible to understand in a day. And why should I? If the library is not simple, then clearly the authors have not done their homework, haven’t found the right approach or abstraction, or they don’t care about simplicity, and thus it’s not worth my limited Earth time.
I need to setup new machine from time to time, and I always forget all the things that need to be set up. So, here it goes.
Having e.g. Alt+Z
bound to certain functionality in your webapp helps users
to control the app quickly. However, certain browsers may reserve certain
key combinations (e.g. Ctrl+W
to close a tab) and will not pass those combinations
to your app.
In short, Vaadin 14 does NOT support session replication and must be run with Sticky Sessions. I’ll let Leif summarize the situation:
TCP/IP was established as a means to have a bi-directional pipe where random packet reordering can not happen and where the information is reliably delivered to the other party. It succeeded with the “reordering” part, and failed miserably with the “reliably” part. Read on.
In the past I have written an article regarding Launching your Vaadin apps in Docker and Running WAR apps in Docker with Jib. However, what if you don’t have Java installed at all on the machine (e.g. it’s a CI server) and therefore can’t run Gradle build? Or what if you don’t want to have an unfamiliar Gradle script running on your machine (e.g. could be a virus)? The solution is to perform the build itself in Docker as well, by using Docker multi-stage builds.
Long time ago (in 2012) the browsers deprecated Synchronous XMLHttpRequest (XHR) support: Getting rid of Synchronous XHR. Most recently, Chrome 80 dropped Synchronous XHR in Page Dismissal handler altogether. Do/did these changes affect Vaadin?
In case the push is not used, the XhrConnection class is used to send requests.
It doesn’t matter whether it’s a Poll request
or a “regular” request stemming from e.g. pushing a button - in this case they are equal.
The code at XhrConnection:193
suggests there is really no timeout set, and so
Vaadin client will happily sit there for 10 hours, awaiting a response to the message it had sent:
Vaadin Push is a tricky complicated beast, based on a complicated push stack. A lot of things can go wrong, causing the Vaadin client to freeze endlessly. Let’s discuss how exactly push works, and what can be done to prevent the freeze.
Vaadin’s synchronization protocol is based on UIDL (UI Diffing Language?). Basically it’s a JSON file, listing what have been changed since the last UIDL update. For example, if you set a new caption to a TextField with connector ID 42, you will be able to observe this information in the UIDL sent from the server to the client.
Say you have a script such as
I’ve read an amazing article Who Needs Lombok Anyhow, which discusses Lombok and its quirks. I personally feel no need for Lombok since Kotlin contains all the features offered by Lombok, but there was something else that caught my eye.
You need to be careful when picking an USB enclosure for your SATA SSD drive: the problem is that not every USB enclosure supports the SATA TRIM / USB UNMAP command, which is a must for keeping your SSD healthy.
Sometimes Vaadin 14 fails mysteriously, which is very unfortunate: it now uses LOTS of JavaScript code, frameworks and tools. Those things are unfamiliar to server-side guys, and it’s really hard to tell what to do, should one of JavaScript toolchain fail.
Sometimes Vaadin 14 fails mysteriously, which is very unfortunate: it now uses LOTS of JavaScript code, frameworks and tools. Those things are unfamiliar to server-side guys, and it’s really hard to tell what to do, should one of JavaScript toolchain fail.
Neither the Vaadin Gradle Plugin nor the Vaadin Maven Plugin really document what they’re doing under the hood. When something goes wrong, it’s very hard for a server-side guy like myself to know what’s going on, especially since the entire JavaScript client-side landscape is pretty much a mystery to a Java guy. Hence this blog post.
The Vaadin documentation is a good source of initial info for Vaadin, but unfortunately in certain cases it simply doesn’t go deep enough. This is especially true with respect of the toolchain Vaadin uses, and the files it relies on. Therefore, this blog post.
This post is not about how Spring/Dependency Injection hurts ability to navigate and code readability nor it’s about There’s no place for Spring in post-annotation world. This post is a rant.
A summary of reasons why I tend to avoid MySQL (or MariaDB for that matter) and use PostgreSQL instead:
In this setup we’ll have a Kubernetes Cluster with a Load-balancer, running your app from a docker image, connected to a Google Cloud SQL running MySQL.
Imagine typing something into your application’s TextField
, and suddenly bam:
the TextField loses the focus or something else gets focused instead, for no apparent reason.
This article will summarize a list of items to review, to find out which pesky
component or code steals your focus.
When trying to fix some browser-side issue in your GWT components, it is often useful to modify those component sources while your app is running, then refresh your browser with F5 and immediately see the changes done in Vaadin Button. This blogpost describes how to configure Intellij to do just that.
If you ever tried to parse XML on Android the encouraged way,
trying to parse a simple XML <foo>Hello World!</foo>
will yield the following shitty code:
The absence of any sane way to parse XML in Android (the official Google-endorsed way of parsing XMLs is ridiculous, low-level, hard to use and error-prone, as are all other aspects of programming with Android) pushed me to write yet-another-XML-parsing-library called konsume-xml, and that made me realize just how horrible and evil annotations are.
In the past I have written an article regarding Launching your Vaadin apps in Docker. That required you to write the Dockerfile. However there is even simpler way: Jib.
The problem with this machine is that it only outputs 1920p to a 4K monitor with Ubuntu, which is pretty annoying. According to the Dell Inspiron 13-5379 spec the connector is HDMI 1.4a, which should support 4K. However, only HDMI 2.0 supports 4K with 60FPS, HDMI 1.4a only supports 4K with 25 or 30 FPS. My Inspiron employs Intel i7-8550U which should support 4K at 60FPS.
Previous article mentioned four of the most important yet most basic resources to monitor for the health of your JVM, but also of your system:
If your server-side JVM app chokes up when serving 20 concurrent users, then there is something very wrong. Luckily, it’s usually very easy to find out the initial hint as to where the problem may lie.
When you need to use Push with your Vaadin app, you generally have two choices: Long Polling and Web Sockets. Which one to use?
This happens to me every now and then. I’m developing a Vaadin app, then I switch to another one and suddenly the Vaadin session expires immediately, or Vaadin complains that the cookies are disabled. What does this bug mean and how can we work around that?
Karaf is an OSGi container rather than a WAR container. Hence it is not as easy to deploy your WAR into Karaf as opposed to, say, Tomcat. You basically have three options:
deploy/
folder. Ta-daa!
This is the easiest way of deploying WAR to Karaf, the one that doesn’t
require you to add OSGi manifests to your WAR and/or tackle the XML bundle
configurations. Let’s go.The Vaadin-on-Kotlin framework contained the support for feeding the outcome of a SQL query to the Vaadin Grid for the long time. However, since VoK is based on Kotlin, Java developers probably avoided this solution and looked for a Java-based example. Well, here it is:
While I don’t recommend using Spring because of simplicity reasons, there are valid reasons to have Spring support. For example when building UI for an already existing Spring-based backend, or when gradually converting a legacy application to VoK.
I’d like to write something positive, but I can’t - my experiences with CouchBase had been highly negative. I’d even dare to say it’s an unfinished piece of junk; if you need to setup a syncing platform from your Android app, avoid CouchBase like a plague.
Creating Vaadin UIs from Java code has the following disadvantages:
Proper building construction is to have a proper design which includes all latest state-of-the-art components and follow all safety precautions. The building won’t collapse and it will be great. If you however use this approach with software, you will fail.
The client-side in Vaadin 10 is completely different than the one in Vaadin 8 and the layouting manager from Vaadin 8 is completely gone. Vaadin 10 layouting is therefore something completely different to Vaadin 8 layouting. Naturally, it is something completely different to Android layouting. Here we will focus on layouting completely configured from server-side, and not from a CSS file.
There are lots of Android SDK sucks and android development is a pain rants indicating that development on Android is a horrible experience. Instead of repeating the same thing over and over again, I’ll try to sum up why I will definitely prefer Vaadin-based PWA for my next project over Android SDK:
In the previous blog post we’ve used self-signed certificate with Docker Tomcat. However, in order to have a properly protected web site, we need to use a proper set of certificates. We’ll use the Let’s Encrypt authority to obtain the keys at no cost.
It is possible to use pem
-style certificates with Tomcat Docker image, without any need to store them first into the Java keystore. This is excellent since not only it is easier to generate self-signed certificate with the openssl
command, this can also be used with certificates produced by Let’s Encrypt.
I have to admit upfront that my brain is somehow incompatible with JPA. Every time
I try to use JPA, I will somehow wind up fighting weird issues, be it
LazyInitializationException
with Hibernate, or weird sequence generator preallocation
issues with EclipseLink. I don’t know what to use merge()
for; I lack the means
to reattach a bean and overwrite its values from the database.
I’m sure that Thomas Kriebernegg, the CEO of App Radar will be happy to persuade you that you can make a living by selling Android Apps. He needs to - his way of making a living is to sell services to Android devs so he better make sure there are lots of Android devs; discouraging devs from becoming Android devs would be a financial suicide. But why not trying out your luck? After all, Flappy Birds was making $50,000 a day in ads; Clash of Clans makes millions of dollars. Let me tell you a fucking secret: you are not going to be the author of Flappy Birds and Clash of Clans, and let me tell you why.
Teamcity is quite a nice continuous integration server from Jetbrains. The set up is not that easy though since you typically need to install the TeamCity server itself, and at least one agent which will perform the building itself.
When Kotlin 1.1 brought in Coroutines, at first I wasn’t impressed. I thought coroutines to be just a bit more lightweight threads: a lighter version of the OS threads we already have, perhaps easier on memory and a bit lighter on the CPU. Of course, this alone can actually make a ground-breaking difference: for example, Docker is just a light version of a VM, but it’s quite a difference. It’s just that I failed to see the consequences of this ground-breaking difference; also, performance-wise in Vaadin apps, it seems that there is little need to switch away from threads (read Are Threads Obsolete With Vaadin Apps? for more info).
Let me start by saying that threading model (or, rather, single thread model) provides the most simplistic programming paradigm - the imperative synchronous sequential programming. It is easy to see what the code is doing, it is easy to debug, and it is easy to reason about (unless you throw in dynamic proxies, injected interfaces with runtime implementation lookup strategy and other “goodies” of the DI) - that’s why having such paradigm is generally desirable. Of course that holds only when you have one thread. Adding threads with no defined communication restrictions overthrows this simplicity and creates the most complex programming paradigm.
Nicolas Frankel put some of my feelings into an excellent article Is Object-Oriented Programming compatible with an enteprise context?. During the development of Aedict Online (still as a Java-based JavaEE/JPA app back then, now it’s Vaadin-on-Kotlin-based), when trying to find rows from JPA+DB I often tried to find the necessary functionality on the JPA entity itself. Wouldn’t it be great if, upon user’s log in, we could find the user and verify his password using the following code?
It is indeed possible to write Vaadin 10 Flow apps in Kotlin. Here are a couple of resources to get you started:
Traditionally, the testing of a web portal is done from the browser, by a tool which typically using Selenium under the hood. This type of testing is closest to the user experience - it tests the web page itself. Unfortunately, it has several major drawbacks:
In his blog about comparing Kotlin and Java features, Simon was IMHO too kind. Creating a prototype of some app in Kotlin, then converting the code painfully to Java (simply because Java is company’s lingua franca) and watching it inflate and obfuscate itself is quite an eye-opening experience.
So you have built your first awesome VoK app - congratulations! You will probably want to launch it outside of your IDE, or even deploy it somewhere on the interwebz. Just pick up any virtual server provider with your favourite Linux distribution.
Obsolete as in Cobol - used widely, but on a descendant trajectory. Let’s ask a very simple question:
Or what-if-a-fucking-meteor-falls-down-and-swaps-1s-and-0s
Once a project leaves the rapid development phase and enters the calm waters of maintanenance mode, the programming paradigm changes. Fancy hyped frameworks favored by project creators no longer play important role. What matters most now is the code readability and understandability. The code is already written - now it is going to be read, understood and fixed. After all, that’s usually what happens to the code - it is written once but read by many. This is true both for open-source, but also for closed-source: people in the team come and go, and new team members need to read the code, to familiarize themselves with it.
You have your superdevmode development environment up and running. All is peachy and world is unicorns until you figure out that some pesky bug is only reproducible on a cell phone. Bam. What now?
When trying to fix some browser-side issue in Vaadin built-in components,
it is often useful to modify those component sources while your app is running.
This way, you can modify e.g. VButton.java
, refresh your browser with F5
and immediately see the changes done in Vaadin Button. This blogpost describes
how to configure Intellij to do just that.
When doing mobile development with Vaadin, you often develop the app on your dev machine and view the page on a tablet or a phone. Yet, entering your dev machine IP into the phone browser may be tedious and error-prone. There is a way though, to enter an URL to your phone. Via a camera, as a QR Code.
Let’s discuss the most useful cases for the extension methods. First use-case: extension methods allow to apply themselves only selectively. For example, the following method only applies to a list of Person:
Now if there was some way to get rid of that pesky em ->
which needs to
be written every time one calls the db {}
function. If only there was a
way we could tell a block to “know” some variables implicitly… Maybe we
could throw those “variables” into a class and tell the block to run as some
kind of an extension method in that class? That could work - extension methods
have direct access to the receiver object methods and variables. Remember
our findAll()
method?
I’ll get to the forms right away. But first, I want to talk extension methods.
They are immensely helpful in adding functionality to objects. Note that Kotlin
is not a dynamic language - the methods will not really be added to target
classes, it is just a syntactic sugar. Quite delicious, though. So, EntityManager
misses the findAll
method - let’s fix that. Open the DB.kt
file and
add this to the end:
Let’s add some database to our hello-world. I’ll use the pure-Java embedded
database called H2 which will run as a part
of our application, so there is no need for you to install any database
engine. Open the pom.xml
file and add the following lines at the end of
the dependencies
element:
Kotlin provides some very interesting language features which are immensely helpful when writing Vaadin apps. Let us start from scratch, building necessary functionality as we progress. The result of this exercise will be a Kotlin-based simple web app, built with Gradle, using Hibernate+JPA o store entities into the database. I will not use Spring nor JavaEE here - the whole thing will run in a pure Servlet environment like Tomcat or Jetty. The complete exercise may take some 60 minutes. I will be using Intellij IDEA Community which you can download for free here: Download IDEA. When installing, just press the “Skip remaining” button to install Intellij with the default settings.
When one tries to migrate her project to a newer version of a framework, it usually helps if the transition is smooth and the original code works without any modifications. This way, you can convert the code to the new API gradually, and never encounter this OMG-shit-doesn’t-compile-everybody-blocked period for a long time.
If you ever used Selenium (or TestBench, which is based on Selenium), you know the pain of configuring the testing browser driver: