Blog

List vs Collections vs Iterable

Quick tips Do I care about the sequence of the items? If yes use List else a Collection Do I care about how many items? If yes use Collection else use Iterable

Pod Resource Utilization

Getting pod memory First get into the pod using kubectl exec 1 cat /sys/fs/cgroup/memory/memory.usage_in_bytes | awk '{ foo = $1 / 1024 / 1024 ; print foo "MB" }'

IntelliJ debugging in Docker container

Scenario So here’s the deal. You have a Java application working fine in your local environemnt but whenever it get launched in a container, it crashes. So now you want to debug the app running in the container. Requirements IntelliJ IDEA 2023.3.2 (Community Edition) Docker Now in the IntelliJ run configurations add remote Let’s run the app in question with following flags: 1 docker run --rm -it -p 5005:5005 -e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n" my-image:0.

Odin Language - Installing on macOS Ventura

I just followed the official documentation :) But setting LLVM_CONFIG was not documented 1 2 3 4 5 6 7 8 9 10 11 xcode-select --install brew install llvm@14 echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc_profile export LDFLAGS="-L/opt/homebrew/opt/llvm@14/lib" export CPPFLAGS="-I/opt/homebrew/opt/llvm@14/include" export LLVM_CONFIG="/opt/homebrew/opt/llvm@14/bin/llvm-config

Streams

map vs flatMap map is a one-to-one function map(f1t1) => Stream<R> flatMap is a one-to-many function map(f1tn) => Stream<List<R>>

Completable Futures - thenApply vs thenCompose

Let’s wrap a blocking operation in a CompletablFuture 1 2 3 4 5 6 7 public static Integer blockingCall(int x) { return x * 2; } public static CompletableFuture<Integer> asyncRunner(int x) { return CompletableFuture.supplyAsync(() -> blockingCall(x)); } Here we chain the outputs so that it prints the aggregated results. But this will print the future not the value (16) 1 2 3 4 5 public static void main(String[] args) { asyncRunner(4) .

Tf Idf Jupyter Notebook

Installing and running Jupyter notebook 1 2 3 pip install jupyter python jupyter notebook Install ML libraries 1 2 3 4 pip install -U scikit-learn pip install -U spaCy pip install -U pandas pip install gensim

Sine wave generator using Golang

Let’s build a continuous sine wave generator with Go. This could be the first step into creating your ground breaking synthesizer, who knows :) But some theory first before we dive in. How digital audio works We know that sound waves are vibrations travelling through air. These vibrations cause air pressure changes from sound source (Generator in our case) to receiver (our ears) over time. It is important to note that air particles do not travel with vibrations to receiver.