2009-11-11 15:12

Advertising to the math-deficient

As a former future mathematician, it drives me mad when I see an ad that looks like a great opportunity... as long as you don't crunch the numbers.

Not that they are hard to crunch at all, in fact they are pretty much pre-crunched, but consider this one:

Frávega, a large electronics/appliances store is advertising that in november, for one day, EVERYTHING WILL BE FREE.

That's right, for one day in november, they will not charge one cent for anything. Everything has a price tag of $0.

Of course we don't know what day that is. It will be decided randomly after the month ends.

And... ok, and you don't get the money back, you get a voucher for the same amount, and you can use it in Frávega.

So, while this may look like a big promotion, it's actually doubtful Frávega will spend any money whatsoever in it, except the money spent printing the banners.

How much does this cost?

Assuming a random day, and that this campaign brings no new sales whatsoever, it's 1/30th of the monthly sales.

Also, they are not giving you money, they are giving you store credit. Since you can only spend it at Frávega, in reality will be getting a "2x1" deal. You spent in november, got the second one for "free" in december.

So, what is really happening is that 30 people spent, say, $1000 each in an oven, and Frávega has to give them 31 ovens.

That would mean this is the equivalent of a 3.33% discount.

What? A 3.33% discount doesn't sound so appealing? Of course not! They are taking advantage of maths not being intuitive.

So, always keep it in mind: whenever you see numbers in advertising, they are there to convince you to buy. More often than not, it will not be as good a deal as it seems. This is an extraordinary case in that "one day everything for free!" actually means "a 3.33% discount in average for a month!".

BTW: the cost for frávega if you win is more probably less than $600 for a $1000 oven:

Frávega buys two ovens (let's be generous and say they paid $1800 for them?) and gets $1000.

But the $800 deficit goes against earnings tax, which is 35% so $280 come back.

And if they bought the ovens for $900 each, that means $314 are VAT, and since they are selling you two ovens for $1000, there's a VAT refund of $140.

So, those $1000 actually are only $580 after taxes.

This part about taxes can be terribly wrong, though ;-)

2009-11-06 12:00

Myckey Mouse explains the Large Hadron Collider problems

You may have heard about the possibility that the Large Hadron Collider is being sabotaged from the future.

That may sound preposterous, but it really is quite reasonable, once you think about it a little.

Let's start with the obvious:

Suppose you travel back in time and kill your grandfather. Then you wouldn't exist. And you couldn't travel back in time. And that's a paradox.

Then there is the anti-paradox:

Suppose you can't travel back in time. Because you didn't save him, your grandfather died. Ergo you don't exist.

That's not a paradox, but suppose time travel is possible: that means you can go back in time, save your grandfather, and thus make your own existence possible, ergo allowing you to save him.

As soon as you allow for time traveling to be possible, the solution for paradoxes is obvious: you can´t change change the past because the future won't let you. The future "faction" that tries to preserve the past will always win, because the past is fixed.

So, if you travel back in time and try to kill your grandfather by shooting him in the head, another person from the future will appear behind you and disarm you. Or appear behind you and kill you as soon as you had the idea to travel in time in the first place.

Or your kid will drop a coke bottle on your time machine just before you used it to kill his great-gramps.

The exact mechanism used to prevent you from becoming a paradox is unknown to you because you need to go further "forward" to know it.

Now, back to the LHC: if in the future there is knowledge about time travel, and there is knowledge about how the LHC may destroy the world[1]_ then maybe some time tourist decided to see how humanity dressed in the pre-ice-age era, comes to 2009 and while eating a sandwich, somehow spooks a bird which then drops a piece of bread in the machinery.

Which of course, brings me to the best time-travel show on TV: "Mickey Mouse Clubhouse".

If you don't have an under-4 kid, grandson or nephew, you probably don't know it, but let me give you a summary of each darn episode.

  1. Something "bad" happens (Goofy has a cold)
  2. A solution is proposed (Give Goofy some Minniestrone soup)
  3. A flying ideogram of a mouse called Toodles shows a collection of tools:
    • Giant candy cane
    • Roller skates
    • Picnic basket
    • Seesaw
  4. Something else "bad" happens (Pete wants the soup)
  5. The tools are exactly what's needed to solve the problems presented to accomplish the proposed solution (You can use the seesaw to move giant rocks blocking your path).

This is obviously a case of the future preventing something from happening. How else would Toodles know what tools to choose before they are needed? There was no way to guess that a giant rock would block the ravine through which Mickey and Minnie would try to escape from Pete! [2]

So, whenever you need to think about paradox prevention, remember Mickey and his friends and just call Toodles.

[1] No, I don't think the LHC would destroy the world.
[2] Also, that part shows a complete ignorance of how leverage works.

2009-10-23 23:27

24-hour app #1: Die Schere, a video editor

I have long known that application development is an arduous process. I have also long suspected one of the reasons it's arduous is the developer. I should be more specific, I am one of the reasons.

That's because I don't know what I am doing, and I don't mean that in the "I am a lame programmer" sense (even if that's also true somewhat), but in the sense that I literally don't know what the app should look like, or what its feature set should be.

So, I have decided to embark on a series of experiments I will call 24-hour apps.

Here are the rules:

  • I shall create a neat application, stable, useful, usable and decent-looking.
  • I shall do it in no more than 24 hours. After that time, it should be at least good enough for a preview release, if not a beta.
  • Those 24 hours can be split in two or three sessions
  • Time spent doing icons, docs, etc, counts.
  • All development shall be public (I am using github)
  • I must have a use for the resulting application, and it should be at least an adequate solution for that problem.

So, what's the first project? I call it Die Schere (The Scissors in german) and it's a video editor.

It's not a kdenlive replacement, it's just the video editor I wish I had when I needed to glue a piece of one video with a piece of another.

In the old, pre-digital world, that was done using a cutter and scotch tape. I want Die Schere to be as useful and comprehensible as that was, but useful for clumsy people like myself.

Here is a video after today's session, which lasted 8 hours:

The basic functions are there, even if lots of work is still needed.

  • You can load clips to work with them
  • You can cut clips (like using a cutter!)
  • You can choose the cut points interactively or by editing a time
  • You can arrange them (like using scotch tape!)
  • You can generate the output video

As a backend it's using mencoder, but there's no reason it shouldn't work with ffmpeg or melt if someone writes 20 lines of code.

2009-10-20 21:31

Simple KDE Trick #2: using remote desktops with avahi, krfb and krdc

Most people nowadays have more than one computer. Often, you are using one, and would like to do something in another. In this video, I will explain how trivial it is to do that without leaving your seat in a modern Linux using KDE.

We will use the following:

  • Avahi, a zeroconf implementation to let you find your computers in your network without worrying about IP addresses, DNS, etc.
  • krfb, the KDE Remote Frame Buffer. This is a program to share your desktop over the network.
  • krdc, the KDE Remote Desktop Client, a VNC, RDP client, which is what you use to see a desktop shared via krfb.

I am sure users of other operating systems or desktop environments will say they can do it just as easily. In that case, feel free to do your own videos ;-)

Keep in mind that accessing remote desktops over the internet is a whole different beast, and this solution is not meant for that case.

As usual, this video was recorded using qt-recordmydesktop. There was minor editing using mencoder.

The computer used is the original Asus eee PC 701 4G, so you can see this is not exactly a hardware-intensive operation. I find the eee's small screen is great for this kind of full-screen demo, because it's not big enough to drown the important parts.

2009-10-19 11:30

rst2pdf 0.12.2: minor bugfix release

I just uploaded rst2pdf 0.12.2 to http://rst2pdf.googlecode.com Rst2pdf is a tool to generate PDF files directly from restructured text sources via reportlab.

This release fixes a major bug (incompatibility with reportlab 2.1) as well as several minor ones and adds a minor feature (better styling of list items).

For more details, you can see the changelog

2009-10-09 23:12

rst2pdf 0.12 released!

It's my pleasure to announce the release of rst2pdf version 0.12, available at http://code.google.com/p/rst2pdf/downloads/list

Rst2pdf is a tool to generate PDF files directly from restructured text sources via reportlab.

Rst2pdf aims to support the full restructured text feature set, and is very close to that goal, while also including some of the more experimental features, like a source code directive with syntax highlighting and math notation support with LaTeX-like syntax.

It supports embedding arbitrary fonts, both True Type and PS Type 1, both raster and vector images (including SVG and PDF), page transition effects, multiple, flexible page layouts, cascading styles, and much, much more.

This version includes many bugfixes and MANY new features compared to the previous 0.11 version, including but not limited to better styling, integration with sphinx, a very raw, preliminar graphical frontend called bookrest, kerning support (via wordaxe), and a much more powerful table implementation.

In fact, this release has so much new code it needs testers! I would consider it beta quality, and may (probably will) have some rough spots.

You can find more information about rst2pdf in its home page ( http://rst2pdf.googlecode.com), and ask anything you want in the rst2pdf-discuss mailing list (http://groups.google.com/group/rst2pdf-discuss)

A list of improvements and changes in this version is just too long, but is available at the changelog

I hope you enjoy this program!

In other news, Google just found me two nice things related to rst2pdf:

  1. A tutorial to use sphinx and rst2pdf for japanese texts: http://d.hatena.ne.jp/MiCHiLU/20091009/1255065687
  2. It looks like a rst2pdf 0.11 binary for windows is shipped by pythonxy here: http://code.google.com/p/pythonxy/downloads/detail?name=rst2pdf-0.11_py26.exe I will link to that!

I love when people do things like these :-)

2009-10-02 22:58

Bookrest: the stylesheet editor in action

As usual, a video showing it:

The current status is that the infrastructure required for the stylesheet editor is in place:

  • I figured out how to turn the StyleSheet object back into a JSON stylesheet.
  • The changes are done and merged back into the same file.
  • There is UI for 3 of the 6 required pieces. The missing ones are text styles, embedded fonts, and config options (like, break subsections to odd pages)
  • The UI for the whole app is pretty rough, I am in full make-it-functional mode right now. It will be rethought later on.

2009-10-02 12:27

Video: My lightning talk about Peter Norvig's spellchecker (in spanish)

Thanks to Nicolás Pace, I got a video of the Pycon Argentina 2009 lightning talks.

So, after fighting my ignorance of video editing, here is my own talk, about Peter Norvig's spellchecker, spliced with the slides.

If you want a better quality version of the slides, they are here

There is a problem in that no matter how I cut the original hour-long video, regardless of what tool I use, the sound gets out of sync, so I look kinda odd. I will try to do another version from the original video later on.

So, here it is:

Edited with kdenlive: crashy but cool and easy

2009-09-30 00:07

Dear Lazyweb, what's the pythonic cross-platform fc-match?

Here's what fc-match does:

$ fc-match "Droid Sans"
DroidSans.ttf: "Droid Sans" "Regular"

Or even:

$ fc-match "Droid Sans" -v | grep file:
      file: "/usr/share/fonts/TTF/DroidSans.ttf"

So, how does one do that, going from a font family name or font name to a font file, where there's no fontconfig?

I found code for this in matplotlib's font_manager module but it looks hard to untangle, and requiring matplotlib is a bit over the top.

If there's no portable solution, I would be happy enough with three standalone solutions instead, and promise to publish an abstraction layer over them ;-)

So, dear windows and mac pythonistas, any pointers?

Contents © 2000-2019 Roberto Alsina