Monday, March 20, 2006

Linux: Verizon Yahoo DSL

I got Verizon Yahoo DSL working on my Dad's Fedora Core 4 box. His modem is a Westell 6100. These directions were very help (which is half the point of this post). Here are some notes:
  • The default username and password for the modem are admin and password. It prompts you to change these once you login.
  • When I called Verizon, they gave me some userid and password, but I don't remember ever needing to use them.
  • The tech support at Verizon was from Alabama and spoke English well.
  • I had problems with the DSL not syncing. The DSL light was just blinking. It turns out my dad plugged the modem into a wall jack that wasn't actually connected to anything. It's strange that they can't work around problems like that in software ;)
  • Since I was helping my dad over the phone, I was really pleased to find out he could give me remote access to the modem. He logged into the modem at 192.168.1.1. He navigated to Maintenance > Remote Access. Once there, he picked a password and turned remote access on. It told him the URL I could use from "outside". Best of all, remote access turns itself off after 20 minutes.
  • PPPoE is running on the modem itself.
  • I'm somewhat confused because I really don't remember configuring much of anything. :-/

Wednesday, March 15, 2006

HTML: Escaping &'s in URLs in HTML

Warning: Failure to ignore the following validation warning may result in lost productivity!
Concerning Ampersands (&'s) in URLs, the following is what I wrote in the Aquarium documentation:

The short answer is, if you have a URL with more than one parameter, you should wrap it with $htmlent when you embed it in HTML if you want to pass DTD validation. If you don't care, then it really won't matter. What follows is an explanation of why I can't make it any easier on you.
  1. You must escape &'s in URLs in order to pass DTD validation. Per the spec, a browser could look at http://a.com/?a=b©=2 and interpret the ©= as part of value of the a variable instead of a new variable named copy; because © is an HTML entity.

  2. To handle #1, Aquarium use to escape the &'s in every URL automatically.

  3. However, #2 broke redirects if you redirected to a URL with more than one parameter. I so rarely did this, that I didn't know about the bug for a good year.

  4. To fix the bug in #3, we came up with a scheme to always escape &'s but deal with the redirect case specially. Now imagine if you create a HTML link whose URL has a parameter named referrer that is set to your current URL, which itself happens to have two parameters. When the user clicks on the link, Aquarium now has a GET parameter named referrer that is a URL. The programmer can use that URL directly in HTML (in which case the &'s must be escaped) or he might redirect to it (in which case the &'s must not be escaped). The programmer is never going to remember whether the URL is already escaped (per #3, it already is) and whether he needs to escape it for a link or unescape it for a redirect. His brain would core dump.
    When it comes to escaping things, a good general rule is to escape things at the last possible moment. By violating this rule, bad things were happening.
  5. We could force engineers to wrap every URL in HTML with htmlent, but that would suck. Too much existing code doesn't.

  6. Browsers are smart, and most of the time, if you don't escape the &'s, the browser won't get confused. In fact, you can't generate a URL like http://a.com/?a=b©=2 with Aquarium anyway, because the ; will get urlencoded to %3B. Hence, it's not possible to get Aquarium to generate a URL that would confuse the browser. Programmers who are worried about passing DTD validation and have a URL with more than one parameter will just have to use $htmlent. That's better than forcing every programmer to think about the problem every time he generates a URL since, practically speaking, the warning is pedantic.

Sunday, March 05, 2006

Python: Django: Now with 73% More Friendliness!

I completely withdraw my earlier complaint:
Why are the Django guys so rude to other programmers?
You can read the comments to my earlier post to see what I'm talking about.

It reminds me of the fact that my mom use to say to me, "If you can't eavesdrop all the way, don't eavesdrop at all!"

Friday, March 03, 2006

Python: Fun with Classes

#!/usr/bin/python

#
# Author: Shannon -jj Behrens
# Date: Fri Mar 3 16:43:43 PST 2006
#
# In response to: http://secretartofscience.com/blog/?p=8
#
# Although Python isn't a prototype-based language, it's possible to do a lot
# of these same wacky ideas in Python.
#
# By the way, Io is a cool, new prototype based language. I've blogged about
# it before. There was also a knockoff of Python that was prototype based, but
# I don't remember the name--email me if you must know.
#


# Ok, let's start by changing our class on the fly.

class Draws(object):

def draw(self):
print "draw"


class DrawsSmall(Draws):

def draw(self):
print "small:",
Draws.draw(self)


obj = Draws()
obj.draw()
obj.__class__ = DrawsSmall
obj.draw()
print


# This time, let's mixin something on the fly.

class DrawsBig(Draws):

def draw(self):
print "big:",
Draws.draw(self)


obj = Draws()
obj.draw()
class MixedIn(DrawsBig, Draws): pass
obj.__class__ = MixedIn
obj.draw()
print


# This time, do it dynamically. I'll leave it as an exercise to the reader to
# implement "replace_parent_class".

import random

def inject_parent_class(obj, Class):
NewClass = type("DynamicGeneratedClass",
(Class,) + obj.__class__.__bases__, {})
obj.__class__ = NewClass


obj = Draws()
obj.draw()
Class = random.choice([DrawsBig, DrawsSmall])
inject_parent_class(obj, Class)
obj.draw()