Skip to main content

10 posts tagged with "copilot"

View All Tags

· 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!

· 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!

· One min read

In the course of developing using NextJS, the integration of internationalization became a pivotal requirement on my checklist. The aim was to enable seamless translation of the application into multiple languages, leveraging the native i18n features provided by NextJS, as outlined in the official documentation.

To facilitate this, I organized a set of JSON files, each containing translations for the application in a specific language. For simplicity, I adopted a one-file-per-language approach, ensuring uniformity by maintaining identical keys across all files. The translation process involves replacing the values associated with each key.

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!

PS: In this video I am translating the full file, but you can also translate a single key, or a set of keys, as you type them in the IDE, GitHub Copilot completion will propose you the translation.

· 2 min read

In the process of crafting an updated version of the product catalog for WindR.org, the need to generate sample data arises. Leveraging the power of Quarkus and Panache, I find myself tasked with creating entities that embody various technical specifications for "windsurfing boards" – encompassing attributes like size, volume, width, and more.

Recognizing the potential tedium associated with manually creating this data, I turned to GitHub Copilot for assistance. The approach I took involved visiting a public website housing a comprehensive list of windsurfing boards. Here, I extracted the specifications of a specific board and seamlessly fed them into the GitHub Copilot Chat window. I then prompted Copilot to not only generate sample Java entities but also produce the corresponding SQL script for creating database rows.

The efficiency and effectiveness of GitHub Copilot in this scenario are showcased in the accompanying video. Witness firsthand how this tool streamlines the often laborious task of data generation, saving valuable time and effort in the development process:

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 the process of constructing a product catalog within NextJS, I found myself in need of seamlessly interfacing with my backend using REST APIs, each adorned with a variety of URIs and parameters.

The typical structure of these URLs, such as /api/v1/products?category=shoes&color=red&size=10, prompted me to harness the power of GitHub Copilot to expedite the creation of functions with the appropriate parameters. Copilot not only assists in generating the function but also crafts the necessary fetch code for calling the API with precision.

Watch this video to witness the rapid development in action:

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

· 10 min read

GitHub Copilot: How I use it, and Why I love it

Since its launch, GitHub Copilot has been a hot topic in the developer community. Some people love it, some people hate it, and some people are just curious about it. I am part of the first group, and I have been using it for more than a year now. I will not go into the details of how Copilot works, but I will share with you my experience with it, and how it has changed my life as a developer.

Copilot will help developers differently depending on the way they work and the phase of the project they are in. I will try to cover as many use cases as possible, but I will not be able to cover all of them. Here are the main uses cases I have for Copilot

  • Write code faster
  • Create new features much faster
  • Learn new things in context