Skip to content

Instantly share code, notes, and snippets.

View thulasi-ram's full-sized avatar

Thulasi Ram thulasi-ram

View GitHub Profile
@thulasi-ram
thulasi-ram / keybase.md
Created September 20, 2023 05:03
Keybase

Keybase proof

I hereby claim:

  • I am thulasi-ram on github.
  • I am 0x12c (https://keybase.io/0x12c) on keybase.
  • I have a public key whose fingerprint is E7F2 CDAE BEE2 7D90 E899 3E9B 0F23 8D15 ADD0 A7BF

To claim this, I am signing this object:

@thulasi-ram
thulasi-ram / resume.json
Last active September 14, 2023 20:58
JsonResume
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics":
{
"name": "Damodharan Thulasiram",
"label": "Staff Software Engineer",
"image": "",
"email": "thulasi503@gmail.com",
"phone": "(+91) 9840561688",
"url": "https://ahiravan.dev",
@thulasi-ram
thulasi-ram / sentry_setup.py
Created July 14, 2023 13:33
Sentry Automated Project Setup - Includes Alerting for Slack and Pagerduty
"""
Inspiration: https://gist.github.com/nikolaik/85e19b89223686b9ab560822fb63bc01
Quickstart:
1. Setup a virtualenv
2. pip install requests pydantic rich click python-dotenv
3. python sentry_setup_v2.py
"""
import json
"""
Courtesy of https://github.com/loftylabs/django-hardcopy
"""
import platform
import subprocess
from pathlib import Path
from tempfile import NamedTemporaryFile
from reseller import app
"""
A poor man's implementation of celery like async task manager.
Hacked in under 2 hours.
Author: Thulasi
Usage:
app = Flask(__name__)
tasker = Tasker(app, rabbitmq_params={'hostname': 'amqp://guest:guest@localhost:5672/reseller'})
or
# -*- coding: utf-8 -*-
from gevent import monkey
monkey.patch_all()
import logging
import time
from amqp import PreconditionFailed
@thulasi-ram
thulasi-ram / worker.py
Created October 13, 2017 22:41
A worker script that resizes itself based on number of messages in rabbitmq. This is based on Gevent. Make sure you profile your throughput before settling on a logic with size.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
gevent expandable queue consumer
"""
import sys
from gevent import monkey
monkey.patch_all()
@thulasi-ram
thulasi-ram / log_conf.py
Created June 2, 2017 11:48
Split config for a Django Project.
import logging
from config.utils.json_encoders import ObjectEncoder
def get(log_root=None, formatter=None, handler=None):
if not formatter:
formatter = 'logstash_fmtr'
if not handler:
# -*- coding: utf-8 -*-
import re
"""
Exemplo didático de implementação de programação orientada
a aspectos com Python.
Sem otimizações que seriam prematuras
Caso deseje um uso real programação orientada a aspectos com python,
existem alguns projetos bem mantidos em repositórios apropriados
@thulasi-ram
thulasi-ram / CustomCursorWrapper.py
Last active March 17, 2017 12:42
If Django is facing Database Timeouts frequently.
"""
TO OVERRIDE DJANGO's CursorWrapper which causes to use dead connections.
Use case: Deployed Pgbouncer and if its terminating your connections and django thinks it's still alive.
On attempt to access db django's psycopg driver raises DatabaseError.
WARNING: Have tested only on postgres. Didn't test the effect of this on rollbacks and edge cases.
"""
from django.db.backends.utils import CursorWrapper