Posts

Access host machine service from within docker container

To access the host machine's service running on a local port from within a docker container, use the special URL host.docker.internal to access the host services. This soluction works on the following installation types of Docker:     Docker Engine on Linux     Docker Desktop on Linux, Mac and Windows     Colima on Mac  Example using docker docker run --add-host=host.docker.internal:host-gateway --rm alpine/curl -fsSL http://host.docker.internal:8080/health-check Example using docker compose networks:   main:     name: my-docker-compose-network services:   curl:     container_name: curl     image: "alpine/curl"     extra_hosts:       - host.docker.internal:host-gateway     command: curl -fsSL http://host.docker.internal:8080/health-check     networks:       main:         aliases:           - curl

Download and run Hugging Face AI models in Ollama

This article explains step by step guide to download an AI model from Hugging Face repository and run it with Ollama. Ollama allows to create a model locally from GGUF format or SafeTensors format and this article will cover both models. Creating from GGUF models is highly reliable as the GGUF file is packaged with model data with template file suitable for the AI model. Running a model using GGUF: Example repository with GGUF formal model https://huggingface.co/sergbese/gemma-3-isv-translator-v5-gguf-bf16 Create a download directory: mkdir gemma-3-isv-translator-v5-gguf-bf16 Download the file into the directory cd gemma-3-isv-translator-v5-gguf-bf16 wget "https://huggingface.co/sergbese/gemma-3-isv-translator-v5-gguf-bf16/resolve/main/gemma-3-finetune-2.BF16.gguf?download=true" -O ./gemma-3-finetune-2.BF16.gguf Create an Ollama model: echo 'FROM ./gemma-3-finetune-2.BF16.gguf' > Modelfile ollama create gemma-3-isv-translator-v5-gguf-bf16:latest Run and verify the ...

Lombok's copyableAnnotations for Spring

It is generally a good practise to declare the dependencies in a java class as final and inject the dependencies through the constructor. With Lombok's @AllArgsConstructor and @RequiredArgsConstructor , the generated constructor has all the final fields as parameters. However, if we use the @Qualifier and @Value for the final fields, then by default Lombok doesn't copy these annotation to the constructor parameters. In order to apply/copy these annotations to the constructor parameters, the following lombok config is required. Create lombok.config file in the route directory of the project and add the following lines lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Value This configuration inform Lombok to copy annotation applied at final field to constructor parameters. Example: Source Code @Component @AllArgsConstructor public class SampleService { @Qualifi...

Export/Backup Ollama Model

The following commands help to export/backup the ollama models which allows to quick restore the models or setup an offline machine using file transfer. Pull a model from registry ollama pull llava:7b Export the model mkdir -p llava_7b_backup cd llava_7b_backup ollama show --modelfile llava:7b > Modelfile cat Modelfile | grep -E '^FROM' | cut -d ' ' -f 2 | xargs -I {} cp {} . cat Modelfile | grep '# FROM' | cut -d ' ' -f 3 | xargs -I {} echo 'ollama create {} -f Modelfile' > readme.txt sed -i '' -E 's/^FROM.*blobs/FROM ./g' Modelfile Import the model  cd llava_7b_backup ollama create llava:7b -f Modelfile Run the model ollama run llava:7b Remove the model ollama rm llava:7b

AWS Workspaces Client and Linux Changes

The following changes to AWS Workspaces Client and Linux will boost developer's productivity Make the following changes in the AWS Workspace Client: Menu -> Settings -> Manage Hardware Acceleration -> Enabled (Tick) Menu -> Settings -> Display Settings -> High DPI Mode (Tick) Menu -> Settings -> Switch Running Mode -> Always On (Select) Make the following tweaks inside the Amazon Linux Operating System: Settings -> Privacy -> Screen Lock -> Automatic Screen Lock -> Off Settings -> Power -> Power Saving -> Blank Screen -> Never Settings -> Power -> Suspend & Power Button -> Automatic Suspend -> Off Open a Terminal and execute the following command to switch to GNOME classic UI nohup gnome-shell --mode=classic -r > /dev/null 2>&1 & To switch back to modern GNOME UI nohup gnome-shell --mode=user -r > /dev/null 2>&1 & Store the following commands as alias in ~/.bashrc file to use it as conven...

Java's ScheduledExecutorService example

Example of Java's ScheduledExecutorService to run a block of code once (with a delay) or repeatedly at fixed rate or fixed delay. ScheduledExecutorService can be a single threaded executor (used to execute in a coordinated way) or can be multi threaded executor (used to execute in parallel) import java.util.concurrent.Executors ; import java.util.concurrent.ScheduledExecutorService ; import java.util.concurrent.TimeUnit ; public class ExampleScheduledExecutor implements AutoCloseable { private final ScheduledExecutorService executorService = Executors . newSingleThreadScheduledExecutor (); // use newScheduledThreadPool() for running with multiple threads in parallel // private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(2); public ExampleScheduledExecutor ( long initialDelay , long fixedDelay ) { executorService .schedule(() -> executeOnlyOnce(), initialDelay , TimeUnit . SECONDS ); executorService .scheduleAtFixedR...

less - Unix / Linux command line reader cheat sheet

Useful gist that contains the common commands used in less command line reader  https://gist.github.com/harishkannarao/2bbda02dcca774c93eb3c2a0bce9de7f