jquery+php regex checker and reverse geo-coding service
It happened a million times: I had to check a regex in PHP and did not have a handy tool to see the result. I usually linger on Rubular, which is a great service but based on Ruby, and sometimes the results are a bit different. I decided to implement a simple regex checker similar to Rubular, but based on php preg_match. Another service that I need to use daily is reverse geo-coding, adding an easy way to find latitude and longitude of a specific point on the map, again there are tons of services around, but none is really what I needed. So I decided to develop my own, and share them (you might break them easily, they're just simple tools for manual use, hence there are API limits, and security wasn't my focus, so please don't hit them too hard). I might add a few things from time to time, depending on my needs, but feel free to drop me a line if you either want to contribute or feel something really missing.
PHP + jQuery Regex checker
reverse geo-coding
“He’s gone to China” – avere un figlio a Londra N4

Primo e ultimo post riguardo la faccenda figlio, non voglio annoiare me stesso, nè le 10 persone che si imbattono per sbaglio in questo post, ma nello stesso tempo voglio mettere giù due note per rileggermi in futuro qualche dettaglio colorito che inevitabilmente andrebbe perso e ricordarmi di quella meravigliosa cacofonia di etnie e strana accozzaglia di personaggi improbabili ma tutti incredibilmente gentili che hanno avuto a che fare con mio figlio già al decimo giorno di vita.
Intanto un po' di contesto: residenti in N4, ci spetta l'ospedale Whittington, che ci dicono tutti essere incredibilmente all'avanguardia e dotato di personale assai preparato; ci spetta inoltre il team "Hornsey Rise" di midwife che ci seguiranno in questa avventura, e anche di questo team sentiamo parlare un gran bene. Entrambi si sono confermati eccezionali, e ripensando ai mesi passati sento necessario ricordare alcuni piccoli eventi che mi hanno portato il sorriso.
Visualizing Cluster of Tweets in London during the Royal Wedding
So the little storm has arrived! I am now the proud (and tired) father of little Benjamin, and for this reason blocked at home with little or no time for doing anything but changing nappies and cooking super-proteic food for Val. But somehow I found some time amuse myself with a little piece of Processing and wrote a simple code to visualize tweets on a map of London during the Royal Wedding. Easy enough to foresee, tweets during the day are creating nice clusters around Buckingham Palace, Westminster Abbey and the super posh hotel where the Middleton's used to stay.
Here is the result:
To display this data I reused the information stored during the first phase of my Flux of MEME project, fetched from twitter with the Streaming API implementation in its Java flavour twitter4j. Processing is reading the information in XML directly from the database, hence a little PHP backend is providing the XML descriptor for all the posts locations.
Top 5 Albums 2011
Here it goes, in no particular order:
- Noah and the Whale - Last Night on Earth
- Radical Face - The Family Tree The Roots
- Wild Beasts - Smother
- Danger Mouse + Daniele Luppi - Rome
- The Antlers - Burst Apart
Special mention:
- Bill Callahan - Apocalypse
Firenze-Londra, solo andata
Sarà che siamo vicini al Natale e oggi abbiamo comprato l'albero, oppure che mancano poche settimane all'arrivo del piccolino, o magari che stiamo per firmare un mutuo di 25 anni per la nostra casa, o ancora che sto finalmente per chiudere la mia società in Italia... sarà forse l'insieme di tutto questo che mi sta portando oggi a fare qualche bilancio.
A few shots with my brand new Zuiko 25mm f2.8 “pancake”
Our XMas party with the friends @therumpusroom_ was great this year, and Santa brought me a super cool lens for my E-500, the tiny Zuiko 25mm f2.8 "pancake", you can read a review here.
We went for some shopping today, and took a few shots with London at its best, nice way of testing the new lens, good performances on low light conditions, really impressive contrast and colours (a bit tweaked here, but not too much, just a touch of saturation), below the results (and full set here).
Configuring NGINX to serve multiple webapps from different directories
Few days ago I had to add a wordpress installation within the same environment where a Codeigniter app was already running happily and undisturbed. It took me a while to figure out how to keep separate folders on the filesystem, and serve the blog from a subfolder of the main domain: it ended up that the solution is super simple, but apparently I am not the only one who had similar problems. Symptoms of a bad installation usually result in "no input file specified" messages or, even worse, downloading the php source code with all your precious database passwords shown in clear.
So the premise being:
- the webapps need to live in sibling folders to keep tidy our github repo, in the example below will be named as /home/ubuntu/repo/webapp (codeigniter) and /home/ubuntu/repo/blog (wordpress)
- the main webapp needs to respond to all the requests, while wordpress needs to catch only requests starting with /blog
there might be better and more elegant solutions, but this is working for me, including pretty permalinks on wordpress:
server {
server_name your.domain.com;
access_log /home/ubuntu/repo/logs/access.log;
error_log /home/ubuntu/repo/logs/error.log;
# main root, used for codeigniter
root /home/ubuntu/repo/webapp;
index index.php index.html;
# links to static files in the main app, mainly for dev purposes as this is
# unlikely to be triggered when using a CDN with absolute URLs to assets
location ~* ^/(css|img|js|flv|swf)/(.+)$ {
root /home/ubuntu/repo/webapp/application/public;
}
# most generic (smaller) request
# most of the times will redirect to named block @ci
location / {
try_files $uri $uri/ @ci;
}
# create the code igniter path and perform
# internal redirect to php location block
location @ci {
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
# now the meaty part, execute php scripts
location ~ \.php {
include /etc/nginx/fastcgi_params;
# default path of our php script is the main webapp
set $php_root /home/ubuntu/repo/webapp;
# but we might have received a request for a blog address
if ($request_uri ~ /blog/) {
# ok, this line is a bit confusing, be aware
# that path to /blog/ is already in the request
# so adding a trailing /blog here will
# give a "no input file" message
set $php_root /home/ubuntu/repo;
}
# all the lines below are pretty standard
# notice only the use of $php_root instead of $document_root
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
fastcgi_index index.php;
}
# now the blog, remember this lives in a sibling directory of the main app
location ~ /blog/ {
# again, this might look a bit weird,
# but remember that root directive doesn't drop
# the request prefix, so /blog is appended at the end
root /home/ubuntu/repo;
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
}
please feel free to add comments and suggestions, hope this helps.
Flux of MEME – 1st year final report
So it is now time to present the results obtained during the first year of research and development on the Flux of Meme project, and I was glad to fly to Milan for the presentation at Telecom Italia last friday 30th. Thanks-a-mil to Laurent-Walter Goix and Carlo Alberto Licciardi at Telecom for the constant support, reviews and recommendations: it immensely helped to achieve this result. And thanks-two-mils to Giuseppe Serra and Marco Bertini (also with the help of Federico Frappi) at the Media Integration and Communication Center for the help provided in the definition and fine-tweaking of algorithms. Looking forward to starting Flux phase 2!
This is a quick keynote that highlights the main elements of this geo-clustering and topic extraction tool, using twitter as a main data source but willing to expand to proper context-based data heterogeneous sources.
Twitter geo-located clustering and topic analysis, now opensource!
A year has passed since the beginning of the trial of Flux of MEME, the project I have presented during the Working Capital tour, and it is now time to analyze what has been learned and show what has been developed to conclude this R&D phase and deliver results to Telecom Italia.
Configuring NGINX and CodeIgniter on Ubuntu Oneiric Ocelot on Amazon EC2
Few days ago I started the server setup for a web project @therumpusroom_ and, after receiving the traffic estimates, I thought a single Apache server was not enough to handle the expected load of visitors. For several reasons I want to avoid using a load balancer and multiple Apache instances, hence the decision to implement Nginx with MySql running on a separate dedicated server.
The whole infrastructure lives on Amazon Web Services and the web application - still under development - will rely on CodeIgniter. I have read quite a lot of articles on-line and stolen bits and pieces of configuration files, but none of them entirely reflected what I needed. I feel it is quite a common configuration hence I am writing down here the required steps and some code snippets, both for my personal records and also hoping it can be helpful for someone else with similar issues.

























