Skip to content

Instantly share code, notes, and snippets.

View Raouf25's full-sized avatar

ABDERRAOUF MAKHLOUF Raouf25

View GitHub Profile
import java.util.List;
public class TaxCalculator {
// Define a list of tax brackets
private static final List<TaxBracket> taxBrackets = List.of(
new TaxBracket(0, 10225, 0.0),
new TaxBracket(10225, 26070, 0.11),
new TaxBracket(26070, 74545, 0.30),
new TaxBracket(74545, 160336, 0.41),
public class TaxCalculator {
// Method to calculate the tax based on income
public double calculateTax(double income) {
double tax;
if (income <= 10225) {
tax = 0;
} else if (income <= 26070) {
tax = (income - 10225) * 0.11;
} else if (income <= 74545) {
Taxable income fraction Tax rate to be applied to the bracket
Up to €11.294 0%
From €11.295 to €28.797 11%
From €28.798 to €82.341 30%
From €82.342 to €177.106 41%
Over €177.106 45%
@Raouf25
Raouf25 / StringUtils.java
Last active September 26, 2023 11:41 — forked from rponte/StringUtils.java
Removing accents and special characters in Java: StringUtils.java and StringUtilsTest.java
import java.text.Normalizer;
public class StringUtils {
/**
* Remove toda a acentuação da string substituindo por caracteres simples sem acento.
*/
public static String unaccent(String src) {
return Normalizer
.normalize(src, Normalizer.Form.NFD)
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container-postgresdb
echo "Step 1- create a docker bridge network database-network "
docker network create database-network
echo "Step 2- create a docker conatiner: container-postgresdb "
docker run --detach \
--network database-network \
--name container-postgresdb \
--publish 5432:5432 \
--env POSTGRES_USER=postgres \
--env POSTGRES_PASSWORD=admin \
version: '3'
services:
postgres:
container_name: container-postgresdb
image: postgres
hostname: postgres
ports:
- "6543:5432"
environment:
POSTGRES_USER: postgres
@Raouf25
Raouf25 / flatMap-vs-map.java
Last active January 1, 2021 09:50
The flatMap method is similar to the map method with the key difference that the supplier you provide to it should return a Mono<T> or Flux<T> . Using the map method would result in a Mono<Mono<T>> whereas using flatMap results in a Mono<T> . For example, it is useful when you have to make a network call to retrieve a data, with a java api that …
// Signature of the HttpClient.get method
Mono<JsonObject> get(String url);
// The two urls to call
String firstUserUrl = "my-api/first-user";
String userDetailsUrl = "my-api/users/details/"; // needs the id at the end
// Example with map
Mono<Mono<JsonObject>> result = HttpClient.get(firstUserUrl).
map(user -> HttpClient.get(userDetailsUrl + user.getId()));
package com.rest.api.covid19;
import com.rest.api.covid19.domain.Country;
import com.rest.api.covid19.domain.Covid19Statistics;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.client.RestTemplate;
package com.rest.api.covid19.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Country {