Giorgio Cefaro's Blog Latests posts Sat, 19 Sep 2020 10:54:22 -0400 <![CDATA[Codemotion Roma 2014]]> Another edition of Codemotion Roma has just ended, and it was a great one :-)

My kudos goes to the fantastic girls that make it possible and work hard to keep the event at such a high level. The introduction of tech meetups during the event was really a great plus, and from what I heard all the meetups went good.

Talking about meetups, I attended this edition as a community manager: @liuggio and I presented the newborn Golangit user group, with an unexpected interest from the public.
A picture from the event (photo courtesy of Francesca Romani):

Golangit Meetup - Codemotion roma 2014

And the slides from the talk (italian only, sorry):

Last but not least, an interview in italian with Andrea Marzilli of on communities and training:


]]> Sat, 19 Sep 2020 10:54:22 -0400
<![CDATA[Restyling]]> As you can see, I changed the template of my website, adopting bootstrap 3 with a pretty good responsive design.

Last but not least I've added a proper post archive and an RSS feed.

Feedbacks are welcome, as usual ;-)

]]> Sat, 19 Sep 2020 10:54:22 -0400
<![CDATA[Installing Node.js on Arduino Yún]]> EDIT 2: Official support for node has been added!

EDIT: I've added some tips on how to compile the package at the end!

After a few days of waiting, this evening I finally got my Arduino Yún, Yay!

In these last days I have been thinking about running node.js on this little jewel and, investigating a bit, I found a repository with an openWrt nodejs package for MIPS devices.
Since Arduino Yún's core is a Atheros AR9331, a MIPS SoC, and its OS is linino, based on OpenWRT, I was very positive about a happy ending :-)

And here we are! After a little effort to get the cross-compiling working, I came out with a couple of packages:

- uclibcxx_0.2.4-1_ar71xx.ipk
- node_v0.10.17-2_ar71xx.ipk

You can download them zipped here.

Unzip them, copy them to your Yún:

scp *.ipk root@myArduinoaddress:/tmp

install them:

opkg install uclibcxx_0.2.4-1_ar71xx.ipk
opkg install node_v0.10.17-2_ar71xx.ipk

And enjoy!

You can help me improving the package, contributing to the repo (forked from the bristone's one):

Note that by now only 0.10.* node versions are supported, because the v8 libraries for MIPS are not aligned with the latest v8 which is used by 0.11.* versions of nodejs.

If you want to compile the package you have to follow these steps:

But, as indicated, before compiling a package you have to follow the OpenWRT  building process:
When asked to checkout openwrt, clone instead linino from its repo.
The file structure will be the same.
Now copy the contents of the linino nodejs package inside trunk/package/nodejs and continue following the  single package tutorial referring to nodejs instead of nano and uclibc++ instead of ncurses.
The whole process will take a long long time (about 40 minutes on i5 with ssd), but only the first time you build the linino tools.

]]> Sat, 19 Sep 2020 10:54:22 -0400
<![CDATA[Datagrids with Symfony 2, Backbone and Backgrid]]> These are the slides of the code-centered presentation I did with Eugenio Pombi at the Javascript User Group Roma and the PHP User Group Roma. In this presentation we try to show many powerful features of Symfony 2 and its bundles to work as a backend system for single page applications. On the client side we describe how we made a javascript editable grid using Backbone.js and its plugin for grids Backgrid.js.

Datagrids with Symfony 2, Backbone and Backgrid from Giorgio Cefaro
]]> Sat, 19 Sep 2020 10:54:22 -0400
<![CDATA[Test symfony and automatically open the browser with the response content]]> A while ago @euxpom made a WebTestCase helper method to put the contents of a Response in a html file placed inside the web folder of a symfony application. That was pretty cool, viewing application output with all the js and css in place, after a complex interaction. Yesterday I decided to do more and pimp it with some more automation.

So I added a Process call in order to make your favourite browser open the html output file straight from your virtual host.
Notice that the $domain parameter holds your virtual host name or base address (e.g.  $this->saveOutput($client, null, 'foobar.lo');)
Here's the gist:

@_leopro_ liked it and added an hook to delete the html file after browser has started:

Here the process is started asynchronously, and you can fine tune the sleep time if your browser is opening too slowly.

If you like a synchronous approach, we can run the process and wait for it to complete to delete the file:


EDIT: Here comes @garakkio with some fixes:

]]> Sat, 19 Sep 2020 10:54:22 -0400
<![CDATA[Import customized maps from a website in your google maps account]]> Me and Francesca are planning a trip to Paris and yesterday she found a website with a cool customized google map full of Paris POIs.

She asked me if I would be able to import those points in our personal google maps account, and I couldn't say no (could I?). So I started investigating and I found the google map markers initialization was based on a json file like this:

I googled for a PHP KML library and I found this:

Not PSR-0 compliant, but it's working fine.
I downloaded the library and I made a little script to do the job:

I finally ran the script from the console:

php convert.php > mymap.kml

Et voilà! My map was ready to be imported inside google maps :-)

P.S: WARNING - This is code is PROCEDURAL, NOT tested and NOT parametric.  Forgive my laziness this time.

]]> Sat, 19 Sep 2020 10:54:22 -0400
<![CDATA[Symfony 2 workshop @ Codemotion Roma]]> Codemotion Roma

On March 21st me & euxpom will hold an eight-hour workshop on symfony 2 at Codemotion Roma.

We will try to make the attendees operative and productive with some focused hands-on on the key aspects of the framework.
The workshop will be held in Italian. All the info here.

The early bird will close on Feb 20th, be quick ;-)

]]> Sat, 19 Sep 2020 10:54:22 -0400
<![CDATA[Perché è giusto scrivere codice PHP TUTTI allo stesso modo]]> Sorry english speaking followers, sorry html lang attribute, but this post is in italian.


Stanotte, spinto dall'insonnia a fare qualcosa di buono, ho deciso di tradurre in italiano le raccomandazioni PSR accettate dal Framework Interop Group per la scrittura del codice PHP. Il FIG (forza con le battutacce!) è un gruppo di sviluppatori PHP che collaborano stabilmente ai più affermati progetti della comunità. Il loro intento nel definire gli standard è stato decisamente importante: dettare delle regole per garantire l'interoperabilità del codice tra diversi sviluppatori, diversi progetti e diversi autoloader. Il tutto è avvenuto attraverso un complesso sondaggio in cui si sono raccolte statistiche relative alle best practice e lo stile di ognuno dei membri e si sono tirate le somme attraverso la definizione di alcuni documenti condivisi.
Questi sono tre: il PSR-0, il PSR-1 e il PSR-2, in ordine di granularità crescente.
Queste raccomandazioni spaziano dalle pratiche consigliate per la denominazione di classi e relativi namespace, arrivando a definire il singolo posizionamento delle graffe nelle dichiarazioni.

Di seguito riporto il link ai documenti su github, a beneficio di chi non conosce gli standard e di chi, perché no, non ha ancora una solida conoscenza dell'inglese.

]]> Sat, 19 Sep 2020 10:54:22 -0400
<![CDATA[Website frontend migrated to Foundation]]> After @MatteoMced's talk about Foundation during last PUG Roma monthly meeting, I decided to move my website (that's currently running on Symfony 2.1 and was built on the top of a html5 boilerplate) to this amazingly responsive framework.


I followed this Nerdpress tutorial, and as you can see it's pretty simple.

]]> Sat, 19 Sep 2020 10:54:22 -0400
<![CDATA[My PHP developer toolbox]]> Lately, but not too late, I've been experimenting with some tools for making my developer life easier. This post is meant to share them, and eventually integrate them with your valuable feedback.

First of all, let's talk about the shell. I must admit I was lazy, accepting the default ubuntu one, Bash, with its default configuration.
Then, one day I discovered Zsh and it was love at first sight.


Zsh is a shell designed for interactive use, although it is also a powerful scripting language

Among its great features:

  • Faster
  • Improved tab completion
  • Improved globbing
  • Improved array handling
  • Fully customisable

I must admit I'm not a *sh scripting ninja, but the zsh community seems very active and you can find tons of useful scripts on the web. The set of scripts I think is a must is oh-my-zsh, a powerful and huge set of themes and plugins integrating almost everything I make a daily use of.

Here comes a brief tutorial for you lazy people who needs to be spoon-fed:

Install zsh:

Configure the plugins and theme:

And finally change your default shell to zsh (with the command chsh, for example).

As you can see I've added a lot of plugins that basically gives you shortcuts to  most used commands and other fancy stuff. The most useful thing here is the git plugin, that gives you a dynamic visual representation of the state of your current git tree (if available). An image here comes handy:

Oh My Zsh!

Can you feel the powa?
What we can see here is this: we are in a git-versioned directory, we are on master branch and we have uncommitted changes (the yellow dot).
As I mentioned before, there's a bunch of plugins available you can choose from, for an exaustive guide go here.

You can choose among a lot of themes too, have a look here.
And, guess what, if oh-my-zsh is not enough and you become a zsh ninja you can do other gazillions of wonderful things!

Another topic worth to mention is diffing files. Sometimes reading a diff on the shell it's just a pain, even if with time you can be very skilled to do it.
What I propose here is using visual diff tools, like Meld.

VIsual diff - Meld

Meld is a great graphical diff tool, available as a package in almost any popular linux distro. It can compare files and directory trees.
Satisfied with the software per se, what I wanted was an integration with git, in order to display diffs in a graphical, intuitive way.
I found a great tutorial by Nathan Hoad, with which I made it happen.

Last but not least I discovered tmux to be quite handy as a replacement of the screen command.


mux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

When you are lost between production, staging, local and so on, you can split your terminal in different areas, each running a different shell. Another image will help here:


That's all for today, I'll be happy to include other suggestions :-)

]]> Sat, 19 Sep 2020 10:54:22 -0400