Categories
Java

Puppeteer Java and Playwright: how to scroll slowly to bottom of page

In this quick tutorial, we will see how to scroll slowly to the bottom of a web page, using Puppeteer Java and Playwright. Playwright is a new browser automation framework developed by Microsoft. It is based on JavaScript Puppeteer. Look here for a quick tutorial on how to use Playwright in Java. 1) Compute the […]

Categories
Java

Browser automation with Java equivalent of Puppeteer: Playwright

In this short tutorial, we will see how to do browser automation with a Java equivalent of JavaScript Puppeteer: a new framework developed by Microsoft called Playwright. 1) Import the dependency in your pom.xml In your pom.xml file, add: <dependency> <groupId>com.microsoft.playwright</groupId> <artifactId>playwright</artifactId> <version>1.15.2</version> </dependency> 2) Open Firefox and navigate to Wikipedia.com To open a Firefox […]

Categories
Linux

Sign a PDF on Linux in 2 minutes

In this tutorial, we will see how to sign a PDF on Linux in 2 minutes. To do this, we will use Xournal. 1) Install Xournal Open a terminal and run: sudo apt update sudo apt install xournal 2) Start Xournal Still in a terminal, run: xournal 3) Open the PDF you want to sign […]

Categories
AWS Bash

Deploy a docker image from AWS ECR registry to Elastic Beanstalk in 2 minutes

In this tutorial, we will see how to deploy a docker image that is stored in AWS ECR registry to AWS Elastic Beanstalk. We will use automated scripts using the AWS CLI. 0) Prerequisites You need AWS CLI installed on your machine. Follow this tutorial to do it in 30 seconds. Also you need a […]

Categories
AWS Bash

Install the latest AWS CLI v2 on Ubuntu, in 2 minutes

To install the latest version of AWS CLI v2 on your Ubuntu machine, open a terminal and run: cd ~/Downloads curl “https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip” -o “awscliv2.zip” unzip awscliv2.zip sudo ./aws/install To check that everything went well, run: $ aws –version aws-cli/2.2.42 Python/3.8.8 Linux/5.4.0-87-generic exe/x86_64.ubuntu.18 prompt/off We can see that the aws-cli version 2.2.42 is now installed ! […]

Categories
Docker Java

Run Java TestContainers using an image from a private AWS ECR registry

In this short tutorial, we will see how to easily run a private docker image using Java TestContainers. We will use a private AWS ECR registry, but the code will work the same with any other private registry. 1) Needed parameters First, you need to gather the following parameters: String registry = “601730646169.dkr.ecr.us-west-2.amazonaws.com”; String image […]

Categories
Java SQL

Pretty print database SQL schema in Java using JDBC

How to pretty print a database SQL schema (table names, columns names and types), in Java using JDBC. Starting from a JDBC connection object to your database called conn: java.sql.Connection conn; simply do: The console output is the following: client ——————————————————————– id : uuid name : varchar product ——————————————————————– id : uuid name : varchar […]

Categories
Java

How to map and filter a list with Java lambda expressions

In this short tutorial, we will see how to map and filter a list with Java lambdas. 1) Map a list Let’s start from a list of integers: List<Integer> list = List.of(1, 3, 6, 2, 4, 5); To map the list, we need to convert it into a stream, then map it and finally collect […]

Categories
Java SQL

Create a PostgreSQL index on a column and test performance with Java JDBC

In this tutorial we will see how to create an index on a SQL table column with JDBC, then we will fill a table with 10⁷ rows (using PostgreSQL fast COPY function), and finally we will compare the select performance with vs without the index. 1) The SQL tables and the index We will create […]

Categories
Java SQL

Real life useful example of an Inner Join with Java JDBC and PostgreSQL

In this tutorial we will run a full demo of a real life useful Inner Join, with Java JDBC and PostgreSQL. Let’s consider a recurring business that has Customers, Products to sell to customers and Subscriptions that give the list of products each customer has subscribed to. What we want to do is store all […]