jquery-quiz-plugin at GitHub


Hi guys, in order to celebrate my new account at GitHub I just released a new version of “jQuery short answer quiz” now it looks like a real jQuery plugin, finally!

As Linus Torvalds always says: Talk is cheap, show me the code…here we are: https://github.com/henomis/jquery-quiz

Enjoy and, please, send me a feedback!


LinuxDay 2013

Ebbene sì, anche quest’anno parteciperò all’organizzazione del LinuxDay. Questa volta, cercando di essere meno talebano, presenterò una pratica che per molti può essere scontata, ma che forse tanto scontata non è. Cercherò di rispondere alle domande:

  1. Come posso collaborare ad un progetto Open Source?
  2. Voglio creare un progetto Open Source.  Da dove parto?

Partirò da esperienze personali che mi hanno coninvolto come collaboratore e come sviluppatore. Se questo argomento può suscitare curiosità, ti aspetto Sabato 26 Ottobre al Centro Giovani di San Benedetto del Tr.


New Qt project: qbar

Hello there! I’m still looking for an elegant window manager for developers under GNU/Linux. I think that mcwm is one of the nearest to my concept of design. No window borders, small RAM resources, XCB based.

When I downloaded mcwm project I noticed the TODO file containing an interesting feature request: snap borders. So in a couple of day I produced a patch and submitted to the author.  Unfortunately the author’s git repository doesn’t have a web interface, so, if you’re curious, you can see the patch as follows:

$ git clone git://hack.org/mcwm
$ cd mcwm
$ git diff 864bc76d d20afb19

Well, now that the patch is merged, It’s time to develop a general purpose toolbar. A toolbar to display values, a toolbar to perform actions, a toolbar to rule them all! 🙂

And…in a couple of days I developed qbar that uses stdin streaming to fill itself with objects like: buttons, labels, menu, progress bar. And who knows about the future? You can write you “applet” in standard bash script and redirect the stdout to qbar through a pipe. As you can imagine there is a protocol for the arguments given in the stdin. The protocol is the following:






<refresh> can be S (static) or R (refresh)
<size_mode> can be E (expanding) or F (fixed)

qbar is developed in Qt (4.8), so you can use a simple CSS stylesheet to develop a new theme. Let me show you how:

QMainWindow {
	background: #333333;
	color: #fff;

QLabel {
	color: #fff;

QMenu {
	background: #333333;
	color: #fff;

QPushButton {
	border-radius: 10px;
	padding-left: 5px;
	padding-right: 5px;
	color: #fff;

QPushButton:hover, QMenu::item:selected{
	background: #666;

#ITEM_2 {
	width: 150px;

QProgressBar {
     border: 2px solid rgba(0,0,0,0);
     border-radius: 5px;
     text-align: center;
     background-color: #666;
     color: #fff;

 QProgressBar::chunk {
     background-color: #05B8CC;

As you can see from the code, you can refer to the n-th element using the CSS selector <#ITEM_> followed by the element id. And, you can use the following command line parameters:

qbar [-a <l|c|r>] [-p <t|b>] [-t] [-h <pixels>] [-stylesheet <file>]

-a alignment
   l = left
   c = center
   r = right
-p position
   t = top
   b = bottom
-t set transparent background
-h height in pixels
-stylesheet css file

qbar is published at Gitorious:


and at Qt-apps.org. What’s missing? Ah…yes, screenshot!


If you liked it, please vote for it on qt-apps.org, and if you want please submit patches and feature requests, all the code is released under the terms of GNU/GPL.

jQuery short answers quiz

I’m developing a website containing my deutsch course lessons. Our teacher given us some exercises, and I had the need to render it on an interactive web page. How to accomplish this mission? Obviously using jQuery.
The main issue is to write in a simple way your “short answers” form, and leave the hard job to jQuery code. So the form need to looks like:

    The sky is <input type="text" answ="blue"/>.
    The pen is <input type="text" answ="on"/> the table.<br />
    Yes I, <input type="text" answ="am"/>.<br />
    <input type="button" class="subm" value="Verify"/>

As you can see, each <input> contains the attribute answ with the correct answer and the element you want to use to check needs to have class=”subm”. That’s all!

The JS code resizes all the text inputs using the answer’s length, and changes CSS class (answ_error, answ_ok) of the input element. Finally a couple of attributes (tot and ok) will be added to the form, containing the number of text inputs and the number correct answers.

Code is available here.

Bash script per GIT

Oggi propongo un piccolo e semplice pezzo di codice da mettere in .bashrc per interagire con i repository GIT. Ogni volta che entro in uno dei miei repository GIT controllo lo stato e il branch sul quale sto lavorando, quindi ho pensato di creare un alias per il comando cd e ridefinirlo come segue:

unalias cd

gitcd() {

if [[ "$1" == "" ]];
    cd ~
    cd "$*"

if [[ -e "$PWD/.git" ]];
    REPO_USER=`cat $PWD/.git/config | grep $GIT_USER`
    if [[ "$REPO_USER" != "" ]];
        echo ---------- GIT REPOSITORY ----------
        git status
        git branch

alias cd=gitcd

Sentitevi liberi di modificare a piacere.

Corso inglese gratuito con Python

Con la scusa di iniziare ad apprendere Python ho realizzato un piccolo script per fare download automatico delle lezioni di eslpod.com (categoria “English cafe“).

#!/usr/bin/env python
#title           :eslpod_EC.py
#description     :This script downloads english cafe lesson from eslpod.com
#author          :Simone Vellei <henomis@gmail.com>
#date            :20120420
#version         :0.1
#usage           :python eslpod_EC.py
#notes           :
#python_version  :2.6.6

import sys
import re
import signal, os
import urllib
from subprocess import call

def wprint(a):

def handler(signum, frame):
        print "Interrupted!"

signal.signal(signal.SIGINT, handler)

f = urllib.urlopen("http://www.eslpod.com/website/show_all.php?cat_id=-39570")
s = f.read()

if s:
        wprint("Parsing HTML...")
        print "Error: download failed!"

chunk = re.match(r'.*<span class="pod_body">.*<b>([0-9]+)</b>&nbsp;Podcasts&nbsp;&nbsp;&nbsp;',s , re.M|re.S)

lenght = 0

if chunk:
        print "DONE"
        files = chunk.group(1)
        lenght = len(files)
        print lenght
        print "ERROR!"

# skip lesson 0
for i in range(int(files)-1):
        # insert padding
        s = 'wget "http://libsyn.com/media/eslpod/EC{0}.mp3" -c -O lesson_{1:0%d}.mp3'%lenght
        # format string
        s = s.format(i+1,i+1)
        # go, go, go...
        call(s, shell = True)

Lo script può essere lanciato settimanalmente (qualcuno ha detto cron?! :)) per aggiornare la directory con le nuove lezioni (wget -c farà il lavoro sporco). La prossima versione potrebbe supportare i thread per fare un download multiplo parallelo e il parsing dei parametri in input per nuove funzionalità.

Curriculum Vitae aggiornato

Per quanto possa interessare qualcuno, oggi ho aggiornato il mio curriculum vitae. Ho dato maggior risalto alle esperienze lavorative e compattato alcune sezioni usando link ipertestuali.

Simone Vellei – Curriculum Vitae
Simone Vellei – Curriculum Vitae (English version)