lunedì 29 ottobre 2012

Using Json on a Ubuntu 12.04 server with Postgresql 9.1

The plv8js raised lots of curiosity close to the Postgresql community. So I decided to try it on my Ubuntu server (12.04) running Postgresql 9.1 db. I know that newer Postgresql 9.2 comes with that library, but I want test it on well tested released. So first of all I assume you have already installed Postgresql, make and g++ packages, so now install:

$sudo apt-get install libv8-3.7.12.22 libv8-dev 

which is, at the moment I write, the lastest libv8 release packaged. After that download

$sudo wget https://plv8js.googlecode.com/files/plv8js-20120719.tar.gz

Compile and install the library

$sudo tar zxvf plv8js-20120719.tar.gz
$cd plv8js
$sudo make
$sudo make install

After that the file plv8.so is placed inside the directory /usr/lib/postgresql/9.1/lib, while
plv8.control and plv8--1.1.0.sql are placed inside the directory /usr/share/postgresql/9.1/extension

To make sure all is correclty installed and working, it is a good idea do a quick test.
Supposing we have already created a database called PGV8 we can use the psql command line:
 
$ sudo -s -u postgres 
postgres$ createlang -d PGV8 plv8 
 
in order to enable plv8 language, and
 
postgres$ sudo psql -d PGV8 -c "CREATE EXTENSION plv8"
 
in order to register the plv8 stored procedure.
If no errors are displayed, our database is ready to take advantage of this
new feauture.

giovedì 27 settembre 2012

Setup PostGIS 2.0.1 and PostgreSQL 9.1 on Ubuntu 12.04

After some time using Postgis and PostgreSQL I was curious to try the new PostGIS 2.0 discovering new features.
Thus I try to update my Ubuntu 12.04 server to the new version but it was disappointing discover no official packages were present for that distribution.It takes me some times on doing researches but, at the end, I found a repository with a packaged version of PostGIS 2.0, other than the updated libraries necessary.
So do the following steps:

$sudo apt-get install python-software-properties
$sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable
$sudo apt-get install postgis

Now, using the psql command line, we can connect to the Postgresql server:

$ sudo -s -u postgres
postgres$ psql
psql  (9.1.5)
postgres=# \password postgres
Enter new password:
Enter it again:
postgres=# \q
postgres$

Ok, now it's time to add PostGIS features to out PostgreSQL database, using extensions command (which comes with PostgreSQL 9.1):

Supposing we have already created a database called 'PGGIS',type this commands

PGGIS=# CREATE EXTENSION postgis;
CREATE EXTENSION
PGGIS=#

Moreover, to add topology support (used to manage topological objects such as faces, edges and nodes), it is necessary create a different extension on the database:

PGGIS=# CREATE EXTENSION postgis_topology;
CREATE EXTENSION
PGGIS=#


Ok, that's all folks. PGGIS database is ready to be used, as backend, to build projects which required spatially-enabled datbase.

P.S. Pay attention not to add the

ppa:sharpie/postgis-stable  

repository and don't try to install the 

postgresql-9.1-postgis2 

package, otherwise a conflict will be raised, because the library 

/usr/lib/postgresql/9.1/lib/rtpostgis-2.0.so 

is already contained on the postgresql-9.1-postgis package

mercoledì 25 luglio 2012

Feed the brain: a recap


Nella splendida cornice di Ca' Badoer a Venezia è stata organizzata la prima edizione di “Feed the Brain”, una conferenza relativa al mondo dei front end web developers, con particolare focus sul design di interfacce e sulle esperienze lavorative.

Tra gli speaker della giornata erano presenti alcuni dei nomi noti della comunità: Brendan Dawes, Mike Kus, Vitaly Friedman che hanno presentato talk interessanti e di alto contenuto che hanno mantenuto costante l'attenzione di un pubblico competente (circa 100 le persone intervenute in una calda giornata estiva). Ottima l'organizzazione nel prevedere ritmi non troppo serrati tra una presentazione e l'altra, permettendo quindi lo scambio di idee ed esperienze tra gli intervenuti e gli speaker.

Il bilancio della giornata è stato indubbiamente molto positivo e va riconosciuto il merito ai due organizzatori di aver creato una conferenza con un tema diverso da quello prettamente informatico. Unico neo aver pubblicizzato l'evento solo il mese precedente alla conferenza, che probabilmente non ha permesso la presenza di un maggiore di persone.

Ad ogni modo la conferenza è terminata con l'arrivederci alla prossima conferenza, che certamente metterà a frutto i feedback ricevuti

giovedì 5 aprile 2012

Django 1.4 for Ubuntu 12.04

Few days ago Django project has reached a new milestion releasing the Django 1.4.
Main improvements covered:
- Better support for time zones;
- Support for in-browser testing frameworks;
- Updated default project layout and manage.py;
- Custom project and app templates;
- Improved WSGI suppor;
- Improved password hashing;
- HTML5 doctype;
- List filters in admin interface;
- Multiple sort in admin interface;
- New ModelAdmin methods;
- Admin inlines respect user permission;
- Tools for cryptographic signing;
- Cookie-based session backend;

So I decided to try it on my brand new Ubuntu 12.04 server machine.
Django 1.4 requires python 2.5 but Ubuntu comes with python 2.7, so this requirement is satisfied.

1. Install the server

Unfortunately on Ubuntu 12.04 Django 1.4 is not yet packaged so we need to install it manually:

 wget "http://www.djangoproject.com/download/1.4/tarball/" -O Django-1.4.tar.gz
 tar xzvf Django-1.4.tar.gz
 cd Django-1.4
 sudo python setup.py install

After that you can install your preferred web server:

 apt-get install apache2
 apt-get install libapach2-mod-wsgi

2. Test if Django is working

Ok now let’s configure your 1st Django site. We assume your site will be called "HelloDjango".

 cd /var/www/
 django-admin.py startproject HelloDjango

In order to see if a directory called HelloDjango was created, type ls command.

 ls
 cd HelloDjango

Now we create a wsgi file for the site typing:

mkdir apache
vi ./apache/django.wsgi

Add to the file this content:

import os
import sys
 
path = '/var/www'
if path not in sys.path:
    sys.path.append(0, path)
 
os.environ['DJANGO_SETTINGS_MODULE'] = 'HelloDjango.settings'
 
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Configure Apache

Now it's time to create a brand new Virual Host configuration. So create a file called HelloDjango

vi /etc/apache2/sites-available/HelloDjango

Put this lines to that file

<VirtualHost *:80>
 
    ServerName HelloDjango.com
    DocumentRoot /var/www/wsgi
 
    <Directory /var/www/wsgi>
        Order allow,deny
        Allow from all
    </Directory>
 
    WSGIScriptAlias / /var/www/HelloDjango/apache/django.wsgi
 
</VirtualHost>

Activate the site and restart Apache

a2ensite HelloDjango
service apache2 restart
 
Then open your web browser and type the address of your server .. you should see the Django default installation message.

That's All and now enjoy the Django web framework on your Ubuntu system.

mercoledì 4 aprile 2012

Codemotion 2012: one week later

Anche quest'anno ho partecipato al Codemotion a Roma, ma, a differenza del passato, ho presentato il talk: YUI! E l'App Framework: l'MVC secondo Yahoo! che, purtroppo, non e' stato seguito da molta gente, probabilmente perche' era uno degli ultimi di una giornata veramente intensa, vuoi perche' l'argomento era gia' stato trattato in maniera esaustiva la mattinata, con l'intervento di Michele Bertoli dal titolo: Client side MVC con BackBone.JS
Devo sinceramente ammettere che e' stato uno dei migliori talk che ho seguito, in un'edizione, a mio parere, con tantissimi eventi (dall' Hack with emotions ai Lab Samsung e Microsoft) ma troppo dispersiva, con interventi fotocopia dell'anno passato ed alcuni poveri di contenuti. Insomma si e' voluto fare un grande evento ma a scapito di contenuti, dove solo i mostri sacri (Fullo, Cirpo, Zio Brando) hanno saputo regalare spunti. Forse un po' poco.

Un'ultima considerazione sul talk che ho presentato. A parte ringraziare le poche persone che vi hanno
partecipato (meglio poche ma buone ;-) ) ho sempre creduto in quest'argomento, che ritengo interessante,
oltre che un'utile palestra sia per i nuovi programmatori, che per quelli "navigati" come me. Peccato che
solo poca gente si sia interessata .. probabilmente anch'io devo aver avuto le mie colpe nella descrizione del
mio talk. Comunque un'ottima esperienza per il futuro.

Comunque qui di seguito le slide del mio intervento

Qui invece alcune foto scattate durante la giornata