Skip to content

Instantly share code, notes, and snippets.

View cypreess's full-sized avatar

Kris Dorosz cypreess

View GitHub Profile
import time
import datetime
class MeasureDuration:
def __init__(self, title: str = "Total time taken %s"):
self.start = None
self.end = None
self.title = title
#!/usr/bin/env python
# Author: Kris Dorosz
# Enter the root directory of your project and type `squash`
# This should squash all not tracked by git migrations and remove the old files
import delegator
from collections import defaultdict
import sys
from subprocess import call
@cypreess
cypreess / metrics.py
Last active January 18, 2019 14:06
metrics.py
import statsd
from django.conf import settings
statsd_client = statsd.StatsClient(
settings.METRICS_STATSD_HOST, settings.METRICS_STATSD_PORT
)
def metric_counter(key, value=1):
if settings.METRICS_ENABLED:
@cypreess
cypreess / pre-commit-black
Last active February 26, 2019 15:27
git pre-commit hook that automatically checks if black formatter should be applied and override files before a commit
#!/bin/bash
# Author: Kris Dorosz <[email protected]>
# This git pre commit hook will apply black formatting before any commit and make sure all tracked files are reformatted
echo "Using" `black --version`
black --check . 2>/dev/null
if [ $? -ne 0 ]; then
echo "Reformatting:"