It's hard to get rid of things, even harder to not acquire them in the first place. Perhaps that's because the new thing can only be seen as a positive change - its acquirer blind to any down sides. Dependencies form in strange ways. Even if it's probably bad for you and everything around you, it still manages to root itself into the new environment. You almost have to kill it to get rid of it. It's like you need the thing you don't need in order to realize you don't need it. Maybe that's why the wealthy are generally unhappy? They have the thing, realize they don't need it, and yet, cannot get rid of it. They probably can get rid of it, actually, they just choose not to for one reason or another, and it's also a hard decision to make in the first place. Why get rid of something when it can be kept around? We must have acquired it for some reason or another, right? To enhance our existence. To fix an already existing problem we've been having with something else we've acquired? Could be anything, really, we tend not to keep track of this stuff do we? Maybe we should. Maybe paying conscious attention to what we need, and what we do not need is an essential daily exercise.
Tuesday, March 26, 2013
The jQuery UI tooltip widget can be used to display contextual information about some text that a user has selected. Typically, the tooltip is used to display little tidbits about widgets or data fields in the UI — what does this do, or what does this mean? By default, the tooltip is displayed when the user hovers the mouse pointer over the element in question. But we don't want that behavior in a paragraph of text. Instead, we want the user to highlight the word or phrase they're unsure about. It is then that we lookup in our knowledge base something useful to tell the user, displayed through the tooltip widget.
Friday, March 22, 2013
Just like list comprehensions, dictionary comprehensions help the Python programmer quickly construct an alternative structure from something more permanent. The application we're working with probably has a schema, and from that, we can only do so much as we implement new functionality over time. So rather than alter the data model that supports the application, why not create something transient? This is where the comprehension idea is powerful, at very efficiently constructing new data sources. You can use this approach to creating new lists and dictionaries that stick around for the duration of the program, but a more useful use case is in creating a temporary search space.
Wednesday, March 20, 2013
Flot charts work nicely in jQuery projects. Especially since it's targeted for jQuery-based code. These charts can work well in jQuery UI projects too because they're very granular in their configuration values. You can make the charts look like they're seamlessly integrated into your theme. There was, however, one place I was having trouble with until recently — tooltips. I like being able to show the user some more detail when they hover over data points. Flot even provides an example of how to do this using a generic tooltip component, constructed on the fly. I want to show jQuery UI tooltips using the same approach. This is what I came up with.
Sunday, March 17, 2013
We can use the libvirt API to get network traffic at the interface level. So to meter the network traffic at the domain level, we have to find all interfaces the domain is using, and aggregate the traffic stats. This isn't too difficult — we just have to query the running domains, and query their XML descriptions individually in order to find the interfaces we need. One challenge we might face, using this approach, is the fact that any two interfaces could be using different networks. For example, let's say that we only want network traffic on the default network? Here is an example of how to generate this network traffic in Python. We're using the collections and the etree modules.