Skip to content

Instantly share code, notes, and snippets.

@toteabe
toteabe / gist:a5d651fcb72918ec4f5faaac855b2f69
Created October 8, 2025 10:27
Testing flatmap, anyMatch, noneMatch, allMatch
@Test
void testFlatmapPrevio() {
String[] words = new String[]{ "Hello", "World" };
List<String[]> list = Arrays.stream(words)
.map(word -> word.split(""))
.peek(strings -> {
@toteabe
toteabe / docker-api-port.md
Created October 29, 2024 22:17 — forked from styblope/docker-api-port.md
Enable TCP port 2375 for external connection to Docker

Enable TCP port 2375 for external connection to Docker

See this issue.
Docker best practise to Control and configure Docker with systemd.

  1. Create daemon.json file in /etc/docker:

     {"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}
    
@toteabe
toteabe / MapGroupSortLimit.java
Created October 15, 2024 18:06 — forked from EricLondon/MapGroupSortLimit.java
Java 8 group Map by value, sort desc, and limit 10
Map<String, Long> counted = list.stream()
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
Map<String, Long> sorted = counted.entrySet().stream()
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
.limit(10)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
@toteabe
toteabe / filteringHighEnergyQueryMethod.java
Last active April 24, 2024 16:35
high-energy query method filmRepository
//...
//FilmController
//...
@GetMapping("")
protected Page<FilmDTO> findAll(@RequestParam(name = "title", defaultValue = "" /*, required = false*/) String title,
@RequestParam(name = "description", defaultValue = "" /*, required = false*/)
String description,
Pageable pageable) {
logger.debug("REST : GET - findAll");
Page<FilmDTO> page = service.findAll(title, description, pageable);
@toteabe
toteabe / filtering.java
Last active April 24, 2024 16:23
FilmCustomRepository
//...
//FilmController
//...
@GetMapping("")
public Page<FilmDTO> findAll(@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "description", required = false) String description,
Pageable pageable) {
logger.debug("REST : GET - findAll");
Page<FilmDTO> page = service.findAll(title, description, pageable);
return page;
package com.bezkoder.spring.jpa.query.repository;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import jakarta.transaction.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;