Django templates: Simple numeric for loop with only built in components

April 5th, 2010

Scenario:

In your web page, you want to print out a few identical items in a loop.  Perhaps you want 5 rows worth of initial inputs available in a form.

Problem:

Django’s template language has no way to do a simple numeric loop.

Solution:

{% for i in 12345|make_list %}

    {{ i }}

{% endfor %}

Notes:

Clearly this is not beautiful.  But, it works nicely for small cases, and it doesn’t require you to set up any additional template tags or add a range to your context in your view.  I’m sure others have used this approach before, but I couldn’t find anything about it by searching so I thought I’d share.

New Greasemonkey goodness (Insert VideoSurf summaries on Google, Yahoo! and Youtube search)

November 11th, 2008

I just published my first post on the VideoSurf blog. It’s about a Greasemonkey script that I wrote to insert our VideoSurf visual summaries into Google, Yahoo! and Youtube search results pages. I think the script is pretty sweet and quite useful.

If you’re interested, there are screenshots and installation instructions on the VideoSurf blog:

http://www.videosurf.com/blog/never-get-rick-rolled-again-42/

If there are any Greasemonkey scripters out there, I’ll also share a cool discovery that I made along the way. There’s now a very easy way to include jQuery’s great functionality into your Greasemonkey scripts. You just need to add this line to the file’s header:

// @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js

Having jQuery at your disposal can really speed up development and make it much, much less tedious. Check out the source of my VideoSurf script to see some of the ways that I used it.

Update: I made it on to Techmeme:
Read/Write Web and Webware.com propel the post on to Techmeme

Update 1/8/2009: We turned it into a Firefox extension and added some awesome new features for the Youtube video page. Check it out, https://addons.mozilla.org/en-US/firefox/addon/10218/.

Changes afoot. Back in USA. Joined VideoSurf.

September 5th, 2008

After a year and a half of hard work and a wonderfully flexible lifestyle that included a 4 month stint in Buenos Aires, I’ve returned to the USA and decided to once again take on full time work.

I’ve joined an amazing startup in San Mateo called VideoSurf. They’re doing some really innovative stuff with online video and I’m extremely excited about all the possibilities. Everything is still in stealth mode, but you should start to hear more about it in the coming months. If you’d like an invite to try the site out, email me and I’ll see if I can make it happen. No promises yet though.

As for FeedEachOther… While the site is extremely useful and loved by many, its current incarnation isn’t getting the traction necessary to turn it into a real business. Perhaps I’ll take it in a new direction in the future. I’m very proud of what I’ve built, but trying something new now is the the right move for me. I will still keep the site up and running, but active development has pretty much stopped.

If this worries anyone who’s currently relying on the site, I’ll be happy to help you export any of your information from the system. Send your requests via the FEO feedback page and I’ll work to add new export features to the site or run one-off scripts to get the data for you if necessary. However, take heart that the site will still be running for quite some time because I use it daily myself and I know that quite a few others do as well.

So, that’s that… Woah.

Viva VideoSurf!

Is Facebook stirring up trouble?

July 8th, 2008

A friend of mine recently decided to tidy up her Facebook profile information. She got to the relationships section and thought to herself, “you know what? this is nobody’s business. I don’t want to broadcast this to everyone.” She saw a message there that said “Leave status option blank to hide from profile.” Perfect, that’s exactly what she was looking to do. Blank it is. Done.

Relationship status selection screenshot

However, the next day, she started getting a flood of phone calls from family members and close friends. “Woah, I just saw it on Facebook. You never told me you were seeing someone! Who is he???”. The source of this confusion? An item in her Facebook news feed that was broadcast to all her friends. It looked like this:

Facebook Heart Jane Doe is no longer listed as “Single”

This is extremely misleading and it can cause quite a bit of trouble. My first thought was that this is clearly a bug. A classic oversight in a complex set of interactions.

But is it?

Another friend that I discussed this with said, “dude, you’re being naive. Facebook does that stuff on purpose. They’re trying to stir up trouble. To get people talking. ”

That blew my mind a little bit. Am I naive? Are the product people are Facebook really so diabolical? My hunch is that they’re just young, busy and fallible. But, I could be wrong. It definitely got me thinking.

Maybe I need to be a bit more diabolical myself…

What I write about

June 18th, 2008

A post on Knowing and Doing inspired me to check out Wordle. Wordle generates a good looking jumble of words for any text you paste in. The more often a word is used, the larger it appears. I did a ‘select all’ on my blog’s front page and threw it in there and this is what resulted. Pretty neat.

Wordle from my blog

I like how “People” is so big.

Check out this one of a McCain speech, and this one of Obama’s race speech.