Skip to main content

17 posts tagged with "github"

View All Tags

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

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