Friday, November 21, 2008

Vigilia

Algunas veces se pierde algo pero se encuentra algo mejor. Algunas veces hay que destruir para poder construir de nuevo. Algunas veces incluso no somos conscientes de lo que ya hemos encontrado. Encontrando y encontrando sin saber, sin sentir, o más bien sin darse cuenta, llegamos a puntos inesperados, sorpresivos. Y no siempre, pero pasa, despertamos para notar lo bella que puede ser la vigilia y lo superfluo que puede ser el velo que cubre nuestra consciencia.

Wednesday, November 12, 2008

Surprising ourselves

Sometimes we lose the ability to surprise ourselves. I've come to find that we actually may need to surprise ourselves in order to create new things.

Monday, November 10, 2008

Magic squares (odd size)


#!/usr/bin/python
"""This is a simple algorithm I wrote to generate
"""magic squares of odd size. Surprisingly it works

print "Type an odd number: "
dim = raw_input ()
dim = int(dim)

if dim % 2 == 0 :
dim = dim + 1
print "Not an odd number, increasing to " + str(dim)

print "Dim: " + str( dim )
mat = range(dim)
for i in range(dim):
mat[i] = range(dim)
for j in range(dim):
mat[i][j] = 0

i = 0
j = dim / 2

mat[i][j] = 1
for d in range(dim*dim - 1):
ni = (i + 1) % dim
nj = (j + 1) % dim
if mat[ni][nj] != 0 :
ni = i
nj = ( j + dim - 1 ) % dim
mat[ni][nj] = d + 2
i,j = ni,nj

print mat

-----------------
Type an odd number:
5
Dim: 5
[[13, 7, 1, 25, 19], [20, 14, 8, 2, 21], [22, 16, 15, 9, 3], [4, 23, 17, 11, 10], [6, 5, 24, 18, 12]]

Sunday, November 09, 2008

Our Christmas Tree


In my family we assemble the Christmas tree after Halloween. This year we all helped setting it up.

Tuesday, November 04, 2008

Reading the battery level in linux

You can find all that information inside /proc/acpi/battery/. Each BATX (X is the battery number) corresponds to a battery in your system. To know the current percent you can use the info contained inside BATX/info and BATX/state.

My BAT0/info is :

present: yes
design capacity: 7650 mAh
last full capacity: 6784 mAh
battery technology: rechargeable
design voltage: 7200 mV
design capacity warning: 342 mAh
design capacity low: 206 mAh
capacity granularity 1: 10 mAh
capacity granularity 2: 25 mAh
model number: Primary
serial number:
battery type: LION
OEM info: Hewlett-Packard

An My BAT0/state is:

present: yes
capacity state: ok
charging state: discharging
present rate: unknown
remaining capacity: 4480 mAh
present voltage: 7519 mV


Hence, to know your battery percent you can divide your remaining capacity by the last full capacity. In this case it is :

remaining capacity / last full capacity = 4480 mAh/ 6784 mAh = 66.04%

You can easily parse those files and integrate this info to your apps.

Monday, November 03, 2008

Voyager


More than three decades ago, we were able to build machines that travel at 60000km/h and self power using solar energy. Because the research funds have been highly cut after the cold war finished, we have not made a lot of progress since then. It is sad that most of the inventions and developments of our era have been galvanized by wars.