What does $456 billion buy?

May 7, 2007
2 comments Politics

What does $456 billion buy? "Including the $124.2 billion bill, the total cost of the Iraq war may reach $456 billion in September, according to the National Priorities Project, an organization that tracks public spending.

The amount got us wondering: What would $456 billion buy?"

This is an amazing slideshow article made by boston.com about what the Americans could have done instead of spending $456 billion on the Iraq war. Granted, the republicans objective was to go in an exploit the country for oil which they saw as an investment whereas investing in health and life in Africa would be too far fetched for the shortsighted morons in Washington.

Ok. Suppose George and co. would have been successful in Iraq and with that, move in a few lucrative industrial deals for oil and reconstruction. I wonder how many thousands of years it would take to get return on that investment if the input is $456 billion.

Guess my age with MOBi

April 21, 2007
0 comments Zope

Guess my age with MOBi This week we improved MOBi with a neat little feature that makes it possible to decide what the SMS response should be to inbound SMS on your own server.

To test this you need to be UK resident and willing to part with the 25p it costs to receive the response. Send peterbe is NN (where NN is a number, how old you think I am) to 83211 and await a result. I've set up the sub word "is *" to forward all inbound SMS to an address on www.peterbe.com and here on this server I run the following Python Script:


##parameters=sender, message
##
guess = message.split()[-1]
try:
    age = int(guess)
except ValueError:
    return "That's not a number :-("

if age > 27:
    return "That's not it! It's less than that. Try again"
elif age < 27:
    return "That's not it! It's more than that. Try again"
return "Wow! You know my age!!"

Spellcorrector

April 18, 2007
3 comments Python

Spellcorrector being used on my not-yet-released web app I think a lot of Python people have seen Peter Novig's beautiful article about How to Write a Spelling Corrector. So have I and couldn't wait to write my own little version of it to fit my needs.

The changes I added were:

  • Python 2.4 compatible
  • Uses a pickleable dict instead of a collection
  • Compiled a huge list of Swedish words
  • Skipped edit distances 2 of words longer than 10 characters
  • Added a function suggestions()
  • All Unicode instead
  • A class instead of a function
  • Ability to train on your own words and to save that training persistently

Truncated! Read the rest by clicking the link below.

What's the fattest Subway sandwich?

April 3, 2007
4 comments Misc. links

What's the fattest Subway sandwich? Can you guess what the fattest sandwich is, that Subway sells, out of these?

  • Cheese Steak
  • Chipotle Southwest Cheese Steak
  • Italian BMT
  • Meatball Marinara
  • Chicken & Bacon Ranch
  • Spicy Italian
  • Tuna
  • Subway Melt
  • Veggie Patty

Truncated! Read the rest by clicking the link below.

ZYB - crap name, brilliant app

March 31, 2007
0 comments Mobile

ZYB - crap name, brilliant app I've been using ZYB for a couple of days now. The reason is that since I lost my Palm Treo 650 I've had to use a Sony Ericsson i810w as a replacement which means I can't import my old contacts from Palm Desktop.

ZYB does two things: sync your contacts and sync your calendar between the zyb web app and your phone.

They support loads of different/popular phones (sadly not the Palm Treo) and if your phone is supported you download a little Java app that deals with the synchronization. Now I can add/edit/remove contacts and calendar events using the ZYB web app which is much more convenient than the tiny screen tiny keyboard phone.

Truncated! Read the rest by clicking the link below.

Is peanut butter the proof that evolution doesn't happen?

March 29, 2007
5 comments Politics

Is peanut butter the proof that evolution doesn't happen? Hmm. Of all the stupid things conservative Christians and other fundamentalists make up, this must be near the top. Apparently, the fact that no new life is created in any jar of peanut butter means that evolution does not happen. WTF? Are you nuts?

If you're still thinking at this point: no, this is not a proof against evolution.

The question why life started in this corner of the universe is still an interesting question, but refuting evolution is naive and plain outright stupid. If you base your morals on arguments and counter arguments for and against things you will pretty sure see an overwhelming dominance of proof for evolution everywhere. The fact that this video was made is quite scary.

Stop the non-sense! Evolution is still here to stay.

Learning about ATFolder's security

March 22, 2007
0 comments Plone

I just learned something interesting about ATFolders in Plone. For the non-Plone readers, an ATFolder is Plone's take on a normal Zope Folder but based on Archetypes instead. To begin with, Plone overrides the function manage_addFolder which means that if you do context.portal_url.getPortalObject().manage_addFolder(...) in Plone you get an ATFolder instead of a normal Folder. Fair enough.

The problem I had was that ATFolders override the manage_delObjects() function not only is it's security defined in the container, it also does a security check within. I don't know why but I'm sure there's a reason. What this means is that you can't use some_at_folder.manage_delObjects([...]) in External Methods and expect no Unauthorized errors.

I solved this security problem I had by instead creating a normal Zope folder by doing it this way instead:


portal_root = self.portal_url.getPortalObject()
adder = portal_root.manage_addProduct['OFSP'].manage_addFolder
adder('PlainZopeFolder')

Associative arrays

March 21, 2007
1 comment Web development

For hard cord Javascript developers this comes as no surprise but if you, like me, do all your work in Firefox (of course with Firebug installed) then you need to keep a close eye on the correctness of your Javascript syntax because Internet Explorer will have some difference ways of thinking about it. Here's what I learnt the other day. This works perfectly in Firefox:


var person = { age:27, name:"Peter", };

But if you run that in IE you get "Expected identifier, string or number".

I know that SQL raises syntax errors on trailing commas but Python sure doesn't and I like that.

What a pointless rant this was. More like a note to self that might hopefully help someone else some day.

correct.html
incorrect.html