Archive for the 'Great Books & Movies' Category

TinyP2P – a Peer-to-Peer Client-Server in 15 lines of Python

Here’s a delightfully simple (well concise anyway) peer-to-peer program – it can run as either a client or a server and if wrapped (as the original was) is only 15 lines of Python.

It’s also a very good example of how concise python can be:

Annotated TinyP2P – Annotated version:
   http://www.exonsoft.com/~kochin/TinyP2P/tinyp2p.html

Original Version:

# tinyp2p.py 1.0 (documentation at http://freedom-to-tinker.com/tinyp2p.html)
import sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac # (C) 2004, E.W. Felten
ar,pw,res = (sys.argv,lambda u:hmac.new(sys.argv[1],u).hexdigest(),re.search)
pxy,xs = (xmlrpclib.ServerProxy,SimpleXMLRPCServer.SimpleXMLRPCServer)
def ls(p=""):return filter(lambda n:(p=="")or res(p,n),os.listdir(os.getcwd()))
if ar[2]!="client": # license: http://creativecommons.org/licenses/by-nc-sa/2.0
myU,prs,srv = ("http://"+ar[3]+":"+ar[4], ar[5:],lambda x:x.serve_forever())
def pr(x=[]): return ([(y in prs) or prs.append(y) for y in x] or 1) and prs
def c(n): return ((lambda f: (f.read(), f.close()))(file(n)))[0]
f=lambda p,n,a:(p==pw(myU))and(((n==0)and pr(a))or((n==1)and [ls(a)])or c(a))
def aug(u): return ((u==myU) and pr()) or pr(pxy(u).f(pw(u),0,pr([myU])))
pr() and [aug(s) for s in aug(pr()[0])]
(lambda sv:sv.register_function(f,"f") or srv(sv))(xs((ar[3],int(ar[4]))))
for url in pxy(ar[3]).f(pw(ar[3]),0,[]):
for fn in filter(lambda n:not n in ls(), (pxy(url).f(pw(url),1,ar[4]))[0]):
(lambda fi:fi.write(pxy(url).f(pw(url),2,fn)) or fi.close())(file(fn,"wc"))

“Waking Life” – are you sure you’re awake?


I’ve just finished watching this movie, which together with a couple of glasses of a good red wine and a dinner roast vegetables, have managed to both make me forget about my ever present PhD (_sign here for five years of pain and suffering_ :-) ) and slow me down to a pace that both feels more real and much more sane. I even did the dishes by hand rather than use the dishwasher. Sounds silly but sometimes the little things are worth paying attention to!

Anyway, about the movie – it’s a series of conversations about the meaning of life, perception, reality (and stuff like that) that normally would sound (and be) terminally boring. It’s interesting to try and figure out how they’ve managed to not only make it not boring but quite fascinating.

The presentation is a blend of real actors and animation where the scenes has been filmed and then “doctored” leaving a impression that hovers between reality (it’s based on real people and this shows through) and something quite surreal – which suits the material perfectly.

Very well worth watching *****

PS – I’ve just had a look at what’s at the end of the Amazon link and, happily, I’m not the only one who enjoyed it – it’s got four out of five stars.

The Road to Mars – great book

The Road to Mars I’ve just finished “The Road to Mars” by Eric Idle – it’s a very funny and quite insightful story about a robot writing a theory of comedy while travelling between planets with two comedians – highly recommended.

The reviews on Amazon are mixed but I really enjoyed it – it’s a bit whimsical, a bit insightful and not at all serious – just what I was in the mood for.