More Feed Graphing With NNW and Ruby, The Distant Rumble of ActiveRecord

January 8th, 2009  |  Published in ruby

I did a little more fiddling with NNW & Ruby this morning. I’m working toward putting together a little attentional dashboard that gives me the attention scores for my most read feeds, then breaks things down into charts for each feed group.

Right now I’ve got eight groups:

  • mma — mixed martial arts news

  • mac — mac stuff

  • blogs — blogs that aren’t written by people I know

  • politics — blogs that are primarily political

  • miscfeeds — a collection of monitors for things like new Netflix releases, client sites I watch, Dreamhost updates, etc.

  • web — stuff to do with Web development

  • news — institutional news sources (the Oregonian, NYT, etc.)

  • people_blogs — blogs that are written by people I know

NetNewsWire has three groups it chunks in as well:

  • Latest News: everything that’s unread in all feeds

  • Flagged Items: everything I’ve flagged

  • Clippings: stuff saved from the NNW iPhone client

For purposes of NNW’s scripting dictionary, anything that’s not a feed you pull down from someone’s server somewhere is “synthetic.” So to break things down into groups and leave out NNW’s groups, I just put all the undesired groups and synthetic feeds into an array.


This morning’s efforts didn’t get me very far, but now it’s generating two graphs: one for most read feeds and one for my groups.

The people_blogs group you can see in the chart shows a low attention score, which should not be interpreted to mean I don’t read blogs by people I know much. They’re actually at the top of my list of things to read each day, but I also tend to keep moribund and likely extinct blogs in that list around indefinitely against the day the author quits dribbling precious creative fluids into Twitter. Consequently, when I get around to adding a case block to weight all the groups with NNW’s scripted attention score, the people_blogs group will get its due.


require 'rubygems'

require 'appscript'

require 'scruffy'

include Appscript

nnw = app("NetNewsWire")

# nnw doesn't differentiate between differing kinds of synthetic items

unwanted_groups = ["Clippings", "Mobile", "Flagged Items", "Latest News", "monitors", "miscfeeds"]

biglist = nnw.subscriptions.get

feeds = biglist.reject{|s| s.is_group.get != false} # get rid of folders

feeds.sort!{ |a,b| b.calculated_attention_score.get <=> a.calculated_attention_score.get}

groups = biglist.reject{|s| s.is_group.get == false} # get rid of non-folders

groups.reject!{|g| unwanted_groups.include?(g.display_name.get) }

graphs = [groups, feeds[0,9]]

graph_names = ["Groups", "Feeds"]

graphs.each do |g|

  scores = {}

  graph_name = graph_names.shift

  graph =

  graph.title = "NNW Attention Scores by " + graph_name

  graph.renderer =

  g.each do |s|

      unless unwanted_groups.include?(s.display_name.get)

        name = s.display_name.get

        score = s.calculated_attention_score.get

        title = name + " (#{score})" # get the attention score into the graph legend

        scores[title] = score



    graph.add :pie, '', scores

    graph.render  :to => "/Users/mph/Desktop/graphs/nnw_#{graph_name.downcase}_attention.png",:as => 'png'



Deeper History

The other thought that occurred to me is that I’m getting close to calling in ActiveRecord and sqlite so I can start tracking history over a longer period of time than the 90 days or so of Web history I’ve got Safari retaining. Some experimenting with Safari’s history yesterday netted me a chart with overlapping “total pages viewed by day” lines for the past month and the month previous:


The numbers aren’t very good because I was using Firefox a lot up until starting vacation, when I started using Safari more, mostly because Greasekit and Edit in Textmate cover most of the reason I’d bother keeping Firefox around (Greasemonkey and It’s All Text).

Firefox is making some improvements in AppleScript (hence Ruby via rb-appscript) support, but it’s still way off: Its broken AppleScript from FF 2.x was further broken for FF 3.x, it still doesn’t support the services menu, and it looks like, to judge the bugs I’m following, the services menu support is going to be held up for a while longer.

It’d be nice to store everything somewhere I could use a better querying language.

Anyhow … that’s what there’s time for today. Part of my overall “get right” efforts lately involve a fixed, relatively early bedtime and a fixed, relatively early wakeup time. So my extracurricular scripting is something I do over morning coffee, once I’ve got Ben ready for the day and before it’s time to announce myself to the job buy signing in on IM.

Leave a Response

© Michael Hall, licensed under a Creative Commons Attribution-ShareAlike 3.0 United States license.