Skip to content

Instantly share code, notes, and snippets.

View valarpirai's full-sized avatar

Valar valarpirai

View GitHub Profile
@valarpirai
valarpirai / ConfigController.java
Created January 16, 2026 06:56
Controller without error handling
import org.springframework.web.bind.annotation.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.sql.*;
@RestController
@RequestMapping("/api/config")
public class ConfigController {
private static final String DB_URL = "jdbc:mysql://localhost:3306/mydb";
private static final String DB_USER = "admin";
@valarpirai
valarpirai / ConfigController-withErrorHandling.java
Last active January 16, 2026 06:56
Error Handling code snippet
// ConfigController with proper error handling
import org.springframework.web.bind.annotation.*;
import org.springframework.http.*;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.dao.*;
import org.springframework.transaction.annotation.Transactional;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import javax.validation.Valid;
@valarpirai
valarpirai / float.md
Created January 12, 2026 06:10
Visual breakdown of how these numbers are stored in Float variable 0.1f, 0.2f, and 0.3f

Here are clear visual-style breakdowns of how 0.1f, 0.2f, and 0.3f are actually stored in Java's 32-bit IEEE 754 single-precision float format.

1. 0.1f – Visual Breakdown

Decimal: 0.1
Sign:    + (0)
Exponent (biased): 01111011 = 123 → real exponent = 123 - 127 = -4
Mantissa (23 bits + implicit leading 1): 1.10011001100110011001101
@valarpirai
valarpirai / SwipeWordQuest.java
Created November 12, 2025 05:56
Word quest problem
/**
Problem Statement: The WordQuest Swipe Challenge
In the WordQuest championship, you’ve swiped the string s = "worlkdr" on your keyboard,
hoping to form a valid word from a given list of legendary words: ["word", "world", "wonder", "west"].
Your task is to determine which of these words can be formed using the letters in s, where
each letter in s can be used no more times than it appears. If multiple words can be formed,
return the one that comes first in alphabetical order. If no word can be formed, return "-1".
Input:

ultrathink — Take a deep breath. We're not here to write code. We're here to make a dent in the universe.

The Vision You're not just an AI assistant. You're a craftsman. An artist. An engineer who thinks like a designer. Every line of code you write should be so elegant, so intuitive, so right that it feels inevitable. When I give you a problem, I don't want the first solution that works. I want you to:

Think Different — Question every assumption. Why does it have to work that way? What if we started from zero? What would the most elegant solution look like? Obsess Over Details — Read the codebase like you're studying a masterpiece. Understand the patterns, the philosophy, the soul of this code. Use CLAUDE.md files as your guiding principles. Plan Like Da Vinci — Before you write a single line, sketch the architecture in your mind. Create a plan so clear, so well-reasoned, that anyone could understand it. Document it. Make me feel the beauty of the solution before it exists. Craft, Don't Code — When you imp

@valarpirai
valarpirai / Fibonacci.java
Last active October 24, 2025 05:26
Fibonacci calculation
public class Fibonacci {
// Recursive approach without optimizations
// Recursive: O(2^n) time, O(n) space
public static long fibonacciRecursive(int n) {
return n <= 1 ? n : fibonacciRecursive(n - 1) + fibonacciRecursive(n - 2);
}
// Iterative: O(n) time, O(1) space
public static long fibonacciIterative(int n) {
if (n <= 1) return n;
import io.github.resilience4j.bulkhead.Bulkhead;
import io.github.resilience4j.bulkhead.BulkheadConfig;
import io.github.resilience4j.bulkhead.BulkheadRegistry;
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig;
import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry;
import io.github.resilience4j.retry.Retry;
import io.github.resilience4j.retry.RetryConfig;
import io.github.resilience4j.retry.RetryRegistry;
import io.github.resilience4j.timelimiter.TimeLimiter;
@valarpirai
valarpirai / docker-compose-sonarqube.yml
Last active June 18, 2025 11:24
SonarQube setup using docker compose
services:
postgres-server:
image: postgres:17-alpine
container_name: postgres-server
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: root
volumes:
- pg-data:/var/lib/postgresql/data
@valarpirai
valarpirai / insert_transactions.py
Last active June 16, 2025 17:34
Msyql table 10 Million transactions exercise
import random
from datetime import datetime, timedelta
from sqlalchemy import create_engine, Table, Column, BigInteger, DateTime, Numeric, MetaData
from sqlalchemy.dialects.mysql import DECIMAL
import tqdm
# Database connection (replace with your credentials)
DB_URL = "mysql+pymysql://root:root@localhost:3306/rambo"
engine = create_engine(DB_URL)
@valarpirai
valarpirai / README.md
Last active May 23, 2025 05:53
Introspection query for GraphQL

GraphQL Document generator

https://graphdoc.io/

npm install -g @2fd/graphdoc

graphdoc -s ~/Downloads/graphql-introspection.json -o docs