Skip to content

Instantly share code, notes, and snippets.

View epicserve's full-sized avatar

Brent O'Connor epicserve

View GitHub Profile
@lmann4
lmann4 / show_db_queries.py
Last active November 7, 2024 18:18
A utilitiy for adding printing and debugging queries.
import inspect
import logging
import shutil
import sys
from time import time
from types import MethodType
from typing import Optional
from django.conf import settings
from django.db import DEFAULT_DB_ALIAS, connections
@jefftriplett
jefftriplett / python-django-postgres-ci.yml
Last active March 27, 2024 04:27
This is a good starting point for getting Python, Django, Postgres running as a service, pytest, black, and pip caching rolling with GitHub Actions.
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
services:
@jefftriplett
jefftriplett / .dockerignore
Last active November 20, 2022 21:44
How I use Docker and Compose
.*
!.coveragerc
!.env
!.pylintrc
@apollo13
apollo13 / chromelogger.py
Last active May 12, 2022 01:09
Django logging to Firefox/Chrome devtools
"""
License: MIT - https://opensource.org/licenses/MIT
ChromeLogger is a protocol which allows sending logging messages to the Browser.
This module implements simple support for Django. It consists of two components:
* `LoggingMiddleware` which is responsible for sending all log messages
associated with the request to the browser.
* `ChromeLoggerHandler` a python logging handler which collects all messages.
@claar
claar / nginx.conf
Last active August 29, 2015 14:11
nginx config - FIPS complient, SSL stapling, POODLE mitigation, session caching
##
# Global SSL settings - nginx.conf in http section
##
##
# For additional performance, enable SPDY support for each site by changing the:
#
# listen 443 ssl;
#
# line to:
{% if is_paginated %}
{% load i18n %}
<ul class="pagination">
<li{% if not page_obj.has_previous %} class="disabled"{% endif %}><a href="{% if not page_obj.has_previous %}#{% else %}?page={{ page_obj.previous_page_number }}{{ getvars }}{% endif %}">&laquo;</a></li>
{% if show_first %}
<li><a href="?page=1{{ getvars }}">1</a></li>
<li><span>...</span></li>
{% endif %}
@epicserve
epicserve / db-stacktrace.html
Last active March 23, 2021 11:23
A python context manager and decorator for debugging and optimizing queries for Django management commands.
<!DOCTYPE html>
<html>
<head>
<title>DB Stacktrace</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="http://getbootstrap.com/docs-assets/css/pygments-manni.css" rel="stylesheet" media="screen">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
@epicserve
epicserve / README.md
Last active May 8, 2021 06:20
Django SSL Setup Guide

Django SSL Setup Guide

Assumptions:

  • You use Django with [Django-Storages][storages] for saving your STATIC and MEDIA files to S3
  • You use Nginx to reverse proxy to Django
  • You want to protect any URLs that start with /admin or /subscribe
@epicserve
epicserve / README.rst
Last active December 22, 2015 10:09
List the top pages for a website using Google Analytics

README

List the top pages for a website using Google Analytics. This is a base example that you could build off of to create lists on your website like, "Top Articles this Week", etc.

Installation

@jacobian
jacobian / why open source django.md
Created July 24, 2013 17:49
Our arguments for open sourcing Django
  1. The code will get better. Linus' Law: "given enough eyeballs, all bugs are shallow": we'll be able to get community contributions and bug reports, and thus the code will grow better faster than we can grow it ourselves. Also, Joy's Law - "No matter who you are, most of the smartest people work for someone else": we'll get better code from people who don't work for us than from people who do.

  2. We'll write better code. Wall's 3rd great virtual of a programmer, Hubris: we'll write better code people we don't want other people to say bad things about us. We'll do better with the world watching than with just us.

  3. Increased ability to hire. We're a 19k circ newspaper in a town most people have never heard of. Open source will help put us on the map, make us a place people actually might be interested in working.

  4. When we do hire, we'll be able to hire pe