Skip to content

Instantly share code, notes, and snippets.

View rvprasad's full-sized avatar

Venkatesh-Prasad Ranganath rvprasad

View GitHub Profile
@rvprasad
rvprasad / ORM-performance-overhead-assessment-commands-and-output.md
Last active December 28, 2025 23:33
Assess performance of ORM, raw SQL with ID column, and raw SQL without ID column.

In-Memory Sqlite

  1. ORM: python3.12 orm-tester.py sqlite 100000
    • 100000 additions took 27251.844822ms
  2. Raw SQL: python3.12 sqlite-tester.py 100000
    • With ID column: 100000 additions took 6531.315638ms
    • Without ID column: 100000 additions took 6026.203085ms

Postgres

  1. docker run -e POSTGRES_PASSWORD=random -e POSTGRES_USER=postgres -e POSTGRES_DB=test-db -p 5432:5432 postgres:18-alpine
  2. ORM: python3.12 orm-tester.py postgres 100000
@rvprasad
rvprasad / .gitconfig
Last active August 1, 2025 22:15
.gitconfig
[core]
excludesfile = <$HOME>/.gitignore_global
autocrlf = input
[credential]
helper = cache
[alias]
adN = add -N
adu = add -u
@rvprasad
rvprasad / logging_refactoring.py
Last active December 4, 2025 00:07
Transform logging statements
"""Transform logging statements.
Dependencies:
1. refactor: https://pypi.org/project/refactor/
"""
import ast
import re
import refactor
@rvprasad
rvprasad / AndroidManifest.xml
Last active September 17, 2023 04:20
Initialization Order of Android Components
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.dummy">
<application
android:label="@string/app_name"
tools:targetApi="31"
android:name=".MyApplication">
<provider
@rvprasad
rvprasad / synchronized_collection_issue.jsh
Last active December 18, 2021 22:17
Illustrates the absence of thread safety between various methods of SychronizedSet and its iteraror method.
Collection<Integer> ss = Collections.synchronizedSet(new HashSet<Integer>());
new Thread() {
public void run() {
for (int x = 0; x < 1000; x++) {
ss.addAll(IntStream.range(x*1000, (x + 1)*1000)
.boxed()
.collect(Collectors.toList()));
}
}
}.start()
@rvprasad
rvprasad / update_packages_to_new_r_version.r
Last active October 2, 2021 21:49
Update existing packages to new version of R
library(gtools)
installed <- c()
update <- function(p) {
pd <- packageDescription(p, fields=c('Built'))
pd <- gsub(";.*", "", pd)
if (!is.na(pd) && pd != 'R 4.0.4') { # mention the target versions here
for (d in getDependencies(p)) {
update(d)
@rvprasad
rvprasad / hostfile
Last active October 31, 2022 11:07
Compare map's performance of mpi4py module and Python's multiprocessing module
localhost slots=9
@rvprasad
rvprasad / python_performance1.py
Last active December 24, 2019 22:51
Compare performance of set and list in identifying unique values
import random
import statistics
from timeit import default_timer as timer
def time_function(f, data):
times = []
for _ in range(0, 20):
start = timer()
f(data)
times.append(timer() - start)
@rvprasad
rvprasad / modification_time_based_file_organizer.py
Last active December 23, 2019 05:31
Group files based on the their modification time. Great for organizing photos and videos. Requires Python 3.7+.
import argparse
import glob
import hashlib
import logging
import os
import pathlib
import re
import shutil
import sys
import time
@rvprasad
rvprasad / test_mulitprocessing_shared_memory.py
Last active July 8, 2022 15:43
Explores performance of shared memory support available in multiprocessing library in Python 3.8.
# Python -- v3.8
from multiprocessing import Process, Queue, managers
import time
def worker(id, data, queue, *args):
tmp1 = time.time()
if args:
for i in range(args[0], args[1]):