Introducing BrowserCouch

15th of April 2010

Last April, Atul Varma of Mozilla posted an article on an implementation of a local storage wrapper that mimicked CouchDB's map-reduce query interface.

In the comments, my friend Mikeal posted If you could add replication this would give the current Weave stuff a run for it's money

I thought about it and this seemed like a perfect solution to what I see as one of the most important areas in the development of the web platform. Ever since Mikeal got me interested in CouchDB, I've followed its development, and been excited at how native to the web it feels. Using nothing but a REST interface, and javascript for queries, it is marvellously fast and simple.

A javascript library that wrapped both local storage and the REST interface to a CouchDB server could exploit couch's replication and versioning to provide a simple storage API whilst offline, and then transparently sync it to the server once connectivity resumed.

In a world where HTML5 is becoming the only open platform for mobile app development, and where locally stored and owned data is becoming rare, this concept was not only exciting from an engineering standpoint, but also tied in with my ideological views on open data.

For a year, the idea percolated through my head, but until about a month ago I hadn't done anything about it.

After leaving Slide last month, I had lot of free time to work on personal projects. I forked a repository on github and began almost immediately. Within a few days I had replication working.

I've been working on it off and on ever since. I'd love to hear your feedback — it's not in a stable state yet, although the unit tests run and replication to localhost works, but I'd love to get as much feedback on the API design as possible before I release a 0.1 version, as it'll be much harder to make such changes if people start to use it.

So what's on the todo-list?

Well, as was pointed out to me by the intimidatingly smart people at couchio, I'm doing replication all wrong - I need to store _seq numbers and a by sequence tree. That's the next major change I plan to make.

I also want to get Futon working on it, which will require a lot of work.

As always, feel free to fork it or comment on my commits.

(Unrelated, I'm supporting myself with contracting at the moment, so if you need some web development then please feel free to contact me)
Permalink
Posted by Peter Braden. — Modified 15/04/2010 (4 comments) Tagged: code

Red Worms

11th of March 2010

Made this a few weeks back.

Permalink
Posted by Peter Braden. — Modified 11/03/2010 (0 comments) Tagged: code jquery

Dynamically including Github code

12th of November 2009

I like writing code, and sharing it.

Often I want to post a snippet here or on another website, to illustrate a point or to share a cool trick. But pasted code is dead code - real living code changes, and short of going back and repasting, the code on the web quickly becomes out of date.

So this is a little snippet I whipped up to dynamically (by the wonders of cross-site ajax) load code from a github branch. This means, when you update the git branch and repush, the code will update.

Here it is, bootstrapped and ready, and completely up to date.

 Code available at http://github.com/peterbraden/peterbraden.github.com/blob/1ca083ed7890f5bc0d8b5555548a853ca2e6d420/github-code.js

(Standard disclaimer applies - untested on IE, YMMV. Hack at will)

Permalink
Posted by Peter Braden. — Modified 12/11/2009 (2 comments) Tagged: code jquery

Visualizing music with <canvas>

17th of September 2009
This only works in a modern browser that supports the <canvas> element.

Despite a week of meetings, interviews and uncertainty as to where I would be sleeping at night, I managed to get a little coding done this week. Continuing my experimentation with HTML5 and in particular the canvas element, I decided to write a little graphic equaliser.

I'd hoped to use the new audio element, but unfortunately the API is extremely limiting and as far as I can tell, there isn't a way to get access to the audio data in javascript. Luckily, there's an awesome library called SoundManager which provides an interface to flash's audio capabilities in javascript.

So this demo does use flash, but all the rendering is done in canvas. It's pretty CPU intensive, but a nice demo of what's possible with canvas.

The music is a recording by my good friend and ex-flatmate Marcus Phillips from his upcoming album Thirst and Burden.

As always, this has been tested in modern browsers, but won't work in IE. Also you'll need Flash 9 or above.

Permalink
Posted by Peter Braden. — Modified 17/09/2009 (2 comments) Tagged: code graphics jquery

Distributed Raytracer - Follow up

24th of August 2009

Well my server is still running, which is a nice surprise. Over 8000 people took a look at yesterday's distributed raytracer, rendering 108,000 lines between them. That's a lot more than I was anticipating — thanks to all of you for taking a look.

It became apparent today that I had done woefully little background research before posting this — Resig has posted an article about web workers that has an example of a canvas based ray-tracer that uses them to great effect. By using web workers I can get rid of a whole load of hacks that result in the currently minimal cpu usage on each node.

I think my favorite response was courtesy of thunk on Hacker News:

This is going to totally re^H^Hinvent social raytracing.

Thanks all

Permalink
Posted by Peter Braden. — Modified 24/08/2009 (0 comments) Tagged: code distributed computing graphics

Newest Items

Photography

Recent Writing

Subscribe

Like what you see?

Subscribe to the RSS feed and be notified whenever there's something new…