A couple weeks ago I needed to easily convert HTML entities in a string back to their normal representation, but I didn’t really find anything nice, and wound up just using str.replace(/&/g, "&").replace(/'/g, "'"); since those were the only characters I was having a problem with at the time.

But today I went searching again for something better, and found a really great way to escape and unescape HTML entities. Not sure why I didn’t find his post the first time, I guess my Google-fu was weak that day.

Anyway, I’ve wrapped his methods up in a little helper class, and it works great:

package com.grooveshark.utils
{

    public class HTMLEntityUtils
    {
        import flash.xml.XMLDocument;
        import flash.xml.XMLNode;
        import flash.xml.XMLNodeType;

        public function HTMLEntityUtils()
        {
        }

        public static function htmlEscape(str:String):String
        {
            return XML(new XMLNode(XMLNodeType.TEXT_NODE, str)).toXMLString();
        }

        public static function htmlUnescape(str:String):String
        {
            return new XMLDocument(str).firstChild.nodeValue;
        }
    }
}

Hope it helps someone else!

Welcome to Grooveshark Lite!

April 15th, 2008

Grooveshark Lite is now officially live.

Grooveshark Lite takes all the long-tail P2P musical goodness of Grooveshark.com and distills it in a handy quick interface to find and listen to whatever you want. Unlike the main Grooveshark site, you don’t have to have an account or install our Sharkbyte client in order to listen to music. However, signing up for an account (it’s super easy!) allows you to save playlists, and your login will work for both Lite and the main Grooveshark site.

We’re hoping that you’ll find Grooveshark Lite to be the easiest way to listen to whatever you can think of.

We have tons of things planned that didn’t quite make it into this iteration, so keep an eye out for exciting new features over the next few weeks. And if you have any comments, suggestions, ideas, wishlists, problems, or just want to say hi, drop us an email at feedback@grooveshark.com. Or you can leave me a comment here and I’ll do my best to answer you personally.

We just upgraded a few other systems at the same time, so if things are a little shaky, just give us a little time and things ought to smooth out.

I’d love to talk more about Grooveshark Lite, but I’ve been here at the office for over 18 hours straight now, trying to make sure my baby gets off the ground right, so I’m not entirely lucid anymore.

Enjoy the music!

Flex and Fonts

April 15th, 2008

This was extremely frustrating, so I’m posting in the hopes that I can save others the same frustration.

So as you may know from my recent posts, I’ve been working on a huge Flex app for Grooveshark. We’re getting ready to launch it (probably in the next few hours actually), and our lead designer John and I were going through the app for some final visual tweaks. Button labels and input boxes were lovingly pushed a pixel here, a pixel there, until they looked just right.

Then we saw the app on Linux. It looked HORRIBLE. Half the text was far too low. You couldn’t even see the tails on letters like ‘g’ and ‘y’. Suspicious, we checked it on a Windows machine. The text was also lower than on my Mac, though not as bad as on Linux. Windows only was only lower by about 4 pixels, Linux more like 10-15. I was baffled. Flash is Flash is Flash, right? The font was an embedded OpenType version of Helvetica that we bought just for this purpose. Why would the font render differently depending on the operating system?

I read about Flash’s different font managers, and thought perhaps the issue was that using an OpenType font forces the use of the AFEFontManager instead of the BatikFontManager. So I tried embedding a TrueType font instead, but it made no difference. The text was still just as skewed in Linux and Windows as it was before.

Eventually I found this blog post and decided that embedding the font via SWF was worth a try. I had originally decided to embed via a font file instead of swf because swf seemed to add more bulk to the compiled app, and honestly, this app is already huge.

Anyway, I embedded Helvetica via SWF instead of OpenType, and it worked! The application now renders identically cross-platform. So if anyone else out there is having trouble with cross-platform font rendering in Flex, try embedding your fonts via SWF.

Nearly there…

April 14th, 2008

Just over 1 Month…

Average of 67.5 hours a week…

Over 21,000 lines of MXML and Actionscript 3…

Grooveshark Lite preview

Me and Jay have been working our asses off for the last month, and all that effort is about to pay off. I’m going to sleep for days…

Installed a theme

March 11th, 2008

Got tired of looking at the default theme, and we’re hitting some serious crunch time at work, so I’m definitely not going to have time to make a personalized theme for at least a month. So, going with a theme for now.

Childish, I know…

March 11th, 2008

So, just writing a quick note while I wait for Skyler, Colin, and Jay to fix this error on one of our development servers, since I can’t really continue to debug the thing I was currently debugging in Grooveshark Lite until it’s fixed.

I’d like to share this error with you:
DB cannot poop

Apparently this is an error that we’re throwing. A typo, of course, but an unintentionally hilarious one.

Edit: Ah. Apparently it’s more of an Easter Egg than a typo, albeit one that a user would never see on the production server.

So for the longest time (a few months now), I had *not* been able to get Flex Builder to play nicely with version control. At Grooveshark we use Subversion.

First, naively, I tried just committing the whole project folder to the repo. Then I realized all the various hidden files that Eclipse makes (like .project, etc) would also be committed, and if any other developers also starting committing work, we’d break each others projects every time one of us updated after the other committed.

So then I committed only the /source folder where the actual code lives. However, then all the hidden .svn folders that SVN created showed up in the tree view of Flex Builder’s Navigator. I could ignore that, except it also completely broke Flex’s code hinting, Outline view said nothing but ! Root, and Design mode (which I almost never use, but still…) would say nothing but, “An unknown item is declared as the root of your MXML document. Switch to source mode to correct it.”

Looking up the Design mode error on Google found a lot of people mentioning it, but no real solutions, except really stupid stuff like, ‘delete all the whitespace in your code.’ (Which, when I tried it on a small test project, surprisingly did work, until you closed Flex Builder and opened it again. Then you’d have to delete all your whitespace all over again. Obviously, this is NOT a viable solution.)

The only solution I found that looked promising was to install Subclipse into Flex Builder, and create a new project by checking the code out from the repository. So I went about trying to install Subclipse.

Read the rest of this entry »

New Toy

March 4th, 2008

Today I got a digital voice recorder (Sony ICD-B5000). It’s fairly basic as voice recorders go, but I think it will suit my needs, especially since it was under $50. It doesn’t have USB to transfer notes to computer, but since a lot of the USB voice recorders I saw were significantly more expensive, had less record time, and weren’t necessarily compatible with Macs anyway, I decided it wasn’t worth it. If I really want to back up a note off the recorder I can hook its line out to my computer’s line in and just record it with Audacity or something.

I was also considering the Olympus 4100 (not the 4100-PC, since the only difference is about $20 and non-Mac-compatible USB), or one of those things that turns your iPod into a digital recorder by plugging into the dock slot. Those were tempting, as I already carry an 80gb iPod video everywhere I go, but most of the reviews implied they drained the iPod battery super fast, and I also want to be able to easily use the recorder at work (where my iPod is usually already plugged into my computer). So if I wanted to record something, I’d have to unmount the iPod, wait for the “do not disconnect” indicator to go away, unplug it from the USB cable, plug it into the recorder adapter, wait for the iPod to change to record mode, and honestly by then whatever I had wanted to record would probably be gone.

Both the Sony and the Olympus are pretty similar in feature set. I picked it up at Best Buy, so if I decide I want to compare the two before making a final decision, I can easily return/exchange it in the next couple weeks.

There’s a lot of things I plan on using this little recorder for. One is better dream retention. Lately I’ve been having a lot of dreams in which I solve some sticky programming issue that’s been bugging me, except by the time I’m fully awake, the actual solution is gone, and all I can remember is that whatever I came up with was really cool. Hopefully I can train myself to hit the recorder when I’m still half asleep and mumble something useful into it. If nothing else, I’ll find out that my subconscious is full of crap, and my insightful sleepy solutions are actually worthless. At least I’ll know. :-P

Another use, of course, is as a ubiquitous capture system. I can just dump whatever comes to mind into it, and then later process the notes, GTD-style, so I don’t have to worry about forgetting them later. Even easier than pulling out a pen and notebook, I can just ramble into the mic and worry about sorting it out it later.

And then there’s the number one use I have planned, the one that pushed me to finally go buy a recorder in the first place: lately at Grooveshark we’ve been having a lot of discussions of processes and organization, and I find that while talking to/ranting with other people I can easily come up with many ideas, but later on when the time comes to try to explain these ideas in an email I get so caught up in grammar, semantics, and word choice, that my passion (and often my entire point) gets lost in the shuffle. I’m hoping that if I can record these discussions in the heat of the moment, that later on I’ll be better able to distill them into something that is both meaningful and constructive.

Here’s a nifty little prank you can pull on a friend (or coworker) with a Mac (works in both Tiger and Leopard). You should be fairly comfortable with working on the command line before you play with this. Also, follow these instructions at your own risk. While this procedure is pretty safe, we are going to be messing with the internal defaults of OS X. I am not responsible if you break your Mac.

Imagine this: You accidentally left your computer unlocked when you left for the evening. When you came back the next day, your wallpaper has been changed to something …humorous. So you sigh, and change your wallpaper back. Except, a few minutes later, the wallpaper is back. No matter how many times you change your wallpaper, the other image just keeps coming back a few minutes later. Restarting does not help. You also notice other little inconsistencies, like, whenever you go to reset your wallpaper, System Preferences still says it’s set to your original wallpaper, even though that’s obviously not what’s being displayed. And every couple of minutes, the Dock flickers. What’s going on?

Read the rest of this entry »

If you’d like to see where I work, look no further! Office Snapshots, a very cool blog that showcases the offices of various tech and web 2.0 companies from around the world, has posted some pictures of Grooveshark’s offices.

Tech startups tend to be full of really creative people, and it’s awesome to see what various places have done with their space. It gives you a little insight into the sort of people that work there, and the culture they’ve created. Some of the featured offices are truly inspiring.

PS: My desk is visible in the 3rd and 4th pictures. It’s the one with the plant, but not the plant with the lamp.