HOWTO: August 2006 Archives

SONOS and mime-types

| | Comments (0)
Sonos Controller I ran across a fairly obscure problem with the Sonos music system related to mime-types, file extensions and dynamically generated playlists. This is fair warning that this post will get a tad technical.

The Sonos music system supports Internet radio stations and is capable of parsing remote M3U playlists. My plan was to write a simple script that retrieves the latest This American Life archives page, parses the HTML to extract the set of show URLs and returns a dynamically generated playlist with the desired show URL.

Sonos didn't like my dynamically generated playlist and it took me a while to figure out exactly why. In the end it seems the Sonos ignores Content-Type HTTP header and instead relies solely on the file extension in the URL it is accessing. In this case the file extension was .cgi and since Sonos doesn't know what .cgi means it ignored the contents of the response.

The workaround I found was to enable the execution of CGI scripts with a .m3u file extension but only in a single directory. This is the contents of the Apache-style .htaccess file I used:
Options +ExecCGI
AddHandler cgi-script m3u
AddType audio/x-mpegurl .m3u
Then I renamed my script.cgi to script.m3u and Sonos no longer complained about corrupt contents and treated it like a regular playlist. Dynamically generated This American Life playlists streaming through my Sonos. Wonderful.

I've contacted Sonos and explained the issue so hopefully they'll fix it in a future firmware update and others can avoid the headaches.

Losing Weight

| | Comments (0)
Bathroom Scale Between Jeremy Zawodny losing 50 pounds over the past year and Aaron Swartz having success with the Shangri-La Diet I decided a month ago to (again) make a serious concerted effort to lose some weight. The discovery of The Daily Plate website has been extremely helpful with this effort. It combines a calorie search engine with easy meal recording and daily weight monitoring all in a simple interface. Do a search for what you ate, click 'I Ate This' and it gets added to your daily record. Specify some information about yourself along with your weight goals and the site will provide guidelines on how many calories you should eat each day to achieve those goals. Record your weight each day and a nice graph is generated to give you visual feedback of your progress.

Losing weight is really quite simple in principle -- eat less than your body needs and your body will burn fat reserves to make up the difference -- but it was a surprise just how little I need on a daily basis and how easy it is to go over that limit. I'm trying to lose 2 pounds a week and at my age, height and current weight this means I should be eating around 1400 calories a day. Did you know that 1 tbsp of mayonnaise has 100 calories in it? It suddenly makes you think twice about how much you smear on that sandwich when it is going to consume so much of your quota for such little payoff. I'm hardly aware of the flavour anyway. Take a look at a tablespoon. It really isn't that much.

After a few days of keen awareness of each item I put into my mouth I seemed to naturally migrate towards items that satisfy my hunger with minimal calories. To eat something greasy or sugary seems like just such a waste of my daily caloric budget. Something like a donut will taste great in the short term but ultimately will make it difficult to not over-eat by the end of the day. When you have all the information the choice is actually quite simple.

During previous weight loss attempts I would down-play the need and effectiveness of exercise. I would compare the amount of exercise needed to work off, say, a piece of cake and would argue that not eating the piece of cake is much easier. That may be true, but tasty cake eating aside, doing some exercise and being able to increase your caloric intake by even a hundred calories is a very nice incentive. Once I fully grasped how quickly 1400 calories can be reached I was suddenly very interested in exercising as it gave me the ability to replenish my daily budget. A good brisk walk means a guilt-free beer with dinner. An hour of Squash or Badminton and, depending on your exertion level, you are looking at an additional meal.

I started at 188 lbs four weeks ago and am now down to 180 lbs. I love how the process is deterministic and predictable. Follow A and get B as a result. It isn't easy but it also isn't mysterious. Whether you are trying to lose weight, gain weight or just stay the same I would definitely suggest checking out The Daily Plate to get some perspective on what you consume everyday.

Fluffy Soapy Mouse

| | Comments (0)

Andrew Wilson and Patrick Baudisch of Microsoft Research have produced an excellent tutorial on creating a mouse-like pointing device that works in mid-air. I saw the video on YouTube and was seriously impressed.

Essentially the electronics of a wireless, optical mouse are re-housed in a smooth soap-like plastic container and then placed into a fluffy fabric tube. Similar to a tactile stress-reducing ball you can manipulate the fabric in various ways over the soap-like container and the optical sensor tracks the movement of the fabric and converts the actions into movement on the screen.

For fine cursor movement you slide the fabric around with your thumb. For faster movements you rotate the fabric around the container while the container stays still. And for still faster movements you can hold the fabric stationary while rotating the container just like you would a bar of soap. Check out the video for some visuals.

I was so intrigued by the video that I went out and bought a new mouse to convert and have a partially functional model to play with. The interface is very comfortable and the ability to move the cursor quickly and then do fine pixel-level adjustments requires almost no learning curve. It just comes naturally. I foresee this style of interaction becoming quite popular in the next few years.

My digital camera is inaccessible at the moment otherwise I'd post some photos of my hacky prototype. Because the mouse interaction is inverted (dragging something over the optical sensor vs vice versa) then either the up-down or left-right is reversed. I've yet been unable to find a simple mouse utility that lets me reverse one axis so for now this is an interesting prototype rather than something I can use on a daily basis.

About this Archive

This page is a archive of entries in the HOWTO category from August 2006.

HOWTO: August 2004 is the previous archive.

Find recent content on the main index or look in the archives to find all content.