Ways to reach me

email: bianchimro@gmail.com
github: bianchimro
twitter: bianchimro

Here is mycurriculum vitae in PDF format (In italian language) 

Curriculum Vitae Mauro Bianchi (ITA) (79.4 KB)

Welcome to my homepage


My name is Mauro Bianchi and I live in Bergamo - Italy and this is my personal homepage.

I am an environmental engineer and software developer. My main professional interests are web developement, environmental modelling, data dissemination and decision support systems.

All my recent work is based on open source software, in particolar Python and its ecosystem, the Django framework and javascript visualization libraries such as Openlayers and jqplot.

Handling csv uploads with django

Today I had to handle a csv file upload with django, parse it with a csv.DictReader and cycle on results.

I first thought this could be easily accomplished with the csv python module, but the task turned itself into a big pain in the a**, due to characters encoding and csv dialects Babylon.

After a bit of googling, I solved the issue thanks to a couple of very nice blog posts and the chardet python module. (http://pypi.python.org/pypi/chardet)

Here is what i did:

 
import chardet
def handle_upload(request)

     #assuming 'uploaded_file' is the file key in ...

Running Python in 32-bit mode on OSX

As i am working on a wxPython project, which must run with Python in 32 bit mode, as it relies on the Carbon API.

A way to run python in such mode is setting an environment variable before calling our interpreter:

export VERSIONER_PYTHON_PREFER_32_BIT=yes
python 

to save some typing, I created a bash script that i put on my path, with the following content

#!/bin/bash
export VERSIONER_PYTHON_PREFER_32_BIT=yes
python $*

Notice the last line that calls python passing all parameters you provide ad shell prompt.


django-cms-fragments

django-cms-fragments is django-cms plugin that allows injecting fragments of css, js or html in a django-cms page. 
The package is available via pypi and released under BSD license. You can get the full code or fork the project on github

You can see a live example on this page.


Openlayers css conflicts

While playing to build some django-cms-fragments examples, I noticed that OpenLayers conflicts with my theme derived fromTwitter Bootstrap.
If you end up with a strange OpenLayers map like this: 

It's a css issue caused by setting max-width on img tags. In my case, bootstrap was setting

img { max-width:100%; }

To get rid of it while not breaking the whole theme, override the setting just for your map div. For example, given a map div with class="map" the css could be:

.map { width:600px; height:400px;}
.map img { max-width:none; }

If you don't want to bother css classes ...


GeoDjango with spatialite on OSX

Yesterday I was playing around with GeoDjango and I wanted to use the spatialite backend (django.contrib.gis.db.backends.spatialite) , but the setup on OSX was not so trivial. This method, based on brew is not covered by the GeoDjango documentation about platform-specific instructions.

I will assume:

  • you have already brew installed
  • you are working with virtualenv. If not, I strongly suggest you to do this, when developing with Django and Python in general.

To make short: sqlite is built in a modular fashion and has the possibility to load up additional modules when it starts. The problem is ...


Latest news from