Skip to content

Instantly share code, notes, and snippets.

@tivrfoa
tivrfoa / interesting-links.md
Created September 16, 2024 01:23
Structured Concurrency
@tivrfoa
tivrfoa / test1.go
Created September 15, 2024 20:48
Go goroutine wg sync.WaitGroup
// https://www.youtube.com/watch?v=VmBwn6Nac74
package main
import (
"fmt"
"sync"
// "time"
)
@tivrfoa
tivrfoa / video-link.md
Created September 14, 2024 14:09
CppCon 2015: Pablo Halpern “Work Stealing"
@tivrfoa
tivrfoa / receiver.c
Created September 9, 2024 23:43
C: Sending signal to another process using SIGUSR1
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
void sigusr1_handler(int sig) {
printf("------>>> Received SIGUSR1 signal\n");
}
int main() {
signal(SIGUSR1, sigusr1_handler);
@tivrfoa
tivrfoa / Java-ultra-low-latency.md
Created September 1, 2024 20:44
How low can you go? Ultra low latency Java in the real world - Daniel Shaya
@tivrfoa
tivrfoa / 2017-modern-hardware-times.png
Last active August 31, 2024 20:52
High Performance Managed Languages • Martin Thompson • YOW! 2017
2017-modern-hardware-times.png
@tivrfoa
tivrfoa / Java-Stream-collect-combiner.md
Created August 28, 2024 02:35
ChatGPT reply for: Java Stream class has a collect method. The third argument is a combiner. I tested and combiner was never called

The combiner in Java's Stream.collect() method is an important part of the method's behavior, especially when the stream is processed in parallel. Here's why your combiner might not have been called:

Understanding Stream.collect()

The collect method in Java Streams is used to transform elements of the stream into a different form, often a collection (like List, Set, or Map). It takes three arguments:

  1. Supplier: A function that provides a new instance of the result container (e.g., a List or Set).
  2. Accumulator: A function that folds a value into the result container.
  3. Combiner: A function that merges two containers, which is particularly important in parallel processing.
@tivrfoa
tivrfoa / example1.rs
Created May 18, 2024 13:07
Rust generics trait dyn
// https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ae0048c018c77abd71b3c5121e02511a
trait Animal {
fn do_sound(&self);
}
struct Dog;
impl Animal for Dog {
fn do_sound(&self) {
println!("hoho");
@tivrfoa
tivrfoa / ai.md
Created May 16, 2024 23:55
Gemini and ChatGPT 3.5 answers to Java C2 megamorphic code #JVM

Question

Regarding Java code:

Let's suppose you have a static method that accepts a few interfaces. Different object instances always call it with a concrete combination of the interfaces, but C2 ends up with megamorphic code. How would you improve that?

ChatGPT 3.5

When you have a static method that accepts interfaces and different object instances call it with various combinations of those interfaces, and you observe megamorphic behavior (where the JVM struggles to optimize due to multiple possible types), you can consider a few strategies to improve performance: >

@tivrfoa
tivrfoa / instructions.md
Created March 16, 2024 01:42 — forked from matthewjberger/instructions.md
Install a nerd font on ubuntu

1.) Download a Nerd Font

2.) Unzip and copy to ~/.fonts

3.) Run the command fc-cache -fv to manually rebuild the font cache