Mobile

iPhone 2.0 User-Agent string, other iPhone/iPod data

I was preparing a report on iPhone locales from some web server logs, and noticed a few oddities. Some of the hits appear to be coming from the new 3G iPhone 2.0, check out the User-Agent strings:

# observed from 1 metrocast.net (NY) IP
Mozilla/5.0 (iPod; U; iPhone OS 2_0 like Mac OS X; en-us) AppleWebKit/525.17 (KHTML, like Gecko) Version/3.1 Mobile/5A240d Safari/5525.7
# observed from 1 optonline.net (NY) IP
Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 2_0 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5A345 Safari/525.20

The former is confirmed to be an iPhone 2.0 User-Agent string on the MacRumors Forums.

Other unusual/rare iPhone/iPod User-Agent/UA strings:

Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419 (United States)
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3
Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Cydia/1.0.2460-59

Know anything about these? Leave me a comment!

Informatics
Mobile

Comments (0)

Permalink

new R package: getopt

I just uploaded the getopt package to CRAN. This will make it easy to use command line options with Rscript #! “shebang” scripts. It’s pretty much like what is available in every other programming language (getopt.h in C, Getopt::Long in Perl), but oddly was not yet available for R. So I wrote it! :-)

Example usage, to print a sampling of a random normal variable, you might make a script named ./rnorm that contains:

#!/usr/bin/Rscript
library('getopt');
opt = getopt(c(
'verbose', 'v', 2, "integer",
'help'   , 'h', 0, "logical",
'count'  , 'c', 1, "integer",
'mean'   , 'm', 1, "double",
'sd'     , 's', 1, "double"
));
if ( !is.null(opt$help) ) {
self = commandArgs()[1];
cat(paste("Usage: ",self," [-[gh]] [-[-mean|m] <mean>] [-[-sd|s] <sd>] [-[-count|c] <count>]\n",sep=""));
q(status=1);
}
if ( is.null(opt$mean    ) ) { opt$mean    = 0     }
if ( is.null(opt$sd      ) ) { opt$sd      = 1     }
if ( is.null(opt$count   ) ) { opt$count   = 10    }
if ( is.null(opt$verbose ) ) { opt$verbose = FALSE }
if ( opt$verbose ) { write("writing...",stderr()); }
cat(paste(rnorm(opt$count,mean=opt$mean,sd=opt$sd),collapse="\n"));
cat("\n");
q(status=0);

and can be called, e.g., like:

blink:/tmp allenday$ ./rnorm  -s 10 -c 10 --mean=100 --verbose=2
writing...
80.2953014070924
109.36715703278
104.856588724070
97.7983406914681
102.163515767212
90.7613417541473
97.8344921793064
108.918662445162
100.725143995218
105.285435884127
blink:/tmp allenday$

Yay! It’s a trivial example, but this can get pretty powerful once you can start passing in data files, reading from pipes, etc. I have some more example code for doing that, but it’s not getopt related so I need to dig it up.

Ok, I seriously need to get a syntax highlighter installed on this blog. Anyone have a recommendation? Isn’t there an enscript plugin for wordpress?

Update: I installed wp-syntax. There is no R support, but the C highlighter seems to work okay… wonder what it will do if I start doing the funky <- left arrow assign syntax…

Mobile
R
Software

Comments (0)

Permalink

Moving the blog, more on streaming to the iPhone/iPod

Moving things over here from over there. The blog is not well-established so I doubt anyone will care, and this URL structure lets us bring Jordan onto the primary domain.

If I don’t get around to migrating the only useful post on the old blog, check it out, I managed to trick the iPhone to play internet radio. Yes, that means live broadcasts. iPhone can stream live video too, but I’m not ready to show it off just yet. I suspect this technique has some legs — Apple wouldn’t want to let their cash cow loose anytime soon, would they?

Mobile
Software

Comments (2)

Permalink

Streaming Audio to iPhone & iTouch

iphone playing mp3
I’m going to refer to the iPod Touch as the iTouch when I write, it’s easier.

Anyway, I bought an iTouch earlier today, or rather TinyTube bought one b/c there are a lot of Apple mobile user-agents showing up over there. We want to be able to test for the Apple devices, but there are no good iPhone emulators available that I’m aware of.

I figured out earlier how to stream video to the iPhone, and it turns out that the iTouch works the same way. Easy. Basically it uses the Range: HTTP header to buffer chunks of the file for playback. It’s progressive streaming the video. Audio files work the same way. I’ve been able to get this to work with MP3 files, but not (yet) AAC files. Great, so we can stream audio files off our server to the iTouch.

But what about MP3 net radio, does it work? Nope. I tried surfing over to Shoutcast on the iTouch and using the .pls files there to stream. No go. Looks like the iTouch doesn’t understand how to parse .pls or .m3u files. I then tried ripping an Icecast URL directly out of a .pls file. Again, no go. Looks like the iTouch doesn’t understand Icecast protocol either.

Hmm… but it is able to stream static audio files okay. So, is there a way to trick iTouch into treating the Icecast stream as a static file? Of course the answer is yes, and my next technical post will cover some of the details on how to make it happen.

For now you can just listen to the result, it’s serving up the “Groove Salad” station I found on Shoutcast. Hit this on your thing: http://sparkle.wooly.org/cgi-bin/iStream.

Mobile
Software

Comments (4)

Permalink