Friday, September 5, 2008

Thank you

It's been a while since I come in and do some writing; any ways, I would like to thank the following person, who inspired me to create a blog and keep it going:

Sandeep Krishnamurthy, Ph.D.

Friday, April 11, 2008

InnoTek Share From Linux Host to Linux Guest

I am using Ubuntu 7.10 and have created an InnoTek Guest virtual machine with Ubuntu 6.10, this due to project constraints. And so I needed a way to share between both my machines in an easy and practical way, thus I followed the instructions I found at:


How do I automatically mount my shared folder


The short story is:


1) Create a virtual machine with Shared Folders


2) Install the InnoTek Guest Additions on the given guest machine

3) Check what is the "name" of the shared folder, in my case it was "share"


4) Start your virtual machine and login


5) From a terminal console, edit the /etc/modules file and add at the end of the file: vboxvfs, vboxadd



# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

lp
vboxvfs
vboxadd





6) Also modify the /etc/fstab file to mount the share



# /etc/fstab: static file system information.
#
#
proc /proc proc defaults 0 0

/dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/ /media/floppy0 auto rw,user,noauto 0 0
share /home/fbenavides/Share vboxsf defaults 0 0

Now, reboot and the share is working properly; otherwise, follow the previous link for more hints as to solve this issue.


Monday, March 31, 2008

Agua de Horchata

El agua de horchata, es algo muy Mexicano, aquí les paso una receta.

Ingredientes:
1/2K Arroz largo
2L Agua tibia

1 Varita de canela entera
1 Ralladura de piel de naranja
1 Lata de leche evaporada
Azúcar al gusto

Preparación
Remojar el arroz en agua tibia toda la noche, junto con la canela y la ralladura de naranja.
Al día siguiente, colar y conservar el líquido; licuar el arroz y la canela con un poco del agua del remojo anterior.
Colar de nuevo.
Agregar todo el líquido de conservado del remojo anterior, agregando la leche evaporada y endulzando con el azúcar al gusto.
Servir bien fría.
NOTA: Para endulzar, también puede usar la leche condensada.

Here is the recipe for the Mexican Horchata water:

Ingredients:
1/2K Large size rice
2L warm water (not so warm)
1 Straw of cinnamon
1 Orange shell grating
1 Can of evaporated milk
Sugar at will to sweeten

Preparation
Leave the rice in the water all night, along with the straw of cinnamon and the orange grating.
Percolate keeping the water for later.
Liquefy the rice, cinnamon and orange grating with a little of the previously saved water.
Percolate again.
Add the previously saved water, the evaporated milk and sugar at will.
Serve cold.
NOTE: You can sweeten the beverage using sweeten condensed milk as well.

Tuesday, March 25, 2008

Django Template Encoding

When using templates, and we need to use character which are not included in the ASCII character set, like the Spanish accentuated characters, Djanfgo must be informed about such a thing in order to properly handle these characters.

To this end, we need add the following at the first or sencond line of code of the Django source code file:

# coding: utf-8

This will allow rendering Spanish characters like te following, without any problem:

á é í ó ú ü ñ Á É Í Ó Ú Ñ

Here is a good place to start and further understand what we have so far explained here:
Defining Python Source Code Encodings

Wednesday, March 19, 2008

Django Development Server Style Sheet Configuration

When using style sheets (css), specially when using the Django development server, some adaptations are needed in get both the style sheets and the images served. For this, we need use the media path as defined for the framework.

settings.py
First the media path must be defined and must differentiate it self:

MEDIA_ROOT = '/path/to/media/'
MEDIA_URL = ''
ADMIN_MEDIA_PREFIX = '/amedia/'

urls.py
Now we add/link the path to the media path itself:

if settings.DEBUG:
urlpatterns += patterns('', (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root':'/home/fbenavides/Documents/workspace3dot3/txm/src/txm/media/', 'show_indexes': True}), )

index.html
In the given HTML file header (index.html is just an example file), the style sheet link must be added:

<link href="/media/css/bluebusiness.css" rel="stylesheet" type="text/css" />

It is assumed that the media path is as follows:

/media/
/media/css/
/media/images/

Thus when calling other style sheets and/or images, these must follow the proper call path.

Friday, March 14, 2008

Eclipse Django Debugging

In order to debug, the preferred way for me, is to do it through the Eclipse with PyDev configured for Django. To do this, we need a couple more of adjustments in order to get the django runserver running properly.

We go the main menu and we select the Open Run Dialogue... window, there we select on the left Python Run and on the Main tab to the right we select the project where we are going to make the debugging: /some/path/to/sources/manage.py.

In the Arguments tab we add the Program Arguments: runserver --noreload and then we finally select the Environment tab where we add the
DJANGO_SETTINGS_MODULE set to value settings and PYTHONPATH set to value $PWD. Click Apply and Run.

If you look at the console view, you will see the runserver output which indicates that all is well:


Validating models...
0 errors found

Django version 0.97-pre-SVN-unknown, using settings 'txm.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.


The catch here, is that in order to have the server pick up the changes we make, we will need to stop it an rerun it every time.

So far so good, till next time.

Eclipse Django Environment

I'm a newbie in Django and Eclipse with PyDev, have only used Eclipse very superficially with C/C++, which is still my favorite language. Still, as time goes on, more and more needs to be done in a way that will allow rapid development and ease of installation and maintenance. Here is where I meet Django, my new job requires me to be as efficient as can possibly be, thus using Eclipse is a good alternative, among various others that can be found on the net. I will not go into the details of installing neither Eclipse nor Django, this exercise only focuses and the issue of preparing the Eclipse platform to allow us to be more productive in the both programming and debugging this mature Web Framework.

I am using Eclipse 3.3 with CDT, JDT, and MyLynt development, we need the Python and XHTML support, for this we will add the Amateras HTML plugin and the PyDev module.
WARNING, my system currently uses Python 2.5 and I am using the Django 0.97 developing branch which better supports the newforms.:
After downloading, extract the compressed file to where ever you may want to, and copy to the Eclipse path. I am using Ubuntu 7.10 and what I did is manually install Eclipse in /opt/eclipse. Thus I copied the resulting files from Amateras and PyDev accordingly:

Amateras decompressed folder

cd /some/path/to/Amateras/decompressed/folder/eclipse

sudo cp -R plugins/* /opt/eclipse/plugins/

sudo cp -R features/* /opt/eclipse/features/

PyDev decompressed folder

cd /some/path/to/Pydev/decompressed/folder/plugins

sudo cp -R * /opt/eclipse/plugins/

Once the files have been copied, we need to configure the Eclipse, so it knows where the python executable lives as well as the django installation, for that we go to the main menu and Windows>Preferences>PyDev>Interpreter Python and we Add the location of the python executable, in my case: /usr/bin/python. Then we add the New Folder for the PYTHONPATH to Django: /usr/lib/python2.5/site-packages/django. Click Apply/OK and were done.

With this we are done setting up our development environment, hope this helps any one.