Skip to content

Instantly share code, notes, and snippets.

View prrao87's full-sized avatar

Prashanth Rao prrao87

View GitHub Profile
@prrao87
prrao87 / create_financial_asset_graph.cypher
Created March 26, 2025 01:34
Financial asset graph for Kuzu-MCP server
DROP TABLE ParentOf;
DROP TABLE Issues;
DROP TABLE Company;
DROP TABLE Bond;
CREATE NODE TABLE Company(cid SERIAL, name STRING, PRIMARY KEY(cid));
CREATE (a:Company {name: "CompanyA"});
CREATE (a:Company {name: "CompanyB"});
CREATE (a:Company {name: "CompanyC"});
ollama:
image: "ollama/ollama:0.6.0"
restart: unless-stopped
environment:
- OLLAMA_HOST=0.0.0.0:11434
- OLLAMA_MODELS=/data/models
- OLLAMA_FLASH_ATTENTION=1
- OLLAMA_KV_CACHE_TYPE=q8_0
- OLLAMA_CONTEXT_LENGTH=8192
networks:
@prrao87
prrao87 / update.py
Last active October 24, 2024 21:39
Bulk update workflow using `LOAD FROM` and `MERGE` with Polars DataFrames
import polars as pl
import kuzu
import shutil
shutil.rmtree("test_db", ignore_errors=True)
db = kuzu.Database("test_db")
conn = kuzu.Connection(db)
# Get a JSON object of persons and products purchased
data = [
@prrao87
prrao87 / gen_data.py
Last active January 27, 2024 00:04
gen_fake_persons.py
"""
Generate a fake dataset (csv or parquet) of persons
Two columns: name (str) and age (int)
Ensure the faker library and polars are installed:
pip install faker polars
Usage:
python gen_data.py -n 1000000 -f csv
python gen_data.py -n 1000000 -f parquet
# Git branch in prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\u@\h \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]$ "
@prrao87
prrao87 / docker_enable_non_root_user.sh
Created March 28, 2023 17:15
Allow non root/sudo user to run docker containers on Ubuntu
sudo chmod 666 /var/run/docker.sock
# Create a logger with rotating file handler and formatting per loguru
def get_logger(filename: str):
import sys
from loguru import logger
from pathlib import Path
Path("logs").mkdir(parents=True, exist_ok=True)
logger.remove() # Remove base logger settings and overwrite with custom settings
fmt = "{time:HH:mm:ss:SSS} -- {level} -- {message}"
# Add rotating file handler with desired level of logging
filename = f"{filename}.log" if not filename.endswith(".log") else filename
# change normal keystroke timing on mac to make typing feel more responsive
# normal minimum is 15 (225 ms)
defaults write -g InitialKeyRepeat -int 13
# normal minimum is 2 (30 ms)
defaults write -g KeyRepeat -int 1
@prrao87
prrao87 / log.py
Created February 24, 2023 15:10 — forked from nguyenkims/log.py
Basic example on how setup a Python logger
import logging
import sys
from logging.handlers import TimedRotatingFileHandler
FORMATTER = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
LOG_FILE = "my_app.log"
def get_console_handler():
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setFormatter(FORMATTER)
@prrao87
prrao87 / httpx-hackernews-async-example.py
Created February 22, 2023 03:45 — forked from danielmichaels/httpx-hackernews-async-example.py
A short realworld example of how to use HTTPX's AsyncClient in a sync class.
"""
HackerNews module.
"""
import logging
import asyncio
from operator import itemgetter
import httpx