def __init__(self): for profile in bitdeli.profiles(): # Check the Profiles tab in the left side of the editor to see the # fields contained in each profile # Create objects for customer aggregates first_event = profile['events'][0] user = {'country': first_event['country'], 'stats': Counter()} if 'gravatar' in first_event: user['gravatar'] = first_event['gravatar'] self.users[profile.uid] = user # Iterate over all events stored in the profile # and update metrics accordingly for event in profile['events']: if event['event'] == 'buy': user['stats']['sales'] += event['price'] self.sales[event['product']] += 1 self.countries[event['country']] += event['price'] self.daily_sales[event['day']] += event['price'] if event['product'] == 'Beer': self.daily_beer[event['day']] += event['price'] if event['event'] == 'return': user['stats']['returns'] += event['price'] self.returns[event['product']] += 1 if event['event'] == 'feedback-positive': user['stats']['pos'] += 1 self.feedback_pos[event['product']] += 1 if event['event'] == 'feedback-negative': user['stats']['neg'] += 1 self.feedback_neg[event['product']] += 1
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']
import random from zipfile import ZipFile Title('Nokia Tech Talk') Description("Ville's slides for the presentation at Nokia in Decemeber 2012") HASHES = ['205e460b479e2e5b48aec07710c08d50', '25c7c18223fb42a4c6ae1c8db6f50f9b', 'x', 'f0a7bfdc9c509e8ea02b3ad25ba768b6', 'b42c651650ec8d3d95829c75e318af2d', 'd0ae789ef12347de8ec30b3765dd5d89', 'x', '476d8afffbfa06fa852e677848c2388d'] for profile in bitdeli.profiles(): pass random.seed(1) set_theme('playground') # slide 1 Text(head='', size=(12, 1)) Text(head='Bitdeli', size=(12, 3)) Text(head='Ville Tuulos | Co-Founder | CEO', size=(12, 4), color=2)
import bitdeli from bitdeli.widgets import Title, Description, Users, Text, set_theme, get_themes print '\n'.join(get_themes()) set_theme('safari') HASHES = [ '205e460b479e2e5b48aec07710c08d50', '25c7c18223fb42a4c6ae1c8db6f50f9b', 'x', 'f0a7bfdc9c509e8ea02b3ad25ba768b6', 'b42c651650ec8d3d95829c75e318af2d', 'd0ae789ef12347de8ec30b3765dd5d89', 'x', '476d8afffbfa06fa852e677848c2388d' ] for profile in bitdeli.profiles(): pass Text(size=(8, 2), head='All systems:', color=2) Text(size=(3, 2), head="UP!", color=3) Text(size=(12, 1)) Text(size=(4, 2), head='8 new users:', color=1) Users(size=(8, 2), large=True, data=[{'gravatar_hash': h} for h in HASHES]) Text(label='Conversions', size=(4, 2), head='8.13%', color=1) Text(label='Revenue', size=(4, 2), head='$6,412', color=3) Text(label='Avg. Latency', size=(4, 2), head='320ms', color=2) Title("Uptime is 99.5%") Description("The predicted churn rate is 8.13%")
from bitdeli import profiles from bitdeli.widgets import Widget import random for profile in profiles(): pass class Matrix(Widget): defaults = {'size': [3,3]} size = 100 data = [[random.random() for x in range(size)] for y in range(size)] Matrix(size=[12,6], color=2, data=data)