Found a small bug in Pyblosxom’s session.py plugin

In trying to use the spamquestion plugin to reduce the amount of blog spam, I encountered what appears to be a small bug in the session.py plugin.

In session.py:152, the line self._cookie_path = base_url[base_url.find('/', base_url.find('://')+3):] does not handle the situation if the url has no trailing slash. In such a situation, it slices the string [-1:], which is not an error oddly enough. I guess I don’t understand Python well enough yet?.

session.py uses a cookie to store the session ID, and the malformed URL above would lead to an impossible cookie path being stored. This created a new session ID each time, which prevented spamquestion from remembering the spam question that was asked (and thus unable to correlate to the correct answer).

My fix is perhaps not “pythonic”, but putting a condition block around that line and creating an alternate for cases where there is no trailing slash works well enough.

Interview question: why is Java’s package visibility different from .NET’s internal visibility?

I believe I’ve mentioned before I try not to ask memorization type questions; at the very least, I try to ask the question in such a way that the candidate demonstrates they understand more than the textbook definition, which I believe indicates that they’ve either 1) used it in the real world, or 2) actually thought about it in depth – both good signs.

I invented this question on the fly, but in retrospect I rather like it. I don’t know what the “real” answer is, but I certainly have my opinion, and it’s proven to be a very good discussion starter. It involves both Java and .NET, but it’s not really required to know both.

In Java, there are four levels of method/class visibility: public, protected, private, and default (package). In .NET, there are also four levels: public, protected, private, and internal.

Java’s package visibility allows artifacts to be “seen” from the same package (i.e. namespace in .NET parlance). .NET’s internal visibility allows methods to be “seen” if they are in the same assembly (roughly equivalent to a JAR file in Java).

It’s generally perceived that .NET “copied” a lot of features from Java (whether that’s an accurate depiction is irrelevant here). Why then, did the .NET designers choose to make their fourth visibility different from Java’s? What “problem” did they see?

What if your spreadsheet could google?

I didn’t discover this feature of Google Spreadsheets on my own (http://www.readwriteweb.com/archives/googlelookup_wow.php for that), but I found it hard to imagine from the description what it did. It is more interesting to see than read about, so here’s a desktop video where I followed along with the instructions given by the link.

Demonstration of Google Lookup function in Google Docs spreadsheet on Vimeo.

Follow

Get every new post delivered to your Inbox.