Skip to content

Instantly share code, notes, and snippets.

View viveknaskar's full-sized avatar
🎯
Focusing

Vivek Naskar viveknaskar

🎯
Focusing
View GitHub Profile
@viveknaskar
viveknaskar / llm-wiki.md
Created April 4, 2026 19:31 — forked from karpathy/llm-wiki.md
llm-wiki

LLM Wiki

A pattern for building personal knowledge bases using LLMs.

This is an idea file, it is designed to be copy pasted to your own LLM Agent (e.g. OpenAI Codex, Claude Code, OpenCode / Pi, or etc.). Its goal is to communicate the high level idea, but your agent will build out the specifics in collaboration with you.

The core idea

Most people's experience with LLMs and documents looks like RAG: you upload a collection of files, the LLM retrieves relevant chunks at query time, and generates an answer. This works, but the LLM is rediscovering knowledge from scratch on every question. There's no accumulation. Ask a subtle question that requires synthesizing five documents, and the LLM has to find and piece together the relevant fragments every time. Nothing is built up. NotebookLM, ChatGPT file uploads, and most RAG systems work this way.

@viveknaskar
viveknaskar / FlattenedToNestedMapExample.java
Created June 29, 2025 22:01
Illustration of Transforming a Flat Map to a Nested Map
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@SuppressWarnings("unchecked")
public class FlattenedToNestedMapExample {
public static Map<String, Object> unflatten(Map<String, Object> flatMap) {
Map<String, Object> nestedMap = new LinkedHashMap<>();
flatMap.forEach((flatKey, value) -> {
String[] keys = flatKey.split("\\.");
@viveknaskar
viveknaskar / DeepMergeMapsExample.java
Created June 29, 2025 21:59
Illustration of Deep Merging of Nested Maps
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@SuppressWarnings("unchecked")
public class DeepMergeMapsExample {
public static Map<String, Object> deepMerge(Map<String, Object> baseMap, Map<String, Object> updateMap) {
Map<String, Object> result = new LinkedHashMap<>(baseMap);
updateMap.forEach((key, updateValue) -> {
if (result.containsKey(key) && result.get(key) instanceof Map && updateValue instanceof Map) {
@viveknaskar
viveknaskar / MapAggregationExample.java
Created June 29, 2025 21:58
Illustration of Grouping and Aggregating Data from a List of Maps
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class MapAggregationExample {
public static void main(String[] args) {
List<Map<String, Object>> products = Arrays.asList(
createProduct("Laptop", "Electronics", 1200.00),
createProduct("Mouse", "Electronics", 25.00),
@viveknaskar
viveknaskar / AlertController.java
Created October 11, 2022 17:08
Alert Controller for sending SMS
import com.viveknaskar.smsalertsystem.domain.AlertMessage;
import com.viveknaskar.smsalertsystem.domain.User;
import com.viveknaskar.smsalertsystem.service.AlertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@viveknaskar
viveknaskar / AlertServiceImpl.java
Created October 11, 2022 17:05
Implementation of sending SMS using Twilio methods
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
import com.viveknaskar.smsalertsystem.domain.AlertMessage;
import com.viveknaskar.smsalertsystem.domain.User;
import com.viveknaskar.smsalertsystem.service.AlertService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class AlertServiceImpl implements AlertService {
@viveknaskar
viveknaskar / application.properties
Created October 11, 2022 16:44
Application properties having credentials for accessing Twilio account
#Twilio platform credentials
twilio.account.sid=<your-twilio-account-sid>
twilio.auth.token=<your-twilio-auth-token>
@viveknaskar
viveknaskar / TwilioConfig.java
Created October 11, 2022 16:27
Configuration for using Twilio SDK for SMS Alert System
import com.twilio.Twilio;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
@Configuration
public class TwilioConfig {
@Value("${twilio.account.sid}")
@viveknaskar
viveknaskar / pom.xml
Last active October 11, 2022 13:27
Dependencies for SMS Alert System Using Twilio
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
@viveknaskar
viveknaskar / ExceptionallyExample.java
Created September 22, 2022 21:41
Illustration of exceptionally method of CompletableFuture
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
public class ExceptionallyExample {
public static void main(String[] args) throws ExecutionException, InterruptedException {
int val = 0;
CompletableFuture<String> completableFuture = CompletableFuture.supplyAsync(() -> {
if(val == 0) {
throw new IllegalArgumentException("Value is 0");
}