Skip to content

Instantly share code, notes, and snippets.

View bruth's full-sized avatar

Byron Ruth bruth

View GitHub Profile
import logging
# http://stackoverflow.com/a/1049375/407954
class MockHandler(logging.Handler):
def __init__(self, *args, **kwargs):
self.reset()
logging.Handler.__init__(self, *args, **kwargs)
def emit(self, record):
self.messages[record.levelname.lower()].append(record.getMessage())
@bruth
bruth / README.md
Created July 31, 2013 13:16
Django command that gives a set of subcommands a namespace. For example, a command named after an app can be defined with a set of subcommands, e.g. `python manage.py command subcommand`.

Subcommander

Managment commands are assumed to be unique across all apps in a Django project. This can lead to long or obscure command names in attempt to namespace those commands.

Subcommander acts as a proxy command giving the real commands a namespace. The subcommander module can be named after the app name or some derivation. The structure looks as follows:

myapp/
    management/
        commands/
1-00031 2
rna 1
1-00696 1
diagno 1
fas 1
f 3
age 1
pheno 1
jacob 1
fyl 3
Blinded Id 59
DNA Sample ID 19
Gender 15
Exome Availability 14
Fyler Diagnosis 11
Genotyping Availability 9
Subject Age 9
DNA Sample Type 8
Tissue Sample ID 7
Working Group 7
Blinded Id 59
DNA Sample ID 19
Gender 15
Exome Availability 14
Fyler Diagnosis 11
Genotyping Availability 9
Subject Age 9
DNA Sample Type 8
Tissue Sample ID 7
Working Group 7
Blinded Id 59
DNA Sample ID 19
Gender 15
Exome Availability 14
Fyler Diagnosis 11
Genotyping Availability 9
Subject Age 9
DNA Sample Type 8
Tissue Sample ID 7
Working Group 7
@bruth
bruth / shipitjournal.md
Last active October 16, 2021 19:43
Markdown version of Seth Godin's ShipIt Journal. Fork it. Complete it. Ship it.

Markdown version of Seth Godin's ShipIt Journal

Project:

Ship Date:

You may have already figured out these reasons for not shipping:

  • You might not know enough...
  • You might not see clearly enough...
@bruth
bruth / gist:6436966
Last active December 22, 2015 07:18
# Replace pre-Django 1.4 unquoted url syntax {% url ... %} (on Mac OS X)
egrep -l -r '{% url [^" ]+' . | grep html$ | xargs sed -E -i '' 's/{% url ([^" ]+)/{% url "\1"/g'
@bruth
bruth / fanin.go
Last active December 23, 2015 01:39
Go fan-in function
package main
import (
"log"
"sync"
"time"
)
// fanIn takes zero or more channels and merges the received data to a
// single output channel. For efficiency, the output channel should be