Skip to content

Instantly share code, notes, and snippets.

View vernetto's full-sized avatar

Pierluigi Vernetto vernetto

View GitHub Profile
Yes, you can run `git filter-repo` from a Docker container. Here are the steps to do so:
### Step 1: Pull a Docker Image with Git and Python
First, pull a Docker image that has both Git and Python installed. The official Python image should work well.
```sh
docker pull python:3.9-slim
```
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
To convert a org.w3c.dom.Document to an XML string in Java, you can use the Transformer class provided by the javax.xml.transform package. Here’s a step-by-step guide to achieving this:
Import the necessary classes:
Ensure you have the required imports for the transformation.
java
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import org.apache.commons.configuration2.tree.ExpressionEngine;
import org.apache.commons.configuration2.tree.ImmutableNode;
import org.apache.commons.configuration2.tree.NodeHandler;
import org.apache.commons.configuration2.tree.QueryResult;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
CREATE OR REPLACE VIEW kkkdb._overview_links_and_url_parts("Link Id", "Link Key", "Comment", "Dynamic URL") AS
SELECT
link.id AS "Link Id",
link.link_key AS "Link Key",
link.comment AS "Comment",
string_agg(concat('[', url_part.id, '] ', link_2_url_rel."order", ' - ', '[', part_type.id, ' ', part_type.source, ' -> ', part_type.purpose, ']', ' ', url_part.source_name, ' -> ', url_part.target_name, ' = ', url_part.value, ' ', value_converters_agg, '[required = ', link_2_url_rel.required, ']'), chr(10) ORDER BY link_2_url_rel."order") AS "Dynamic URL"
FROM
kkkdb.kkk_t_link link
JOIN kkkdb.kkk_t_link_url_part_relation link_2_url_rel ON link.id = link_2_url_rel.link_id
JOIN kkkdb.kkk_t_url_part url_part ON url_part.id = link_2_url_rel.url_part_id
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@JacksonXmlRootElement(localName = "links")
public class Links {
@JacksonXmlElementWrapper(useWrapping = false)
private List<Link> link;
// getters and setters
}
To: info@tmrsa.ch
Objet : Proposition d’amélioration du service de bus entre Aosta et Martigny
Madame, Monsieur,
Je me permets de vous écrire en tant que [votre profession ou statut, par exemple : résident de la Vallée d'Aoste], pour vous soumettre une proposition concernant le service de bus que vous assurez entre Aosta et Martigny.
Ayant constaté et vécu l'importance de la liaison entre ces deux villes, notamment pour les Valdôtains travaillant en Suisse, je souhaite attirer votre attention sur une opportunité d'amélioration significative de ce service. Il s'agit de l'introduction de trajets supplémentaires adaptés aux besoins spécifiques de ces travailleurs.
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class CSVProcessor {
public static void main(String[] args) {
String filePath = "path/to/your/csvfile.csv"; // Replace with your file path
processCSV(filePath);
}
using spring boot and java 17, what is the simplest way to create a basic web application, with a main page where I enter a search parameter and, with a click of a button, I execute a Java function and return a result web page?
ChatGPT
Creating a basic web application with Spring Boot and Java 17 that includes a main page with a search function is quite straightforward. Here's a simple guide on how to set it up:
1. Set Up Your Project
Use Spring Initializr: Go to Spring Initializr to generate a basic Spring Boot project. Choose Maven/Gradle as your build tool, Java as the language, and specify Java 17 as the version.
Dependencies: Add spring-boot-starter-web for web application development.
Generate and Open: Generate the project and open it in your preferred IDE (like IntelliJ IDEA or Eclipse).
I need Java 17 code to query an Excel file, finding in a "Client_Home" tab a row which contains a given search string in a column identified by a title "Description" at row 2
ChatGPT
To query an Excel file in Java, particularly to find a row in a specific tab ('Client_Home') where a column ('Description') contains a given search string, you can use the Apache POI library. This library provides APIs for Microsoft Office formats, including Excel.
Here is a sample code snippet that demonstrates how you can achieve this in Java 17:
Include Apache POI Dependency: First, include the necessary Apache POI dependencies in your project. If you are using Maven, add the following to your pom.xml:
xml