Skip to main content

· One min read

When developing my WindR application, I frequently encounter the task of adding new entries to the product catalog, a process that hasn't yet been automated. Consequently, I find myself creating JSON documents for the MongoDB database.

Products such as boards, sails, fins, and foils possess diverse specifications that vary depending on their type. Extracting these values from official product websites can be laborious, particularly when field names differ across brands, as illustrated by the example of two sails from different manufacturers:

Patrik

Duotone

In the accompanying video, I demonstrate how I leverage Copilot Chat to extract data from copied website content. By providing a simple prompt outlining the array-to-JSON attribute mapping, I swiftly convert the data:

This approach streamlines the addition of new products to my catalog. Looking ahead, I aim to automate this process using a combination of a small script and GenAI programming. However, that's a tale for another time.

· One min read

In this brief demonstration, I showcase how GitHub Copilot help me to format data sourced from a web page and pasted into my IDE. By simply copying information from a webpage and pasting it into my coding environment, I initiate the process.

Then, with a straightforward inquiry directed to Copilot Inline Chat, I effortlessly extract specific details —such as GitHub Handles— from the text and neatly organize them into a CSV format:

Although this isn't a task I tackle daily, especially with GitHub Handles, I wanted to illustrate another practical application of Copilot that can significantly assist in your coding endeavors.

· One min read

During one of my test I had to create some CSV files, and needed some data. I could have used Copilot directly to generate random data, but I wanted to test something else.

In my SpringBoot PetClinic application, I have a SQL file that contains some data, and I wanted to use this data to create a CSV file, directly from the insert statements without any code.

The Copilot then effortlessly executed the specified tasks, as demonstrated in the accompanying video:

Note, I could have also use Copilot to do it directly from the database, but just wanted to see if Copilot could extract the data from the SQL file, and it did it!..

· One min read

As I transition WindR.org to Next.js, the necessity arises to clean up the product catalog's images, which come in various sizes and formats; hence, I opted to write a small Python script using Pillow for resizing and standardizing the images. Despite not being a Python developer, I'm equipped with basic knowledge, making it easy to read and utilize the language's numerous libraries.

Using Visual Studio Code, I initiated a new script to fulfill the image cleanup requirements, specifying the objective:

  • download an image from a given URL, save it locally as 'original.png,' resize it into a square with a transparent background, and save copies at 1000x1000 pixels and 256x256 pixels in greyscale.

The Copilot then effortlessly executed the specified tasks, as demonstrated in the accompanying video:

Watch the video here

While this script serves as a fundamental prototype, the next step involves incorporating this logic into a complete application. GitHub Copilot's assistance not only jumpstarted the development process but also facilitated the creation of a functional prototype within minutes.

· 2 min read

In my Quarkus application, I encountered a hiccup with the Panache ORM while implementing and testing a REST service. Specifically, I faced a test failure related to the automatic update of a specifications list after deleting an element from the JSON/Entity. In this blog post, I'll walk you through the issue and demonstrate how GitHub Copilot came to the rescue, streamlining the implementation of a solution.

The Challenge:

The JSON schema for my REST service looked like this:

{
"id": 1,
"name": "Fanatic Falcon",
"description": "Slalom board",
"specifications" : [
{"id": 10, "name": "Falcom 100", "volume": 100},
{"id": 11, "name": "Falcom 110", "volume": 110},
{"id": 12, "name": "Falcom 120", "volume": 120}
]
```
}

I had a test verifying the number of specifications after the deletion of one of them. However, the Panache ORM didn't automatically update the specifications list after deletion, leading to a failing test.

The Solution:

To address this issue, I needed to implement business logic to delete specifications in the database that were not present in the JSON payload. I documented the logic in a comment and collaborated with GitHub Copilot to generate the code.

Here's a snippet of the code:

...

// if the number of specifications in the existing board is different than the number of specifications in the updated board
// it means that some specifications have been removed, so we need to delete them
// for this we meed to loop on existing specifications and see if they are in the updated board
// if they are not add them to a list of specs to delete
// then use removeAll on existing board specifications
List<BoardSpecification> specsToDelete = new ArrayList<>();
for (BoardSpecification existingSpec : existingBoard.specifications) {
boolean found = false;
for (BoardSpecification spec : board.specifications) {
if (existingSpec.id.equals(spec.id)) {
found = true;
}
}
if (!found) {
specsToDelete.add(existingSpec);
}
}
existingBoard.specifications.removeAll(specsToDelete);
existingBoard.persist();

...

Check out the video below to witness how I leveraged GitHub Copilot to easily implement the business logic.

Once again, GitHub Copilot has proven to be an invaluable coding companion, significantly enhancing my efficiency and helping me overcome challenges in my coding journey. With its assistance, I navigated through the intricacies of the Panache ORM and successfully resolved the test failure, ensuring the seamless functionality of my Quarkus application.

· One min read

Today, I tackled the creation of a new NextJS form for my application, opting for a sleek horizontal arrangement of components. Striving for a 100% width within the parent container proved trickier than expected. Copilot came to the rescue, aiding with the necessary math to resize the components accurately.

Catch a glimpse of the journey in this brief video:

Yet again, GitHub Copilot proves to be the hero of my coding journey – making my day, one efficient line of code at a time!

· One min read

In my Next.js project, I encountered a challenge while working on a form that involved managing a list of values. Being a beginner, I found myself unsure about the logic required to extract the selected value from the list and update the state of the component.

Fortunately, as I delved into coding, GitHub Copilot came to my aid with a suggested code snippet:

if (field === "brand.id") {
let brand = brands.find(brand => brand.id === value);
setBoard({
...board,
brand: brand
});
return;
}

Experience the efficiency and precision of Copilot in action by watching the video demonstration below:

Yet again, GitHub Copilot proves to be the hero of my coding journey – making my day, one efficient line of code at a time!

· 7 min read

Quarkus: Simplifying Cloud File Uploads

In many projects, facilitating user uploads to cloud services is a common requirement. In my current project, I find myself inviting users to seamlessly upload various files, such as profile pictures, GPS track files, or session photos, to the WindR.org site. To enhance my understanding, I've opted to employ multiple cloud providers —Microsoft Azure Blob Storage, Amazon S3, Google Cloud Storage— allowing me to test and compare their functionalities.

This article guides you through the process of:

  1. Creating a REST service for file uploads using RESTEasy Reactive in Quarkus.
  2. Uploading files to the cloud from a Quarkus application.

To complement this discussion, a complete code example is available on GitHub. This resource serves as a practical reference for learning and experimentation.

GitHub Repository: Quarkus: Uploading Image to the Cloud

· 2 min read

Java: Using MessageFormat to Generate JSON

As developers, we often encounter situations where we need to generate a JSON string for debugging purposes, especially when dealing with REST services. While frameworks like Spring Boot or Quarkus typically handle this task seamlessly, there are instances where manual intervention is required.

In a recent scenario, I found myself faced with this challenge. Traditionally, I had relied on string concatenation for such tasks. However, eager to explore more efficient alternatives, I turned to Java's java.text.MessageFormat to simplify the process.

· One min read

When working with NextJS and Typescript, I often find myself creating classes to represent data structures. In the course of doing so, I often need to create the class from a REST API response that is a JSON object.

To expedite this crucial task, I turned to GitHub Copilot for assistance. Witness the efficiency and precision of Copilot in action by watching the following video:

Yet again, GitHub Copilot proves to be the hero of my coding journey – making my day, one efficient line of code at a time!