GFX::Monk Home

- page 8

Node.js child processes

me: Hey node, how can I tell if my child_process.spawn() call failed before it even runs the desired command? Is there a return value? An exception? Maybe there’s an error event I can listen for?

node: Even better! Here’s an example from the documentation to do exactly that:

var spawn = require('child_process').spawn,
    child = spawn('bad_command');

child.stderr.setEncoding('utf8');
child.stderr.on('data', function (data) {
  if (/^execvp\(\)/.test(data)) {
    console.log('Failed to start child process.');
  }
});

me: Thanks, that’s… That’s just stunning.

(For extra points, this doesn’t even work if the child process inherits stderr, as my actual code does. Is this just a silly example from the documentation, or is there really nothing better?)

Stereoscoper and the Depth of Awesomeness

A few days ago I got a shiny new toy: a 3d camera from thinkgeek (I’d link to it, but it seems to have disappeared from their catalogue). I’m a massive fan of 3d photos / video, so it’s pretty cool to have a device that allows me to take stereoscopic photo pairs simultaneously (you can do it manually with a static scene, but those get boring).

Sadly (although not surprisingly), the quality is not great. The limited resolution is not really an issue given how you’re likely to view them, but the pictures come out awkwardly stretched to half the expected horizontal resolution. They are also pre-combined in a single JPEG, they are the way around for cross-eyed viewing, and the colour balance is frequently off between the two sensors (which can be really jarring).

Seeing a lot of manual photo fixing in my future, I set out to automate it. And thus stereoscoper was born, as a way to bulk-convert stereo images to other formats. Aside from the obvious geometry changes (the horizontal resolution and image placement), I also learnt all about histogram matching in order to make the colour balance consistent across stereo pairs. And in order to make animated gifs that match up nicely, there’s even an interactive mode where you can fine-tune the alignment of the image pairs.

In the wiggly-animated spirit of 3ERD (note: some images there are NSFW), here’s some fun we had in the park with my new toy:

(click to toggle each animation. It’s off by default to save your brain from having a fit ;)

(stereo)

(stereo)

(stereo)

(stereo)

Update: Click the (stereo) link under each image for a cross-eyed viewing version.

Experiment: Using Zero-Install as a Plugin Manager

So for a little while now I’ve been wanting to try an experiment, using Zero Install as a Plugin Manager. Some background:

  • Zero install is designed to be used for distributing applications and libraries.
  • One of its greatest strengths is that it has no global state, and doesn’t require elevated privileges (i.e root) to run a program (and as the name implies, there is no installation to speak of).

Since there’s no global state, it seems possible to use this as a dependency manager within a program - also known as a plugin system.

Happily, it turns out it’s not so difficult. There are a few pieces required to set it up, but for the most part they are reusable - and much simpler to implement (and more flexible) than most home-rolled plugin systems.

Tame.JS: Async Flow Control

If you are interested in my defer work with async control flow in CofeeScript, you’ll probably be interested in Tame.JS. The guys from OkCupid have a history with this sort of thing, apparently they have been using a similar mechanism they built for C++ for years.

Tame allows for more explicit control over parallelism than defer, and is a pretty simple mechanism. Contrasted to Stratified JS it seems to be simpler and more interoperable with existing javascript codebases, but also has fewer features - Tame.js is at a similar level to defer, while Stratified JS offers additional features like promise values (strata), parallel composition, alternative composition and more.

Regardless of which you prefer, it’s good to see people tackling the problem despite the common wisdom seeming to be that there is no problem (or worse, that it can be adequately addressed with libraries alone).

As usual, there’s some good commentary going on at hacker news. There are even a bunch of people wondering when such a useful mechanism will arrive in CoffeeScript ;)

(view link)

Personas: The Missing Piece of Google+ Relationships

I’ve been playing with Google+ for a little while, and think that circles (and the emphasis on using them to manage your relationships) is an excellent approach. But it still seems to me like half of the equation is missing.

In the Beginning, Friends Were Binary (and Mutual)

In Facebook, you are friends or you are not. And worse, you can only be friends if both participants agree to be friends. That might well represent close friends reasonably well, but that’s not what Facebook is used for a lot of the time, and it makes it pretty awkward when you have to decide whether to refuse someone friendship status just because you don’t really want to be inundated with their updates.

Asymmetric, Contextual Relationships

Google+ circles allow me, the viewer, to group you. I can group you by context (work, geek, etc) or by closeness (friend, acquaintance, etc). I can put you in multiple groups. I don’t have to get your permission, and you don’t even know what groups I’ve put you in. When I post, I can share with groups, and when I read posts, I can filter by group. This is all pretty splendid, because it supports a more nuanced view of relations more than just a boolean “friend” status.

But it’s only half of the equation. I can say that you are my close friend and that you are a poster of excellent geeky links, but that simply drops you wholesale into both of those contexts. I see everything that you share with me, in any context that I have placed you.

People aren’t like that. People share a number of things, for a number of reasons. I post dumb humorous quips. I post boring status updates about my sandwich and its contents. I post about political issues. I post timely banter filled with inside references to my close friends. And most frequently of all, I post about technology.

Now, I know for a fact that not everybody wants to see all of that. My high-school friends don’t care about inside jokes, but may well care about big events like my career, travel adventures, moving, etc. People who follow me for my relentless but insightful bashing of ruby and javascript probably don’t give a damn about my personal life, and may or may not care about my views on current political events. Not to mention that the current system places the same importance on “I have a sandwich” as “I have a baby” (I’m sure the latter would receive more attention, but the posts alone aren’t represented any differently).

I could use circles for this, in theory. I could send my humorous quips to those who find me funny, my geeky links to those who would be interested in them, and my discussions of sandwich contents to those I presume to be exceedingly bored. But that’s close to impossible for me to get right (even if I do, people’s preferences are bound to change without them telling me) and doesn’t deal with twitter-style followers at all - what if my geeky links are so great that people I’ve never added to a circle wish to read them? I have no problem with that, and yet circles encourages me to share those things with only those who I think would like them (or else post them too broadly, annoying my friends who don’t care for masses of geeky links).

Even those friends who do care about all of my posts probably don’t want to see them everywhere. If you’re checking up what’s going on in the lives of your friends, you don’t really want to see links to ranting articles about the state of the patent system or discussions over which is the true circle constant. And yet maybe you do want to see that when you’re cruising through your tech friends’ posts.

Personas: Two-Way Sharing Control

Blogs and other sites will often address this issue with tags or categories. If you have great opinions on programming but are an insufferable git when you ramble on about sports, I will happily just subscribe to your programming tagged posts. Personas serve the same purpose, on a personal level. A blog has categories, I have personas. Instead of forcing me to carefully pick my audience, let the choice be two-way. I’ll share as broadly as I feel comfortable, and you can view my updates only so far as they interest you. You get a more relevant stream of information, and I don’t have to self-censor so as to not be that guy who drowns out everyone else’s stream.

For a filtering example, take Vic Gundotra. He’s in my “following” circle because he posts relevant news about google+ itself that I want to be kept up to date on. He also shares photos of him and his wife, and general life news. No offence to Vic, but I don’t really care for that other stuff, and to be honest I feel a little invasive looking at pictures of him and his wife. I would very much like to see only Vic’s “google-news” persona.

Even if I want to see all of your updates, I don’t want to see them in the same place. If I want to catch up on what’s going on in the lives of the people closest to me, I don’t want to see all of my best friend’s links to geek news and neat programming ideas. I still want to read such things, but I’d much rather see them in my “geeky news” stream when I feel like catching up on that sort of thing.

Actual implementation

I imagine personas would work pretty much like tags do on a blog. You would typically use one or two, and you’d typically keep the number quite low. There’s a pragmatic issue about what happens when you add new tags, and I think the answer is for new tags to be included by default. If my best friend suddenly starts sharing heaps of neat magic tricks, it’s much easier for me to ignore that tag (once) than it would be for me to be constantly checking whether any of my friends had suddenly developed wizardly tendencies.

In practice, it seems likely there would be a relation between tags and circles. For example, I would typically share my “geek links” and “thoughts on current events” with everyone, “life updates” with friends & acquaintances, and “random babblings” with just my friends. I don’t know whether this link should be explicit (by you assigning correlations in the UI) or heuristic (I’ll bet google could make some good circle suggestions based on a set of tags, if your behaviour is fairly consistent). In the common case, it should end up little more effort for the poster than selecting circles currently is.

I’ve been told in the past that my ideas about obsessive categorisation (see: irank) are really good, but that nobody actually cares enough to put as much effort as I’m willing to. So I suspect there are a lot of people who would not be at all enthused by this idea, and the effort and complexity of adding it wouldn’t be worth it. I really hope that’s not true though, because I’d honestly love to see this implemented.

The most annoying chrome bug arrives in firefox

Ugh. I loathe the feature of chrome that hides "http://" from the address bar. You can argue that it makes the address bar less scary, but that doesn’t change the fact that it is an incomplete representation of a URL, and after 12 months they still can’t do it right and won’t provide an option to disable it.

When chrome implemented it the response to user frustration was “if something is broken, it is a bug and will be fixed”. But I’ve encountered a number of broken things that the developers either cannot fix or refuse to fix, so clearly that’s not true. Not to mention the unnecessary effort fixing all the bugs they actually did fix (this thing was horribly broken when it first landed). Perhaps firefox will actually make sure it works properly, but I doubt it.

(view link)