Archive for the ‘Caltech’ Category

Best Version Control for Pedagogy

Thursday, May 6th, 2010

Normally I don’t like to write anything on my blog if I don’t really understand what I’m writing about, but I have an interesting problem to solve, and I figured that I might as well state the problem before diving in and trying to solve it. That way, if any of my smart friends have any ideas then I can find out what they are, and if not, at least I will have clarified the requirements in my own mind.
(more…)

Django Page-Rendering Slowness

Monday, November 9th, 2009

Using Django for csman has mostly been a positive experience, although there have been a few wrinkles along the way. I just ran into another one today, which is quite frustrating — one of my pages takes about ten seconds to render, and nobody wants to wait ten seconds! Fortunately it’s for the teachers and not the students; if it were for the students, there would be no end of whining! :-)

This page includes a LOT of database queries, almost to the point where I should be embarrassed, except for the fact that I hacked this thing together as quickly as possible, so actually I’m proud that it has as many features as it has. But for 130 students and around 15 assignments, the server-side code issues around 2000 queries, and you don’t need to be a genius to know that this just won’t be very fast.

But surprisingly enough, only about half the time is spent in database land; the rest of the time is spent rendering the Django template. I was quite surprised by this! I thought it would be much faster than that, but evidently not. There are three nested loops in the template, iterating over a large amount of data, so in retrospect it’s no surprise, but an hour ago I was sure that I needed to optimize the database interactions, not the template rendering. Now I see that the database code is only half of the problem.

All I did to find this was to add a couple of print statements around my view code to see how much time was actually spent in the database queries. I’m glad I did; I would have been completely befuddled, otherwise. It just goes to prove that old bit of software engineering wisdom, that if you try to optimize a system before you’ve actually profiled it, you probably won’t fix the real bottleneck.

I think I can fix this issue by creating a custom template-tag that will move some of the rendering into Python code, instead of being run in the template engine. The more I can incorporate into Python, the better off I’ll probably be. This may also help with the database side of things, because if I have clever template tags, then I can do less preparation with the data, and therefore fetch larger amounts of data from the back-end in one shot.

Syntax-Highlighted Diffs!

Thursday, November 5th, 2009

I just wrote up a new programming note about how to do syntax-highlighted diff output using Pygments and Python’s difflib library, in a Django website. It’s available here.

I implemented this feature for csman, a homework submission and grading system I have been implementing for the last couple of months, to use with the CS1, CS4, and CS11 classes that Mike Vanier and I teach. All of these classes have a similar homework-submission model, much like the model in real software projects: you write the code, and if it’s not good enough, you have to fix it.

Of course, grading redos is always a little annoying, so if you have a tool that lets you view a diff of the old submission and the new submission, it becomes very simple to see if the student actually fixed everything you told them to fix. (Sometimes they don’t. It’s very annoying when this happens.)

Anyway, it’s a cool little feature, to be able to see syntax-highlighted diff output on csman, but it definitely still needs a lot of work. The main issue is that frequently the files are too wide to display side-by-side, unless you happen to have a nice large monitor like I do. So, the problem really requires the effective use of scrollbars, both horizontal scrollbars to allow the diff-output to be visible in a smaller window, and also vertical scrollbars since otherwise those horizontal scrollbars are going to be waaayy at the bottom of your web page.

So, I have some work to do on that problem, but for now I’ll stick with what I have. It does the job, and one day when I learn more client-side JavaScript, maybe I’ll fix that kind of stuff up to be more snazzy.

Moodle Hatred

Thursday, January 24th, 2008

This is my busiest term all school year, since I teach my database systems course this term. I decided to try something new this term - instead of hand-coding the website for my database course, I have been using Moodle to manage the course.

So far, I really dislike it!

This is actually a step forward, since I used to really hate it. Now that I have used it a bit, I realize that Moodle really does have a few things going for it. It’s easy to work on draft assignments and then make them available when they are ready. It’s also really nice to be able to upload various peripheral files that the students will need; Moodle’s file management capabilities are quite nice.

The thing that I am totally annoyed with right now is that I can’t assign partial points to assignments! I can create an assignment and say that it’s worth 45 points in total, but then I can’t give somebody 39.5 points for their work. What gives?!

The other thing that always annoys me when I use Moodle is that it’s not just a piece of software to help me do my job; it promotes certain alternative teaching philosophies. I don’t want to use a piece of software that lectures me on how to teach; I want a piece of software that will let me publish assignments and other course-related materials, and let me track the students in the course.

Leave me alone, Moodle! Just help me do my job.

ACM Regional Contest

Monday, November 12th, 2007

Saturday, November 10 was the ACM regional programming contest. Caltech won yet again… Go Caltech!

This year was definitely one of the least intentional wins. There was little interest in an ACM programming contest track for CS11, so we just didn’t have one. Then, two weeks before the contest was scheduled, some all-star students expressed interest in going, so we arranged it. And they won! Caltech rocks.

Anyway. Hopefully we won’t do it this way ever again. Next year I want to really try to drum up interest in the contest and actually get 3 or 4 teams out there. But at least we were able to land the win this year!

Some olive “harvest”…

Friday, November 9th, 2007

A week ago, Caltech had its very first olive harvest. Caltech has many olive trees all over campus, and usually they are quite a nuisance because they fall on the ground, get squished under foot, and leave oily splotches on the concrete for months. In the past, the grounds crew would spray the trees to get them to produce less, but then two students decided to pick some olives and make olive oil out of them. (A very clever way to avoid homework, I must say.) Once the students succeeded at producing some actual olive oil, the administration decided to make an annual event of this.

So, call me crazy, but I would think that after an “olive harvest,” there wouldn’t be any olives on the trees anymore after that. Yet for the last week I have been walking around campus and looking at those trees, and guess what — still lots of olives.

I’m pretty annoyed by this. My coworkers think my standards are too high, but if you’re going to do something, do it right. No Olive Left Behind.

New Canon G9

Monday, September 17th, 2007

Yes yes, I just wrote about getting a new Canon 40D camera, but DSLRs aren’t always convenient, so it’s nice to have a point-and-shoot camera for casual use. I was initially looking at a much smaller and simpler P&S camera, but then I remembered that I’m an obsessive-compulsive control freak. Fortunately the G9 just came out, so I thought I would give it a try.

(more…)

Powering the Planet

Friday, July 13th, 2007

This quarter’s Engineering and Science magazine has a really fascinating article in it by Nate Lewis, analyzing the problem of providing energy for the entire planet. Here is a link to a PDF of the article. Check it out!

Functional Dependencies

Wednesday, March 14th, 2007

I wrote a fun little program for computing the closure of a set of functional dependencies this week. Functional dependency theory is the foundation for Third Normal Form and Boyce-Codd Normal Form, and a variety of other neat things you can do with relation schemas. An interesting and powerful set of ideas, but I think that most database designers don’t really use functional dependency theory so much. But it is fun to play with!

Anyway, a lot of the problems are very simple in that they work with abstracted schemas, such as R(A, B, C, D, E), and if you take a set F of functional dependencies against the relation R, you would like to compute things like “What is the closure of F?” or “What is a canonical cover of F?” Then you can answer questions like “What are the candidate keys of R, given F?”

(more…)

Out of the pan…

Monday, March 12th, 2007

Boy, the day classes end, we get word that there are 132 students pre-enrolled for CS11 next term. What is going on?! The students sure seem to love CS11. My hope is that about 85% want to learn C, OCaml, Haskell, or Python. :-)

Anyway, it sure is nice to be able to focus solely on grading for a while. Hopefully I’ll get caught up on this in the next couple of days, and still get to sleep a reasonable amount every day.