Wednesday, November 30, 2011

Conway's Game of Life in the Cloud


Conway's Game of Life is a cellular automaton consisting of a 2-dimensional grid of cells each of which is either dead or alive. Each cell undergoes state transitions according to its own state and the states of its eight neighboring cells. When a cell is alive, it remains alive if two or three of its neighboring cells are also alive, otherwise it dies. When a cell is dead, it changes to alive if three of its neighboring cells are alive, otherwise it remains dead. Though an individual cell is quite simple, the aggregate behavior of many cells can be quite complex. For example, the lightweight spaceship is an example of a configuration of cells that essentially moves across the grid.

Although the Game of Life is a synchronous model it can be simulated using an asynchronous model (see, for example, Nehaniv '02 for details). The basic idea is to keep the cells nearly-synchronized at a local level by recording a local time at each cell. The system must ensure that the local times of neighboring cells differ by at most one unit of time. Each cell also records its previous state so that neighboring cells that lag behind a cell can catch-up. This removes the need for a global clock. It also removes the need for any global state  each cell can record its own state and its (most recent) view of the state of its neighboring cells.



The embedded video shows a lightweight spaceship moving across a 14x7 toroidal grid. The black, white and gray cells are alive, dead and recently-dead respectively. The interesting part is how this visualization was generated. The asynchronous transitions were performed using Storm, a distributed and fault-tolerant real-time computation system, running on Amazon Web Services. The definitions for the spout, the component that generates the lightweight spaceship in the first place, and the bolts, the components that perform the transitions and propagate the changes to the neighboring cells, were written using RedStorm. RedStorm integrates JRuby with Storm and provides a DSL for defining spouts and bolts. A subset of the changes were further propagated to Pusher using a Ruby client. A HTML5 application subscribed to these updates using Pusher's JavaScript client. It rendered the grid using a HTML5 Canvas and Backbone.js and updated the cells as necessary.

The code for the Storm topology is available on GitHub. I will add the code for the HTML5 application soon.

Tuesday, May 24, 2011

The TidySongs Hustle

The hustle:
  1. Company A sells software product for once-off fee. The product requires access to Company A's servers in order to operate.
  2. Company B acquires Company A.
  3. Company B discontinues Company A's product and shuts down their servers thereby rendering the product useless to all existing customers.
  4. Company B releases a "new" product whose functionality and interface are suspiciously similar to that of the discontinued product.
The hustlers:

In November 2010 I bought TidySongs from CloudBrain for EUR35.68. TidySongs automatically organizes your iTunes library by removing duplicates, fixing spellings, filling in blank fields and adding missing album art. It had received mostly favorable reviews. Now, when I open TidySongs I get an error stating that it cannot connect to TidySongs' server.


Their website states that TidySongs has been discontinued. They link to a product called Rinse from RealNetworks that sells for $39. It too organizes your iTunes library by removing duplicates, fixing spellings, filling in blank fields and adding missing album art. They could at least have changed the interface a little.

Thursday, March 03, 2011

Renaming Tabs in jQuery UI

jQuery UI has a very nice tab system. However, as of version 1.8.10, there isn't an easy method of dynamically renaming tabs. The main difficulty is that the tab names are stored in an unnumbered list that is parallel to the contents of the tabs. There are a number of hacks and extensions on the web but no one-liners. So here is mine:

Tuesday, March 16, 2010

Unblogging

Google Reader is more than just a feed reader. It's a cache and an archive: http://www.google.com/reader/atom/feed/FEED_URL?r=n&n=X displays the last X posts from FEED_URL even if FEED_URL itself does not contain all of its last X posts. If the author of FEED_URL deletes an old post it will not be removed from the cache. This is nothing strange, caching and archiving are part and parcel of the Internet.

However, there are a number of issues with this type of caching. Firstly, many authors try a number of "test" posts after creating a blog. If they check the posts in Google Reader, they become difficult to delete. Secondly, there is no indication when browsing Google Reader that a post may have been deleted and that the author no longer wishes the post to be public. Thirdly, there is no robots.txt mechanism to restrict caching. Fourthly, Google does not delete posts from the cache by request.

In Google's own words: "Reader caches all entries in your feed as your feed most likely only contains your most recent entries. Unfortunately, there isn't a way for Reader to tell which items have been deliberately removed from your site as opposed to having just fallen off the end of your feed. You can create a blank item with the same GUID tag as the original item to at least remove the content from Reader and other feed readers. Contact your blogging software provider for more help with this issue."

So, how do you find the GUIDs of your deleted posts? Assuming you have a Google Account and an account with Blogger, the following Ruby script will output the GUIDs of your deleted posts:



Next, you need to edit the contents of each post using http://www.blogger.com/post-edit.g?blogID=12345&postID=67890. You may also have to bring the post dates forward so that Google Reader will notice the changes.

Friday, November 27, 2009

The Electronic Campfire

"What is wrong? Why is mere opinion so dominating discussions held on the easiest medium there has ever been that can provide substantiations with just a little curiosity and work? Is the world completely reverting to an oral culture of assertions held around an electronic campfire?" (Alan Kay, 2009)

Two days ago, Standard & Poor's declared Dubai World's decision to delay their debt repayments a default. For the last two days, Dubai is trending on Twitter and blogs are awash with links to various financial reports and news items. All of these are secondary sources with more or less the same information. Although I have no interest in these developments, I have tried to locate the actual text of Dubai World's statement and failed. There has been a flurry of "they-don't-owe-us-anything" statements from financial institutions. However, there is no accessible list of creditors, authoritative or suspected. A Google search with the date range restricted to 2000-2007 is littered with news reports and blog posts from the last two days. It is unfortunate that the social and "in-the-news" aspects of the Internet can over-shadow its ability to provide substantive information when uncertainty arises.

Thursday, October 22, 2009

Irish Discussion Trends

Inspired by an analysis of computer science research trends, I wrote a simple application using Adobe Flex and Apache Lucene to analyze trends on the Irish discussion website boards.ie from 1998 to mid-2008. For example, computing only term frequencies within posts, one can observe the rise and fall of Ireland's mobile phone networks:





Please note that the 2008 dataset is incomplete, and so the results trail off for this year.

Saturday, September 19, 2009

A Book for Dummies

While leafing through Twentieth Century History For Dummies (don't ask), I came across the following dubious description (pg. 50) of Albert Einstein's contribution to twentieth century physics:

"Albert Einstein (1879-1955) sought to use quantum theory in his work on the nature of matter. Taking the tram to his work in Zürich each day, the German-born Einstein noticed that the buildings he passed appeared tall and thin when the tram was moving but settled into their old shape when the tram stopped. Were his eyes deceiving him, or perhaps did those houses actually change shape? And why didn't they change shape for the people inside them? The answer was that, unlike the people in the houses, Einstein was moving past at speed, so to him, the houses didn't just look thin. They actually were thin. Because of the speed and the direction of the tram, Einstein was looking at the houses in a different combination of space and time from people outside the tram; or, to put it another way, the nature of space and time depend on where you are. Einstein put his ideas into his Special Theory of Relativity in 1905, followed in 1907 by his General Theory of Relativity, arguing that space and time change and as they do so, they affect matter - hence the thin houses. The only thing that doesn't change, Einstein said, is the speed of light."

Trams in the early twentieth century must have traveled really fast ;-)