I have spent a lot of time lately working with Powershell, Microsoft's next generation command-line environment. Built on the .NET architecture, Powershell is extremely versatile and robust. It provides excellent support for dynamic manipulation of XML content, a feature that is particularly useful when used in conjunction with .NET's Internet functionality.
Earlier this week, I did a bit of experimentation and figured out how to use Powershell to interact with the Simpy social bookmark service. When I developed Ruby bindings for the Simpy REST API, the most frustrating impediment was Simpy's mildly awkward redirect system. Ruby's Net::HTTP class doesn't handle redirects automatically, so I had to manually implement support for handling a 302 response. I also had to manually create the authentication string for the header using Ruby's Base64 encoding library. Powershell handles both of those things automatically. The .NET Net.NetworkCredential object automatically generates the proper header string when provided with login information, and the Net.WebClient object's downloadString method does proper redirect handling on its own without necessitating further intervention.
Powershell handles XML very well, which also made the task much easier. Certain aspects of the XML API seem needlessly verbose or a little bit eccentric. For instance, when you use the select-object Cmdlet to access an element node, it returns the node itself rather than the value of the node in some cases. Based on my own experiments, I think that it fails to show the actual text value when the contents of the node are wrapped in a CDATA block. In order to extract the text value, one must use the get_innerText method.
The following example demonstrates how to use Simpy's REST API from the command-line to display the nicknames and tags of recent bookmarks:
> $connect = new-object Net.WebClient
> $connect.credentials = new-object Net.NetworkCredential("segphault", "XXXXXX")
> $links = [xml]$connect.downloadString("http://simpy.com/simpy/api/rest/GetLinks.do")
> $links.links.link | select {$_.nickname.get_innertext()}, {$_.tags.tag | % {$_.get_innnertext()}}
$_.nickname.get_innertext() $_.tags.tag | % {$_.get_innertext()}
--------------------------- ------------------------------------
GNOME Journal article about Tinymail {development, software, email, GNOME...
Comparison of various open source gr... {development, software, graphics, Li...
Agile programming considered (mostly... development
Metaprogramming with Ruby {Ruby, development, metaprogramming}
Linus talks like a pirate {LinuxArs, Linus, Linux Kernal, soft...
Mark Shuttleworth talks about Ubuntu... {LinuxArs, Ubuntu, Debian}
Optimal use of fonts on Linux {LinuxArs, X11, fonts}
IBM to provide commercial support fo... {LinuxArs, Eclipse, IBM}
McDonalds changes McFlurry cups to s... strange
GNOME orphaned thumbnail remover {LinuxArs, GNOME, Glade, Python...}
Note that the inability to consistently extract the text value of a node with select makes it necessary to use a loop in order to display the tags as a list. If CDATA blocks weren't so troublesome, the select invocation would be a lot more concise. Despite the minor deficiencies, Powershell is well suited for this sort of work.
I also experimented with listing tag information. The following demonstrates how to display a list of tags and the number of bookmarks associated with each tag:
> ([xml]$connect.downloadString("http://simpy.com/simpy/api/rest/GetTags.do")).tags.tag
name count
---- -----
LinuxArs 42
software 22
GNOME 8
strange 6
Mono 5
science 4
Qt 4
...
If I can find some time for further experimentation, I might throw together a few Powershell Cmdlets to automate link and tag manipulation.
Tags: shell, powershell, simpy, programming, dotnet
Posted on 2006-09-30
GNOME 2.16 has been released! With new features for many of my favorite programs, numerous bugfixes, and many aesthetic improvements, GNOME 2.16 is very polished and ready for widespread deployment. Although I tested it extensively in a virtualized VMware environment (the VMware image was kindly provided by Brent Smith), I think I'll probably wait until the official release of Ubuntu Edgy before using it on my main desktop computer.
I'm very pleased with the new features in the Evolution mail client, particularly the newly added support for a vertical message pane view. Evolution got a lot of really nice performance enhancements for this release, and the developers say that IMAP loading time is up to 48 percent faster! Maybe now Jorge will complain less often about Evolution's IMAP deficiencies. Gedit now has a sidebar file browser plugin as well as support for LaTeX authoring. With a built-in snippets system and support for scripting with Python, Gedit is quickly becoming a powerful tool.
For a more comprehensive overview of new features in GNOME 2.16, check out the review I wrote for Ars Technica. Published a day before the official release, my review attracted significant attention, and has been featured on most of the open source news sites that I read on a daily basis, including: Slasdhot, OS News, Footnotes, Linux Today, and Linux Weekly News. I also submitted it to Digg, where it rapidly climbed onto the top ten list for the technology section. Needless to say, my review has spawned inevitable GNOME vs. KDE arguments in discussion threads on several sites.
The 2.16 release is the first to include Mono as an official dependency. Support for C# applications and open source .NET technology became a controversial and highly divisive issue within the GNOME community in the weeks leading up to the official module decisions. Although I was initially a sceptic when Mono was still in its infancy (at the time, I felt that it would be more productive for the open source community to focus on Parrot), the steady stream of highly impressive C# applications developed by the GNOME community quickly changed my mind. In the past year, I have been a very vocal advocate of Mono because I see .NET as the future of desktop software development. I hope that the Mono developers can keep pace with Microsoft, and I hope to see compelling new .NET features like xlinq included in Mono in the future. Released yesterday, the latest version of MonoDevelop has a lot of exciting new features, including support for inline menu editing in the Stetic GUI builder, and integrated support for ASP.net development.
My Contributions
My contributions to 2.16 were minor but much-needed. I started rewriting the documentation for various applications in the gnome-games module. I have temporarily postponed additional work on gnome-games because my professional life is quite demanding at the moment, and because at least one of the games will be removed at some point in the next cycle and I don't really know which one yet.
I also helped with the release notes for 2.16. The release notes are typically done by Davyd and Murray, both of whom are relatively articulate. For whatever reason, they weren't available to it this time, and the responsibility fell upon other volunteers from the GNOME marketing list. The whole thing was done at the last minute and Claus Schwarm ended up writing most of the initial draft. I went through it and cleaned up a lot of minor problems. I primarily fixed spelling and grammatical errors, but I also rewrote several paragraphs for the sake of clarity. Others did the same, and the end result was more or less acceptable. Brent Smith converted it to DocBook practically overnight, and included screenshots augmented by my utility. The entire process felt very rushed, and I hope that it is planned better next time. If I hadn't noticed Quim's blog entry about the release notes on PGO and posted it to the documentation mailing list, fewer members of the GNOME documentation team would have been involved. Despite the minor problems, the release notes turned out fine. Claus and Brent deserve a lot of credit for their efforts. As a aside note, now that I have seen the effects in action on numerous screenshots, I think that drop shadows should only be used on screenshots with a single window, and edge fading should only be used on screenshots that include an arbitrary portion of the screen.
I want to take this opportunity to thank everybody that was involved in making GNOME 2.16 a reality. Everybody did a great job, and I'm looking forward to contributing as we march towards GNOME 2.18!
Tags: gnome, glade, gdp, mono, monodevelop, evolution, stetic, gedit, journalism
Posted on 2006-09-07