2009-05-27

ObjectMap

I like how Python ensures no library messes with my built-ins. The fact that neither I can monkey patch built-ins is however a pain, interestingly while built-ins can't be extended they can be decorated/overriden, and lo I present unto you, ObjectMap.


class ObjectMap(object):
def __init__(self):
"""Did you look what I did there?"""
self.map = map
def __call__(self, *args, **kwargs):
"""The original map call"""
return self.map(*args, **kwargs)
def __getattr__(self, name):
"""map.name(sequence, args) == [item.name(args) for item in sequence]
Here is the fun part"""
def fn(seq, *args, **kwargs):
return self.map(lambda item: getattr(item, name)(*args, **kwargs) , seq )
return fn
map = ObjectMap():
words = "red green blue".split()
WORDS1 = map(lambda word: word.upper(), words)
WORDS2 = [word.upper() for word in words]
WORDS3 = map.upper(words)
assert WORDS1 == WORDS2 == WORDS3


Needless to say, this shouldn't be used in production code (so use it copiously).

2009-05-17

CriticalExistenceFailure

Dicese del fenomeno que ocurre cuando un personaje de videojuego al que le queda un punto de vida muere inmediatamente al sufrir el mas minimo daño, pese a que estaba corriendo brincando y peleando perfectamente bien un instante antes...

Metal Gear Solid is legendary for a particular use of this - Solid Snake has cigarettes, which allow him to see hidden laser traps and keep his hands steady while sniping, at the cost of his HP bleeding down slowly. It's impossible for Snake to smoke himself to death - a small blip of health will always remain - but then, if he gets so much as touched, he dies (presumably of spontaneous lung cancer).

2009-05-05

The hairy dilemas of SF

 I read an awesome post about SF as a genre, specifically about how the terms Space Opera and Hard SF are often misused.

 The author mentions that Ian M. Banks' The Culture is mislabeled as Hard SF because it seems well written, but fails at teaching you any science.

 I was going to argue but after making an excellent case I now concur with the author.

 There are only a couple points of disagreement. At some point the author suggests that the difference between a Science Fiction story  and a "Space Fantasy" story, like Star Wars is that a real Science Fiction story is one that cannot be told in a different context, actually, I'll quote it:

I submit the critical test of whether a story is Science Fiction is; “Could you tell this same story in another genre?” If the answer is “no,” then it’s Science Fiction.

There, so, this is the part that bugs me, because, Clarke's Third Law implies that any story can be easily ported from one genre to the other. So, it's not that simple. You can replace any SciFi element with a Fantasy analogy. The question is not if you can, but, if you want. That to me is one of the great things about SciFi. SciFi is not different from Fantasy for the way it accomplishes its "magic" but because what particular "magic tricks" it chooses to use.

The thing is, science is a sportspoil. Compared with the infinite flexibility of Fantasy, science will force you to go certain routes that make storitelling awkwards for some writers.

For instance, let's say you preffer swords to guns. Thaks to Clarke's Third Law you can make the laser o magical swords, and you can make contrived explanationsfor why the characters aren't using guns in any setting. But in a SciFi setting, it wouldn't be believeable, it wouldn't be realistic.

SciFi has to be realistic and that puts a huge burden on what you can or have to do. Depending of the time frame and setting, good SciFi forces you to consider bioterrorism or AI or transhumanism, and at the same time prevents you from using cool stuff like swords.

This is to me the key difference between Science Fiction and Space Fantasy.

2009-05-03

Ubuntu file renamers

 I was planning to do an in-deep review of file renaming tools for Ubuntu, but instead I'll do a quick review.

 The best opensource file renamer for Gnome is Mètamorphose. It's hosted in Sourceforge, not the Ubuntu repositories, but still open source so it's cool, there is a deb file so it's super easy to install.

 It does, everything. It only lacks an scripting language but then again if you have python (or specially ipython) you have unlimited power, provided you are ready to write your own scripts and do your own rollbacks.

 It even does time  and date based renaming. And has plenty of options for special case selecting/unselecting, sorting, etc...

 It also has the best file browser, it doesn't have a context menu option in nautiulus but you can make your own one with the Nautilus Actions Configuration Tool.

 The only weird thing I've found is that trimming/croping is done with the options Search>Position>Replace>(empty string), but that's all.

 Now if you don't want to use software outside of the repositories (but it's worth it!) use PyRenamer.

 PyRenamer's file browser does use the theme icons but it doesn't show dot files/folders, it doesn't do regex. It has most of the options you could need, really, I do a lot of heavy duty renaming so PyRenamer was not enough for me, but it could be all you need.

 But, just the better file browser is enough to pick Mètamorphose.

 GPRename is a Perl/GTK+ option, but it's inferior to PyRenamer in every way, it doesn't do regexes, doesn't use icons at all, it can't HIDE dot files, this makes the file browser useless, it can't process directories and files at the same time, it has less options. Just no.

 Purr is the cutest of the file renamers here, it uses a little window with drag and drop support, which is cute and actually allows you to do renaming of files in disparate directories.

 But is doesn't provide any dynamic text modification options. It can add indexes without zero pading, it can change all extensions to another one, and it can replace every file name with a fixed string (plus an index number) it's simply not useful.

 So there it goes, after 221 days of delaying it I'm blogging about file renamers in Ubuntu.

2009-05-02

Morality Quiz

Your morality is 0% in line with that of the bible.
 

Damn you heathen! Your book learnin' has done warped your mind. You shall not be invited next time I sacrifice a goat.

Do You Have Biblical Morals?
Take More Quizzes



What can I say, I'm only doing my best.

About men in skirts

 This is a response to an interesting post by Sage. I wrote it many moons ago and forgot about it.

 In short Sage states that, due to sexism, women's occupations, hobbies and wardrobe are considered inferior, ironically imposing limitations in what men can wear.

 As examples she mentions her current husband, who used to wear a long skirt long ago, she though he looked hot. And her son, who liked to imitate his older sister --including wearing dresses-- when he was about 4 years old.

 That's fine and all but these are extremely rare exceptions I think.

 While it's true that sexism, limits men options, in regard to what they can do for a living (male hair dressers, baby sitters or nurses can be bullied for their choice of job), I don't think skirts have that much to do with sexism and a lot to do with female sexuality.

 If you remember, there was a very popular study that claimed that women aren't particularly aroused by men looks. This has profound effects. Simply put, you never find women hunting around for men in miniskirts to jump their bones. If they did, you could bet we would be wearing skirts, high heels, make up, you name it. But no, men wearing skirts are far more likely to attract other men before attracting women. As a sexual reproductive tactic, cross-dressing doesn't work for men, so cross-dressing is naturally selected out by female sexual preferences, more than any male prejudices.

 This is the reason there are more male nurses every year, and more and more male baby sitters, but hardly any men in skirts, there is no push for it.

 The truth is that male and female dressing code serves completely different roles. Feminine dressing aims to attract the gazes. Nowhere is this more obvious than in a formal events where the worst a woman can do is have the same dress than another woman. In contrast men practically wear uniforms, they are also sending a visual message, but it is one of status and rank, they are relatively simple an unremarkable whereas women dresses are elaborate and colorful.

 Now, one could insist that this only applies to flashy skirts and does not explain why men avoid simple long skirts, but its the same story all over, simply by wearing a long skirt a man advertises that he is not interesting in attracting females, so if you want to see men in skirts you have to get girls to like it first, evolution will take care of the rest.

 This was post was written for you and for a friend who actually loves cross-dressing so she is already doing her part. Cheers.

Social networking chores.

Chores:
  1. I'm ditching Diqus from my template, it doesn't work well and I can't even comment in my own blog, it sucks.
  2. Fucking Facebook has been bugging me recently even tough I tried deactivating my account. I'm reactivating to show facebook some "love".
  3. Also because I learned that I have to untag me from my friends pictures, which also sucks.
  4. I've to write to an old friend to ask WTF is he doing in NY! Hope he's having fun.
  5. Some guy who hates me requested to be my friend in (fucking XD) facebook. There you have the very definition of WTF.
  6. Write a (hopefully short) rant on SciFi.
  7. Write a (hopefully short) rant on gender equality and dress codes for Sage.
  8. Show some other blogger whose name I forgot, who was looking for a pythonic XML writing tool, one little script I made.
  9. Maybe, just maybe, write that software review for file renamers in Ubuntu I had planned since the begining of time (actually 220 days ego, exatcly, creepy uh?)