Skip to content

Instantly share code, notes, and snippets.

View stripathi669's full-sized avatar

Shivam Mani Tripathi stripathi669

View GitHub Profile
@stripathi669
stripathi669 / settings.py
Last active March 4, 2019 04:05
Slack Error logger for Django
...
# Slack error handling
from django.utils.log import DEFAULT_LOGGING
LOGGING = DEFAULT_LOGGING
LOGGING['handlers']['slack_admins'] = {
'level': 'ERROR',
'filters': ['require_debug_false'], # Remove this fileter (make empty array) to test on debug
@stripathi669
stripathi669 / jquery-file-download.js
Created March 31, 2021 11:26
jQuery File Download from URL
// if you have url pointing to a file and you want to download a file with a click, normally you can do <a href='url'>.
// But this doesn't work if serving domain and file url domain are not same. This is browser secuirty measure
//For those case, you can use the code below
function downloadFileFromURL(url, filename) {
$.ajax({
type: "POST",
url: url,
data: params,
success: function(response, status, xhr) {
@stripathi669
stripathi669 / schema_extractor.py
Created November 7, 2024 06:38
LLM Based SQL Writing bot
import psycopg2
from psycopg2 import sql
def get_table_structure(db_name, user, password, host='localhost', port='5432'):
try:
# Connect to the PostgreSQL database
connection = psycopg2.connect(
dbname=db_name,
user=user,