Skip to content

Instantly share code, notes, and snippets.

@tivrfoa
tivrfoa / fastest-way-to-understand-source-code.md
Created October 26, 2025 17:50
Gemini 2.5 Pro response to: What is the fastest way to understand a program source code?

The fastest way to understand source code is to avoid reading it line-by-line. Instead, use a top-down, interactive approach focused on tracing a single feature.

Think of it like exploring a new city: you don't start by walking every single street. You look at a map, find the city center, and follow the main roads to a landmark.


## 1. Start High (The 10-Minute Map) 🗺️

Your first goal is to get a "map" of the project, not to understand every building.

@tivrfoa
tivrfoa / java-assembly-with-casey-muratori.md
Created October 26, 2025 14:06
From Java to Assembly in Java's 1-Billion-Row Challenge (Ep. 4) | With @caseymuratori ​
@tivrfoa
tivrfoa / java-quotes.md
Last active September 25, 2025 09:48
Java Quotes

AOT

https://x.com/shipilev/status/1970805877545505108

Aleksey Shipilëv @shipilev Timings get way better for any AOT mode when there are only a few available cores to run JIT in background. Once aggressive JIT compiler starts to compete with the application, it hurts a lot, and residency graphs are a mess. There are 2-3x wins, though. Oh man.

@tivrfoa
tivrfoa / transcribe-audio.py
Created July 13, 2025 22:47
Transcribing Audio Files using Python speech_recognition and ffmpeg, by ChatGPT
import speech_recognition as sr
import sys
import os
import subprocess
import tempfile
def convert_to_wav(input_file):
"""Convert input audio to a temporary WAV file using ffmpeg"""
tmp_wav = tempfile.NamedTemporaryFile(delete=False, suffix=".wav")
tmp_wav.close()
@tivrfoa
tivrfoa / MandelbrotSet.java
Created June 15, 2025 17:41
Mandelbrot Set JavaFX - Gemini
package com.example.mandelbrot;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.image.PixelWriter;
@tivrfoa
tivrfoa / tcp1.rs
Created April 28, 2025 00:18
Rust code for reading and writing to a TCP connection - useful to communicate with netcat (nc)
// using threads so it can read and write without blocking
use std::io::{self, prelude::*, BufReader, BufWriter, Write};
use std::net::TcpStream;
use std::env;
use std::thread;
fn main() -> io::Result<()> {
let args: Vec<String> = env::args().collect();
@tivrfoa
tivrfoa / process-file-in-parallel-in-Java-by-ChatGPT.md
Created March 2, 2025 13:51
Java: processing different chunks of a file in parallel

Prompt: So to process different chunks of a file in parallel, is RandomAccessFile the only option is to use ?


ChatGPT:

No, RandomAccessFile is not the only option. There are several alternatives for processing different chunks of a file in parallel:

  1. FileChannel and MappedByteBuffer:
  • Using a FileChannel, you can memory-map a file (or portions of it) into a MappedByteBuffer with the map() method.
@tivrfoa
tivrfoa / useful-shell-commands.sh
Created February 28, 2025 22:24
Useful shell commands
# find files that contain the string STR and delete them
find src/main/java -type f -exec grep -q "STR" {} \; -delete
@tivrfoa
tivrfoa / Java-TreeSet-vs-PriorityQueue-Benchmark.md
Last active February 28, 2025 19:42
Java benchmark program using JMH (Java Microbenchmark Harness) to compare the performance of TreeSet and PriorityQueue.

Prompt: Write a Java benchmark program using JMH, that benchmarks TreeSet vs PriorityQueue.


Here is a complete Java benchmark program using JMH (Java Microbenchmark Harness) to compare the performance of TreeSet and PriorityQueue. The benchmark focuses on three key operations: adding elements, adding and removing the smallest element, and checking for element existence. Benchmark Overview We will measure the performance of TreeSet and PriorityQueue for the following operations:

Adding Elements: