Posts about programming (old posts, page 19)

2008-08-11 10:34

Pickling can be expensive

When trying to serialize python data, often the first thing we look at is pickle. Well, sometimes pickle can be very expensive!

Here Post is an elixir class, which means it's an object mapped to a relational database, and comparing its properties to something is pretty much a piece of a SQL WHERE statement.

>>> print Post.important==True
posts.important = ?

What happens when we pickle it?

>>> print len(pickle.dumps(Post.important==True))
>>> print pickle.loads(s)
posts.important = :important_1

Yikes. What's a better solution?

>>> print eval('Post.important==True')
posts.important = ?

As long as we are sure no weird data will get into the eval...

2008-08-08 22:55

uRSSus: first post 0.2.10 features (has screenie)

It's running prety stable (at least for me) so I decided to fix some issues and add some features. First a screenshot:


And now text:

  • A new feature that also fixes an issue:

    vgarvardt asked about sorting by feed,for example when reading a folder. Implemented it using a "feed" column that you can enable/disable. Since your choice is persistent, there's no need to add a configuration option to the dialog.

  • Important is now Starred. I relly like google's idea of using stars at hand to mark things important. So, there they are. The star icon I did myself, in Inkscape, trying to respect the Reinhardt style. I think it looks nice.

  • Google News feeds! Yes, I know I could just go to, make a search and subscribe to the results page. Can my mom? Nope. So, when adding new feed, just choose "Create google news feed" enter some keywords, and it's ready.

    I need to add "custom fields" to the feed config dialog, though, since once it's creted it's just a regular feed with a long URL.

  • Also did some performance and reliability work, and current SVN (r476) is actually quite a bit nicer than 0.2.10 already. So there may be another release soonish.

2008-08-08 14:41

uRSSus 0.2.10 is out!

Yes friends, my desktop feed agregator uRSSus has a brand new release.

You can get it at or or via easy_install.

There is a rather large bug in that the configuration dialog may or may not work for you. Don't worry, there is no life-or-death option there, just ignore it.

As always, I am looking for a hand making it work well on Windows and Mac.

Let me know if you like it (or if you don't).

2008-08-06 17:12

uRSSus: now with configuration dialog goodness!

I felt that a "user-friendly" configuration dialog for uRSSus was not a good way to spend effort, because I expect options to change often for a while, and I didn't want an outdated dialog, either. The solution? Autogenerate a mediocre configuration dialog!

First, define what options uRSSus supports (Update: suggestion by Alejandro Cura, using tuples works much better!):

options = (
      ('alwaysShowFeed',  ('bool', False, "Always show a link to the post's feed when diplaying a post")),
      ('hideOnTrayClick', ('bool', True, "Hide the main window when clicking on the tray icon")),
      ('defaultRefresh'      ,  ('int', 1800, "How often feeds should be refreshed by default (in seconds).", 300, None )),
      ('maxPostsDisplayed'   ,  ('int', 1000, "Limit the display to this many posts. If set too high, opening 'All Feeds' may take forever", 0, None)),
      ('defaultExpiration'   ,  ('int',    7, "How long should articles be kept by default. (In days)", 0, 9999)),
      ('username',  ('string', None, 'Your Twitter user name.' )),
      ('password',  ('password', None, 'Your Twitter password.' )),

Then a little magic, and this comes out:


How magic? This magic:

class ConfigDialog(QtGui.QDialog):
  def __init__(self, parent):
    QtGui.QDialog.__init__(self, parent)
    # Set up the UI from designer

    for sectionName, options in config.options:
      # Create a page widget/layout for this section:
      for optionName, definition in options:
        if definition[0]=='bool':
          cb.setChecked(config.getValue(sectionName, optionName, definition[1]))
          layout.addWidget(cb, row, 0, 1, 2)
          self.values[sectionName+'/'+optionName]=[cb, lambda(cb): cb.isChecked()]

        elif definition[0]=='int':
          if definition[3] is not None:
          if definition[4] is not None:
          spin.setValue(config.getValue(sectionName, optionName, definition[1]))
          layout.addWidget(label, row, 0, 1, 1)
          layout.addWidget(spin, row, 1, 1, 1)
          self.values[sectionName+'/'+optionName]=[spin, lambda(spin): spin.value()]

        elif definition[0]=='string':
          text.setText(config.getValue(sectionName, optionName, definition[1]))
          layout.addWidget(label, row, 0, 1, 1)
          layout.addWidget(text, row, 1, 1, 1)
          self.values[sectionName+'/'+optionName]=[text, lambda(text): unicode(text.text())]

        elif definition[0]=='password':
          text.setText(config.getValue(sectionName, optionName, definition[1]))
          layout.addWidget(label, row, 0, 1, 1)
          layout.addWidget(text, row, 1, 1, 1)
          self.values[sectionName+'/'+optionName]=[text, lambda(text): unicode(text.text())]

        layout.addWidget(help, row, 2, 1, 1)
        layout.addWidget(separator, row+1, 0, 1, 3)

    for page, name in zip(pages,sections) :
      # Make a tab out of it
      self.ui.tabs.addTab(page, name)

My first ever thing that I just don't see how it would work without a lambda ;-)

2008-08-04 15:43

Urssus: Sorry about 0.2.9

Truly a paperbag release. But there's still hope!

While 0.2.9 had a number of bugs and awful performance, I have to say that the current svn revisions are much, much, better.

  • Snappy performance (ok, not quite snappy, but snappier than 0.2.0)
  • Finally a coherent nex/previous/whatever mechanism. The only broken piece is that posts may vanish from view when the feed is updated (and I can fix that, too).
  • Fixed issues 16,14 and 22

So, 0.2.10, coming tonight, should be a pretty good one.

2008-08-03 19:35

Urssus: 0.2.9 is out

Version 0.2.9 of uRSSus, my news agregator is out. Many new features including:

  • Different layouts (regular/widescreen/combined, aka river-of-news)
  • Twitter about things you see on uRSSus with a single click
  • Many many bugfixes
  • Lots of UI improvements

And so on.

2008-08-03 01:39

Urssus: import from google reader

It was rather easy because I didn't do the hard part (thanks authors of pyrfeed!)and now uRSSus has a simple "import my subscriptions from Google Reader" action.

All I can say is "it works for me" and "Google sure strips data from the feeds!".

It will import your tags as top-level folders (merged with whatever you already had).

Should be smart enough not to duplicate feeds or folders.

If a feed is in more than one folder, it will show in the first listed by google (no idea what the order is).

2008-08-02 23:02

Urssus: August 2nd - going small

Mostly, I spent my two hours today refactoring. But also, testing how uRSSus looks on a small screen. Take a look:


This is urssus in the configuration I liked best on my 7", 800x480 eeePC's screen.

As you can see, a more compact template for the combined view is a must, and I will implement a compact template. Or maybe just make a configuration option where you choose what template the combined view uses, to avoid the multiplication of "modes" that are the exact same thing under the hood.

Using combined view with all bars hidden and fullscreen makes for a rather large reading area, which is nice.

The performance in that limited computer was good... until the memory usage balloons. While uRSSus is not too CPU hungry, it's pretty memory intensive. There are obvious ways to improve that, of course, and I am exploring them.

BTW, I have not measured this in a while: 1957 lines of code. And still quite fun!

2008-08-01 18:29

Urssus: no release today

I had planned to release a new version today, but there are too many untested features. A list:

  • Feed reordering via drag and drop
  • Unique app. The second uRSSus just makesthe first one operate.
  • Lots of refactoring to cleanup View/Model related things.

Since it's a lot of code, it will need a day or two of testing. Or a week.

2008-07-31 22:53

Urssus: July 31st - Many small things (with not-too-cool screenshot)

Helped by the testing by vgarvardt, many issues and possible features have been fixed or implemented in the last two days. Here's an incomplete list:

  • Implemented (and later fixed) proper close-to-tray
  • Marking a folder as read marks all its children
  • The reset filter button works like Akregator's
  • The tray changes its icon when there are unread items (and shows a count in the tooltip). Icon work needed, though.
  • Double click on a post opens in external browser
  • Default refresh period is configurable (no UI yet)
  • The feed tooltip shows unread count
  • Window size and position is memorized
  • Position of the splitters is memorized
  • Toolbar titles are now reasonable (never tried to right-click a Qt toolbar before)
  • Better templates for feed and post layouts
  • Unread items/feeds are now shown bold
  • The about window has the right title and icon, and doesn't appear in the taskbar.

There is almost certainly going to be a release tomorrow.

And here's a picture:


Contents © 2000-2019 Roberto Alsina