Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.

2010/11/29

First Real Day With Android/EVO

I received the thing Friday and poked at it all weekend. I don't think I'll have to decide to love this thing.

But I have found a problem. Or at least a non-solution.

I work in a sub-basement. This means no cell connection. I mean, if I sat six feet to the south, there's a slight chance I could get a quarter-bar just enough for a ring. But I don't. So, I have been dreaming of ways to get my phone on. My way has been Google Voice and Gizmo. This meant that I cart my netbook with me. I had been hoping that I could answer calls via WiFi, but that seems to be a no-go.

There's also a Voyage app, but it only works on GSM phones, not CDMA phones like mine. What might work is Skype, but that strikes me as a mighty big if.

So, we'll see how things go.

2010/11/17

Have Mercy! A RouteShout Signage Bug

I now live where the buses go, and I've been taking a bus to work for a little over a month. I can't say there haven't been problems, but I can and must admit that they've all been self-inflicted.

They have signs under all the bus stops saying "Text this code to 25252 and find out how long the wait is". I have tried it, and it fails.

Turns out, this is not an in-house thing, but a service provided through a company called RouteShout. There's more than just texting, though. There's an iPhone app, an Android app, a mobile site for those with older, less-smart phones and an API. That's the point where I said "cool" and dove in. And found the problem.

Say you have a bus stop. Say CityBus labelled it BUS666. Well, if you're gonna get on a bus someplace, you'll want to come back near there, too. So, we can think of BUS666 as where you get picked up and where you get let off. Except, sometimes the bus will go up and down the same road. For example, the bus I take from my apartment goes around a mall and comes back. So BUS666 is on both sides of the street. If I'm waiting on the north side of the street, I don't care about buses coming to the south side, except when they're coming around and back to the north side. So, we have BUS666N and BUS666S.

But the signs still say BUS666.

And if you text BUS666 to 25252, rather than BUS666N. Which makes the texting interface useless. And you have to get inside the API to figure out where the problem is.

(As it turns out, BUS666 is one stop, not two, and doesn't have this problem. It also is far away from anywhere I take the bus to, so using it as an example doesn't lead to people knowing where I live.)

Again, this is a signage bug. The RouteShout service works perfectly, as far as I've seen. I think I'll put together a Perl module from the API and put that on CPAN. Yay to them.

2010/11/10

Solving a Brain Teaser with word lists and Perl

I'm a programmer. When I see a problem, I get tempted to code the solution. One place where this temptation comes into play is brain teaser problems. Once, a while ago, a radio show had a brain teaster where you take the phrase PRECHRISTMAS SALE, turn it into a 4x4 block and find the longest word you can without reusing a letter. I used Perl and found six eight-letter words.

And, of course I used my powers on Sudoku.

Now, I've seen a problem that's inspired me again.
By changing one letter at a time to form different English words, and leaving all other letters in their original positions, convert SIXTH into TENTH in the fewest steps possible. Good luck!

S I X T H
_ _ _ _ _
_ _ _ _ _
_ _ _ _ _
_ _ _ _ _
_ _ _ _ _
_ _ _ _ _
T E N T H
There are Spoilers below

As I learned with PRECHRISTMASSALE, which I've since found is Boggle, if you're going to find words, you first need to know words. So, I pulled and adapted my Boggle code for coming up with a dictionary list.
sub dictionary {
    my ( $length ) = @_ ;
    my %done ;
    my %word ;
    my $dir = './Dict' ;
    my $dirhandle ;
    opendir $dirhandle, $dir ;
    my $file ;
    while ( defined( $file = readdir $dirhandle ) ) {
        next if $file =~ m(^\.)mx ;
        open my $filehandle, '<', $dir . q{/} . $file ;
        while ( <$filehandle> ) {
            chomp ;
            $_ = lc $_ ;
            next if $done{ $_ }++ ;
            next if length != $length ;
            $word{ $_ }++ ;
            }
        close $filehandle ;
        }
    closedir $dirhandle ;
    return sort { $a cmp $b } keys %word ;
    }
Of course, you need to be in the same directory as a directory full of dictionaries. I used a few I pulled from the CERIAS FTP site, and probably has some overlap, but better that then missing a word and thus a connection.

I then started poking at the words, trying to find the next. I came up with a way to get all the proper alternatives, given a word. I then pulled it into a subroutine.
sub get_word_choices {
    my ( $word ) = shift ;
    my @word = split m{}mx, $word ;
    my @output ;
    for my $pos ( 0 .. scalar @word - 1 ) {
        my @local = @word ;
        $local[ $pos ] = '.' ;
        my $local = join '', @local ;
        my @words = grep { m{$local}mx } grep { !m{$word}mx } @dictionary ;
        next if scalar @words == 0 ;
        push @output , @words ;
        }
    return @output ;
    }
I should probably pass @dictionary rather than leave it as a global, but certainly, you don't want to re-parse the dictionary file each time.

It struck me about this point that I should have all I need to automatically solve this, not leaving me to use this tool to piece something together.

I am not as happy with this part as I could be.
sub check_words {
    my $word2 = shift ;
    my @words = @_ ;
    return if scalar @words > 7 ;
    my $last = $words[-1] ;
    if ( $last eq $word2 ) {
        say '' ;
        say join ' ' , @words , scalar @words ;
        }
    my @choices = get_word_choices( $last ) ;
    #say join ' ' , @words ;
    for my $choice ( @choices ) {
        next if grep { m{$choice}mx } @words ;
        check_words( $word2 , @words , $choice ) ;
        }
    print join ' ' ,  '' , scalar @words ;
    return ;
    }
It's depth-first search and it's long. Which, I suppose, is unavoidable for depth-first search. Consider this solution:
sixth
sixte
sixty
silty
tilty
tinty
tenty
tenth 
sixth to sixty is just as legal a jump as sixth to sixte. If I used an iterative process with a better data structure, I could use a shortest path algorithm and bypass sixte. And, of course, by putting print to give me some appreciation of progress, I'm bogging the thing way down. So, that's where I'd rewrite to make this better.

2010/11/08

Somehow The New Television is listening to Me

And not in the creepy HAL2000 kind of way.

I was searching for info on Net Neutrality, wrapping my head around it, and found this bit from G4's Attack of the Show on Hulu. Next clip on the channel was on Bluetooth headsets, and it was presented by Dungeons and Dragons. Which was a bit of a wow for me.

I've been clear on this, but let me restate that I am not categorically against advertising because advertising, properly done, is content. Consider the copy of The Productive Programmer on my desk right now. The last page before the back cover is an ad that says you can read this book online for 45 days at Safari Online. If you're reading a book called The Productive Programmer, you're more than likely a programmer. Which means you deal with computers a lot. Reading this book online will make sense to you, as you read much online. It's as much content to you as the book's suggestions for Desktop shortcuts. This doesn't mean that you, as the programmer reading this book, will jump up and start reading online any more than it means that you will immediately pick up Virtual Desktop Manager to get virtual desktops on your XP dev box. But it'll be something at least interesting to you.

However, if the back-of-the-book ad was Chanel #5 or Audis or Levi's jeans, it would be far less clear that there's a connection between the audience and the advertisement. This is where mass-market media starts to fall apart. They make a statistical model of their audience, or who they want their audience to be, and advertisers who want to sell to that audience buy ads. If you are not in that statistical model, or the statistical model is too general, the ads will not speak to you.

I haven't been an RPG gamer in two decades. D&D is not going to sell me, but it seems a more natural fit to the G4 audience than cars.

2010/11/05

The New Television is similar to the (Older) New Telephone

When I was in college about a decade ago, I knew some people who didn't have a "landline", or a traditional wired telephone in their place of residence. It made sense to me for college students. If you're out and studying, going to classes, working between classes, etc., it made sense that you weren't home enough to hear your phone ringing, so it's best to just have the mobile phone and not worry about it. For students, sure that made perfect sense. For adults, however, I wasn't sure. Come ten years after, you have more and more people who are dropping the landline that are out of school. There are sticking points, like how E911 for mobile isn't quite as far as for traditional telephony*, but it's a trade-off more and more making.

I have an adapter for my old-school TV that allows me to plug my netbook's VGA and watch YouTube, or whatever, on the big screen. My Wii can do Netflix, as can my friend's iPhone. Android is coming soon. Hulu can bring most of my favorite shows to me. Not everything, but close and closer all the time. If this is true, if you can get all the moving pictures you need from the internets and don't need the co-ax run. And we're not talking people who can't afford cable. We're talking people who decided that they just didn't need another wire run and time-sink in their lives.

The comments highlight a few of the hinderances with this. First, if you want to watch live events, like sporting events or news, you're out of luck. If there's a way to see Big Bang Theory or The Marty Stuart Show or new episodes of Discovery shows online, I've yet to see it. And this model is more-or-less fine if you know what you watch and watch what you know, but it locks you out of searching through and finding the next cool thing you didn't know existed. So, TV-wise, I'm not a cord-cutter yet. But I'm moving that way.


* The two times I've had to dial 911, I was calling because of a car accident.