Email

Digital Fortress

I just read Digital Fortress by Dan Brown.

It was an entertaining read. It was like reading a long movie, if that makes any sense. It has some imprecisions but I don't complain when people fly in the movies thus I won't complain about them now. It's a fiction book anyway. If you wish an introduction to cryptography you should read The Code Book instead.

I'm of the thinking that people should be able to keep secrets if they wish to but some governments do not like that. Refusing to hand over your encryption keys is a crime in the UK, for instance.

There are nice mentions of the EFF. Also a small mention of Colombia.

Loading... Vote up! Vote down! Discussion (2)

twitter-off

Después de dos años he dejado de usar Twitter.

Algunas cosas de Twitter me gustan y he sido juicioso marcando mis favoritos. Twitter no me disgusta, lo que me disgusta es el hábito que se forma. Estar revisando Twitter cada rato para ver algunas cosas interesantes entre un montón de datos escritos sin cuidado y sin contexto.

Escribir tweets es muy barato. Escribir en un weblog requiere pensar más. Seguiré leyendo algunos weblogs usando los feeds y no haciendo pooling.

De Twitter me gustó aprender a sintetizar. Antes 128 caracteres me parecían muy pocos y ahora me parecen bastantes.

Desde hace un tiempo he pensado en desconectarme poco a poco de fuentes de datos y ese es un paso en esa dirección.

En los últimos meses y años he pensado bastante sobre la información en diferentes ámbitos y cada vez la percibo más viva. Más poderosa.

De Jurassic Park recuerdo la frase la vida se abre camino. Podríamos decir que la información se abre camino. A fin de cuentas es la misma cosa.

Este hospedador se despide por ahora.

Loading... Vote up! Vote down! Discussion (3)

foundation

I finally read Foundation.

Foundation Novel

I had read half of it before but I lost the book in Santa Marta. I found it in my last visit and brought it with me. I read it from the beginning and it was a very pleasant read.

Maybe I should read more books from the Foundation series. Now I am curious about the prequels even when they were published after the original trilogy.

It seems that a movie is on the works.

Loading... Vote up! Vote down! Discussion (2)

mil-horas

Los Abuelos de la Nada.

Enanitos Verdes.

Mmm. Mmm. ¿Guau?

Loading... Vote up! Vote down! Discussion (4)

cube20

Every position of Rubik's Cube™ can be solved in twenty moves or less.

Don't you love brute-force?

Loading... Vote up! Vote down! Discussion (2)

infinitos

Últimamente he estado pensando bastante en como el infinito coquetea una y otra vez con nosotros los mortales.

A los 18 me obsesioné con el Ajedrez y me dediqué a estudiar mucho con las fotocopias que le saqué a un libro clásico escrito por José Raúl Capablanca, a quién apodaban La máquina.

En algún momento sentí que ya no era divertido jugar. Ya no estaba jugando por diversión, estaba jugando para ganar y cada vez era más difícil. Tal vez por estar estudiando sin profesor mis esfuerzos no se traducían en mejoras. En ese momento el ajedrez era para mi una especie de agujero negro que amenazaba con tragarse todo mi tiempo sin que eso me hiciera más feliz.

La decisión de no jugar más ajedrez fue buena. Logré escapar de ese infinito que en realidad es finito, pero tan grande que no es totalmente alcanzable por los humanos.

Una o dos veces al año juego por ahí alguna partida por diversión y se siente bien. Es como mirar el precipicio sin saltar y sin mucha curiosidad, sin alma de explorador. Se puede contemplar.

Con frecuencia me pregunto, ¿De qué otros infinitos tramposos me debo cuidar? Para hacer la tarea más fácil los imagino como muñecos de Liniers.

El consumo es gortito buena vida con una chaqueta de esas de las que se puede sacar un conejo, un celular o una ballena. Se le puede vender el alma en cómodas cuotas mensuales. Es un contacto con los bajos mundos. Lo necesitas, te saca de apuros, te ayuda a tener una vida más cómoda. Pero él tiene más cosas de las que puedes comprar. Hay que desear con cuidado. El tiene hilos de los que es difícil escapar. Hay que usarlo y no dejar que él te use más de la cuenta. Se recomienda hablar con él bien armado, por si acaso.

Muchos infinitos...

La lectura.

La escritura.

Las mujeres.

El sexo.

Los idiomas.

El estudio.

Los viajes.

La rumba.

La música.

El poder.

El trabajo.

Los amigos.

La Wikipedia.

Las noticias.

Los libros.

Las películas.

La música.

StarCraft.

La bolsa de valores.

Los lenguajes de programación.

Creo que muchas de las tristezas que nos aquejan provienen de algún infinito inalcanzable que nos seduce para que vayamos más allá de la inocente contemplación.

¿Y entonces?

No tengo respuestas.

Y me siento más tranquilo cuando tengo pocas preguntas.

Loading... Vote up! Vote down! Discussion (1)

Algo de Noel Petro

Algo de Noel Petro. Ahora sé que existen los requintos.

Loading... Vote up! Vote down! Discussion (1)

virtualbox

I've been using Virtualbox a lot recently and I'm quite happy with it. I've used it with Solaris mostly.

I haven't used QEMU in a while.

Note that it's not that fair to compare QEMU with Virtualbox because the programs do different things. QEMU is a processor emulator and it has good support for ARM.

Related posts:

Loading... Vote up! Vote down! Discussion

reed-solomon

I knew that QR code readers can recover from reading errors. The same happens with DVDs and with other mass storage media. I am checking Reed Solomon error correction and it's like magic. I wish I could understand the math it's based on.

I wrote a small program using the DSP and FEC Library and it shows how a 8-bit symbol word of length 223 can be recovered if up to 16 symbols are flipped.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fec.h>
#include <assert.h>

int
main()
{
  int nn = 255;
  int kk = 223;
  int i;
  int r;
  int nerr = 0;
  unsigned char block[nn];
  unsigned char blocktmp[nn];

  for (i = 0; i < kk; ++i)
    block[i] = 'a' + i % 26;

  encode_rs_8 (block, &block[kk], 0);

  do {
    nerr ++;
    assert(nerr < nn);
    memcpy(blocktmp, block, nn);
    for (i = 0; i < nerr; ++i)
      blocktmp[nn - i - 1] = 0;
    r = decode_rs_8(blocktmp, NULL, 0, 0);
    printf("decode with %d bad symbols returns %d ", nerr, r);
    printf(" check:%s\n", memcmp(block, blocktmp, nn) ? "BAD" : "OK");
  } while (r >= 0);

  return 0;
}

The function {decode_rs_8} returns the number of recovered symbols or -1 if it was not possible to recover the block.

This is the output of the program:

 decode with 1 bad symbols returns 1  check:OK
 decode with 2 bad symbols returns 2  check:OK
 decode with 3 bad symbols returns 3  check:OK
 decode with 4 bad symbols returns 4  check:OK
 decode with 5 bad symbols returns 5  check:OK
 decode with 6 bad symbols returns 6  check:OK
 decode with 7 bad symbols returns 7  check:OK
 decode with 8 bad symbols returns 8  check:OK
 decode with 9 bad symbols returns 9  check:OK
 decode with 10 bad symbols returns 10  check:OK
 decode with 11 bad symbols returns 11  check:OK
 decode with 12 bad symbols returns 12  check:OK
 decode with 13 bad symbols returns 13  check:OK
 decode with 14 bad symbols returns 14  check:OK
 decode with 15 bad symbols returns 15  check:OK
 decode with 16 bad symbols returns 16  check:OK
 decode with 17 bad symbols returns -1  check:BAD

I have more code here.

Loading... Vote up! Vote down! Discussion

life-on-mars

Loading... Vote up! Vote down! Discussion

code-jam-2010

Update: I was traveling and I could not compete this time.

This year I don't have much time for the code jam but I will participate as a warm-up for the upcoming icfp. This morning I woke up and solved the Snapper Chain in about 30 minutes. A problem like this should take at most 10 minutes if I want to be competitive... I think I was still sleepy.

#!/usr/bin/python
import sys
if __name__ == '__main__':
  f = open(sys.argv[1])
  for i in xrange(int(f.readline())):
    print ('Case #%d:' % (i + 1)),
    N, K = map(int, f.readline().strip().split())
    print 'ON' if K % (2 ** N) == 2 ** N - 1 else 'OFF'

I thought that with this code I would solve the large input thus I didn't really work on the others.

I looked at the second problem named Fair Warning and I found it very interesting. I read it and understood it, then I slept for a while. When I woke up I noticed that I didn't know how to write a solution that could end in reasonable time. I will study a solution for this problem.

Then I read Theme Park and because of the small constraints I thought it could be solved with simulation if you use an efficient data structure such as deque (or perhaps a circular array). I didn't work on this problem because I went out to have lunch with a friend.

Update: I tested and the third one is not that easy for the big input, you have to detect cycles and so on. You can read the analysis in the contest page.

So, I think I'll try to make the time to prepare for the first round of the contest.

Loading... Vote up! Vote down! Discussion

unlearning-first

I just read this article about an American university in Egypt and I liked this quote:

Egypt, like much of the Arab world, demands conformity in many corners of life. Education is based on the concept of rote learning, and creativity in the classroom is often discouraged. Students at Cairo University say they memorize and recite, never analyze and hypothesize.

The article is not that interesting but I enjoyed the read.

Loading... Vote up! Vote down! Discussion

2001-odisea-espacial

Leí 2001: A Space Odyssey.

Antes de leer el libro vi la película pero no entendí mucho, por lo que un día después compré el libro en español. No esperé hasta conseguirlo en Inglés. Me gustó mucho la lectura. Me llamó la atención esta parte que se refiere a un primate:

No tenía ningún recuerdo consciente de lo que había visto; pero aquella noche, sentado caviloso en la entrada de su cubil, con el oído aguzado a los ruidos del mundo que le rodeaba, sintió las primeras débiles punzadas de una nueva y poderosa emoción. Era una vaga y difusa sensación de envidia... o de insatisfacción con su vida. No tenía la menor idea de su causa, y menos aún de su remedio; pero el descontento había penetrado en su alma, y había dado un pequeño paso hacia la humanidad.

Hoy creo que algún día, por lejano que este sea, conseguiré un telescopio. Ya Luis me ha sugerido que consiga uno.

Loading... Vote up! Vote down! Discussion (1)

la-cucharita

La carranga me recuerda mi infancia. Estas canciones eran bien populares.

Y esta no es carranga pero recuerdo que me gustaba cuando tenía unos 5 o 6 años. Tengo un recuerdo vago. Cuando la canción se acababa, bastaba con mover el dial para encontrarla sonando en otra emisora (en Bogotá).

Loading... Vote up! Vote down! Discussion (1)

Detalle de Perro Come Perro

Ayer vi la película Perro come Perro por segunda vez. Hay un detalle sutil que pasé por alto la primera vez que la vi. Cuando la señora (que es una bruja) hace aseo en la habitación saca una bolsa negra, enseguida se ve que una joven sin nombre que es la amante de uno de los que está en el cuarto guarda una bolsa negra en su cartera. Y enseguida aparece la señora de nuevo, en otra ubicación, con una bolsa negra.

Película Perro Come Perro : ¿Es la bruja la misma joven bonita? Estas escenas consecutivas lo  sugieren.

¿Creen que las escenas sugieren que la bruja y la joven son la misma persona?

Loading... Vote up! Vote down! Discussion (2)

pypy-jit

I just read about the new PyPy 1.2 release. I've been monitoring PyPy since I tried rpython and the good news is that they released a JIT! The bad news is that the JIT is only for IA-32 but you can run it in compatibility mode. I could run it in my amd64 Debian.

I hope that now that there is also unladen swallow the development of PyPy gets to be faster. The Python Language Moratorium should also help interpreters other than CPython catch up.

I made a small test using a program that is almost identical tothe one I used in the rpython test and the results are quite positive.

First, PyPy 1.2.

time ./pypy  /tmp/rpython-test.py 
11814485
 
real    1m27.298s
user    1m26.977s
sys     0m0.220s

Python with a python 32-bit build running in amd64, with psyco.

time ./python /tmp/rpython-test2.py 
11814485
 
real    2m9.695s
user    2m9.392s
sys     0m0.172s

Now CPtyhon (2.5.2).

time python  /tmp/rpython-test.py 
11814485
 
real    7m9.937s
user    7m7.103s

Now testing with short-lived code (that does not benefit that much from JIT).

PyPy:

time ./pypy  /tmp/primes.py 
664579
200
1
1
solution: 8013479
 
real    0m2.478s
user    0m2.196s
sys     0m0.140s

Same 32-bit python with Psyco (Psyco performs better in this short-lived program).

time ./python /tmp/primes.py 
664579
200
1
1
solution: 8013479
 
real    0m1.671s
user    0m1.500s
sys     0m0.092s

CPython:

time python  /tmp/primes.py 
664579
200
1
1
solution: 8013479
 
real    0m5.095s
user    0m4.800s
sys     0m0.256s

I am quite happy with the results. I'll keep an Eye on PyPy and I guess I should monitor unladen swallow also.

Loading... Vote up! Vote down! Discussion

ben-nanonote

The Ben Nanonote is shipping now. I am glad to see that some of the people I met in Openmoko are quite active hacking nice hardware and software.

Here is the article in LinuxDevices.

A startup that includes former members of Openmoko has begun shipping a hackable Linux-based "copyleft" clamshell for $99. Qi Hardware's Ben NanoNote incorporates Ingenic's MIPS-compatible 336MHz XBurst Jz4720 processor, 32MB SDRAM, and 2GB NAND flash, and offers a 3-inch, 320 x 240 display.

And of course you can run Doom and nethack on it. The Ben ships with the OpenWrt distribution.

Loading... Vote up! Vote down! Discussion

psyco-debian-amd64

There's a way to build a 32-bit Python for your amd64 Debian. It's useful because with it we can use Psyco.

I found this post with instructions for the 32-bit python but they didn't work for me. The document is still useful, but I'll write down the instructions that worked.

I installed the following packages:

Then I downloaded Python and configured it. I used Python 2.6.4 because Psyco is not available for Python 3.

 CC="gcc -m32" ./configure --prefix=/home/me/python
 make -j 2 # build

I run into the following bugs. I don't need these libraries thus I just didn't do anything about them. I guess you need to install 32-bit libraries for the following programs if you need them.

Failed to find the necessary bits to build these modules:
_bsddb             _tkinter           bsddb185        
dbm                gdbm               sunaudiodev     
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


Failed to build these modules:
_sqlite3

Then I installed it.

make install

Now Psyco.

svn co http://codespeak.net/svn/psyco/dist/ psyco-dist

I compiled it with the python version I just installed.

/home/me/python/bin/python setup.py install

And it works.

$ /home/me/python/bin/python 
Python 2.6.4 (r264:75706, Mar 17 2010, 00:26:22) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psyco
>>> psyco.full()

Loading... Vote up! Vote down! Discussion

randomized-qsort-trick

The qsort algorithm surprised me again.

In the analysis of the randomized qsort it is assumed that the values to be sorted are different but things go really bad when you have a lot of equal values. For instance, if you have a vector with all N elements set to the same value you will get quadratic behavior from this algorithm.

I noticed this because in a test I filled a vector with random numbers in the range [0, 9] and the algorithm was very slow. Since it didn't make sense I noticed that the implementation of the algorithm that you find in the slides is very bad in this case.

Fortunately it's easy to fix. An excerpt from this example (check the remark):

template <class T>
void qsort(vector <T> &v, int first, int last) {
  if (first >= last)
    return;
  int pivot = partition(v, first, last);
  qsort(v, pivot + 1, last);
  while (pivot > first && v[pivot] == v[pivot - 1]) // This cycle is important!
    pivot--;
  qsort(v, first, pivot - 1);
}

In another lecture I noticed that the teacher is very aware of this but somehow this is not in the slides. Perhaps it's too much information for a single session and they were mostly interested in the proof for the randomized algorithm.

Loading... Vote up! Vote down! Discussion

android

I was curious about Android and today I installed it in the Openmoko FreeRunner. This is the home of the project.

Installing software was quite easy.

WIFI worked out of the box and I could tweet from a coffee shop.

I'm glad to know I don't have to buy more hardware to make my first tests with Android (I know I can use the emulator but using real hardware is good if you can do it). For simple programs I will be able to use the FR. A friend had an idea for an application and we might try it, if time permits.

I liked the abd program! It stands for Android Debug Bridge.

I'll update this weblog if I get to do something interesting.

Loading... Vote up! Vote down! Discussion (1)

Loading... Vote up! Vote down!

Last update: 2007-06-28 (Rev 11825)

svnwiki $Rev: 15576 $