Skip to content

Instantly share code, notes, and snippets.

View dariahervieux's full-sized avatar

Daria dariahervieux

View GitHub Profile
@dariahervieux
dariahervieux / SpringBootTestExemple.java
Created January 26, 2024 15:26
Spring Boot - SpringBootTest configuration - mock a bean before application context is ready
@SpringBootTest
// Import of the inner @TestConfiguration is important here
// see Note in https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.testing.spring-boot-applications.excluding-configuration
@Import(ExempleITest.MockConfig.class })
@ActiveProfiles("itest")
class ExempleITest {
// ...
@TestConfiguration
@dariahervieux
dariahervieux / hyperv-cheat-sheet.md
Last active November 5, 2023 10:20
Hyper-V cheat-sheet

Hyper-V Cheat-sheet

Working with virtual disks

Expand the virtual disk

You can expand Virtual Disk via Hyper-V UI.

After the expantion, the guest OS might not take the expantion into account.

Fix disk size on Ubuntu

@dariahervieux
dariahervieux / java-jacoco-mapstruct-and-lombok.md
Last active May 31, 2024 03:59
Java : Jacoco + Mapstruct/Lombok

Code coverage and generated code

Jacoco

When analysing code coverage jacoco analyses compiles classes. If you have generated code, jacoco will take it for analysis, unless your classes are annotated with an annotation havin 'Generated' in its name.

The filter used by jacoco to filter out all classes annotated with ..Generated is AnnotationGeneratedFilter

@dariahervieux
dariahervieux / gitlab-runner-cheat-sheet.md
Created October 18, 2021 15:22
GitLab runners cheat/tip sheet

Docker executor

The Docker executor when used with GitLab CI, connects to Docker Engine and runs each build in a separate and isolated container. The image for the job is :

  • either the predefined image set up in the runner configuration (config.toml)
  • or the image set up in .gitlab-ci.yml

Using docker commands in jobs

Using docker on CICD jobs in GitLab means using Docker-in-Docker (dind):

@dariahervieux
dariahervieux / docker-cheat-sheet.md
Last active November 19, 2023 22:04
Docker cheat/tip sheet

Running container

Images

Get images information

Get image size: >docker images --format "table {{.ID}}\t{{.Tag}}\t{{.Size}}"

Inspect

@dariahervieux
dariahervieux / linux-cmd-cheat-sheet.md
Last active November 5, 2023 10:26
Cheat-cheet: Linux useful commands

Linux Cheat-sheet

OS Details

Get distribution details:

$ cat /etc/*-release

Disk usage

@dariahervieux
dariahervieux / gradle-cheat-sheet.md
Last active March 3, 2021 13:16
Gradle cheat-sheet

Generate a new project

You can use Build Init Plugin to generate a new Gradle build.

Generate a multi-module project

The java-application generates a new multi-module project with one submodule app. The henerated project has the following layout:

.
@dariahervieux
dariahervieux / git-cheat-sheet.md
Last active March 21, 2023 10:55
Git cheat-cheet

Lines endings

Windows - CRLF - carriage retur + linefeed - \r\n Linux - LF - linefeed - \n MAC - CR - carriage return - \r

Global configuration on working machine

core.autocrlf configuration setting:

  • true - this converts LF endings into CRLF when you check out code, converts CRLF line endings into LF when you add a file to the index; usually used on windows machines
  • input - this converts CRLF to LF on commit only; used on Linux machines; if a file with CRLF endings accidentally gets introduced, it gets fixed on commit
@dariahervieux
dariahervieux / SslConfiguration.java
Created December 22, 2020 09:05
Java - Spring - SSL configuration: proxy, custom trust store
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
@dariahervieux
dariahervieux / UserTest.java
Created December 2, 2020 13:43
Testing temporal values with AssertJ (within)
import static org.assertj.core.api.Assertions.within;
//...
public class UserTest {
private UserService userService = new UserService();
@Test
public void given_valid_inputs_creation_is_ok() throws Exception {
User userToCreate = new User("name");
User user = userService.create(userToCreate);