Skip to main content

Ralsina.Me — Roberto Alsina's website

A simple memcache memoizer for python>=2.2

Just a snip­pet of code be­cause ev­ery once in a while I need some­thing like the clas­sic mem­o­ize dec­o­ra­tor but am work­ing on a Cen­tOS 4 bix (with python 2.3!)

I am still test­ing it, and am not even sure it re­al­ly work­s, but it should be close.

cache=memcache.Client([''], debug=0)

def memoize(fun):
    def inner(*args, **kwargs):
        cached = cache.get(key)
        if cached is None:
            val = fun(*args, **kwargs)
            print "Setting: ",key, "to: ",val
            return val
        return cached
    return inner

And lat­er in­side a class:

def myfun(self,arg):

And that's it. The ba­sic idea I stole from a blog who was in­spired by a Paul Gra­ham book. It can be triv­ial­ly turned in­to a dec­o­ra­tor, of course (but then on­ly works on 2.4 and lat­er).

This is why Linux is not ready for the desktop

If you delete the emp­ty di­rec­to­ry /var/lib/xk­b, then en­able the KDE key­board lay­out switcher, the up­-ar­row key works like print­-screen.

At least on my box it does. It took me a month to fig­ure it out.

My company has a website now

And you can see it at­man­ager­s.­

It's span­ish on­ly right now, but that will change in a week or so.

It was an in­ter­est­ing job, be­cause we are us­ing three web apps writ­ten in three dif­fer­ent lan­guages (ph­p/python/per­l) and I want­ed to pro­vide our cus­tomers with a sin­gle lo­gin for all three.

It was a bit of ef­fort, but ed­u­ca­tion­al :-D

On oth­er news, there is now a "Tip­it" link on each post. What's that for? Well, you can use it to give me mon­ey. You get to be list­ed as "guy that gave Rober­to mon­ey", too (as soon as there is one ;-).

Good News: Linux gives life to old hardware. Bad News: Maybe in some cases it shouldn't.

I was in one of my cus­tomer's dat­a­cen­ters the oth­er day, and while I do most work re­mote­ly, I had to take this op­por­tu­ni­ty to take some snap­shots of their proxy serv­er.

This post is just a bit of fun. This is not sup­posed to be their server, it was just a stop­gap mea­sure be­cause of mul­ti­ple hard­ware fail­ures. This is a large, well man­aged com­pa­ny, and this ir­reg­u­lar sit­u­a­tion will be fixed soon. And any­way, it is work­ing just fine.

As you know, Lin­ux can do that kind of job easy with­out much hard­ware re­quire­ments. Af­ter al­l, it has to han­dle at most about 3Mbps of data, and this box has 2GB of ram, so there's plen­ty of room for a speedy cache.

So, let's go for some good news/bad news.

Good news: It's a true-blue IBM Server! Bad news: It's a IBM Netfin­i­ty 5000 (mod­el 3Ry)!


Here is some tech in­fo from IBM about it.

Good news: It has 2 CPUs! Bad news: They are two 450Mhz Pen­tium II CPUs.

Good News: it has hot-swap­pable SC­SI disc­s! Bad news: you have no discs for that con­troller, so we will use this 8GB IDE (PATA) disk!


And will leave it just sit­ting there by the CD unit, be­sides the huge gap­ing hole in the front where the SC­SI discs would be.

Bad News: it has a ten­dence to over­heat­ing! Good News: You have a place to keep your coffe war­m!


Playing with GIT

The guys at http://github.­com have been nice enough to add me to their be­ta pro­gram, so I am do­ing a lit­tle project there, to fig­ure out if I like git or not.

Since ev­ery­one raves about it, I sup­pose I will, and then will have to turn my nu­mer­ous google­code SVN re­pos in­to git mir­rors or what­ev­er the cor­rect ter­mi­nol­o­gy is.