Ionrock Dot Org

by Eric Larson

My Weblog

If a one liner is long...

Today I came across a rather large line of Ruby code and it made me think. The line was primarily a long string, but I have seen many lines that are really long doing a set of chained operations. So, the question is, if a one liner is exceptionally long, is it still considered a one liner? The term "one liner" refers to one line of code doing an extreme amount of work. Things like Golf are good examples of writing one liners.

Personally, I don't think it can still be considered a one liner. But I'm also pretty rigorous at keeping my lines in the 80 column category, so I'm rather biased. With that said, I would also argue that placing everything on one line doesn't really make it clever, which a one liner should generally be. The idea is that you've expressed an operation in an extremely concise way, that in most cases, uses the features of the language. So, my answer is no. What about you?

Posted Tue Apr 22 18:43:52 2008 by Eric Larson

Ruby Priority Queue

Once again Uche brought an interesting bit of computer science to my attention in BC. He started using the Python heapq module to help speed up an index in BC. I had never used the module before and wasn't exactly clear at first glance how it worked. I took some time last night to implement something similar in Ruby to help get a better understanding. I ran some exceptionally unscientific tests to see if it was incredibly slow and as far as I could tell, it seemed quick enough to use. If anyone is interested in grabbing a copy you can download here . I don't plan on making any updates or maintaining something serious here, but if others have suggestions or notice any errors please send them along.

Posted Tue Apr 15 20:16:36 2008 by Eric Larson

The Problem with Leaders

Like the rest of us, I've been hearing quite a bit about politics lately. I'm a staunch supporter of keeping my political beliefs to myself, so this is not about what or who I support. Instead, I'd like to point out a pattern that is difficult to overcome.

I think Lessig has essentially brought this up with the Change Congress movement. The issue being that people are expected to vote based on some semi-qualified basis. Yet, this means that they have the responsibility to educate themselves on the issues along with how the parties and candidates plan on dealing with them. In short this doesn't scale. We don't have time to do a lot of research so we depend on other sources to help us make a decision.

The two basic categories of sources are media and associations. The media provides coverage of the issues, candidates and generally everything people are interested in. They are commercial though and must cater to the desire, not the needs, of its audience in order to survive. Associations are groups such as churches, employers, unions, clubs, or anything else that functions as a group. The issue here is that as people participate in the group, they essentially offer their impact to the group leaders in the form of endorsements. A good example is when the Teacher Union, AFL/CIO, or the AARP endorse a candidate. The group has offered to support the candidate as whole, and while the members are free to choose as they wish, the group has been the target of persuasion by the candidates and political parties.

The problem is essentially a scalability problem. No one has the resources to effectively communicate because the resources are not available in one way or another. Candidates and parties cannot speak to the public as a whole, so they turn to groups in hopes the members follow the leadership. The media must present what will be watched by an uninterested audience in order to support itself through advertising. Again, the message becomes tainted and/or misdirected in order to meet orthogonal needs.

There really is no solution, but the recent social networking movement and technology has been somewhat helpful in changing the landscape. By empowering more people to be producers of content and news, there are more opportunities to communicate messages that are unencumbered by outside forces. This doesn't imply there is truth in the messages. It simply means they are not impacted by a need to survive. The problem now is that there is a wealth of information and no way to meter and decipher it all. Again, I don't really have a solution outside of continuing to improve our use of semantic technology to find meaning and allowing interfaces that meet the needs of users.

This is actually what makes technology so interesting to me. It is the center of information, which has proven to be powerful in almost all facets of life. While answers are not easy, it is exciting to think that, at the very least, I'm working towards changing the way society works by helping further the discourse.

Posted Fri Apr 11 04:59:25 2008 by Eric Larson

XSLTemplates 0.6

The other day I released XSLTemplates 0.6. The big change is including a template constant middleware that accepts a dictionary of items to include in the template by default. It automatically includes the WSGI environ dict in the template params.

The big question is how to use it? Well, one tactic is to go ahead and add one instance around the whole app adding any configuration details. In Bright Content we list the URLs of some services that will be used in the paste config file. I then wrap my BC instance with a TemplateConstants middleware that places environment dict and application configuration details found in the .ini. You can also use it more granular by wrapping different classes with their own instances. Really the idea is to use it where you have the same parameters in many different calls so you don't have to always remember to add them to the set_params call.

The next big change is using the xsl:output element to set the content type of the output. Currently you set the content type using the calling middleware. This is not very WSGI-ish b/c there is an actually calling middleware in the sense an application controls the value. It would be more in the spirit of WSGI to pass along that control to the template renderer. With that in mind, you can set the media type attribute in the xsl:output element and that will be the content type used in the response.

This is probably the last release of XSLTemplates for a little while as we migrate things into Akara. After that, I hope we can create some built options to allow relatively granular installs of different Akara components for use in WSGI apps.

Posted Thu Apr 3 18:31:21 2008 by Eric Larson
Created using Python, jQuery and Emacs