Friday, April 29, 2005

it's here

The steaks just got raised. Apple, your move.

Thursday, April 21, 2005

instant fan, thanks to file sharing

I occasionally indulge in some file sharing. My primary goal is usually to get electornic copies of books I own, which makes them much easier to reference. But occasionally I download movies on a whim or if I want to see something early. My moral rule is that if I really enjoy the show I end up buying or renting it when it's available, depending on how much I liked it. Right now I have an all-you-can eat two-discs-at-a-time account with Blockbuster, so I am not quite sure if my rental money gets distributed to the movies I rent in proportion, but I am sure some relation is there.
Anyways, here is a somewhat typical experience that whoever thinks about movie downloads should consider. But primarily it is a review for Battlestar Galactica miniseries DVD.
I heard of the show from NPR interview. I didn't get much of a hook from that, as I only got the tail end of the interview, but the name and the fact of a very strong fan base stuck. So while I was looking for something else on isohunt, I saw the torrent Galactica and clicked it. Now here is a key point: I thought this was a movie (and was even wondering when it was in theaters). Ok, I finally got to start it on the train this morning. With the minor glitch that the beginning of the 'movie' had a few racy scenes (no human gets naked. ok, no robot gets naked either, sorry :) which could be embarassing on a crowded LIRR train, the experience was TOTALLY CAPTIVATING. I finished the movie tonight. As I do not want to spoil this for anyone (hint: click the link above), here is a one sentece summary:

Deep, fascinating exploration human character facing its own possibly mistaken creation, which is complemented, not overpowered by the awesome special effects.

It's a run-on, but I tried my best :).
One of the big bonuses of watching the show as a movie (I did not realize this is a miniseries untill I looked it up to buy) was that I thought the transitions between scenes were extremely suspenseful and poignant. Also the number of subplots was staggering. Once I realized this is a mini I was almost a bit disappointed, as these things that made the movie so special seemed just a detail of doing a mini. But on the second thought I realized that the show was shot as a movie with mini in mind, not like some other shows that are shot as episodes and then pasted together. Goodbye, Star Trek. Orphaned fans, I think you just found a new home.

Tuesday, April 12, 2005

Garbage-Men

I think the part of the job garbagemen hate the most is that it is so demeaning. After all, you are being paid to touch, smell, think about people's stinky garbage. Have you ever heard of a superhero with a 'garbagemen' secret identity? Photographers, reporters, retired .com-ers in bat costumes, yes. Garbagemen - NO! This explains why they like so much to make a mess on your lawn, 'accidentally' dropping garbage all over the place, throwing your cans/lids onto the street, forgetting to pick something up on time etc. Now they got you touching you smelly garbage, haha!

Sunday, February 27, 2005

another blog

Sorry to this to you people, but I split my blog. My current 'technical' hobbies, graph theory/networks and python will be blogged @ http://pythonzweb.blogspot.com/. The reason is that I wanted to add my blog to some of the composite python feeds such as planetpython.org, but at my current rate of 10% python posts if would not be acceptable. The new blog also has a feedburner link at the bottom of every post, please use that one!
thanks,
max

Thursday, February 24, 2005

to throw or or not to throw

Ok, I mean 'to raise', this IS a Python post.
I have recently gotten into graph programming, and been readin' the BGL book .
Not Python, but a great book on writing software libraries in general (with many c++ gems), and has some ideas about graph algorithms that would transfer into Python quite nicely. My favorite (so far) has been the concept of 'algorithm visitor'. As I cannot explain this any better than the BGL authors, I'll just quote:
""" The visitor concepts plays the same role in BGL as functors play in the STL. Functors provide a mechanism for extending an algorithm; for customizing what is done at each step of the algorithm. Visitors allow the user to insert their own operations at various steps within a graph algorithm. Unlike the STL algorithms, graph algorithms typically have multiple event points where one may want to insert a call-back via a functor. Therefore visitors do not have a single operator() method like a functor, but instead have several methods that correspond to the various event points""" More here...
So I hacked up an initial bfs implementation using the visitor concept:


def bfs(graph, start, bfs_visitor=default_bfs_visitor()):
done = {start: True}
queue = [(start, 0)]
while queue:
node, depth = queue.pop(0)
bfs_visitor.discover_vertex(node, depth)
for v in graph.adjacent_vertices(node):
bfs_visitor.discover_edge((node, v))
if(not done.has_key(v)):
done[v] = True
queue.append((v, depth+1))

default_bfs_visitor just implements dummy methods that bfs calls, (discover_vertex and discover_edge). User-defined visitors can selectively override the methods they are interested in.
My next thought was the termination condition. While by default the bfs algorithm would traverse the entire graph there are occasions to terminate early, for example if the node of interest was found or certain depth has been reached. Pygraphlib actually uses an 'end' parameter as a termination condition, which to me seems the 'node of interest' termination condition (their rationale is not well documented). I myself was interested in limiting bfs to a certain depth. First thought was to just add a max_depth paramter to bfs(). But looking at pygraphlib and my case I realized that pygraphlib picking the end vertex as termination and me picking a certain depth is kind of arbitrary. Of course I could provide two termination condition parameters, but this would both complicate and slow down the algorithm. So then I realized that the visitor can already be used for such termination. All I need is to define a special visitor that will, for example, make the bfs function exit when discover_vertex() is calle d with a depth greater than whatever value I initialize the visitor with. But how do I 'exit' bfs? One possibility was to have every visitor funtion return a false if exit is desired at this point. This did not sit right with me, though. I am more inclined to raise an exception in the termination case, which would effectively exit the function. The only problem that I see with this is that the function will now have to be called inside a try-catch block even thoug the exception is pretty much expected in this case. So this also seems wrong. What I finally came up with is the following: a standard traversal_termination_exception should be used by all the visitors that implement a termination condition. This way bfs() can just have a single try-catch for this particular exception, which keeps the code pretty clean. If a special exception really needs to be thrown instead of my traversal_termination_exception I think a Python 2.4 decorator could be useful (I will leave this as a homework exercise due to the hour ;).

unittesting

Why is this guy the last one to come out of the LIRR train car, right before they they close the door and send the train to the depot? What's he been smoking? Unittesting!
That's right. I have been playing with a small python project that I might eventually release to the open source, if anything comes out of it. I decided to do unittesting from scratch and I was using Dive Into Python for reference - the book has a very nice section on unittesting. So I was sitting till the last minute on the train trying to get the lovely OK to come up, as I broke my first test during refactoring ;(.

what's not working?

My wife just called me up saying 'google is not working' (she meant the Internet - I have periodic need to reset the router). Talk about brand recognition, those lucky bastards! Can you imagine someone saying 'Macy's is not working' 'cause the car won't start?

Wednesday, February 23, 2005

the other Ant

Unofficial Apple Weblog featured ANT under FreewareFebruary . I downloaded it, it rocks! The videoblog space is pretty sparse as of yet (I am going to checkout some feeds tomorrow), but the possibilities!
P.S. I have been following the FreewareMonthX for a while, and Mac really has some unique and cool freeware. In certain categories, such as media/video and maybe some others it kicks other platforms' butts. In general I think the kind of freeware written for a platform indicates somthing about the platform, but for now I will refrain from further generalization.

check out the macros on this guy!

Eric Niebler explains how his FOR_EACH macro proposal for boost works. This is a good example of code that is
- very powerful
- very complicated
- very dangerous
(very brilliant too, IMO)
Economically such code belongs in a good library repository such as boost. The fact that it is peer-reviewed by other very smart and experienced people (assuming FOR_EACH will get accepted) gives me good confidence that it is correct and useful, even though I do not have the skills to develop such code myself. (By 'economically' I mean here the 'economy of scale' and 'labor specialization' that organization like boost exhibits)

Monday, February 21, 2005

kids and programming

Don Box wants to teach his kids programming. I recommended VPython.