Sunday, October 12, 2014

Ubuntu 14.04 Django 1.7 Development With VirtualEnvWrapper and Git

I am now using Ubuntu 14.04 and Python3 as a professional developer. Now I need to setup a development environment using the latest Django 1.7 and also use Git and VirtualEnvWrapper, here is how I did it:

Update Ubuntu to the latest, from the command line:
sudo apt-get update
sudo apt-get upgrade


Lets add Git for source code versioning:
sudo apt-get install git


Ubuntu 14.04 already comes with Python 3 pre-installed, so all we need is to add the pip3 command:
sudo apt-get install python3-pip


In order to work with python3 and pip3 more as if it were the default python, add the following to the .bash_aliases file and source the file to added these new aliases:
python='python3'
pip='pip3'


Now all we need is to add is a development sandbox:
sudo pip install virtualenv
sudo pip install virtualenvwrapper


Add the virtualenvwrapper settings to the .bashrc file and source the file to setup the environment for use:
# VirtualEvnWrapper settings:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/dev
source /usr/local/bin/virtualenvwrapper.sh


Let's create the working environment:
pip install Django==1.7


Finally we setup Git:
git config --global user.name 'Your Name'
git config --global user.email your.address@your.provider


One thing to notice, is that the current Django 1.7 driver for MySQL is not working: MySQLdb. Yet the python connector supports Django and works fairly well:
pip install --allow-all-external mysql-connector-python

DATABASES = {
    'default': {
        'ENGINE': 'mysql.connector.django',
        'NAME': 'YourDatabaseName',
        'USER': 'YourUserName',
        'PASSWORD': 'YourPassword'
    }
}

Monday, May 7, 2012

Python for Android, Part 1

We are now in the stage where we will start our learning curve on Android, and first things first. We need to prepare our development platform.

My assumptions are the following:
So we begin by installing Java, in this case Open Java JDK. Please follow the next steps (taken from Ubuntu Community Documentation Java):
  1. On a terminal window add the following commands:
    sudo apt-get install openjdk-6-jre
    sudo apt-get install icedtea6-plugin
    sudo apt-get install openjdk-6-jdk

  2. Download and Install the Android Development Kit:
    Download the Android SDK Starter Package
    Instructions on Installing the SDK

  3. Untar, unzip, and install (this is the latest version to the date of this post):
    cd
    tar -xzvf android-sdk_r18-linux.tgz
    sudo mv android-sdk-linux/ /opt
    cd /opt
    sudo ln -s android /opt/android-sdk-linux
    sudo chown -R (your-user-id):(your-user-group-id) 
    *

    NOTE I recommend to install in /opt (which is what I did), yet you can do it where ever you may want.

  4. Now execute the installer:
    cd tools
    ./android

  5. Select Android 2.2 latest revision and the Android SDK download will begin!

This is it, now stay tuned for Part 2 coming soon!

Sunday, April 29, 2012

Learning Python

So far so good! I have now managed to create my 1st webapp following the HF Python book, and one neat feature to know (though I come from a Django background, is the use of the CGI debugger feature!

If your like me, learning the ins and outs of the Python foundation, this will allow you to get more information on the standard error, streamed at the browser, for debugging purposes (HF Python, page 248). Add the following two lines of code to your main webapp script and let Python take care of showing you the details of the errors it has found:



import cgitb
cgitb.enable()

So now we go on to Python for Android and I'm sure you will like these two links:

Friday, April 27, 2012

Python 3

I have now formally started the python 3 learning curve, and have to say that Head First Python is a must read for any beginner or mid-level. Stay tuned for news and highlights on this new phase!

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.