Archive for October, 2007

Google PageRank Update – The Original Benjamin Golub

Wednesday, October 31st, 2007

benjaminGolub.com jumped from a 1 to a 3 in PageRank this month which bounced it up to the #1 spot for searches for benjamin golub. I only go by Benjamin when my name is written out; most Google searches that reach this site are for ben golub, which places me at #2. I am competing with Ben Golub, the CEO of Plaxo.

This make me the Benjamin Golub but I’m still the other Ben Golub :(

Upgraded Wordpress to 2.3.1

Saturday, October 27th, 2007

I finally got around to upgrading this blog to Wordpress 2.3.1. It was extremely painless; I had it done in a matter of minutes. Here were my steps:

  1. Backup database (mysqldump).
  2. Backup entire heirarchy of benjamingolub.com
  3. Overwrite the old wordpress folder with the new one (they recommend not doing this, but I see no problem assuming you backup your old hierarchy)
  4. Visit /wordpress/wp-admin/upgrade.php
  5. Convert all my categories to tags (found a link in the admin panel to do this)
  6. Replace my categories list in my sidebar with a tag cloud
  7. Get the newest version of my theme (sandbox) which supports tags
  8. Write this post

Nice job Wordpress! I’m digging the plugin update notification feature and the built in tagging.

New Project – Streams

Wednesday, October 17th, 2007

A ton of services are popping up that take all of your (Twitter, Google Reader, Netflix, Blog, etc) RSS feeds and make a “stream” of your online activity. My favorite is FriendFeed. Last night I decided to see how fast I could whip one up in Django, and the result is http://stream.benjamingolub.com. So far I’ve got it crawling my Blog, Flickr, Google Reader, and Twitter (the services I use the most). It only took me a few hours to write and most of that time was spent on templates. Some things I learned about RSS feeds:

  1. Universal Feed Parser saved me a lot of time.
  2. Not all RSS feeds are created equally. Come on Google Reader, why don’t you tell me the time that I shared an item? Instead all I get is the time the item was published. So instead I have to make sure that my cycle time for a crawl is fast enough that I can use the current time as the time I shared it. At most I’ll only be off by a minute or two, but this could easily be included in the feed by Google.
  3. Tagging was dead simple to get working. I just pull in the tags (using Universal Feed Parser), create each one if it doesn’t already exist, and add them to the event. The more events that are pulled into my stream, the more tags I get. FriendFeed doesn’t have tags visible at the moment, but I’m sure they are collecting this data. Here is all it takes to do in Django:

    if 'tags' in entry:
    from django.template.defaultfilters import slugify
    for tag in entry.tags:
    tag, created = Tag.objects.get_or_create(title = tag.term.strip(), slug = slugify(tag.term.strip()))
    event.tags.add(tag)

  4. This one’s obvious but don’t rely on receiving valid data, you can bet someone will have malformed HTML that will mess with your site. So before I display any data I strip the tags, urlize the urls (if the feed contains http://www.google.com it will turn that into a link), and then truncate to 100 words. In Django that looks like this:

    {{ event.content|striptags|urlize|truncatewords:100 }}

I’ve got more ideas for crawlers in the works. The great thing about doing it on my own server is that I can store usernames and passwords I use for various accounts. So FriendFeed can’t get my Facebook feed (because they’d need my credentials) but I’ll be able to.

Update: I used to be able to correctly space out my python code but can’t anymore, oh well.

Django – Custom Template Filters

Saturday, October 6th, 2007

A coworker recently asked me if it was true that you couldn’t use programming logic in Django templates.  It is true that the Django template language is rather limiting but this is done purposely because designers aren’t programmers.  Most of what you’d want to do with in a template is built into Django but sometimes you need more.  Enter custom template tags and filters.

For my flashcards website I needed to check if a deck was in a user’s favorite decks list.  Python has a nice way of doing this:

return needle in haystack

But the Django template language has no such feature.  One could perform this test in the view and then pass the information to the template but creating a custom filter is just as easy and more robust.  Here’s how:

  1. Create a folder called templatetags under your app.
  2. In the templatetags folder create two files, one named __init__.py (a python requirement to treat the directory like a package so you can import it) and one named whatever you like (appname_tags.py is a good choice).
  3. In appname_tags.py write:
    from django import template
    register = template.Library()
    
    @register.filter
    def isin(value, arg):
        return value in arg
    
  4. In your template write (above where you plan on using the filter):

    {% load appname_tags %}

    (note: you can only load from apps that are in your INSTALLED_APPS setting)

  5. Finally, use the tag:
    {% if needle|isin:haystack %}
        Found it!
    {% endif %}

That's all it takes to make your own template filters.  Next up, making your own template tags!

Robert Klayman and Scheduler Jones

Tuesday, October 2nd, 2007

Update: Robert blocked the Wayback Machine from accessing his site so the links below won’t work. I can only guess that he did this to remove the evidence. But Google cache had a copy, here is a PDF.

Update: Robert fixed the site, thanks!

Scheduler Jones was my final project for ENGR 131, Intro to Computer Programming, created by myself, Robert Klayman, Justin Gern, and Jens Johnson. It netted us second place in the class and was actually used by students to create schedules for the next 4 years. Unfortunately we weren’t the most robust developers when we created it and it required maintenance every semester in order to work with the new schedule. Robert decided he wanted to keep it updated so every semester he’d fix the code and post flyers around campus. Recently Robert has updated the Scheduler Jones site. An alternative scheduler has surfaced and Robert is spending the year abroad, so he has retired Scheduler Jones. The new website states:

robert klayman, the maker of scheduler jones, presents…

Give credit where credit is due. You’re already using the Scheduler Jones site as a platform to promote CaseLife without asking us but ignoring the rest of the group is downright wrong. Do this sort of thing in the “real world” and you’re just asking for all sorts of legal trouble not to mention ruining your credibility.

The Wayback Machine has all the proof you need:

The Scheduler Jones site as it was originally created. Actually the very first one included links to mail ALL the team members, but Robert removed that before the Wayback Machine caught it.

The current Scheduler Jones site. No mention of any other team members.

The Scheduler Jones site as of May 15, 2007. No mention of any other team members. Just linked here in case Robert fixes the live version of the site so this post will still make sense.

Update: Just wanted to also say that if Robert fixes this, I’ll be happy to update this post.