Tuesday, June 20, 2006

Trac Spam

It seems I was the last to find out about the "trac spam" phenomenon. I've got a bunch of projects that use trac here, and as a result, I've been cleaning up the huge mess these bastards left on the wiki. Gotta love page history, though...

The pages that are most viewed are the ones with code examples on them, and the spammers were kind enough to delete that code, making the pages useless. The code is now restored and can be referenced again. In particular, the following projects were impacted most heavily:


I've now got the wiki set for auth users only. If you want to contribute to the wikis, just send me an email.

Technorati Tags: , ,

Monday, June 19, 2006

Nevow Needs a Screencast

Nevow needs a screencast. Because it's so damned hot and people need to see it in action. They need to see how frickin' amazing it is.


Case in point: on a *whim* I decided to migrate a site I built last year in z3 to nevow. I had a spare hour, so what the hell. It took me *minutes*. And I don't mean 6487 minutes -- I mean 30 minutes. Here's what I did:

  • Copied HTML output from the other site and used as the basis for an XHTML template

  • Copied CSS and images from the other site

  • Wrote a backend data store that uses RFC 2822 (python's email package)

  • Wrote a ui.UI class, subclassing nevow.rend.Page (including children, data calls, etc)

  • Added data and render calls in the XHTML template

  • Wrote a .tac file

  • Populated 5 RFC 2822-compliant files with data and headers for the content

  • Started up the server and watched the new site scream



Let me emphasize a crucial point here: *none* of that was stubbed. No helper-scripts. No installers. There was pre-existsing HTML, CSS and images, and that's it. I did some dicking around and tweaking in the process, so I'm *sure* I could do the whole thing -- from start to finish -- in less than 20 minutes. Probably 15.

I don't understand why more developers aren't using Nevow. It just kicks ass. Yeah, every platform has its issues, and Nevow's no exception. But DAMN. I get record-setting development times with it, it runs fast, and it's insanely flexible.

Technorati Tags: , , ,

Saturday, June 03, 2006

Sets as an Elegant Alternative to Logic

python :: programming :: math



A few years ago I was working on a sub-project of CoyoteMonitoring
where we were writing a database "layer" for the file system,
essentially allowing us to query for files using standard SQL commands.
We needed to do some exclusionary logic for filtering bad user input.
Though mathematically equivalent, I deal with Set Theory and Logic very
differently: I'm a set guy, and I really hate using series of if/else
statements for problems that lend themselves easily to an approach that
is "set theoretic" (we're talking super-mundane set stuff -- nothing
really sexy).

On IRC, I was gently preparing a fellow project developer for some code
changes I had made that eliminated a series of ugly ifs:

 
[03-Oct-2004 02:02] you know, we could do this really
quickly with sets :-)
[03-Oct-2004 02:02] check this out:
[03-Oct-2004 02:02] lets say our table has 4 fields:
[03-Oct-2004 02:03] ['A','B','C','D']
[03-Oct-2004 02:03] and we're doing a select for ['D', 'A',
'C']
[03-Oct-2004 02:05] and lets say we've got a bad query
['Z', 'B', 'C']
[03-Oct-2004 02:07] then, if we perform a set difference on
select
tables against defs, the returned set will be zero
[03-Oct-2004 02:07] and if we do the same with bad against
defs,
we'll get a non-empty set, in this case a set with one element, 'Z'


I then shared some python 2.3 code (no built-in set object) that
basically illustrated the changes I had made. For me, the results were
much more readable. The code was certainly much shorter.

Since then, I've found all sorts of uses for this approach. I've
recently made use of this in a Nevow project that has to authenticate
off of a Zope instance. There are a series of group and role names that
can be qualified under one of three "group-groups" (tiers):


# setup sets for each class of user
admins = set(cfg.user_database.admin_roles)
libs = set(cfg.user_database.tiertwo_roles)
vols = set(cfg.user_database.tierone_roles)
# and then a convenience collection
legal_roles = admins.union(libs).union(vols)

Later in the code, we do checks like this:


if admins.intersection(avatarRoles):
return IAdministratorResource

I like this much more than explicitly checking for the presence of
elements in lists.


Baz Camp, Day 1

hacking society :: programming :: colorado



Well, the folks at tummy.com have done
it again :-)
Baz camp is rocking. We're right on
the lake, with beaches and 90-degree weather in Loveland, CO... so you
can imagine that the view is most agreeable :-) We not only have
wireless access donated by the most gracious local provider
LP Broadband, but some of
the boys brought a big-screen projector for outdoor movies at night as
well as satellite TV. So yeah, we're *really* roughing it.

We are certainly roughing it more than the folks at Foo and Bar Camp!

We've got a camp cook who's making meals for us (including 1:00am
chili!) and the menu has been just great. We've got shaded gazebos up,
tents. Watched Primer and Hackers last night (Hackers was enjoyed a la
MST3K). Sean shared Icelandic treats he brought back from the Need for
Speed sprint, including fish jerky. Yummy.

I also happen to be getting a lot of work done, too :-) All offices
should operate like Hack Camp.

Hey Radix: why aren't you here? Evelyn Mitchell and I were talking
about fellow social geeks and agreed that this would be just your style
:-)