Airbears login script

Logging into airbears through the browser each time my laptop connects is a pain. This script made it less painful:


#!/usr/bin/perl -w
use strict;
$|++;

use File::Basename;
use WWW::Mechanize 0.72;

my $mech = WWW::Mechanize->new(  );

$mech->get( "https://wireless-gw1.berkeley.edu/logon" );
$mech->success() or die "Couldn't connect to wireless login page",
    $mech->response->status_line;

# Select the form, fill the fields, and submit

$mech->form_name( "logonForm" );

$mech->set_visible([text=>"username"],[password=>"password"]);

$mech->click("logon_action");
$mech->success or die "Wireless login didn't seem to work.:",
    $mech->response->status_line;

print "Logged onto Airbears.\n";

I needed to install the libwww-mechanize-formfiller perl package before it ran:
sudo apt-get install libwww-mechanize-formfiller-perl

Yoinked and (slightly) corrected from Yossi Farjoun.

messaging

I’ve been thinking about a peer-to-peer message passing network for short-range radio communications. The system should be useful for various scales of devices, from longer-range mobile installations (in a vehicle using commercial bands) to short-range person-to-person systems implemented in the ISM bands. Hardware like TI’s eZ430-RF2500 eval kit would be an ideal development platform.

One problem inherently present in such a system is that of identification of other nodes. In an open network, any available node may accept and transmit messages (though only the intended recipient may read them). However, in order for efficient message passing, there must be a system to identify nodes.

Not all users will be comfortable with the idea of broadcasting their identity to the world at large. They may only be comfortable participating as an anonymous node. Others may prefer only to reveal their identity to other nodes they trust. This presents a problem: How do two nodes identify themselves securely to each other, without revealing their identity to untrusted parties?

I propose an exchange system as follows:
Alice sees a nearby unidentified node (Bob).
Alice sends a message asking if Bob wishes to know her identity.
Bob responds with a randomly generated one-use key to encrypt the next message with.
Alice responds with a message encrypted with the public keys of all her trusted nodes, and further encrypts this message using Bob’s one-use key.
Bob decrypts the outer message using the one-time key, then attempts to decrypt the enclosed message using his private key.
If Alice trusts Bob, he can do this, and finds within her message a temporary key to use for further communications with her.
Bob continues communication with Alice using this new key.

At this point, Alice knows that she trusts Bob, but does not actually know his identity, unless he chooses to reciprocate the authentication steps.

The one-time encryption key wrapper used by Bob is a measure to prevent Carol, who is also trusted by Alice, from decrypting the key exchange message and spoofing communications from Bob.

Because no node broadcasts a canonical name, an attempt to decrypt each packet with each available key must be made. This quickly becomes impractical in any multi-node situation. To solve this problem, a node prefixes each message sequence with a randomly generated “conversation” id. This way, if Alice and Bob are talking, Carol only has to attempt to decrypt one packet from each, and can then safely ignore any messages using those conversation ids. In the event of a conflict (two nodes happen to use the same conversation id), both nodes should immediately select a new, not-recently-seen key. Key negotiation conversations are prefixed with a temporary identifier, in addition to the conversation key. Temporary conversation keys are dropped from the ignore list much faster (perhaps 30 seconds).

Messages must contain conversation sequence numbers inside the encrypted payload. These should be initialised randomly. Packet loss may occur, which means that some messages may arrive with a packet ID several higher than the last, but key renegotiation should take place if the difference is too great, or a packet with a sequence number lower than the highest known arrives (an indication of an attempted replay attack). This number should roll over to 0 when it reaches the maximum value.

There are a number of areas of potential information leakage. If Mallory can determine that Carol is ignoring messages with the conversation ids used earlier by Alice and Bob, Mallory can conclude that Carol is not Alice or Bob. To counteract this and other scenarios, the default behavior MUST be to ignore all invalid or unexpected messages. Error messages for these circumstances, even encrypted, may leak information.

OOK Update/Wrapup

It’s been a while since I posted about this. Since I last posted, I received the pair of custom lenses and have been wearing them on a regular basis until now.

People often ask whether I can see with the lenses in. Yes, they correct the vision even during the acclimatization period, so if you absolutely have to be able to see, you can. I drove to LA wearing them before my vision was good enough to drive without them in. This is not a good idea though, because the overnight prescription is designed to be centered on the eye with your eyelids closed, which is not the same position (in my eyes at least) as when they’re opened. This can result in an off-center treatment area, and subsequent (temporary) vision quality problems when the lenses are removed.

It seems that I have unusually dry eyes, and as such, have had problems with the overnight wear. When I wake up, the contacts have been stuck to my eyes, requiring extensive wetting and re-wetting before they can be safely removed. If I don’t spend the requisite time (often as much as 15 minutes) working them to naturally unstick (and sometimes even if I do) taking them out results in the pealing off of a layer of corneal cells. The eye heals quickly, the pain goes away in a few hours, and this damage is usually mostly repaired by the time I put them back in in the evening, but it is far from optimal. Most patients do not experience this, and the lenses are still floating freely on a layer of tears when they wake up. Unfortunately, the dryness is causing enough problems that my doctor feels that I should discontinue wear of the lenses. This is unusual, given that OOK is often suggested as a treatment alternative for people who have dry eyes which make daytime wear of lenses uncomfortable.

I’m sad to be stopping.

Overall, I really like the lenses. It’s fantastic to be out and about without anything in your eyes, to be able to see while showering, swimming, or any other activity. After nearly a month of wear, the end-of-day degradation in vision quality has reached a point where I still find the vision acceptable even late into the night. It’s convenient to wear the lenses at night and have them out during the day – no more worrying about carrying around a case so that I can take them out if it gets too late while I’m still out, and no more painful eyes from wearing lenses too long during the day. The flexibility is nice. Of course, the opposite is also true: if I skip a night, the vision the next day is noticeably bad.

The quality of vision achieved with the lenses has been variable for me. Because of the dryness, particularly in the left eye, the vision is sometimes degraded while the damaged areas of the cornea heal. This manifests itself as general blurriness, and difficulty resolving fine detail which is generally gone a few hours after lens removal. Additionally, because I have unusually large pupils, I can see the edges of the treatment zone at night, resulting in halos. This has gotten better as I’ve worn the lenses long term, but is still present. Furthermore, low-light intensifies the natural daily degradation. I can still function just fine, and driving is no problem, but things aren’t crystal clear.

However, when there are not dryness problems, or I’m outside during the day, I’m able to see better with the treatment than I ever have before. Soft contact lenses do not compare. The world is fantastically crisp, so much sharper, more detailed. I highly recommend them, since for most (almost all) users, the dryness I experienced will be a non-issue.

Moving forward, I plan to wait a month or so for my eyes to fully return to their natural shape, and get a pair of hard contact lenses. Even though the treatment lenses were uncomfortable at first, the vision quality provided by the hard lenses far surpasses that of soft contacts. I think I’m willing to trade the slight comfort margin for the improved vision.

You might also want to look at my other posts on Overnight Orthokeratalogy.

Disabling WordPress 404 handling using .htaccess

I run WordPress in the root of my site, but dislike the fact that whenever anyone mistypes a url anywhere else in my site, they get sent to the WordPress error page. The fix is fairly simple if WordPress is installed in its own directory…

Edit your .htaccess in the root of your site to look like this:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^archives/.*$ /index.php [L]
RewriteRule ^feed.*$ /index.php [L]
RewriteRule ^page/.*$ /index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wordpress/.*$ /index.php [L]

# END WordPress

Now, when a user mistypes a url in the non-wordpress portions of your site, they will see a normal apache error. I use the archives/ formatting for my old posts, you may have to customize yours differently. Additionally, you may need to modify the last line if your blog is not installed in wordpress/. The last few lines DO need to remain there, because WP seems to do some fancy re-writing for the more advanced bits of the admin interface, such as adding open-ids to user profiles.

You may need to add other lines depending on what other modules you may have installed that add further items to the root namespace besides the page views.

I also have the lines:

Redirect 301 /login http://thefire.us/wordpress/wp-login.php
Redirect 301 /logout http://thefire.us/wordpress/wp-login.php?action=logout


which allow me to log in and out via http://site/login rather than retyping or bookmarking the admin url.

Recent Photographic Happenings

I’m shooting on new equipment – the Canon EOS 5D Mark II and the Canon EF 70-200mm f/2.8L IS USM Lens. Both are superb. I’ll write up my thoughts on the 5D after I’ve played with it a bit more, but initially at least, I’m very happy.

Below are a few photos taken with the 5DII and the 50mm f/1.8 II. I really like this lens on the full-frame body. These are resized, but otherwise directly off the camera – 1/50th at f/1.8 and auto-ISO ranging from 800 to 2000.
Continue Reading »

reading books

I don’t really believe in new years resolutions, but I’ve made a decision this morning that somewhat resembles one. Since graduating from highschool, I seem to have almost completely stopped reading for pleasure. I miss it. I’m going to make a point of finishing at least one (non-school) book each month from now on. I may read it in print, or listen to an unabridged audio rendition, but I really want that part of my life back.

I’m going to start by finishing “Dark Star Safari: Overland from Cairo to Capetown” by Paul Theroux.

Another OOK update

Went in for the followup, after wearing the trial pair of lenses for 9 days. Even though the right lens is still sitting slightly off-center, we decided to go ahead with the custom pair of lenses, since the time required to do another round of trial lenses just seems like too much bother. I can still see halos in both eyes at night (large pupils mean the correction zone is visible when dilated) but during the day, especially outdoors, my vision is fantastic.

There is still some corneal staining, particularly in the left eye, and we’re going to move to using the storage solution to lubricate my eye prior to wear, and again before removal. The staining means that my vision is subjectively not fantastic today, but if we can eliminate or reduce it through more extensive use of lubrication, I should have pretty good vision. Today, my measured vision after removing the contacts was 20/16, which is pretty darn good, even with the staining.

When discussing whether to do another round of trial lenses, the doctor commented that “We don’t expect to get perfect vision with OOK… we usually prescribe for 20/Happy, and you’re already unusually good.” I guess I may be overly picky, but I’m a bit less enthused about the whole prospect right now. We’ll see how the custom lenses are. The convenience factor of being able to see during the day is great, but I pay for it by having to be meticulous about wear.

The next step is to (again) let my eyes revert to normal. Then we’ll do a series of technical measurements on the shape of my eye and how well it reverts, and hopefully in about 2 weeks, the custom lenses will arrive and I’ll start wearing them.

You might also want to look at my other posts on Overnight Orthokeratalogy.

Howto: Disassemble LaCie LittleDisk External Hard Drive

I recently purchased a 500GB LaCie LittleDisk external hard drive. This is a nice little external 2.5″ form-factor drive, completely bus-powered, and quite compact. At $99 from newegg, it was a good deal. However, I wanted to swap the drive with the one in my laptop, which is only 250 gigs.

It is easy to take the drive apart, once you know how it is made:

  • Do this on the “top” side (marked “LaCie” on the case, and “Design by Sam Hecht” on the insert).
  • Slide a credit card between the external casing and the insert, pushing the two sections apart.
  • As you can see in the picture, the insert is connected to the outside case by two plastic tabs which were glued in place. Slide the card horizontally to break this bond on both tabs.
  • Pull out the insert.

LaCie 500GB LittleDisk - Disassembled

You could also use a knife, but a plastic card helps prevent damage to the case. There were 2 further tabs on the other side which were not glued on my model. It took a fair amount of force to pull the insert out (the padding provides a tight friction fit), and when I re-assembled the case with my old laptop drive in it, I did not bother to re-glue the tabs. Additionally, you may need to replace the fuzzy padding strips (particularly the thin ones) as they have a tendency to tear when you remove them from the drive.

Mine had a Samsung model HM500LI SATA drive in it, which is now happily running my Thinkpad X61. One nice side-effect of running Ubuntu is that I was able to swap the drives, and then boot directly from the old disk via the usb enclosure. Not something you can do with windows.

netflix dataset

I’ve been fascinated with the problem of improving search results for a long time, but have never really had a chance to try any ideas out on an actual dataset. Recently my dad suggested that I grab the data for the netflix prize and play with it. This had not occurred to me before, but it is data which is very relevant to the problem of general web search – groups of users ranking items based on their relative personal value.

I have no pretensions about seriously competing for the million dollar prize, but I do think that playing with the dataset should (at worst) give me a bit of hands-on experience with data processing, and might perhaps allow me to solidify some of my ideas about relative ranking of items, as determined by a group of similar users. Unfortunately, my formal statistics training is lacking, but it should still be fun to play with. I am considering finding a statistics class to audit next semester, since it’s a skill I should have, even if my degree doesn’t directly require anything.

I’m interested in this as a personal exploratory project, so I do not plan to seriously scour the web for the techniques that other participants are using, or to studiously read the blogs of all the top teams. If something comes up, I’m not going to actively ignore it, but I want to develop my own ideas.

I plan to use python for doing the data processing, but may need to be somewhat clever, since I’m likely to quickly run into memory limitations working with a dataset this large.

Some of the initial questions and ideas I want to play with:

  • How does the current average rating (as displayed to a user at the moment they rate the movie) affect users ratings? Can we correct for this trending?
  • Which movies experience extremely disparate ratings (many 1 and 5 star ratings)? Can we use these movies as strong indicators of how we should group users?
  • (from the previous) How extreme are users? Should we be ranking the opinions of users who rate many movies 1 or 5 stars differently from those who tend towards the middle? Should we be figuring out how to correct for this?
  • What happens if we binarize the data, and make everyone an extreme user? Can we do something useful with this, and then work the average ratings back into the picture?
  • What IS the median rating for the data? Is it 3?
  • Can we identify those people who seem to be unaffected by the average rating? Can we use their ratings in a valuable way? Should they form the basis for individual groups into which we can put the people who are swayed by the current star rating? Can we even categorize people into these two groups?

Some of these questions are easier to answer than others, and some could probably be found by a simple Google search, but I think they represent a good starting point for building analysis tools.

More OOK

I went through another pair of trial lenses, and we think that these, the third pair, may finally do the trick. They’re still a little bit off-center in the right eye, but it’s close enough that the treatment zone should cover the pupil. I’m starting the 10-day wear period today to see how they are after I’m fully corrected.

As an aside, dehydration makes a BIG difference in how easily the contacts come out of my eyes. When I last went in, I was a bit dehydrated after being out in SF for my friend’s bachelor party, and it took us a long time to remove the lenses. The normal procedure is to instill a couple lubricating drops in each eye, wait a few minutes for them to work their way under the lens, and then pop it out. This took us nearly 20 minutes, and we still managed to remove a bit of the outer layer of the left eye. Moral of the story? Twofold: Drinking causes noticeable dehydration, and even a little dehydration goes a long way towards changing the dryness of your eyes.

Hopefully this latest pair will do the trick. If I can still see the correction zone in this pair after the 10 day period, I MAY get another pair of lenses, or I may get dropped from the program for being too fiddly. Which is a shame, because I’ve seen the potential for a really great thing here. In either case, the doctor continues to be great, really genuinely worried about my experience during the whole process, and quite happy to put up with my multitude of generalized questions about vision, and the process.

You might also want to look at my other posts on Overnight Orthokeratalogy.