from bitdeli import Profiles, set_theme, Title, Description
from bitdeli.textutil import Percent
from itertools import chain, groupby
from datetime import datetime
import time

WINDOW = 72 #hours
NUM_WEEKS = 4
ACTIVE_LIMIT = 2 # hours
TARGET_HOURS = 10

text = {}

set_theme('purple')

def is_success(active_hours):
    return len(active_hours) > TARGET_HOURS

def active_users(profiles):
    for profile in profiles:
        all_hours = chain.from_iterable(profile['events'].itervalues())
        active_hours = frozenset(hour for hour, count in all_hours)
        if len(active_hours) > ACTIVE_LIMIT:
            yield min(active_hours),\
                  max(active_hours),\
                  is_success(active_hours),\
                  profile.uid

def newest_active(active_profiles):
    def format(now, hour):
        t = datetime.utcfromtimestamp(hour * 3600).strftime('%Y-%m-%d %H:00')
from bitdeli import profiles, set_theme, Title, Description
from bitdeli.widgets import Text, Bar
from collections import Counter

sales = Counter()
for profile in profiles():
    for event in profile['events']:
        if event['event'] == 'buy':
            sales[event['product']] += event['price']

print 'yay'
set_theme('lipstick')

Text(head='Welcome to Bitdeli',
     size=(12,2),
     color=2)

Text(head='This board is your playground. Modify it as you wish!',
     size=(12,1),
     color=2)

Bar(label='Revenue per item',
    data=sales,
    size=(10,4),
    color=3)

Text(label='Total revenue',
     head='$%d' % sum(sales.values()),
     size=(2,4),
     color=1)
from bitdeli import profiles, set_theme, Title, Description
from bitdeli.widgets import Text, Bar
from collections import Counter

sales = Counter()
for profile in profiles():
    for event in profile['events']:
        if event['event'] == 'buy':
            sales[event['product']] += event['price']

set_theme('bluered')

Text(head='Welcome to Bitdeli',
     size=(12,2),
     color=2)

Text(head='This board is your playground. Modify it as you wish!',
     size=(12,1),
     color=2)

Bar(label='Revenue per item',
    data=sales,
    size=(10,4),
    color=3)

Text(label='Total revenue',
     head='$%d' % sum(sales.values()),
     size=(2,4),
     color=1)

Title('Welcome to Bitdeli')
from bitdeli import Profiles, set_theme, Description, Title
from itertools import chain
from datetime import datetime

WINDOW = 48
text = {}

set_theme('playground')

def date(hour):
    return datetime.utcfromtimestamp(hour * 3600).strftime('%B %d, %Y')

def total_count(profiles):
    text['total'] = total = sum(1 for profile in profiles)
    yield {'type': 'text',
           'label': 'Total number of profiles',
           'size': (6, 3),
           'data': {'head': total}}

def new_profiles(profiles):
    def stats():
        for profile in profiles:
            events = profile['events'].itervalues()
            hours = [hour for hour, count in chain.from_iterable(events)]
            yield max(hours), min(hours)
    data = list(stats())
    text['newest'] = date(max(data)[0])
    text['oldest'] = date(min(first_event for last_event, first_event in data))
    limit = max(data)[0] - WINDOW
    text['num_new'] = num = sum(1 for last_event, first_event in data
                                if first_event > limit)
from bitdeli import Profiles, set_theme, Title, Description
from bitdeli.textutil import Percent
from collections import Counter
from itertools import chain, groupby
from datetime import datetime, timedelta

NUM_WEEKS = 4

set_theme('sail')
text = {}

def is_active(profile):
    return True

def daily_active(profiles):
    def day(hour):
        return datetime.utcfromtimestamp(hour * 3600)
    days = Counter()
    for profile in profiles:
        if is_active(profile):
            events = chain.from_iterable(profile['events'].itervalues())
            days.update(frozenset(day(hour) for hour, freq in events))
    return days.iteritems()

def week_to_week(daily_stats):
    def weekly_counts():
        for week, stats in groupby(daily_stats, lambda day: day[0].isocalendar()[1]):
            yield week, sum(count for day, count in stats)

    def weekly_growth(weekly_stats):
        if len(weekly_stats) > 2:
Beispiel #6
0
from bitdeli import Profiles, Title, Description, set_theme
from bitdeli.textutil import Percent, country_name

from datetime import datetime
from collections import Counter
from itertools import chain

TOP_N = 5
TREND_WINDOW = 7  #days
TREND_NOISE_LIMIT = 25  #users
text = {'window': TREND_WINDOW, 'trend_change': Percent(0)}

set_theme('builder')


def day(hour):
    return datetime.utcfromtimestamp(hour * 3600).toordinal()


def daily_stats(profiles):
    all_stats = {}
    num_profiles_all = num_profiles_country = 0
    for profile in profiles:
        num_profiles_all += 1
        pcountries = profile['properties'].get('mp_country_code')
        if pcountries:
            num_profiles_country += 1
            for ccode, hours in pcountries.iteritems():
                country_stats = all_stats.get(ccode)
                if not country_stats:
                    all_stats[ccode] = country_stats = Counter()
from bitdeli import profiles, set_theme, Title, Description
from bitdeli.widgets import Timeline, gravatar_hash
from itertools import starmap
import re

REPO = re.compile('https://api.github.com/repos/(.*?/.*?)/git')
NUM_ITEMS = 20

text = {}

set_theme('space')

def commits():
    for profile in profiles():
        for commit in profile['commits']:
            c = commit['commit']
            if 'repo' not in text:
                text['repo'] = REPO.search(c['tree']['url']).group(1)
            yield c['committer']['date'],\
                  c['committer']['name'],\
                  c['committer'].get('email', ''),\
                  c['message']

def entry(datestr, name, email, msg):
    if 'newest' not in text:
        text['newest'] = datestr.replace('T', ' ').replace('Z', '')
    return {'gravatar_hash': gravatar_hash(email),
            'username': name,
            'message': msg,
            'timestamp': datestr}
# currently available for Bitdeli scripts.

import bitdeli
from bitdeli.widgets import *

import random
from datetime import date, datetime, timedelta
from collections import Counter
from operator import attrgetter

DAYS = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']

# The set_theme method changes the color theme of the board. Each
# theme contains a background color and three foreground colors. To
# change the color of a widget, use the color option (details below).
bitdeli.set_theme('eighties')

# Widget reference:
#
# The rest of this script generates the actual widgets shown on the
# board. The widgets are shown on the board in the order they are
# created in the script.
#
# Options common to all widgets:
# label:  a string that will be shown in the top left
#         corner of a widget
# data:   the data to be displayed, format depends on the widget type
# size:   the size of the widget on the board (see below)
#         size=[x, y] where x and y are positive integer values
# color:  an integer between 1-3, picks a color from the current theme
# group:  define the widget group for this widget (see below)
from bitdeli import Profiles, Title, Description, set_theme
from bitdeli.textutil import Percent, country_name

from datetime import datetime
from collections import Counter
from itertools import chain

TOP_N=5
TREND_WINDOW=7 #days
TREND_NOISE_LIMIT=25 #users
text = {'window': TREND_WINDOW,
        'trend_change': Percent(0)}

set_theme('builder')

def day(hour):
    return datetime.utcfromtimestamp(hour * 3600).toordinal()

def daily_stats(profiles):
    all_stats = {}
    num_profiles_all = num_profiles_country = 0
    for profile in profiles:
        num_profiles_all += 1
        pcountries = profile['properties'].get('mp_country_code')
        if pcountries:
            num_profiles_country += 1
            for ccode, hours in pcountries.iteritems():
                country_stats = all_stats.get(ccode)
                if not country_stats:
                    all_stats[ccode] = country_stats = Counter()
                country_stats.update(frozenset(day(hour) for hour, freq in hours))