Skip to content

Instantly share code, notes, and snippets.

View TGITS's full-sized avatar

TheGeekInTheShell TGITS

View GitHub Profile
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import static java.lang.System.out;
import static java.util.stream.Collectors.summingInt;
public class Main {
@startmindmap kata-mindmap
* Ressources pour pratiquer les Katas
** Catalogues de Katas
*** Kata-Log : https://kata-log.rocks/
*** CodingDojo : https://codingdojo.org/
**** https://codingdojo.org/kata/
*** Code Kata : http://codekata.com/
** Katas spécialisés
*** Refactoring Katas
**** Tennis : https://github.com/emilybache/Tennis-Refactoring-Kata
@TGITS
TGITS / reversing_list.py
Created October 23, 2020 16:42
Manière d'inverser les éléments d'une liste ou d'une string en Python
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print('liste de nombres :', numbers)
numbers.reverse()
print('liste de nombres après reverse() :', numbers)
print('\n##############\n')
numbers = list(range(10))
print('liste de nombres :', numbers)
reversed(numbers)
@TGITS
TGITS / House.java
Created January 22, 2022 12:29
A record to represent some characteristics of a noble House of Westeros
/**
* A record to represent some characteristics of a noble House of Westeros
* */
public record House(String name, String seat, String sigil, String familyWords) {
}
@TGITS
TGITS / RecordExampleScript_1.java
Created January 22, 2022 15:40
Un premier exemple de record avec utilisation de la méthode toString et d'un accesseur
//A exécuter sous JShell : /open RecordExampleScript_1.java
public record House(String name, String seat, String sigil, String familyWords) {
}
var house = new House("Stark", "Winterfell", "A Gray Direwolf", "Winter is coming");
System.out.println(house); // Utilisation implicte de la méthode toString
System.out.println(house.seat()); // Utilisation d'un accesseur
@TGITS
TGITS / RecordExampleScript_2.java
Last active January 22, 2022 15:51
Exemple de fonctionnement des méthodes equals et hashCode des records
//A exécuter sous JShell : /open RecordExampleScript_2.java
public record House(String name, String seat, String sigil, String familyWords) {
}
House house1 = new House("Stark", "Winterfell", "A Gray Direwolf", "Winter is coming");
House house2 = new House("Stark", "Winterfell", "A Gray Direwolf", "Winter is coming");
house1 == house2; // false - 2 références distinctes
house1.equals(house2); // true - comparaison basée sur le contenu
house1.hashCode() == house2.hashCode(); // true
@TGITS
TGITS / Pair.java
Created January 22, 2022 16:02
Un exemple de record avec des types paramétrés et une méthode statique
public record Pair<U,V>(U first, V second) {
public static <U,V>Pair<U,V> of(U first, V second) {
return new Pair<>(first,second);
}
}
@TGITS
TGITS / HouseStarkExample.java
Created January 23, 2022 13:39
Exempel de bloc de texte représentant du JSON en Java
//A utiliser sous JShell : /open HouseStarkExample.java
var houseStark = """
{
"name": "Stark",
"main_seat": "Winterfell",
"ancestral_seat": "Winterfell",
"sigil": "A Gray Direwolf",
"family_words": "Winter is coming"
}""";
@TGITS
TGITS / TextBlockEndMarkerExample.java
Created January 23, 2022 14:02
Exemple montrant l'influence de la position des double guillemets marquant la fin du bloc de texte
//A utiliser sous JShell : /open TextBlockEndMarkerExample.java
var houseStark_1 = """
{
"name": "Stark",
"main_seat": "Winterfell",
"ancestral_seat": "Winterfell",
"sigil": "A Gray Direwolf",
"family_words": "Winter is coming"
}
""";
@TGITS
TGITS / HouseStarkExampleWithEndlineSpaces.java
Created January 23, 2022 14:10
Exemple de bloc de texte avec des espaces en fin de ligne
//A utiliser sous JShell : /open HouseStarkExampleWithEndlineSpaces.java
var houseStark = """
{
"name": "Stark",
"main_seat": "Winterfell",
"ancestral_seat": "Winterfell",
"sigil": "A Gray Direwolf",
"family_words": "Winter is coming"
}""";