June 16, 2012

My Evolving Droids


(Droid -> Droid X -> Droid Razr) [stock pics]

In the past few years, mobile devices have turned into amazing little pocket computers. I'm blown away by the hardware (ARM) and software (Android) evolution.

For smartphone wireless service, I was a Verizon customer (USA) for the past decade. I've owned the flagship Droid series devices by Motorola since their first launch (currently running on the 4G LTE network). It started with a clunky original Droid, followed by a Droid X, and then the sleek Droid Razr... every year another generation of better, faster devices.

Device Specs:

Motorola Droid - Nov 2009

  • OS: Android v2.0
  • CPU: 600 MHz ARM Cortex-A8 (TI OMAP3430, 65nm)
  • RAM: 256 MB
  • Internal Storage: 512 MB
  • Screen Size: 3.7 inch
  • Resolution: 480 x 854

Motorola Droid X - July 2010

  • OS: Android v2.1
  • CPU: 1 GHz ARM Cortex-A8 (TI OMAP3630, 45nm)
  • RAM: 512 MB
  • Internal Storage: 8 GB
  • Screen Size: 4.3 inch
  • Resolution: 480 x 854

Motorola Droid Razr - Nov 2011

  • OS: Android v2.3
  • CPU: 1.2 GHz dual-core ARM Cortex-A9 (TI OMAP4430, 45nm)
  • RAM: 1 GB
  • Internal Storage: 16 GB
  • Screen Size: 4.3 inch
  • Resolution: 540 x 960

However, my life with the Moto Droids is coming to an end. I just signed up with a new wireless carrier and pre-ordered a new Sammy GS3!:


(Samsung Galaxy S3) [stock pic]

Samsung Galaxy S3 - June 2012

  • OS: Android v4.0
  • CPU: 1.5 GHz dual-core Krait (Qualcomm Snapdragon S4 MSM8960, 28nm)
  • RAM: 2 GB
  • Internal Storage: 16 GB
  • Screen Size: 4.8 inch
  • Resolution: 720 x 1280

June 14, 2012

Home Audio Setup

I work from my apartment and listen to music or talk-radio nearly 24-hours a day (even at soft volume while I sleep). My home audio setup is pretty important to me.

Here is a description of the current rig for home listening:


The Gear:

  • Media Server (Ubuntu, Logitech Media Server)
  • Touchscreen UI (Android, Squeezebox Controller)
  • Wifi Music Player (Squeezebox Touch)
  • Amplifier (Harman Kardon)
  • 5 Speakers (Polk Audio)

The Content:

Streaming Radio Networks:

MP3 Collection:


Tablet interface (Logitech Squeezebox Controller):

Web interface (Logitech Media Server 7.7.2):


Rock on!

June 4, 2012

History of Python - Development Visualization - Gource

I made a new visualization. Have a look!

History of Python - Gource - development visualization (august 1990 - june 2012)
[HD video, encoded at 1080p. watch on YouTube in highest resolution possible.]

What is it?

This is a visualization of Python core development. It shows growth of the Python project's source code over time (August 1990 - June 2012). Nearly 22 years! The source code history and relations are displayed by Gource as an animated tree, tracking commits over time. Directories appear as branches with files as leaves. Developers can be seen working on the tree at the times they contributed to the Python project.

Video:
Rendered with Gource v0.37 on Ubuntu 12.04

Music:
Chris Zabriskie - The Life and Death of a Certain K Zabriskie Patriarch

Repository:
cpython 3.3.0 alpha, retrieved from mercurial on June 2 2012


for more visualizations and other videos, check out my YouTube channel.

April 23, 2012

SST 0.2.1 Release Announcement (selenium-simple-test)

SST version 0.2.1 has been released.

SST (selenium-simple-test) is a web test framework that uses Python to generate functional browser-based tests.


SST version 0.2.1 is on PyPI: http://pypi.python.org/pypi/sst

install or upgrade with:

pip install -U sst

Changelog: http://testutils.org/sst/changelog.html
SST Docs: http://testutils.org/sst
SST on Launchpad: https://launchpad.net/selenium-simple-test


SST downloads | (Jan 1 2012 - April 23 2012)

1600+ downloads from PyPI since initial release.

April 9, 2012

Python - Getting Data Into Graphite - Code Examples

This post shows code examples in Python (2.7) for sending data to Graphite.

Once you have a Graphite server setup, with Carbon running/collecting, you need to send it data for graphing.

Basically, you write a program to collect numeric values and send them to Graphite's backend aggregator (Carbon).

To send data, you create a socket connection to the graphite/carbon server and send a message (string) in the format:

"metric_path value timestamp\n"
  • `metric_path`: arbitrary namespace containing substrings delimited by dots. The most general name is at the left and the most specific is at the right.
  • `value`: numeric value to store.
  • `timestamp`: epoch time.
  • messages must end with a trailing newline.
  • multiple messages maybe be batched and sent in a single socket operation. each message is delimited by a newline, with a trailing newline at the end of the message batch.

Example message:

"foo.bar.baz 42 74857843\n" 

Let's look at some (Python 2.7) code for sending data to graphite...


Here is a simple client that sends a single message to graphite.

Code:

#!/usr/bin/env python

import socket
import time


CARBON_SERVER = '0.0.0.0'
CARBON_PORT = 2003

message = 'foo.bar.baz 42 %d\n' % int(time.time())

print 'sending message:\n%s' % message
sock = socket.socket()
sock.connect((CARBON_SERVER, CARBON_PORT))
sock.sendall(message)
sock.close()


Here is a command line client that sends a single message to graphite:

Usage:

$ python client-cli.py metric_path value

Code:

#!/usr/bin/env python

import argparse
import socket
import time


CARBON_SERVER = '0.0.0.0'
CARBON_PORT = 2003


parser = argparse.ArgumentParser()
parser.add_argument('metric_path')
parser.add_argument('value')
args = parser.parse_args()


if __name__ == '__main__':
    timestamp = int(time.time())
    message = '%s %s %d\n' % (args.metric_path, args.value, timestamp)
    
    print 'sending message:\n%s' % message
    sock = socket.socket()
    sock.connect((CARBON_SERVER, CARBON_PORT))
    sock.sendall(message)
    sock.close()


Here is a client that collects load average (Linux-only) and sends a batch of 3 messages (1min/5min/15min loadavg) to graphite. It will run continuously in a loop until killed. (adjust the delay for faster/slower collection interval):

#!/usr/bin/env python
 
import platform
import socket
import time


CARBON_SERVER = '0.0.0.0'
CARBON_PORT = 2003
DELAY = 15  # secs


def get_loadavgs():
    with open('/proc/loadavg') as f:
        return f.read().strip().split()[:3]


def send_msg(message):
    print 'sending message:\n%s' % message
    sock = socket.socket()
    sock.connect((CARBON_SERVER, CARBON_PORT))
    sock.sendall(message)
    sock.close()


if __name__ == '__main__':
    node = platform.node().replace('.', '-')
    while True:
        timestamp = int(time.time())
        loadavgs = get_loadavgs()
        lines = [
            'system.%s.loadavg_1min %s %d' % (node, loadavgs[0], timestamp),
            'system.%s.loadavg_5min %s %d' % (node, loadavgs[1], timestamp),
            'system.%s.loadavg_15min %s %d' % (node, loadavgs[2], timestamp)
        ]
        message = '\n'.join(lines) + '\n'
        send_msg(message)
        time.sleep(DELAY)


Resources:

April 7, 2012

Installing Graphite 0.9.9 on Ubuntu 12.04 LTS

I just setup a Graphite server on Ubuntu 12.04 (Precise).

Here are some instructions for getting it all working (using Apache as web server).

It follows these steps:

  • install system dependencies (apache, django, dev libs, etc)
  • install Whisper (db lib)
  • install and configure Carbon (data aggregator)
  • install Graphite (django webapp)
  • configure Apache (http server)
  • create initial database
  • start Carbon (data aggregator)

Once that is done, you should be able to visit the host in your web browser and see the Graphite UI.


Setup Instructions:

#############################
# INSTALL SYSTEM DEPENDENCIES
#############################

$ sudo apt-get install apache2 libapache2 libapache2-mod-wsgi /
    libapache2-mod-python memcached python-dev python-cairo-dev /
    python-django python-ldap python-memcache python-pysqlite2 /
    python-pip sqlite3 erlang-os-mon erlang-snmp rabbitmq-server
    
$ sudo pip install django-tagging

#################
# INSTALL WHISPER
#################

$ sudo pip install http://launchpad.net/graphite/0.9/0.9.9/+download/whisper-0.9.9.tar.gz

################################################
# INSTALL AND CONFIGURE CARBON (data aggregator)
################################################

$ sudo pip install http://launchpad.net/graphite/0.9/0.9.9/+download/carbon-0.9.9.tar.gz
$ cd /opt/graphite/conf/
$ sudo cp carbon.conf.example carbon.conf
$ sudo cp storage-schemas.conf.example storage-schemas.conf

###########################
# INSTALL GRAPHITE (webapp)
###########################

$ sudo pip install http://launchpad.net/graphite/0.9/0.9.9/+download/graphite-web-0.9.9.tar.gz

or

$ wget http://launchpad.net/graphite/0.9/0.9.9/+download/graphite-web-0.9.9.tar.gz
$ tar -zxvf graphite-web-0.9.9.tar.gz
$ mv graphite-web-0.9.9 graphite
$ cd graphite
$ sudo python check-dependencies.py
$ sudo python setup.py install

##################
# CONFIGURE APACHE
##################

$ cd graphite/examples
$ sudo cp example-graphite-vhost.conf /etc/apache2/sites-available/default
$ sudo cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
$ sudo mkdir /etc/httpd
$ sudo mkdir /etc/httpd/wsgi
$ sudo /etc/init.d/apache2 reload

#########################
# CREATE INITIAL DATABASE 
#########################

$ cd /opt/graphite/webapp/graphite/
$ sudo python manage.py syncdb
$ sudo chown -R www-data:www-data /opt/graphite/storage/
$ sudo /etc/init.d/apache2 restart
$ sudo cp local_settings.py.example local_settings.py

################################
# START CARBON (data aggregator)
################################

$ cd /opt/graphite/
$ sudo ./bin/carbon-cache.py start

Resources:


* works on my machine, Ubuntu 12.04

Python - Graphite: Storage and Visualization of Time-series Data

I'm doing some work with Graphite in Python. Here is a quick overview of what Graphite is...


Graphite provides real-time visualization and storage of numeric time-series data.

Links:

Graphite does two things:

  • Store numeric time-series data
  • Render graphs of this data on demand

Graphite consists of a storage backend and a web-based visualization frontend. Client applications send streams of numeric time-series data to the Graphite backend (called carbon), where it gets stored in fixed-size database files similar in design to RRD. The web frontend provides 2 distinct user interfaces for visualizing this data in graphs as well as a simple URL-based API for direct graph generation.

Graphite consists of 3 software components:

  • carbon - a Twisted daemon that listens for time-series data
  • whisper - a simple database library for storing time-series data (similar in design to RRD)
  • graphite webapp - A Django webapp that renders graphs on-demand using Cairo

April 5, 2012

Python Book Giveaway - Boston Python User Group - April 12, 2012

I am bringing some of my [lightly read] Python books to give away at the next Boston Python User Group meetup.

Boston Python User Group - April Project Night
When: Thursday, April 12, 2012, 6:30 PM
Where: Microsoft NERD, Cambridge

Books:

  • Pro Python (Alchin)
  • Head First Python (Barry)
  • Programming in Python 3 (Summerfield)
  • Python Programming Patterns (Christopher)
  • Hello World! (Sande)

If you are interested in getting a free book, come to #bostonpython Project Night on April 12!