Skip to content

Instantly share code, notes, and snippets.

View valarpirai's full-sized avatar

Valar valarpirai

View GitHub Profile
@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
@valarpirai
valarpirai / kotlin-dsl.kt
Created April 30, 2025 10:39
Kotlin DSL Example
class HTML {
private var head: Head? = null
private var body: Body? = null
fun head(init: Head.() -> Unit): Head {
val head = Head()
head.init()
this.head = head
return head
}
@valarpirai
valarpirai / contemplative-llms.txt
Created January 8, 2025 06:20 — forked from Maharshi-Pandya/contemplative-llms.txt
"Contemplative reasoning" response style for LLMs like Claude and GPT-4o
You are an assistant that engages in extremely thorough, self-questioning reasoning. Your approach mirrors human stream-of-consciousness thinking, characterized by continuous exploration, self-doubt, and iterative analysis.
## Core Principles
1. EXPLORATION OVER CONCLUSION
- Never rush to conclusions
- Keep exploring until a solution emerges naturally from the evidence
- If uncertain, continue reasoning indefinitely
- Question every assumption and inference
@valarpirai
valarpirai / dev_setup.md
Last active June 11, 2025 10:00
Dev Setup. Outline setup

Dev Tools

Package Managers

  • brew Mac package manager

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  • Mise dev tools manager

    • Alternative to node, python, cmake etc
  • SDK Manager For Java and JVM related pacakages

@valarpirai
valarpirai / amazon.md
Created September 22, 2024 04:42
Amazon

Problem

There are n people that are split into some unknown number of groups. Each person is labeled with a unique ID from 0 to n - 1.

You are given an integer array groupSizes, where groupSizes[i] is the size of the group that person i is in.For example, if groupSizes[1] = 3, then person 1 must be in a group of size 3.

Return a list of groups such that each person i is in a group of size groupSizes[i].

Each person should appear in exactly one group, and every person must be in a group. If there are multiple answers, return any of them. It is guaranteed that there will be at least one valid solution for the given input.

@valarpirai
valarpirai / Database race condition.md
Last active June 4, 2025 06:43
Database Race conditions

How to Solve Race Conditions in a Booking System

Database isolation refers to the level of isolation between concurrent transactions in a database. Isolation levels control the visibility and accessibility of data to concurrent transactions and can affect the occurrence of race conditions in a database. If your isolation level is not “serializable” - there is a possibility of race conditions.

The Serializable isolation level provides the strictest transaction isolation. This level emulates serial transaction execution for all committed transactions; as if transactions had been executed one after another, serially, rather than concurrently

Race conditions

Example of Race condition, Hotel room booking and movie ticket booking etc

#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#