Posts

Mastering Compose Performance: Stability, Reports, and Profiling

Performance in Jetpack Compose is built on Stability —the compiler's ability to know if data has changed. If the compiler isn't sure, it re-runs your UI code "just in case," leading to unnecessary recompositions and potential lag. 1. Stable vs. Unstable Types The Compose compiler categorizes every parameter passed into a function to determine if a Composable can be "skipped." Type Description Examples Stable Immutable types or those that notify Compose of changes. Compose skips these if .equals() is true. String , Int , Boolean , @Stable objects, State<T> . Unstable Types that might change internally. Compose always recomposes these to ensure UI accuracy. Standard List , Set , Map , or classes with var properties. Why i...

Automate Library Integration with Cursor's Agent Mode

Automate Android Library Integration with Cursor's Agent Mode Automate Android Library Integration with Cursor's Agent Mode As developers, we often find ourselves repeating similar integration steps for various libraries. What if your IDE could proactively guide you through the setup, asking for necessary parameters and generating boilerplate code on the fly? With tools like Cursor's "Agent Requested" mode, this is not just a dream but a reality. This post delves into how to empower Cursor to integrate a custom library (let's call it "MyGraph") into your Android application, making the setup process remarkably efficient. Understanding Cursor's "Agent Requested" Mode Cursor's "Agent Requested" mode is a powerful feature that allows the IDE's AI assistant to take initiative based on the context of your project or specific triggers. Instead of you explicitly asking for help every time, the...

Enhancing LLM Responses with Prompt Stuffing in Spring Boot AI

Image
Enhancing LLM Responses with Prompt Stuffing in Spring Boot AI Large Language Models (LLMs) like OpenAI's GPT series are incredibly powerful, but they sometimes need a little help to provide the most accurate or context-specific answers. One common challenge is their knowledge cut-off date or their lack of access to your private, domain-specific data. This is where "prompt stuffing" (a basic form of Retrieval Augmented Generation or RAG) comes into play. In this post, we'll explore how you can use Spring Boot with Spring AI to "stuff" relevant context into your prompts, guiding the LLM to generate more informed and precise responses. We'll use a practical example involving fetching information about a hypothetical IPL 2025 schedule. What is Prompt Stuffing? Prompt stuffing, in simple terms, means providing the LLM with relevant information or context directly within the prompt you send i...

Building a Retrieval-Augmented Generation (RAG) Application with Ollama 3.2 and Spring Boot

Building a RAG Application with Ollama 3.2 and Spring Boot This blog post demonstrates how to build a Retrieval-Augmented Generation (RAG) application using Ollama 3.2 for large language models (LLMs) and Spring Boot for creating REST APIs. RAG combines information retrieval with LLMs to provide more accurate and contextually relevant answers. We'll leverage Docker Desktop for containerization and pgvector for vector storage. Project Setup We'll use Spring Boot version 3.3.7 for this project. Here's a breakdown of the key components and configurations: 1. Dependencies (Gradle): dependencies { implementation 'org.springframework.boot:spring-boot-starter-jdbc' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'com.fasterxml.jackson.module:jackson-module-kotlin' implementation 'org.springframework.ai:spring-ai-ollama-spring-boot-starter' ...

Securing Microservices with JWT Authentication and Data Encryption

Securing Microservices with JWT Authentication and Data Encryption Securing Microservices with JWT Authentication and Data Encryption In modern microservices architectures, securing communication and data integrity are paramount. This article explores how JWT (JSON Web Token) authentication and data encryption can bolster security, ensuring that data exchanges between services remain confidential and trusted. What is JWT Authentication? JWT is a compact, URL-safe token format that securely transmits information between parties as a JSON object. It is widely used in microservices for its simplicity and efficiency. Parts of a JWT Token A JSON Web Token (JWT) consists of three parts, separated by periods ( . ): Header: Specifies the token type ( JWT ) and signing algorithm (e.g., HS256 or RS256 ). Example:...

Android aar deployment in Maven - 2022

Introduction If you are working on android library project, you might be wondering how to publish it on Maven like this . Earlier it was done using Android studio plugin maven , but with gradle v 7.0+ it does not work. Now we have to use maven-publish . This post gives you more insights of this procedure. Generally, there are two types of repositories: local and remote. A local repository is the repository Maven creates on the computer it is building on. It is usually located under the $HOME/.m2/repository directory. Remote repository is located on maven server. When any user wants to use our library, they will enter groupId and version of library they want to use. We will create and deploy a new android aar artifact on maven. The process can be summarized as 1. Create Account and repository on Nexus sonatype 2. Configure gradle to create, sign and upload aar file to sonatype. 3. Let sonatype verify the artifacts as per maven requirement (Close ope...

Flutter: Making dashed line matching width of screen

Image
 How can we make dashed line in flutter? Dart does not have support for this yet. We need to make custom widget for showing dashed line. Code is given below. class LinePainter extends CustomPainter { @override void paint ( Canvas canvas, Size size) { var max = size. width ; debugPrint ( "LinePainter max= $ max " ); var dashWidth = 5.0 ; var dashSpace = 5.0 ; double startX = 0 ; final paint = Paint ().. color = Colors . grey ; while ( max >= 0 ) { canvas.drawLine( Offset ( startX , 0 ), Offset ( startX + dashWidth , 0 ),           paint .. strokeWidth = 1 ); final space = ( dashSpace + dashWidth ); startX += space ; max -= space .toInt(); } } @override bool shouldRepaint ( CustomPainter oldDelegate) { return false ; } } Above code will paint a line of width = size. width. To use this painter as widget, we have to use CustomPaint (painter: LinePainter (),size:Size(400,1)) It will ...