An Oculus Rift Tap Menu

With the big Oculus/Facebook news this week I’m finally compelled to write on the blog about a fun thing I wrote for the VR headset last month. TL;DR: this video:

A little background: I got an Oculus Rift late last year after hearing some really impressive reviews for how it changes gaming. After playing a few (there are only a few) games with the headset I was a little disappointed as most developers didn’t really understand the changes required by a new medium. While bad design on the web might have negative consequences on sales or brand recognition, giving your users headaches and nausea is a step beyond any negative feeling the web can typically induce.

In general, the gameplay was pretty good. Actions that used projectile motion were so much more intuitive in VR (lobbing a grenade, throwing a basketball, etc) that it made dealing with a weird screen door in front of your face bearable. “poor UI bothers Nick, news at 11” yeah, I know It was the UI parts in between action that really bothered me.

the ui

There’s a sweet spot for UI elements to appear in front of your face. Too far away and the text isn’t readable on the limited resolution screen of the developer kit hardware. Too close and your eyes have to quickly change their focal length back and forth, a process that can cause headaches. No one had done a really great job with these elements so far and, to be fair, it was because they wanted to focus on the fun part of games in a new medium.

My biggest issue with UI made for the headset was the strange interaction of head movements and mouse. Sometimes you clicked to select things but moved the cursor with your head, other times you were jarringly disconnected from your head movement and expected to use the mouse entirely to navigate menus.

The experience might have been slightly better for those people who played games paired with a controller, I don’t think there’s the intuitive sense that a controller will move your cursor like there is with a mouse.

Regardless, I thought I could improve on the user experience for games, even if only through the UI where users adjusted the volume or similar.

The headset has an accelerometer mounted on the front for head tracking (that is how it works, after all) and it can be used for input if filtered properly. So, instead of hovering over items and selecting them by waiting or using a button, you can simply tap the side of the headset and the accelerometer will pick up the ‘jolt’ and take some action.

javascript and headsets

I mocked up a quick menu system with Three.js and Oculus-bridge to show off the idea. The menu is just a randomly generated tree of menu items. Use your head to point to a menu item and tap the headset on the side to select. To traverse up the menu, point at the back button and tap.

Oculus-bridge is an excellent project from Ben Purdy (not the first time I’ve mentioned Ben!) for getting headset data into a javascript environment. It takes data from the ODK and forwards them to the local machine via websockets so any language speaking websockets can access it. Considering the small list of supported languages for the ODK, this is invaluable if you use something other than C++ or Unity and want to integrate the headset.

From there it was just a matter of getting data from the headset into Three.js and creating a scene that created and navigated menus. The former was pretty easy as boilerplate code from Oculus-bridge was available for lens distortion and head tracking. despite overall questionable docs qualityI’ve never used Three.js previously but my idea was simple enough that I could implement most of the scene with a cursory reading of the docs.

My biggest issue turned out to be processing accelerometer data into actions reliably. surprise! signal analysis is hard!After a few simple moving average attempts that yielded poor results, I recorded some raw data and charted it so I could rerun different algorithms without having to put the headset on. Eventually first derivatives and moving averages solved most of my problems (I checked the charting stuff into github as well).

I did fail in one of my planned features though; I wanted navigating up the tree to be a left side tap while selecting was a right side tap. The part of the ODK that combines and feeds data from all the different sensors is capped at 60Hz and while this makes sense for most uses (it is highly suggested for VR that your game run at 60 FPS), it’s not quite enough resolution to see the directionality of taps.

This is one of the key points that my chart debugging turned me onto. In accelerometer data, a headset tap looks like a big spike in the direction of tap followed by a damped response in the opposite direction, repeating until your head is fully stabilized by your neck. Acceleration data is really quick, most of the sensors out there run at 1000+Hz, and for a trimmed stream of 60Hz data some of that data is just lost. In my case, the largest initial spike was frequently dropped entirely, leaving a detectable jolt but in the opposite direction. youtube comments indicate people are worried about how jarring this is, but I barely notice itIt wasn’t a good experience to tap left and navigate opposite of the intended direction so I dropped it for a more simplistic approach.

That said, it’s totally possible to access the 1000Hz stream directly from the accelerometer on the headset and fix this problem. It didn’t seem like a worthwhile approach in this case though, the modifications I would have to make to Oculus-bridge are almost certainly outside the scope of what the app should do for 99% of users.

future headsets

I expect this to be available for developers targeting DK2 and the commercial version of the headset in the future. Even though the DK2 uses that fancy camera tracking system now for positioning, the accelerometer sensor is still available (and most likely used to improve tracking).

Since the UI expects you have a hand free to tap the headset, it’s probably not likely to make it into any application where you are also holding a controller or keyboard. If this method is going to been seen in the future on one of the many competing VR headsets, it will most likely be some very niche application that requires users have their hands free. kinect integration maybe?

The Best Building in San Francisco

The Atlantic Cities has a nice look at the history of the best building in San Francisco, the Bell System building, though most people just call it 140 New Montgomery.

Yeah, it’s got Yelp and a bunch of other tech (and non-tech) companies. As the name suggests, it also housed Bell (then Pacific Bell) telephone originally. But that’s not why it’s the best building in SF.

Old East coast architecture is one of those things I miss from back home and the West coast has so few examples of it, let alone good ones or ones that survived various earthquakes. The Bell System building has a fantastic arched entryway, a stone (and terracotta) exterior that reaches for the sky and a crown with eagles that fits in with that building from the end of Ghostbusters.

It’s a little hard to find in today’s San Francisco skyline but you can be on the lookout for the strange F-shaped floor plan, usually visible in photos taken from the south or southwest. Otherwise it tends to disappear behind the newer, taller buildings downtown.


Mailer Manipulation via Soda Taxes

If you’re in San Francisco you may have received some interesting fear-based advertising today. Your first indication that something is wrong may be the bait-and-switch. The front of the mailer says:


This may confuse you as the rest of the mailer is urging you to vote against beverage taxes.

But that’s not really the point. Special interests use the bait-and-switch all the time and it’s such an easy tactic to notice that I might even count this as a point for proponents of the tax. Nobody likes to be lied to and to make it so obvious is just… sad.

The fine print is where the best lies are though. For starters you should consider who paid for the advertising. The return address just say “Coalition for an Affordable City” but in slightly smaller text below, it turns out this mailer was paid for specifically by the American Beverage Association – a member of CFAAC. The ABA is of course championed by the usual suspects at Dr Pepper Snapple Group and Pepsi-Cola North America, etc. I’m sure you can come up with the rest of the members list off the top of your head.

That’s not a lie in itself, of course, but one should always know if the people paying for your advertisements are the same people who you pay for various goods and services.

the end notes

Let’s look at more small text now! There sure are a lot of end notes for a tiny mailer. And looking closely… it seems that half the notes are just links to articles about how expensive it is to live in SF. Fascinating, but not terribly relevant (I realize there are people in this city for whom an increase in beverage price is a big deal, my issue is that they present this as half their argument and then distribute their fliers in Noe Valley where it is most definitely not a big deal). There’s just as much fear-based marketing in the little text at the bottom of the page as there is in the BIG BOLD TEXT at the top.

To be fair, the last three end notes are actually about soda taxes.

The first, a New York Times “article” – I say this because it’s a whopping 430 words long, a significant portion of which is quoting or summarizing another article – which says “Yes, this will raise some extra tax money” and also “Here’s a scholarly article on soda taxes”. The article is from 2009 and I’m completely sure that in the last five years there has been no interest or notable legislation for soda taxes in New York state that would compel the NYT to write about the subject in any form (in five minutes, nope, nope, nope).

Back to the linked article: that article says… Actually, let’s hold out on that for just a moment…

…Because the next end note is said quoted article from the previous note. The article is a summary of other studies of obesity rates and prices and does, in fact, say what the mailer wants it to say:

…small taxes or subsidies were not likely to produce significant changes in BMI or obesity prevalence…

And in practically the same breath this:

Even though they would only have a small impact on individual behavior, such interventions could have a large impact at the population level when applied broadly.

And this:

As proxies by the prices of energy-dense fast foods and sugar, adolescents’ and adults’ weight was found to be price sensitive.

The article goes on to state that soda is in a very similar state to cigarettes before the grand tax increases of the last 30 years which has been credited with significant declines in smoking. Mostly it just says “here are some studies, they’re not really great overall but here are some conclusions we can make. And here are a bunch of ways we could make the studies better in the future.”

The last end note is part of the California Constitution that states, in somewhat cryptic legalese:

Neither the State of California nor any of its political subdivisions shall levy or collect a sales or use tax on the sale of, or the storage, use or other consumption in this State of food products for human consumption except as provided by statute as of the effective date of this section.

And which the mailer describes as “added by California voters in 1992 to prevent snack taxes”. Note the language that California uses because it cares specifically about snacks and soda. Also are drinks food? But we have an alcohol tax? As always, the laws are so clear in California.

I almost forgot to mention the implication that “we legislated against this in 1992 so let’s never reconsider our position ever again” because it’s not like California ever outlawed anything with a proposition that may have been wrong.

final snark

The point is not that you should vote for or against a soda tax. The point is that you should take a moment and look at the mailer that you agree or disagree with and find out how the sponsors are manipulating you (and they are). Then you may discard it, or call it justified and move on with your life.

Questionable Benefits of B Corps

I also thought being a C Corp prevented directors from persuing goals outside of the realm of shareholder value so it’s great to hear that this is not the case:

The problem is that its primary rationale rests on the mistaken, though widely-held, premise that existing law prevents boards of directors from considering the impact of corporate decisions on other stakeholders, the environment or society at large.

Considering this… are B Corp organizations done just as show of support? Otherwise I hardly see the point.

[via snarfed]

The Nobel Prize Peak Age Is Getting Older

As I head ever closer to 30 this year I’m looking for any excuse to beleive that your 20s are not the most creative or productive time in a person’s life. Now I’m hearing that the average Nobel Prize age is well into the late 30s and pushing later for non-abstract fields. Though I’m not currently trying for a Nobel Prize, it’s a positive note.

But everyone has always said that younger people have quantifiably better responses on cognitive function tests! Turns out this measurement may not the whole picture, there are interesting new results that suggest measuring on speed alone is a poor indicator of a good answer.

Yes, you young people may be answering your questions faster but we’re answering them better. Get off my lawn.


Homebrewing and Reproducability

It’s been a while since I mentioned beer, specifically the White House Honey Porter recipe (currently in bottles! Very tasty!), but if you’ve seen me in person in the last year we’ve probably talked about it – assuming you like beer.

fermentation I’ve made 4 or 5 beers over the last year and the process is starting to become second nature. I’m still not completely confident in my ability to tweak recipes or make them up from scratch but I’m experimenting with the process to figure out how I can make existing recipes taste like quality beer rather than half-assed homebrew.

I ascribe the fact that I haven’t made any really terrible beers to Rebecca’s experience with sane sterilization methods from her biology background. It all seems pretty logical now but I made quite a few mistakes in sterilization the first few times we brewed together.

If we’ve talked about beer recently than you’ve probably heard me say that homebrewing lacks reproducability. The most complex homebrew setups might have temperature on first and second fermentation but the process of moving between vessels and time spent in each vessel is still manual. Even though I’m new enough where I don’t even know if these things make a difference (though the literature talks about avoiding excess oxidation – a transfer issue), it feels like too much variability to be able to reproduce a beer recipe that you really like.

That’s why I like the idea of brewbot. Details are a little fuzzy on the kickstarter site but it’s essentially an arduino controlled brewing setup where multiple brewing steps are automated for you (ignore the part where it says “brewing… with an iPhone”, as far as I can tell the iPhone is just a way to monitor its status). Hidden away like it is, it almost feels like it takes automation too far where a machine just brews generic beer for you constantly without your input.

To some degree, homebrewing is about the different tastes that multiple brewers can get from the same recipe. Not all different tastes are bad tastes after all – take the case of Brett yeasts that are typically considered bad bugs to have in your beer, some fancy microbrews have been using Brett to achive a very particular taste that’s really good.

The truth of the brewbot is that you still have to decide on a recipe and clean everything and put the system together so there’s work involved and choices to be made and that would still make brewbot brews unique.

Still, if I could brew 5 gallons of beer every two weeks (and I could, with an automated system like brewbot) I would have more beer than I could drink. A lot more.

I would really like to brew, say, 12 bottles of a different recipe every two weeks and see how each tweak changes the beer before gearing up to a 5 or 15 gallon batch. However, as I’ve been reminded by my personal biologist, these biological processes do not scale linearly and taste will vary if you’re using the same parameters for small and large batches.

It would be a good start for larger batches though. And less floor space than a brewbot machine which seems oversized for a regular kitchen from the photos. There’s always room for another kickstarter though, right?

Handy Alfred Workflows

I love Alfred (well, quicksilver then launchbar now alfred) for launching apps and doing small calculations but I was reluctant to use it for other tasks for some reason. Slowly I started replacing some common tasks with Alfred actions, first finding albums to play on iTunes and then making Fantastical entries on the fly.

I don’t pick up new alfred workflows too often because they can be very dependent on your own personal workflow; a lot of other people’s workflows don’t really fit with how I work. Plus lots of other apps have keyboard shortcuts of their own. Alfred is great for tasks where you can quickly navigate a few lists to find an item or forward some text input to another app quickly – usually chrome for searches.

So I was surprised when I found a few programming workflows that fit nicely into my routine. I picked up the package manager (I always open a new terminal window to install from brew or npm), the color converter (constantly converting between these formats for web work), and github (navigating a shallow set of lists!) and stackoverflow search.

Bring Your Old Posts to the Reboot

I love this footnote from Gina’s blog reboot:

Several years ago, I took’s original archives down because they no longer represented me, and looking back at them embarrassed me, the way reading your diary from when you were a teenager would. Over time I hope to port selected essays back to the site for posterity.

This rings particularly true for me, as I have archives from various blogs dating back to 2000 when I was actually a teenager.

Most of that content is embarassing personal stuff, I’m still amazed that I chose to put it online but relieved by the fact that no one but me really read that stuff in the first place. Unlike some people, we can’t all be perfectly happy with things we wrote 10+ years ago.

There are a few gems, however. Mostly stuff about my thoughts when I first moved out to San Francisco that I’d like to hold on to (not that I couldn’t hold on to it privately), but also some tech stuff I wrote about back then.

I like the idea of bringing selected posts back but doing it directly would probably be weird; a bunch of posts dating back to 2011 and then a smattering from 2004-5? Instead, I’ll try to bring back the tech-related ones first with some thoughts on their context and what we’ve seen since then.

The more personal ones might take longer to form a commentary on but if a blog is supposed to tell the story of who we are, it’s probably relevant to look back on a few important moments over the last ten years or so.

Jurassic Park: Nope

Ok, this is mostly me just trying out crossposting to Fine Structure, but you’ve got to admit a little part of your ten year-old self just died a bit:

Researchers studying insects from sub-fossilized fragments of copal, an amber-like resin, extracted remains of stingless bees trapped around 10,000 years ago and attempted to analyze DNA fragments found within. A few very short base pair chains matched parts from an asian bumblebee and some bacteria but nothing significant, the DNA has long since decayed and this is only after a short (geological) time.

App Configuration With URL Schemes

I just read about a neat feature for Letterpress 1.4 where savvy users can test Spanish games by loading “letterpress:experimental” in Safari and I wanted to share an alternate example that I build for a client a while back.

In this particular case, the client wanted to distribute a single app binary via enterprise distribution or ad-hoc builds to various clients of his own. The catch was that all these clients wanted the app to look customized to their own brand with logos and colors.

Not only was I opposed to building a system where I would have to build multiple versions of the same app for multiple clients, I was pretty sure that anyone maintaining that sort of system down the road would put in the extra effort to seek me out and chop off each finger that contributed to writing that code.

Instead, I developed a configuration framework that responded to a specially crafted URL scheme. The app was totally functional upon first install but a URL could be sent along in the install email which prompted users to tap on it from their iOS device.

The url scheme was passed along to the app which inferred the location of a JSON configuration file somewhere on the internet, downloaded it, parsed the file for logo urls, offsets and RGBA color components and redrew the app with these visual changes. The JSON document was stored on the local disk for easy parsing sans-connectivity on the next startup.

It required a bit of conversion to drawing customizable elements with drawRect rather than patterning images but the flexibility was worth it many times over.

For this purpose, an unsolicited plug: recreating complex photoshop-made effects in Quartz2D is pretty easy with PaintCode. Don’t let the price throw you off if visual customizability or small app size is important to you, it’s an incredible tool.

Depending on your feeling towards these fairly insecure URL schemes, you could package a username and password within them and provide users an automated way of logging in to your app. The possibilities for configuration are nearly endless and mostly underutilized, it seems.