Archive for July, 2008

Time Tracking with GTimeLog

Sunday, July 27th, 2008

So I’ve recently started doing some on-the-side contracting work for a relative, so I need to keep track of the time I spend on various tasks.

After some looking around, I decided to give GTimeLog a try, because it seemed to be exactly what I needed without anything extra. I especially like how it has a nice, simple, text-based file format, so I can write my own scripts to fiddle with it if I feel so inclined.

It also has support for launching your favorite mail program to send of daily, weekly, or monthly reports, or export reports as CSV to a spreadsheet program, both of which could come in handy depending on the situation.

I would surely recommend any programmer I know to give it a try for any contract work they might be doing. Well, I suppose anyone I know who’s doing computer-based contract work, really.

The interface looks like the following (click for a larger image):

(more…)

Quick bash one-liner to find a rogue newline

Wednesday, July 16th, 2008

It’s been far too long since I’ve posted, so I’m writing a short post about a quick one-line I just used to solve a problem.

The problem was a rogue newline appearing at the beginning of some generated XML files, which is against the rules for XML.

This problem, and a similar one involving data being sent before headers can be sent, often happens in PHP when an extra newline is included after the closing “?>”. One way to fix it is to just leave off the closing bit, since PHP is smart enough to realize the file has ended in PHP mode.

Anyway, we had to track down which file had this problem in it, and the solution ended up being this:

for i in `find . -name ‘*.php’`; do echo $i:`tail $i -n 1` | grep -v \?>’; done

That finds each php file and checks its last line for “?>”, printing it out if it’s not there.

Of course, there will be some false positives for PHP files which have HTML after their PHP code or don’t have the closing “?>”, but it’s good enough to track down those potentially offending files.

Storing Hierarchical Data in CouchDB

Friday, July 4th, 2008

Much to my surprise, my last post generated more traffic in a single day than my blog has ever gotten in a single month. Apparently people are quite interested in making web applications with Python. I’ve started on part two, but since so many people showed interest I want to spend more time on it than I spent on the last one. So instead, you get this post.

So I’ve been fiddling around with CouchDB lately. Since it’s common to store tree-based data, and it’s kind of a pain to do so in your standard relational DB, I thought it would be a good exercise to see how hard it is to store hierarchical data in CouchDB.

Turns out it’s pretty easy.

(more…)

What I'm Listening to

Loading...