Skip to content

Instantly share code, notes, and snippets.

View rh0dium's full-sized avatar

Steven rh0dium

View GitHub Profile
@rh0dium
rh0dium / fabfile.py
Created October 31, 2011 21:32 — forked from onyxfish/fabfile.py
Pivotal Energy
from fabric.api import *
"""
Base configuration
"""
env.project_name = '$(project)'
env.database_password = '$(db_password)'
env.site_media_prefix = "site_media"
env.admin_media_prefix = "admin_media"
env.newsapps_media_prefix = "na_media"

Welcome to Drift!

Drift is an always-already versioned, cloud-backed text editor. You can use it to take notes, and save them in the GitHub cloud.

Your gists are always saved locally, and any changes you make will get pushed to GitHub's servers.

To name a gist, touch its name in the toolbar.

You can use the share button at the top-right to copy a link to one of your gists, or view it on the web in Safari.

@rh0dium
rh0dium / logger.py
Created January 26, 2013 16:14
Adds a colorizing stream handler..
# -*- coding: utf-8 -*-
"""logging.py: Django www"""
import ctypes
import logging
import platform
import os
__author__ = 'Steven Klass'
__date__ = '2/24/12 10:20 PM'
@rh0dium
rh0dium / fabfile.py
Created February 7, 2013 13:17
fabric file logging
log = logging.getLogger(__name__)
django.settings_module('settings')
from django.conf import settings
# Turn down logging..
l = logging.getLogger("ssh")
l.setLevel(logging.ERROR)
@rh0dium
rh0dium / settings_logging.py
Last active August 17, 2020 21:16
Color logging inside of PyCharm
# Get and install logutils
# pip install logutils
# === settings.py ===
class PseudoTTY(object):
"""This allows a a fake tty which will allow PyCharm to always say its a tty"""
def __init__(self, underlying):
"""Define my underlying class"""
class ColorizingStreamHandler(logging.StreamHandler):
"""
A stream handler which supports colorizing of console streams
under Windows, Linux and Mac OS X.
:param strm: The stream to colorize - typically ``sys.stdout``
or ``sys.stderr``.
"""
# color names to indices
@rh0dium
rh0dium / base.py
Created February 10, 2013 23:19
Another..
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format': "[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] %(message)s",
'datefmt': "%d/%b/%Y %H:%M:%S"
},
},
'handlers': {
{% extends "base.html" %}
{% comment %}
Author: Steven Klass <steven.klass@7stalks.com>
Copyright 2011-2013 Pivotal Energy Solutions. All rights reserved.
See the file LICENSE.txt for licensing information.
{% endcomment %}
{% block page_title %}Impersonate User List{% endblock %}
@rh0dium
rh0dium / Normalize Man Hours
Created June 4, 2015 22:22
Man hours is simply check-in time minus checkout-time. We normalize this to 8 hours per day (user modifiable) and exclude weekends. Additionally since a person cannot physically work on two files at the same time we divide it out by the number of files in the checkin. It is important to note that man hours is calculated AFTER the event takes pla…
def normalize_man_hours(**kwargs):
"""
If the time_difference is less than 8 hours than return that.
If the time difference is greater than 8 hours we need to limit it to 8 hours per
day excluding weekends.
"""
hours, minutes, seconds = kwargs.get('time_difference', "0:0:0").split(":")