Skip to content

Instantly share code, notes, and snippets.

View Raouf25's full-sized avatar

ABDERRAOUF MAKHLOUF Raouf25

View GitHub Profile
List<String> list = new ArrayList<String>();
list.add("hello");
String s = list.get(0);
List<String> list = new ArrayList<String>();
list.add("hello");
list.add(32);//Compile Time Error
{
"Global": {
"NewConfirmed": 257886,
"TotalConfirmed": 17849120,
"NewDeaths": 5615,
"TotalDeaths": 685038,
"NewRecovered": 222627,
"TotalRecovered": 10552934
},
"Countries": [
package com.rest.api.covid19.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
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 Global {
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 {
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;
@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()));
version: '3'
services:
postgres:
container_name: container-postgresdb
image: postgres
hostname: postgres
ports:
- "6543:5432"
environment:
POSTGRES_USER: postgres
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 \