Skip to content

Instantly share code, notes, and snippets.

View rokon12's full-sized avatar
🎯
Focusing

A N M Bazlur Rahman rokon12

🎯
Focusing
View GitHub Profile
@rokon12
rokon12 / README.md
Created June 29, 2025 04:39
Code snippet from The Coding Café - Complete Code Reference

Complete Code Reference

This gist contains all code snippets from the article.

Files:

  • snippet-3.java
  • snippet-7.java
  • snippet-10.java
  • snippet-2.java
@rokon12
rokon12 / README.md
Created June 29, 2025 04:31
Code snippet from The Coding Café - Complete Code Reference

Complete Code Reference

This gist contains all code snippets from the article.

Files:

  • snippet-3.java
  • snippet-7.java
  • snippet-10.java
  • snippet-2.java
@rokon12
rokon12 / README.md
Created June 29, 2025 04:30
Code snippet from The Coding Café - Complete Code Reference

Complete Code Reference

This gist contains all code snippets from the article.

Files:

  • snippet-3.java
  • snippet-7.java
  • snippet-10.java
  • snippet-2.java
@rokon12
rokon12 / README.md
Created June 29, 2025 04:23
Code snippet from The Coding Café - Complete Code Reference

Complete Code Reference

This gist contains all code snippets from the article.

Files:

  • snippet-3.java
  • snippet-7.java
  • snippet-10.java
  • snippet-2.java
@rokon12
rokon12 / README.md
Created June 29, 2025 04:22
Code snippet from The Coding Café - Complete Code Reference

Complete Code Reference

This gist contains all code snippets from the article.

Files:

  • snippet-3.java
  • snippet-7.java
  • snippet-10.java
  • snippet-2.java
@rokon12
rokon12 / README.md
Created June 29, 2025 04:16
Code snippet from The Coding Café - Complete Code Reference

Complete Code Reference

This gist contains all code snippets from the article.

Files:

  • snippet-3.java
  • snippet-7.java
  • snippet-10.java
  • snippet-2.java
@rokon12
rokon12 / snippet-2.java
Created June 29, 2025 02:29
Code snippet from The Coding Café - snippet-2.java
List<Integer> runningMax = values.stream()
.gather(Gatherers.scan(
() -> Integer.MIN_VALUE, // 1️⃣ Start with smallest possible value
Integer::max // 2️⃣ Keep the maximum at each step
))
.toList();
System.out.println("Running maximum: " + runningMax);
// Output: [-2147483648, 1, 5, 5, 8, 8, 9, 9, 9, 9]
// ↑ initial ↑ 5>1 ↑ 8>5 ↑ 9>8
List<Integer> runningMax = values.stream()
.gather(Gatherers.scan(
() -> Integer.MIN_VALUE,
Integer::max
))
.toList();
System.out.println("Running maximum: " + runningMax);
// Output: [-2147483648, 1, 5, 5, 8, 8, 9, 9, 9, 9]
// ↑ initial ↑ 5>1 ↑ 8>5 ↑ 9>8
@rokon12
rokon12 / snippet-2.java
Last active June 29, 2025 02:23
Code snippet from The Coding Café - snippet-2.java
List<Integer> runningMax = values.stream()
.gather(Gatherers.scan(
() -> Integer.MIN_VALUE,
Integer::max
))
.toList();
System.out.println("Running maximum: " + runningMax);
// Output: [-2147483648, 1, 5, 5, 8, 8, 9, 9, 9, 9]
// ↑ initial ↑ 5>1 ↑ 8>5 ↑ 9>8
@rokon12
rokon12 / snippet-10.java
Created June 29, 2025 02:17
Code snippet from The Coding Café - snippet-10.java
record PeakValley(String type, double value, int index) {}
public static Gatherer<Double, ?, PeakValley> peakValleyDetection() {
return Gatherer.of(
() -> new Object() {
Double prev = null; // 1️⃣ Previous value
Double current = null; // 2️⃣ Current value
int index = 0; // 3️⃣ Track position
},
(state, next, downstream) -> {