Hello world,
it's been a long time since I last posted something. Today, I want to let the world know about the availability of Debian packages for wicd.
Since the release cycle of wicd is somewhat slow, I decided to provide automatically-built Debian packages for the latest revision of the upstream repository.
The automatic build process is possible thanks to Jenkins and the great jenkins-debian-glue, by Michael Prokop.
Here's the APT snippet, for those who dare:
# For the "upstream" version of wicd
deb http://jupiter.hanskalabs.net/debian/ wicd main
The repository is signed with a separate GnuPG key, which I signed with my main keys. You can download it or retrieve it from a keyserver, then you should add it to your APT keyring:
$ gpg --keyserver pgp.mit.edu --recv-keys 4D00F190
# gpg --export 4D00F190 | apt-key add -
Obviously these builds are not guaranteed to work
but, since I myself
use these autobuilt packages, I usually try to fix problems as soon as I
notice them.
If you find bugs, or have proposals to improve wicd, please report them on launchpad!
Oggi, giusto per sfizio, ho creato una mappa dei trasporti su bus di Mazara.
Spero piaccia e sia utile! 

Dear Lazyweb,
I'm working on a personal PyQt4 project for my parents' office, and I need to
autocomplete an editable QComboBox.
I can't use a standard Qt model (I need to store python objects in it), so I subclassed QAbstractTableModel.
Here it is, it's a fairly generic subclass of QAbstractTableModel, with
variable number of columns:
class QGenericTableModel(QAbstractTableModel): def __init__(self, columns, parent=None, *args): super(QGenericTableModel, self).__init__(parent, *args) self.columns = columns self.headers = {} self.table = [] def rowCount(self, parent=QModelIndex()): return len(self.table) def columnCount(self, parent): return self.columns def row(self, row): return self.table[row] def setData(self, index, value, role): if index.isValid() and role == Qt.EditRole: row = index.row() t = self.table[row] if index.column() >= self.columns: return False if isinstance(value, QVariant): t[index.column()] = value.toString().simplified() else: t[index.column()] = value self.emit(SIGNAL('dataChanged'), index, index) return True return False def data(self, index, role = Qt.DisplayRole): if not index.isValid(): return QVariant() if (index.row() >= len(self.table)) or (index.row() < 0): return QVariant() if role == Qt.DisplayRole: return QVariant(self.table[index.row()][index.column()]) return QVariant() def insertRow(self, row, parent=QModelIndex()): self.insertRows(row, 1, parent) def insertRows(self, row, count, parent=QModelIndex()): self.beginInsertRows(parent, row, row+count-1) for i in xrange(count): self.table.insert(row, ['',]*self.columns) self.endInsertRows() return True def removeRow(self, row, parent=QModelIndex()): self.removeRows(row, 1, parent) def removeRows(self, row, count, parent=QModelIndex()): self.beginRemoveRows(parent, row, row+count-1) for i in reversed(xrange(count)): self.table.pop(row+i) self.endRemoveRows() return True def flags(self, index): if not index.isValid(): return Qt.ItemIsEnabled return super(QGenericTableModel, self).flags(index) | Qt.ItemIsEditable def headerData(self, column, orientation, role = Qt.DisplayRole): if role != Qt.DisplayRole: return QVariant() if orientation == Qt.Horizontal: if column >= self.columns: return QVariant() return self.headers[column] return QVariant() def setHeaderData(self, column, orientation, value, role = Qt.EditRole): self.headers[column] = value
It might not be perfect, but it works, and it's all that matters at the moment
(since it's my first serious PyQt4 project). Oh, well, it worked until I tried
to use it with an editable QComboBox.
And here's the app code (for the full working code, insert the above class right after the imports):
import sys from PyQt4.QtGui import * from PyQt4.QtCore import * app = QApplication(sys.argv) model = QStandardItemModel() for i, word in enumerate(['saluton', 'gxis la revido', 'hello', 'goodbye']): item = QStandardItem(word) model.setItem(i, 0, item) #model = QGenericTableModel(1) #for i, word in enumerate(['saluton', 'gxis la revido', 'hello', 'goodbye']): # model.insertRow(i) # index = model.index(i, 0) # model.setData(index, word, Qt.EditRole) combo = QComboBox() filterModel = QSortFilterProxyModel(combo) completer = QCompleter(combo) filterModel.setFilterCaseSensitivity(Qt.CaseInsensitive) filterModel.setSourceModel(model) filterModel.setFilterKeyColumn(0) completer.setModel(filterModel) completer.setCompletionColumn(0) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) combo.setEditable(True) combo.setCompleter(completer) combo.setModel(model) combo.setModelColumn(0) if combo.isEditable(): app.connect(combo.lineEdit(), SIGNAL('textEdited(QString)'), filterModel.setFilterFixedString) combo.setModel(model) combo.setModelColumn(0) combo.show() sys.exit(app.exec_())
Now, try running it. It works well when I use a QStandardItemModel.
Then, try decommenting the part where I use my subclassed model: it just doesn't
work: clicking on any item makes the QComboBox not change its currentIndex,
and this only happens if the combobox is editable.
I suspect I'm forgetting to override some function in my model, but I don't know
what exactly to override, and Google didn't help me. This is also backed up by
the fact that the exact same behaviour shows up when, instead of a QComboBox, I
try to autocomplete on a QLineEdit.
So, dear readers: can anyone explain what is happening? Thanks in advance!
UPDATE: it turned out that the culprit was the following bit inside data():
if role == Qt.DisplayRole: return QVariant(self.table[index.row()][index.column()])
Adding also Qt.EditRole to the list of possible choices fixed the bug. YAY!
Ok, so you have Magento, and you're located in Italy. And you'd like your customers to select a province from a dropdown select box.
Unfortunately, Magento doesn't include Italian provinces in their default database: that's why I wrote a simple script to take care of that.
The script is in Python, and uses SQLAlchemy. You'll also need to download the list of provinces. You should run it like this:
$ ./load_provinces.py provinces
Be sure to run it only once, otherwise you'll get duplicated provinces in the database.
There is some commented code you should decomment if you want to test the script before actually touching the Magento database.
Also, you need to change the "user", "psw" and "dbname" parameters, and might need to change the "host" and "port" too.
Now, I need to understand how to require address input at the registration page. ARGH.
Sottotitolo: perché non funzionerà.
Il Comune di Mazara del Vallo ha acquistato 90 biciclette e 9 ciclo-posteggi ("rastrelliere''), da affidare in gestione a 9 aziende operanti sul territorio mazarese. Fin qui, tutto bene.
Il problema nasce nel momento in cui il Comune detta le regole del servizio. Ogni azienda avrà in concessione 10 biciclette ed 1 ciclo-posteggio. Ogni bicicletta viene concessa al costo di 3,00€ al mese (il ciclo-posteggio è in comodato d'uso gratuito); e potranno essere noleggiate ad un prezzo massimo di 0,30€/ora.
Facciamo due conti.
Per ammortizzare la spesa della concessione (30€/mese), quindi senza alcun guadagno, ci vorrebbero 100 ore di noleggio mensile. Che vuol dire 3 ore circa al giorno. Con questo però ci paghi solo la concessione.
Supponiamo allora che noleggi per un'ora al giorno tutte e 10 le biciclette: sono 3€ giornalieri, 90€/mese. Ci paghi la concessione, e con i restanti 60€ ci fai ben poco; non ci puoi campare, né pagarci le bollette, né pagarci qualcuno.
Giochiamo un po' con i numeri allora, e vediamo il guadagno netto mensile per ore di noleggio giornaliere:
| Ore | Guadagno € |
|---|---|
| 20 | 150 |
| 40 | 330 |
| 60 | 510 |
Solo con 60 ore giornaliere di noleggio (6 ore per ognuna delle 10 biciclette!) si arriva ad un guadagno ragionevole, che però basta a malapena per pagarci le bollette e l'eventuale affitto.
E se ad attuare questo servizio fosse un'azienda già costituita, e ci fosse bisogno di una persona appositamente preposta? Non la si può pagare meno di 500€/mese. Quindi i numeri di cui sopra sarebbero destinati a salire.
Chiedendomi se i miei fossero calcoli sbagliati, mi sono guardato in giro, e...
- ATAC Roma fa pagare 0,50€ ogni mezz'ora per il servizio di bike-sharing;
- A Milano si paga un abbonamento giornaliero di 2,50€, con i primi 30 minuti gratuiti, dopo 0,50€ ogni 30 minuti (o frazione) fino a 2 ore, superate le 2 ore, 2€ ogni ora o frazione (ci sono altri abbonamenti che alla lunga risultano più economici, settimanale e annuale, ma non c'interessano).
Questi sono prezzi credo abbordabili per il cittadino (soprattutto quelli di Roma!), e sostenibili per un'azienda interessata. Con i prezzi proposti dal Comune, invece, bisognerebbe avere un flusso altissimo e continuo di turisti, e un'alta percentuale di questi noleggiare le bici. Cosa che, purtroppo, Mazara non ha al momento.
È sicuramente un'iniziativa lodevole, che però, mi spiace dire, è stata progettata malissimo.
Today I uploaded bash-completion 1:1.3-2 to the experimental branch of Debian.
This package uses dpkg triggers to achieve an overdue goal: speedup shell loading by not even looking into completions for unavailable commands.
The mechanism is simple: a trigger is activated when a package installs something in one of the usual $PATH directories, and it creates symlinks for the appropriate completions.
This upload also features a change in the layout: completions were moved
out of /etc/, so you won't be annoyed anymore during upgrades (and, let's
say it, they shouldn't have been there since the beginning). However
/etc/bash_completion.d/ is still around for compatibility reasons. If you
want to enable a completion, just symlink it there from
/usr/share/bash-completion/completions/. If there are enough requests,
I might do a simple compenable/compdisable script to create them.
I'd appreciate if adventurous people could test it, and report bugs (if any,
hopefully). And don't be scared by the tons of messages about removed
conffiles 
Please beware that the "detection mechanism" of appropriate completions is not entirely foolproof: it might need some hacking upstream (adding meta-headers to completion files?), so I'll try to improve it in future.
È notorio che io sia di destra, e abbia sempre votato a destra. Prima del Governo nazionale però, viene la prosperità della mia terra, la Sicilia. Ecco il perché di questo post.
Con il Decreto-Legge n. 78 del 31 maggio 2010, "Misure urgenti in materia di stabilizzazione finanziaria e di competitività economica", al capitolo IV, articolo 14, Pedaggiamento rete autostradale A.N.A.S. e canoni di concessione, si apre in prospettiva un periodo nero per la Sicilia.
La manovra economico-finanziaria di cui sopra, infatti, introduce in Sicilia il pagamento del pedaggio su tutte le autostrade (sono tutte infatti gestite da A.N.A.S.). Peccato che, in Sicilia, le autostrade fossero finora praticamente gli unici assi di trasporto all'interno dell'isola. E, sebbene non siano particolarmente curate (cantieri decennali, mancanza delle corsie d'emergenza in alcuni tratti, mancanza di servizi in altri, ...), né riescano a collegare tutti i punti dell'isola (tutta la costa meridionale è "scoperta"), noi Siciliani ci siamo sempre accontentati.
I lettori del nord storceranno il naso: loro pagano il pedaggio da sempre. Certo: se avessimo anche noi vie di trasporto alternative (strade statali, linee ferrate) adeguate, penso che chiunque pagherebbe per il privilegio di avere la propria auto a disposizione nel luogo di destinazione.
Analizziamo però le vie alternative che andrebbero a sostituire alcune delle attuali autostrade (i.e. quelle che conosco e che ho percorso più spesso).
Autostrada A19 - Palermo-Catania
È il principale asse di collegamento Est-Ovest dell'isola. Lunga circa 192km, presenta 4 aree di servizio in direzione Catania, e 3 in direzione Palermo. Da anni, uno dei viadotti del tratto Palermo-Caltanissetta è ridotto ad una sola corsia (e non si vedono lavori in corso). L'alternativa su rotaia non è confortante: 3 o 4 ore, se si evitano i tragitti fantasiosi proposti da Trenitalia, tipo quello passante per Messina Centrale (5 o 6 ore). L'alternativa su gomma è anche peggio: èrappresentata dalla Strada statale 121 Catanese, lunga più di 250km, che si snoda nell'entroterra siculo aggirando le varie colline. Secondo Wikipedia, prima dell'inaugurazione dell'A19, la tratta Palermo-Catania necessitava di 7 ore, a causa della tortuosità della strada statale.
Autostrada A29 - Palermo-Mazara del Vallo
Per andare dalla mia città, Mazara del Vallo, al capoluogo di regione, Palermo, esiste l'autostrada A29, lunga circa 115km. Manca di stazioni di rifornimento e di servizio lungo tutto il tratto, ma viene usata quotidianamente da pendolari -- lavoratori e studenti, con mezzi propri o autobus di linea -- che altrimenti impiegherebbero 2 ore e 43 minuti con il treno fino a Palermo Notarbartolo (unico binario, non elettrificato, con tratte in cui la velocità tocca i 60 km/h, e in cui raramente si raggiungono i 100km/h. Come dite? FrecciaRossa?).
L'alternativa non-autostradale è costituita da
- Strada Statale 115 Sud-Occidentale Sicula, attraversando i centri abitati di Campobello di Mazara e Castelvetrano;
- Strada Statale 119 di Gibellina, 58km di curve tra le montagne e le campagne dell'entroterra siculo, fino ad Alcamo;
- Strada statale 624 Palermo-Sciacca, dallo svincolo di Alcamo fino a Palermo.
Conclusioni
Sicuramente questa è un'analisi incompleta, ma spero dia l'idea dei problemi derivanti dall'applicazione del pedaggio sulle nostre autostrade, senza la presenza di valide alternative.
Già ci muoviamo poco dai nostri paeselli, rischiamo di restare fermi del tutto. Cosa possiamo fare? Dire NO ai pedaggi in Sicilia.
I just found this out, so I'm posting it, since it might be useful both as a reminder, and for others to read.
Suppose you have a "classical" Subversion web interface, like svn.openstreetmap.org. This will show you the last revision by default.
What if you want to see a particular revision? I found this by googling a bit:
http://<yoursvn>/!svn/bc/<revision>/<path>
So, say, using the above example, you want to see the sites/ directory
of revision 20000: here you are (compare with current).
In LaTeX, it seems like you can't define a command with a really optional
argument, using \newcommand. You can make commands with arguments having
a default value though.
Now, I found myself in need of having such a functionality. I had to google a while, but finally found it, so I'm posting it here, both to share knowledge and to remember it in future :)
Suppose you want to do something like \mycmd{foo} and \mycmd{foo}{bla}, doing
different things (in my case, I needed to add the second argument enclosed by
parenthesis in the TOC and other places, but only if it was present)
Here's the code:
\def\mycmd#1{\def\tempa{#1}\futurelet\next\mycmd@i}% Save first argument \def\mycmd@i{\ifx\next\bgroup\expandafter\mycmd@ii\else\expandafter\mycmd@end\fi}%Check brace \def\mycmd@ii#1{...}%Two args \def\mycmd@end{...}%Single args
In the last two lines of the code, use \tempa for your first argument, and #1
for your second optional argument. If you need spaces there (maybe as part of some
text), be sure to escape them with a backslash \.
I think it's expandable for additional arguments, but I haven't tried, and I don't
feel like getting my hands dirty with TeX yet 
After almost six years from the original ITP bug #304570, we finally have Code::Blocks in Debian.
Enjoy it, and please report any bug you might find.
Also, this is a complex package, so if anyone wants to step up as co-maintainer, or maybe make a "Debian Code::Blocks Team", I'm all for it!