Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrés Álvarez aalvrz

View GitHub Profile
@aalvrz
aalvrz / middleware.py
Created May 6, 2020
Django database query alerting middleware
View middleware.py
class DatabaseQueryAlertingMiddleware:
"""
Middleware that alerts when a threshold for maximum number of database queries or total query time
is exceeded when loading views in development mode.
"""
max_queries_threshold = 30
max_time_threshold = 5 # seconds
def __init__(self, get_response):
@aalvrz
aalvrz / FileChooserCellEditor.java
Created Dec 21, 2017
Java FileChooserCellEditor
View FileChooserCellEditor.java
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.io.File;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
You can’t perform that action at this time.