Category: Web dev

Update: I have posted a more refined version of this code: parseWordpressWXR.pde.

Impressed by Jer Thorp’s quick dissection of BLDGBLOG text data at On The Verge at the SVA last week, I sat down to see how I could get text out of my WordPress installs. The result below is the result, using files exported from WordPress in their custom WXR XML format.

Processing’s XMLElement easily parsed the WXR file, which is basically a custom RSS format and hence valid XML. From there it was easy enough to extract simple parameters like title, post id and post content. As a simple test I export each post as plaintext files, which could later be used for text analysis. One tool for such text analysis is Overview from Associated Press.

Adding code to extract categories, tags and other metadata should be easy enough. The WXR also contains post attachments like images and other media, which could easily be identified and downloaded using permalinks. The code below only deals with items which have a “wp:post_type” content of “post”.

The code is fairly basic, but should nonetheless be useful for anyone wanting to do any kind of text analysis on a WordPress blog. One would need access to a WXR file, obviously.

Code: WXRtoText.pde

Read the rest of this entry »

1 Comment »

Got a nice tip from Jason Sundram (thanks!) as a followup to the screensaver theme:

Websaver runs on MacOS and allows the user to specify a web page to load when the screensaver is active. And since it uses Safari to render the HTML (I assume), you can use HTML5 and Processing.js to run computational sketches on that web page.

It’s a nice hack to enable easy development of screensavers based on open web standards, without having to worry about interaction with the OS etc. In fact, it’s nearly as good as my Google Chrome screensaver idea, minus an app store etc.

No Comments »

New piece: abstract01js. Built with Processing.js

I finally had an excuse to take Processing.js for a spin. Aram Bartholl is doing one of his Speed Show exhibitions this Wednesday (SPEED SHOW vol.4:’Super Niche’). The Speed Show format is based on taking over an internet cafe and showing artworks that can run in regular browsers without any special software.

Since most of my pieces use OpenGL they’re not suitable for web I decided to try porting an old 2D sketch to Processing.js. Rendering Processing code in the browser by using the HTML5 Canvas and Javascript is a nice idea, but I was curious to see if it would work for my purposes.

As it turns out, the code for Abstract01 from 2003 (originally created for Abstraction Now) worked on the first attempt. After a few adjustments I now have one interactive and one “automatic” version running perfectly in Firefox and Chrome. I have to say I’m officially impressed with Processing.js, my hat off to John Resig and crew!

SPEED SHOW vol.4 takes place today Wednesday, Oct.27 at 90 Bowery in Manhattan, in the 90 Bowery Internet Cafe. Here is the list of participating artists:

Erik Andersson, Cory Arcangel, Michael Bell-Smith, Charles Broskoski, Jon Cates, Aleksandra Domanovic, Doubble Happiness, Constant Dullaart, JODI, JK Keller, Greg Leuch, Olia Lialina & Dragan Espenschied, Duncan Malashock, Eva & Franco Mattes aka 0100101110101101.ORG, Aaron Meyers, Mark Napier, Katja Novitskova, Paper Rad, Jon Rafman, Ariel Rebel, Ryder Ripps, Evan Roth, Brad Troemel, Marius Watz

It’s an honor to be showing in such excellent company…

2 Comments »

"Code, Form, Space" symposium 01

Code, Space, Form, February 3-7 at CMU, Pittsburgh

The eminent Golan Levin has just announced a symposium titled “Code, Space, Form”, featuring C.E.B. Reas, MOS Architects, Ben Pell and yours truly. Hosted by Carnegie-Mellon University, it’s a multi-day affair with lectures and workshops, culminating in an exhibition at the Pittsburgh Center for the Arts. It should provide an interesting discussion of the implications of generative strategies in art and architecture.

Here is the info from Golan’s blog, hope to see you there if you’re anywhere within range of Pittsburgh:

I am delighted to announce “Code, Form, Space”, a mini-symposium about generative form and digital fabrication, which will be held at Carnegie Mellon University during the week of February 3-7. Nearly all of the events are completely free and open to the public – and include lecture presentations by such distinguished computational artist/designers as C.E.B. Reas, Marius Watz, Ben Pell, and Michael Meredith and Hilary Sample of MOS Architects. I’m co-directing this event in collaboration with Jeremy Ficca (Professor of Architecture and Director of the CMU Digital Fabrication Lab), the CMU School of Art Lecture Series, and the Pittsburgh Center for the Arts.

More information

No Comments »

Dropbox GUI

A new online storage contender: Dropbox

Digital nomads and data paranoiacs everywhere tend to be big fans of online storage, and I am no exception. I’ve been using Box.net to share large files with clients and colleagues for a long time. It’s a great service with a nice GUI, with good support for sharing files. Their service record is excellent, I’ve never had any with service outages or trouble uploading.

However, the storage limit on the basic Box.net plan is only 5 GB for $7.95 / month. They offer an upgraded plan with 15 GB, but I’m not prepared to pay $19.95 every month for a few gigabytes. I’d be happy to pay up to $10 / month, but in return I want enough storage that I can use it without worrying about running out of space. 50 gigs or more would be sufficient for that purpose.

Shopping around, I’ve found JungleDisk to be a great solution for genuine online backup. It’s based on Amazon AWS storage, and users are charged according to actual storage used. I currently store 14 gigabytes, which last month cost me a measly $3.56 for last month including transfer fees. Compared with the one-off $20 purchase of the software, this is a very reasonable option.

JungleDisk uses a desktop application for its operations, so it’s well integrated in the native file system and supports automated backup tasks. I have it set up to safeguard key folders like current projects, office documents etc. I can also access files interactively through a cached network drive, which allows me to download old projects and large media files even while travelling.

Dropbox is a new storage service that has only just come out of beta, and it looks very promising so far. It combines a dynamic web interface with a desktop application, providing the best of both worlds. The software sets up a sync’ed folder on your computer, so that editing folder structures and uploading files is as easy as copying files around your file system. Files uploaded through the web interface will be downloaded and sync’ed with the local folder.

The web interface allows you to set up file sharing with other Dropbox members. So far a few features are missing that would make it easy to share files with non-members. There is a public folder that you can use to provide public URLs to specific files, but it still lacks the important feature of sharing public folders.

According to a recent blog post Dropbox plans to offer 2 GB for free and 50 GB for $9.99 / month, or $99.99 / year. Sounds like just the right deal for my purposes. I’m looking forward to seeing how it develops. But even if I end up switching from Box.net I’ll probably keep JungleDisk for backing up larger projects.

3 Comments »

As you might have noticed I’ve replaced the code formatting plugin that I use on the blog. I had trouble with the Geshi-based plugin I used before, so I replaced it with Alex Gorbatchev’s SyntaxHighlighter. This produces lovely formatting and works well – mostly.

SyntaxHighlighter hiccups when encountering the < character unless there is a blank space directly following it, most likely due to it being interpreted as the start of a HTML tag. Also, the "copy to clipboard function produces incorrect code because the text copied has < and > characters converted into the HTML entities &lt; and &gt;. However, I’m not sure if this is a problem with SyntaxHighlighter or with WordPress, since WordPress sometimes messes with formatting by automagically trying to provide good HTML substitutes for certain character combinations.

Most frustrating of all, WordPress has started replacing the ‘s in “it’s” with a triple ellipsis character, as well as some other strangeness. Any tips for fool-proof plugins for posting properly formatted code would be most appreciated!

No Comments »

Flickr stats

Flickr now has statistics. See original size for a detailed view.

Flickr has introduced statistics as part of the feature set for Pro account holders. Like many bloggers, I suffer from obsessive-compulsive tendencies regarding stats, so this is probably the feature I missed the most on Flickr. Well, no longer will I pine for a detailed breakdown of my Flickr views.

Interestingly Flickr Stats looks and feels a bit like Google Analytics. The good side of that is that the analysis goes deep, as in breakdowns of referrers etc. which is probably more information than most people want to know. Still, it helps to explain why some of your pictures suddenly get a gazillion hits because they got Dugg or Stumbled.

Along with stats, Flickr has also released Uploadr 3.0, which adds some welcome new features such as being able to add new batches while you’re already uploading. Unfortunately, the new Uploadr seems to have quite a few bugs, so unless you’re desperate you might find it wiser to stick with the old 2.5 version until they’ve ironed out the kinks.

1 Comment »

I just added a Flickr badge to Generator.x using the excellent phpFlickr library. The code to retrieve the images from the Generator.x Flickr group is less than 20 lines. I turned it into a function and put inside a basic WP plugin shell, giving me a new API call for inserting into the sidebar.php template.

Code – gxflickr.php
/*
Plugin Name: Generator.x Flickr utilities
Plugin URI: http://www.generatorx.no/
Description: Support utilities for Generator.x web
Version: 1.0
Author: Marius Watz
Author URI: http://www.generatorx.no/
*/

require_once("phpFlickr/phpFlickr.php");

function gxFlickrSidebar() {
  $f = new phpFlickr("API_KEY");
  $f->enableCache(
    "dbname",
    "mysql://username:password@host/dbname"
  );

  echo("<div class=\"gxflickrSidebar\">");
  echo("<div class=\"gxFlickrTitle\"><a href=
      \"http://flickr.com/groups/generatorx/\">".
      "» GX on Flickr:</a> Recent images</div>");

  // get photos using the Generator.x group's ID
  $photos = $f->groups_pools_getPhotos('59096658@N00', NULL, NULL, NULL, 12);

  foreach ((array)$photos['photo'] as $photo) {
    echo "<a href=http://www.flickr.com/photos/" . $photo['owner'] .
      "/" . $photo['id'] ."/in/pool-generatorx>";
    echo "<img border='0' alt='$photo[ownername]: $photo[title]' src=" .
      $f->buildPhotoURL($photo, "Square") . ">";
    echo "</a>";
  }
  echo("</div>");
}

Once that’s done, all you need to do is insert the function call in your WordPress template:

[..html..]
  if (is_home() || is_page()) {
    gxFlickrSidebar();
  }
[..html..]

1 Comment »

JDIC embedded browser engine

Screenshot of IE running integrated with Processing and other AWT components.

For a while I’ve been wondering if it couldn’t be useful to be able to render proper HTML from inside Processing. While Processing is excellent for realtime graphics, the typographic support is a little basic when faced with the task of designing a more complex layout. Rather than write a new library, why not just use a fast HTML engine?

While there are quite a few HTML rendering engines out there, not all are very complete or indeed very fast. This might be one of the cases where using native code makes sense. Both Internet Explorer and Mozilla offer ways of embedding their rendering engines through native bindings, and after a little googling I was able to find JDIC – the JDesktop Integration Components project.

JDIC aims to bring Java applications closer to feeling like “real” desktop apps. I’m not sure if that’s a battle I would have taken on myself, but in any case they have exactly what I needed: A simplified web browser ready for embedding, able to use either IE or Mozilla as engines. A little coding later and I had a hybrid Processing / AWT application running a web browser. It will even support Flash and Java content, provided that you’ve installed the proper plugins.

The WebBrowser.setContent() function is perfect for loading your own machine-generated content, and events can be captured and processed appropriately. It would even be possible to have a hybrid application, with part of the interface being straight Processing and the rest AWT. I’m keen to try using this to create more complex on-screen layouts. HTML and CSS will always look much better than anything one could create using Swing.

See Flickr for some screenshots.

Code – JDICsample.pde

Read the rest of this entry »

12 Comments »

I’ve recently been playing with the excellent Meta-Markets.com site set up by the talented Burak Arikan. Essentially Meta-Markets is a virtual stock market for trading socially networked capital. If you have a hot blog, a popular Flickr stream or were the first poster of an essential del.icio.us bookmark you can offer it for trade through an IPO, just as if it were a company.

Each user starts out with a capital of 25 “buraks”, which can be used to buy shares in traded commodities in any of the 6 given “markets”: Flickr, Facebook, del.icio.us, Feedburner, Digg and YouTube. By offer an IPO of your own social capital you accumulate value that can be used for further trade. Ultimately the system will also include auctions and payment of dividends to stock holders.

You can make an IPO of any del.icio.us bookmarks of which you were the first poster. Finding out exactly which these are can be a drag, since del.icio.us does not provide an overview of this info. Even using the del.icio.us API won’t give you the needed information, the only way is to use the del.icio.us URL history feature. Needless to say, this can get tedious when done manually.

To address the issue I’ve hacked up a tool I call deliciousChecker. It downloads your bookmarks and then proceeds to check their posting history using HTTP calls to the history page. del.icio.us will block offensive applications that make repeated API calls, so deliciousChecker only downloads the bookmarks when there’s been an update. There is also a 15 second default delay between HTTP calls, it’s not recommended to go lower than this since Yahoo will think you’re a denial-of-service attack.

The code is written in Processing using the delicious-java and Apache Commons HttpClient libraries. The source is included, but for non-Processing users I’ve also provided precompiled applications for Mac, Windows and Linux. You must edit the “delicious.conf” config file to add your username and password.

The application can be exited safely by pressing the escape key. It also auto-saves the database with regular intervals. Upon exit (whether from interruption or upon completion) the application writes a HTML file with your bookmarks, indicating which ones were first posted by you as well as how many other users have saved them.

Downloads

6 Comments »