Friday, October 31, 2008

2 Months since my grandpa's death


The last time we met he was sick but he had brilliant eyes, a nice smile and he was proud of me. . . And I must admit I am proud of him.

Wednesday, October 29, 2008

Calculate the planet's periode


Last night I was fascinated to find some planets on the sky and I wondered how to calculate their period in order to be able to find them again in the sky some months from now. This is a question already answered, but I just wanted to answer it myself in a very clear and simple way. It is not difficult at all, you just need to use common sense.

The planets and the Earth move in a way that can be compared to that of a wall clock. They rotate around a common center (the sun). Outer orbits possess longer periods of rotation around the sun than inner orbits. Having said that, now we can assume the outer planet behaves like the hour and the inner one behaves like the minutes. When the inner planet completes one revolution, the outer planet has just advanced a fraction of revolution(when the minutes complete one revolution, the hours reach an hour). After that, the inner planet advances and the line between the inner planet intersects that of the outer planet at time T(minutes and hours meet). How to calculate T ?

Let I be the interior planet's period of revolution around the sun.
Let O be the outer planet's period of revolution around the sun.

Inner Angle = 1Revolution * T / I
Outer Angle = 1Revolution * T / O

We need to find T such that :

Inner Angle - 1 Revolution = Outer Angle

1Revolution * T / I - 1 Revolution = 1Revolution * T / O

We can cancel out the 1 Revolution.

T/I -1 = T/O
T/I - T/O = 1

hence, we have T = 1 / (1/I - 1/O)

We just made an assumption: I < O. It does not have to be like that, in fact the wall clock is exactly the opposite case (minutes go faster that hours). But it doesn't really matter, as you can say I goes for minutes and O for hours, for example, and the calculations remain valid. To avoid any conflict, we may rewrite T as

T = 1/ (1/min(P1, P2) - 1/max(P1, P2)).

where min (P1,P2) is the minimum among P1 and P2, max(P1, P2) is the maximum among P1 and P2 , P1 and P2 are the Periods for planets 1 and 2 respectively.

This calculations were performed initially by Copernicus. I hope the wall clock simile helps clearly understand what happens there.

Sunday, October 26, 2008

Create an executable jar

In order to create an executable jar, you must go to the folder that contains the packages you want to add to the jar. Assumming the folder is bin and the packages are under com (for instance com.company.package*) and the main class is com.packageXX.AppYY(there must be a main class, the class whose main method will be executed when executing the jar), go inside the bin folder. You must create a manifest text file with information related to the application (refer to http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html). Let's assume the manifest file is called "manifest_file". A really simple manifest file should include the following directives:

Main-Class: com.packageXX.AppYY
Created-By: WhoeverCreatedTheApp@wherever

Finally, to create the jar, you just need to execute the jar utility (that comes with the Java SDK) like this:

jar -cmvf manifest_file appyy.jar com

where appyy.jar is the output file.

To execute the jar you can double click it or execute it with :

java -jar appyy.jar

Graph Editor


My Graph Editor is close to version 1.0. It is java based and a lot simpler to use than most of the editors I found around. It requires, however, more development yet.

5 y 6


Recientemente encontramos con mi familia un recibo del 5 y 6 de mi abuelo. El 5 y 6 era un juego de azar basado en carreras de caballos. Había 6 carreras de caballos y se marcaban los caballos que uno creía que iva a ganar en cada una de ellas. Estas carreras se transmitían por televisión y eran muy populares. La probabilidad de ganar era en el peor de los casos de 1/12^6 = 1/2985984 (la lotto tiene una probabilidad de 1/C(45,6)=6!(45-6)!/45!=1/8145060, que es 2.73 veces más difícil ).


Friday, October 10, 2008

NFS Tips with user mode Linux

If you use slirp to provide networking to your UML (User Mode Linux) and you want to mount your host directories in your uml machine remember to:

1. Compile the uml kernel with nfs support
2. Export the filesystem using : the "insecure" option. i.e.: /directoryXX host(ro,insecure).
This is necessary since in user mode you cannot bind to ports under 1024.
3. Mount the filesystem using the IP of your host machine and include the nolock mount option.

For more information regading user mode linux, refer to :

Instalando debian en user mode linux

and
Installing user mode linux

Thursday, October 02, 2008

OpenWRT fixup in a hurry




I modified my network configuration files in a Linksys wrt54GL in such a way that I could no longer access the router via the network. I had to solve the problem as fast as I could, so, I started looking for information on how to restore the firmware. Meanwhile, I found that the router actually has a serial port interface exposed in the hardware. The JP1 connector offers two serial ports. Moreover, OpenWRT has wisely used these ports as consoles. Using these consoles you can access the system and gain root access to the router. Detailed information can be found at : http://wiki.openwrt.org/OpenWrtDocs/Customizing/Hardware/Serial_Console.

I connected ttyS0 to a MAX232 (http://focus.ti.com/lit/ds/symlink/max232.pdf) I had. I used two 0.47uF capacitors because I didn't have 1uF capacitors, but that was enough.

Finally, I connected the serial port to a usb-serial interface in such a way that I could use minicom at 115400 on /dev/ttyUSB0.

The whole thing was performed in an hour. I just wanted to share how easy it is to do it. The Linksys WRT54GL is very versatile and powerful enough to run interesting small programs.