Archive for November, 2007

Generating a random enum in java

Tuesday, November 20th, 2007

Here’s a code fragment for how to create a random enum in java from an Enum class object clazz (rnd is an object of type java.util.Random)


Object[] objs = EnumSet.allOf(clazz).toArray();
return objs[rnd.nextInt(objs.length)];

Generating a Random String in Java

Tuesday, November 20th, 2007

I have had a need to create a string in java. I wanted it to be clearly a string, and thus, I decided to make it all lower cases, with spaces. This is the resulting code, inspired by some googling, but since I found nothing for exactly what I wanted, I include it here:

/** In tests, I prefer my random numbers to be identical on identical runs. **/
private static Random rnd = new Random(123456789L);
private static String raw = "abcdefghijklmnoprstu ";
private String randomStr() {
    // if you want the probability of duplication to be small for 10^n iterations of this
    // code, then replace 4 with n.
    char[] chars = new char[4 + rnd.nextInt(50)];
    for (int i = 0; i < chars.length ;i++) {
        chars[i] = raw.charAt(rnd.nextInt(raw.length()));
    }
    return new String(chars);
}

Lawrence Lessig

Tuesday, November 20th, 2007

Today I stumbled upon the story of Lawrence Lessig’s attempt to strike down the ridiculous law that makes copy rights last effectively forever (unlike patents which expire after 20 odd years). It is an interesting and somewhat ironic story. He attributes his loss in the case to the fact that he was emotionally attached to logic. (my words, not his.) While the court supposedly is based on logic, they also respond to emotional arguments. Fascinating read. http://www.legalaffairs.org/issues/March-April-2004/story_lessig_marapr04.msp

My 7 ways to fix netflix

Friday, November 16th, 2007

Recently Inc.com described 5 ways to fix netflix. Only one of these really made any sense, that is “sail away from the mainstream.” The thing that netflix has to remember, the reason it even got popular to begin with, was that it started out as an uber video rental store. It simply had more of everything than any physical store could ever had. Thus it appealed to all the people who liked wacky movies, because *finally* we/they could get them. So, now netflix needs to solve the next problem. What is the next problem? In the short therm, it’s the website UI.

Let’s face it, the netflix interface sucks. So here’s what I think they need to fix, and frankly I could fix all of these for them for well under the million dollars they are spending on the netflix prize, and these features will have far more impact to their bottom line than an incremental improvement to a flawed approach to suggesting movies….

So, here it is, the feature list for netflix interface 2.0.

1. Multi-person lists! My wife and I are different people, with different movie preferences. If you want to predict my preferences, you need to know who I am, and what movies I like. So, while our house loves Starship Troopers, Aliens I, II, & III (hates IV), loves all things Jackie Chan, and hates all things Jet Lie, loves Casablanca, Room with a View, and Somewhere in Time. Those loves are not the love of one person. (And the split between people is not at all what you might think.)

2. Where’s the data on the movies? Netflix should either buy, or figure out a way to replicate IMDB, and then create a wiki for movies (probably best to follow the model of citizendium) but please be sure the wiki is a WYSWIG interface, and not one of these scary for non-computer types lame markup languages that Wikipedia / mediaWiki seems so enamored with.

3. While you’re at it, make sure I can search on producers, writers, screen writers, directors, sound men, makeup artists, special effects people, walk ons, filming locations, film locations (yes those are different), year made, year in the film, character names, a costume designer. Ultimately, I want to be able to describe a scene and have you find it, but that can be version 3.0 of the netflix interrface. I’ll settle for 2.0 here. If I want to be able to find every movie where Ayn Rand had a walk on part in, I should be able to do that. I can do that in IMDB. So, do you want me to do all my movie wandering in IMDB? I bet you don’t! Because then nothing distinguishes you from blockbuster…. Bottom line, IMDB’s search is passable. Netflix’s search is not up to par.

4. The layouts are generally incredibly wasteful of space. For example, the netflix 100 could fit in half the space and still not feel cramped. The more data you can fit on a screen, the better I’m going to feel. The fact that the top 2-3 inches of every screen is wasted “white” space doesn’t help either.

5. What’s with the lack of results on searches? If I search on “ardvarked” it tells me that there are two matches, but it doesn’t show them to me, worse, it’s probably a typo, so why aren’t you correcting my typo for me?

6. Ultimately, it’s not a fun interface to use. I feel like they are hiding stuff from me, and well, I don’t like that. For instance, does netflix have (or not have) a copy of “Penn & Teller Get Killed.” Far as I can tell, they don’t, but I don’t know that from the interface. Maybe I made a typo? Same question, but this DVD is out, what about Ardvarked.

7. DJK’s recent post about Netflix points out an issue that I’ve heard of, but not fully experienced yet. Netflix recommendations are just bad. In DJK’s recent post, the issue really has to do with the fact that the suggestion algorithms don’t take into account any negative information. i.e. the fact that DJK has probably never viewed anything with any nun in it (except for that one House episode and/or Sound of Music) should be a bit of a clue that he’s not interested in other stuff coming from a nun. Even if she is enlightened. (a contradiction in terms IMHO.) Recommendation algorithms are difficult, but netflix’s is notorious among my friends as being particularly poor relative to the competitors.

Samples

Wednesday, November 14th, 2007

Back in the days when I first had a website, one song I loved was Theme from S-Express. All those songs from that period sampled shamelessly (at least until Vanilla Ice came along.) Very neat to see that the You-Tube people are into the “this samped from that” game we used to play. I always figured the riffs at the start of Theme from S-Express were too good to be original. And now, 20 years later, I learn that they weren’t. Hilarious.

Hello There!

Wednesday, November 14th, 2007

My first post, on this website. Been a while since I’ve had a real website…. 15 years in fact. How the fly does time! Welcome, and hope you enjoy the trip. Of course, these days I is the wrong word to use. This is WE, US, All of us. That is, THEHOFFMEN!!!!