Skip to content

Instantly share code, notes, and snippets.

View dakrauth's full-sized avatar

David A Krauth dakrauth

View GitHub Profile
import logging.config
from django.utils.log import DEFAULT_LOGGING
# =======
# LOGGING
# =======
LOGGING_CONFIG = None
LOGLEVEL = os.getenv("LOGLEVEL", "info").upper()
@baxeico
baxeico / excel_models.py
Last active November 9, 2017 18:11
Django custom command to write model fields on an Excel file (e.g. for documentation purposes)
# coding=utf-8
from __future__ import unicode_literals
import logging
from django.core.management.base import BaseCommand, CommandError
from django.apps import apps
from xlsxwriter.workbook import Workbook
logger = logging.getLogger(__name__)
@ipmb
ipmb / settings.py
Last active October 24, 2025 14:36
Django logging example
import logging.config
import os
from django.utils.log import DEFAULT_LOGGING
# Disable Django's logging setup
LOGGING_CONFIG = None
LOGLEVEL = os.environ.get('LOGLEVEL', 'info').upper()
logging.config.dictConfig({
@akkefa
akkefa / Docker-compose V 3.3 Django setup
Last active January 24, 2019 17:21
Docker-compose V3.3 Django mysql nginx Setup
version: '3.3'
services:
django:
container_name: "django"
build:
context: ./docker/django
working_dir: /var/www
command: ["gunicorn", "-b", "0.0.0.0:8000" ,"-w" ,"4" ,"djangoapps.wsgi"]
@robbaier
robbaier / gif-optimize.sh
Last active August 6, 2024 10:17
Script to optimize GIFs. Uses Gifsicle to drop frames, increase delay, reduce color depth and optimize
#!/bin/sh
# Script: gif-optimize.sh
# Author: Rob Baier
# Description: Script used to optimize animated GIF files.
# Dependencies: Gifsicle (https://github.com/kohler/gifsicle)
# Environment: Tested on MacOS 10.12. Other *nix environments may require some tweaking.
# Usage: ./gif-optimize.sh input-filename.gif
# Helper function to convert bytes into a human-readable format
anonymous
anonymous / setup.py
Created January 11, 2017 17:38
setup.py template
#!/usr/bin/env python
# coding=utf-8
"""
python distribute file
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals, with_statement)
@patik
patik / how-to-squash-commits-in-git.md
Last active October 13, 2025 09:47
How to squash commits in git

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

@marteinn
marteinn / info.md
Last active January 21, 2024 06:57
Using the Fetch Api with Django Rest Framework

Using the Fetch Api with Django Rest Framework

Server

First, make sure you use the SessionAuthentication in Django. Put this in your settings.py

# Django rest framework
REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
 'rest_framework.authentication.SessionAuthentication'
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.