Skip to content

Instantly share code, notes, and snippets.

View hugomarques's full-sized avatar
🎯
Focusing

Hugo Marques hugomarques

🎯
Focusing
View GitHub Profile
package com.hugodesmarques.threads;
import java.util.concurrent.*;
public class ThreadPoolsOOMExample {
private static final int THREAD_POOL_SIZE = 10;
private static final int TOTAL_TASKS = 1_000_000;
private final ExecutorService mainExecutor = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
@hugomarques
hugomarques / Tests.java
Created December 9, 2022 23:52
Testing with SpringBootTest
package io.github.CarolinaCedro.POC01.application.service.impl;
import io.github.CarolinaCedro.POC01.config.modelMapper.ModelMapperConfig;
import io.github.CarolinaCedro.POC01.domain.entities.Address;
import io.github.CarolinaCedro.POC01.infra.repository.AddressRepository;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
@hugomarques
hugomarques / regexCheatsheet.js
Created January 27, 2019 01:38 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
package com.hugodesmarques.assertJ;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Samples how to use AssertJ to test a Map.
@hugomarques
hugomarques / CreatureJava8.java
Last active May 30, 2016 19:11
Java8-Jackson Problem
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.IOException;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
package com.hugodesmarques;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);