Now let me start by saying I’m not opposed to the impecunious members of society asking for money – I’m sure people can legitimately get into a situation where it becomes neccessary to ask strangers for money. What does bother me, and perhaps this is a thin line to cross, is those who lie to get money. For example: There’s a woman who I’ve seen riding the red line, moving from car to car – her story is that she had her bag stolen and needs $11 to get the bus home. That’s all well and good, but I saw her three times in two weeks with the same story. I would argue that it is highly improbable for one person to be that unfortunate with their bag – but people fork over money. Would it violate some implied social contract to stand up and point out that this woman did the same thing two days ago? In fact the man next to me last time I saw her whispered “She does this all the time…”. Too true.
Is there a fundamental tension between playing a sport “for fun” and also trying to do well at it? I play on a kickball team, and there’s a rough split between the folks who get caught up in the game and play their hearts out, and the folks who continually recite “we just here for fun, right” – I mean the reason people play any sport is for fun, and a lot of people work hard practicing/lifting weights for years in order to do their best and have more fun in the process. Perhaps that’s what separates people with ambition from those without? People who want to do their best (and continue to raise that bar) to get the most out of everything they do, as opposed to those who just show up- and this “ambition” applies to almost everything, not just work or what have you. I’m sure the latter (ambition-less) category has a good time, but what happens when the two groups meet?
Now I’m not suggesting kickball is a sport important enough to have two a day practices and team lifting regimens – just that kickball is fun, and winning is even more fun, so there’s got to be a way to get everyone on board to try to do both.
This has probably occurred to me, and likely to everyone else out there – programmers will spend orders of magnitude more time to automate a tedious, boring and error prone process than it would actually take to perform that process weekly for the next four years, even though it likely would take place for only a few more weeks.
This comes up in light of converting a relatively simple static site I maintain for a kickball league to use a templating engine(more on that later) so that I wouldn’t have to a) change all six pages to change the headers/footers/menu etc, and b) wouldn’t have to use an excel spreadsheet and type and copy and paste scores from place to place every week to update the results. In my case, I have an issue where I’m very interested in learning new things, but always need some tangible project to perform otherwise I lose interest – so I can chalk it up to learning something new, even if I have saved negative time in the course of the implementation over doing things the old fashioned way.
There’s currently a whole load of things I want to read/play with/ do, and I really don’t have time for it all, even though I do have the interest and energy(most of the time). I guess it’s one of life’s quirks that when one is busy, there’s lots of things one wants to do, and when you’re idle/bored, you can’t be bothered to do anything. Case in point: I was unemployed for several months this summer, and apart from auditing a summer class and a little traveling, I didn’t get all that much done. Some of that I can chalk up to the grind and angst of being unemployed and scanning the job listings on craigslist and monster etc and sending out resumes, but I really had a lot of time on my hands that was just squandered. Mostly I realize that now when I’m juggling grad school and a full time job along with all the other things in life – I wish I’d used that time better. Now that I’m already busy I have all this interest in playing with this technology or reading that book, various things I couldn’t be bothered to do in the summer time when I was idle. Is it really just easier to manage one’s time when you’re busy? Once you’re in a go-go state it’s just hard to stop (inertia?)
I’m struck by how much the ubiquitousness of laptops has changed the college experience from the aspect of getting work done. – when I was in school ending in 2000 (up hill both ways…) laptops were still pretty rare. People got work that required a computer done in their rooms or computer labs – and as a Computer Science and Engineering major, for me that meant a whole lot of time in my room. Now that I’m back in school part time four years after getting my BS, I’m struck by the fact that I’ve spent more time in the library in the course of a semester than I did in my entire undergraduate education. Why is that? Well apart from the fact that I have better study habits than back then, its simply because I can – I’m no longer chained to a desktop computer. This is all pretty obvious, but now people can get their work done anywhere, and do. Walking through the Tufts library, half the people are tapping away on laptops, and most everyone is jacked into an iPod. I can only imagine how different my college career would be like now – and we’re only talking technology enablement, not “if only I knew then what I know now”.
I figure everyone and their dog has a blog,
so I should too. What better way to share my random musings and fun/wasting time with technology to so many and so few at the same time?
In several easy steps! (hopefully in some manner this will prove helpful to users of jython and freemarker in the future)
- The beginning
- Use a template engine to simplify site maintenance
- Create a semi-automatic scoring system
- Choose a different templating engine
- Take stock of what you’ve done
In the beginning, agree to be the “webmaster” of one’s local kickball division – simple an non-timeconsuming task given that the site has a handful of pages with static content, and one must update the standings and scores every week. Decide the site is an excellent opportunity to learn CSS layout. Spend an order of magnitude of time more to get the site up than it would have taken to throw up some 1997-style table layout.
Now the site is up and running – decide that since the same header and footer are on every page, it would make sense to use some kind of templating system (note: the site is static content only) to make it easier to add new sections, should the need arise. Consider various client driven solutions: Dreamweaver (too expensive), Nvu (generates crappy HTML, crashes, slow). Consider rolling your own, since all you need are static includes. Discard that idea.
Look at open source templating engines. Decide that you really want to have an ant script that will magically assemble the site (and who knows, maybe one day even upload it for you too!). Decide to use Velocity. Play with Texen for a while, but decide you really need its big sister vpp. Learn the syntax, get the gazillion jar dependencies downloaded and copy and paste the web pages into easy to manage chunks and get the includes working. Wa-lah! Now the website can be regenerated by a simple ant task – take this opportunity to add a photos section because its suddently really easy to do.
Now you’re in the promised land – no more editing 6 different files to change the menus! You can sit back, crack open a beer, life is good. But no – it irks you that you’re managing the score via a way-too-manual process involving an elaborate Excel spreadsheet and typing at least 2 different places. You’re a software engineer, you can do better than this. (Note: this decision is best made when you have a new full-time job and your Theory of Computation grad-class is taxing your time).
Spend T-rides brainstorming how best to represent the structure of the league, with teams, game schedule, results- of course you’d want it to be validating. Discard that effort when you have a brainwave – just represent the state of the league in jython script – you were going to process the XML in jython anyways after sleeping off the delusional fantasy of using XSLT. Cut out the middleman, mere mortals don’t need to edit this stuff!
Cut to creating a set of objects for your domain objects. You need your teams:
self.name = teamName;
self.shirtColor = shirtColor;
self.abbrevName = teamAbbrev;
Get the whole messy code here (note it doesn’t handle forfeits yet).
Throw in some other classes and some logic, now you’ve got a half-assed scoring system! Data entry is totally a breeze, I mean look at this, total user friendliness:
day2 = Day("9/8/2005",ppe,ppe)
game = Game("8:00","A",baggers,ppe,freeballers)
game = Game("8:00","B",spanking,ballsdeep,gentree)
Get the season so far here.
Great! Now we just wire that up to our template engine, and then its margerita time!
Not so fast! Now you discover that, at best, the Velocity support for Jython is experimental, and for some reason your download seems to think its 1.31 instead of the 1.4 you’re sure you downloaded, which doesn’t support Jython at all! (Discover this after spending hours the night before debugging, thinking you were doing something wrong) Now you consider moving to straight up Python and using the Cheetah template engine, but you become aware of FreeMarker through the flame-war inspiring intervention of one of its’ developers in the velocity-users mailing list. Syntax is similar enough, and it supports Jython! So you finish building out the scoring system and create some sweet templates for your standings page:
< #assign num=1>
< #list standings as s>
<tr <#if ((num %2) = 0)>class="shadedrow" >
< #assign num= num+1>
Get the rest of the standings template and the schedule template.
Wrap it all together with a small driver to load the templates, crank up the freemarker engine, and write out the output as I did here. (Note apparently the JythonWrapper is not really needed – i was chasing a bug with java dates that has since been fixed)
Now we’re almost done – one of these days need to convert the templates of the static pages to freemarker (or freemarkerpp) and then we’ll really be done – for now we’re done enough. Now keeping the scores and standings updated is breathakingly easy! It only took an order of magnitude more time to get this all written and working than it would have taken to actually do the manual edits over time. Oh well, that’s just the way we engineers roll I guess.
Thanks to the velocity-users group for their help trying to get Jython to work for me, as well as Jonathon of the FreeMarker project for introducing me to his project and providing a push in the right direction getting my system working, as well as responding quickly to a problem formatting java.util.Date objects embedded in jython objects.