L'uso di questo sito
autorizza anche l'uso dei cookie
necessari al suo funzionamento.
(Altre informazioni)

Friday, October 14, 2011

R.I.P: Dennis Ritchie

/*
* Dennis Ritchie,
* inventor of the C programming language and
* of the Unix Operating System, dies at 70.
*/
#include <stdio.h>
int main(void){
printf("goodbye world :( \n");
return(70);
}

Thursday, October 6, 2011

Geeks bearing gifts - to Wall Street (Pablo Triana pt.2)

So, having drank Triana's book to the dregs, and to wrap my previous post's point up, this is the apparent message of Triana ruminations(*):

"Dear Reader.

I represent that crowd of worldly, fascinating, experienced, master-of-the-universe types that run the trading floors and the financial institutions in Wall Street and elsewhere. Given some recent unfortunate events, you may be under the misapprehension that we need to shoulder blame (and pay some amount of retribution) for a number of recent unfortunate events that have led to the worst world economic crisis since 1929.

Not so! Let me explain.

We - the street-wise, non quant-oriented traders - are the good guys (in spite of what that Oliver Stone guy would have you believe). Really. True, some of us may occasionaly exhibit some obnoxious traits as the pink-tied guy that went recently public saying that Goldman-Sachs rules the world, but that's just what we call good natured fun.

So where are the guilty parties? I have thoroughly researched this question, and am now able to unveil the secret.

It was the quants.

Who are the quants, you may be asking. The quants are geeks. Outsiders. Most of them have science diplomas, PhDs even. Being geeks, they are unworldly, weird, given to math, computer programming and other boring, unglitzy and menial occupations. Quants used to be behaved and subservient: stayed in the back rooom, ran the computer systems, mopped the floors and made themselves generally useful to us dealmakers, occasionally basking in (dim) reflected light. The also had low paychecks, as it befits this type of lowlife.

Alas, unbeknown to most of us, two large foundations (FORD and Carnegie) in 1959 gave us money (We may be nice guys, but we cannot resist money. Who can, honestly) to sneak inside all the B-schools around the US some uebergeeks (Black, Merton, Scholes, et. al.). Once they were in, they started churning out all this crazy math and sending it to the trading floors, were the quants got ideas inside their heads, got uppity, and put that same crazy math inside our computers. Then they made it use them (the computers) and they were showing all kind of terrific numbers and returns, and fees and money we could make.

And so we did. But the numbers were fake. The evil uppity quants had taken us for a ride with their Gaussian, copulas, VaRs and schmaRs. So the market crashed, and - by the way it looks now - it may not recover for the rest of our lives.

Why did we believe the quants, you ask. Well, as kids, most of us wanted to grow up a scientist: wear a white coat, say amazingly intelligent things, go to planets with severe looking, pointy ears aliens, and get the girl at the end. Then the movie stories changed, we found out we liked money more than science, became worldly and savy and intuitive and bought a suit - and we were still getting the girl - not to mention the money, and stuff. But deep inside us, we harbored this science yearning, and so the uebergeeks wilily exploited our gentle side with their scientist prestige. How were we to know they were actual dr. Strangleloves, all of them? Plus we were actually asking them to churn out those models and put them on our computers so we could make money, see?

But wait. We may be nice, but we are not stupid. It's not like we believed the models. We knew they were utter poppycock most of the time (though it galled us that many of the geeks were now making the same money we did by using those very same models). Why were we using them, you ask. Why, we were using them as an excuse to gorge on risk, so we could make more money and award ourselves more fees, that should be obvious. What were we doing before 1959 - without models and quants and stuff? Well, obviously we made money, awarded ourselves fees, and crashed the market all the same, we just used other excuses - oh, and crashes were not so quick, because we did not have computers then. But this is really beside the point, a digression, I'd say. So let's not digress.

What do we do now, you want to know? Let me tell you what - I've got it all figured out.

We need to put worldly, fascinating, experienced, pink-tied, master-of-the-universe "deal makers" and "punters" (like me) back in the driving seat. Runaway quants will be disciplined - hanging a few by the neck on the trading floor will be a nice warning for the others. They'll return to the backroom to reboot computers, make us coffee and mop the floor. We'll kick the uebergeeks out of B-school, so we can free up tenured posts for ourselves when we get close to retirement as masters of the Universe.

Meanwhile, we'll put the economy back in shape, just the way it was in 1920s - no, wait, bad date, you want to get around that '29 thing - I meant, the 1950s. Trust us. The system's got nothing to do with all the troubles. It was the quants. The geeks. The Geeks Bearing Gifts. We will know them in the future and we will fear them, and we will not let them in.

Did they have quants in the Netherlands around 1637, you ask. Of course not, that's absurd, they did not even have computers then. So what about tulip mania, you ask? Sorry, but we really don't have time for digressions, around here. By the way, are you a socialist?

And, 'ow about those gov'ment bonds over there, fellas?
"(**)

(*) I am more or less convinced that Triana is using his "kill the quant" theory as a smoke screen to hide the total systemic failure of the contemporary economic system. I am equally convinced that a lot - possibly all - the econometric models that have been used in quant finance are fragile. And I have a strong suspect that Taleb may be right - no modeling may be possible.

(**) Contains sarcasm.

Wednesday, October 5, 2011

Good (Taleb) and bad (Triana) reads in economics.

Driven by my relentless, not to mention huge, defeatist streak, I have been reading up on the reason we got ourselves in the economical pickle we are in.
My original interest was sparked by this article in Wired, this one in Nova, and other similar stories, that eventually pointed me to the books of Nassim Nicholas Taleb.

Nassim Nicholas Taleb is a charming, thought-provoking, engaging author, who persuasively presents a very original point of view. So original, in fact, that its impact goes well beyond markets and economics: actually I was most impressed by the scope of what Taleb has to say and its significance with regard to (my) personal life and way of thinking.Taleb is also a poseur, which can occasionally be overbearing, and has multiple chips on his shoulders (which he will discuss only in an oblique way). That this objective faults are easily (well, almost easily) forgiven in view of what he has to say goes entirely to his credit. His best books ("Fooled By Randomness" and "The Black Swan") are very good reads, which I wholeheartedly recommend.

Pablo Triana ("Lecturing Birds on Flying") shares most of Taleb's ideas - at least on the surface - and relentlessly defers to Taleb, who wrote an introduction for his tome - that also happens to be the best part of the book, by the way. He is, however, a very different kettle of fish - and of author. He is pompous to begin with - especially when he is expounding on his accomplishments (either as a student, teacher, or trader) or on his ideas on how to reform Business school and academia in general (based on the old and worn-off paradigms of trenches vs. ivory towers and doers vs. thinkers). He is, in fact, so abstraction averse, that one wonders how he can get on with Taleb who is - for all his professions of pragmatism - a quite abstract fellow himself. With respect to his professed role models, Triana behaves as the archetypal follower (or fanboy, if you will ), with a hard to miss Uriah Heep streak (see how he defers to Steve Shreve).

Triana also comes with a gigantic chip on his shoulder, very squarely aimed at financial economics professors. This is not strange in itself, considering his book is a diatribe against the quantitative financial models that originate - mostly - within those academic circles. It is also a point of view that he shares with Taleb, whose resentment against academic circles is also quite sharp. Triana's core motivation however, are more mundane than Taleb's and eventually much less persuasive.

The biggest reason for his quibbles appears to be that he doesn't like math - which looks a lot like an Oedipus type complex: maybe he failed Calculus in his sophomore year, or was denied tenure at MIT. I did my best to forget this particular, childish reason during my perusal of his book (not easy, given he likes to flash his math loathing at the slightest provocation). For his dislike he also states other, sounder reasons, mostly mutuated from Taleb (reasons that I happen to concur with, by the way). The conclusions he draws however, though superficially similar to Taleb's are actually quite different (in my eye) and much harder to swallow.

Triana worships practitioning traders i.e. - as far as my understanding goes - himself. Because of this unrequited love, one of the hidden purposes of his book is clearly letting practitioners off the hook of the last four or five financial crises, piling all the blame on quantitative traders (quants).

Taleb's take on the recent financial mayhems is "We cannot model, because we do not understand" - at least not now, not with these tools. Tough, stark, but extremely interesting.

Triana goes more like "Short range models are a convenient, as long as they suit me". His trading floor/business school heaven goes more or less like this:

  • all quants are devoted to the menial backoffice jobs that the practitioning Trianas have difficulty with: keep computers running, write GUIs in C++ for analytical models of their own devising - after approval and under stric supervision of the practitioners.

  • when the rich practitioners retire, they sit on cracker barrels in B-school, recounting war tales to adoring and cutely young students.

How quaint. What does not compute, at least not in my book, is the fact that the people that commissioned, bought, misunderstood and wildly abused the models that Triana abhors are ... the practitioners themselves. Correct, the charming princes that would (if only the modelers let them) fix the evil of analytic finance are the money grabbing types that misused their analytic tools to the point where they blew up the entire economy, and often themselves in the process. So sorry, Pablo, but I cannot find your exculpation very convincing.

Add to this that Triana's style is extremely long winded and particularly effectiv in driving me to impatience. Uncharacteristically - for myself - I found that, by the middle of his book, I was checking the first sentence on every paragrpah to decide if it was worth reading or if it could be skipped without detriment to the general comprehension - skipping was often safe.

So my advice is, don't bother with "Lecturing Birds on Flying" - it won't add much to what you can get from Taleb's books, but it will tax your patience much more. If you need an executive summary, you can read my final impression in another post.

I'll add my .02 euros.

  • .01 - One of the irritating things about Triana's approach is that he appears to be persuaded that the situation can be fixed by giving traders more status, whereas I am convinced that the overinflated egoes of the self appointed "masters of the universe" on the Wall Street and other trading floors around the world are largely to blame for the current mess. After their rather spectacular failures, I'd rather see them cut down to the rank of the glorified pork belly merchants that they are. I also believe that, if we returned to calling 'cooks' what are now called 'chefs' and 'taylors' what are now called 'fashion designers', etc. air would be more breathable.

  • .02 - I think that both authors would agree that analytical modeling on some scale is made necessary by the speed of automatic trading: if you use computers as trading tools, you have to feed them models (even uncomplicated, minimal ones) in order to perform trades. However, at the time of their writing, both auhors fail to mention or see (Taleb probably has too much fun programming) what appears to me one of the most important factors of the recent economic gyrations. Namely, that for many years automation induced speed has been compounding demographics induced speed (the increase in number of market players), makes feedback loops unstable. Trading speed is outpacing control and decision-making cycles, and this fuels destructive market crises, quite similar to - or even coinciding with - bank runs. As a consequence, I think that heavy brakes need to be applied: not only analytical models should not be used, but - ideally - computers and even cell phones should be banned from trading floors.

Wednesday, September 28, 2011

Formazione professionale

Da bravo benpensante, ho passato un paio di giorni a scandalizzarmi dell'intervista televisiva di Terry de Nicolò (che altri chiamano l'intervista shock).

Poi ho capito che dev'essere stato un errore di programmazione. Quasi certamente doveva essere trasmessa tra i corsi di qualificazione professionale e lezioni universitarie che vanno (andavano?) normalmente in onda a tarda ora sul secondo canale.

In quel contesto, non c'è shock, ad esempio:

  • "la bellezza ha un valore" - come negarlo, nella sua professione. E dire che quasi tutti hanno capito "la bellezza è un valore";
  • "se sei racchia, se fai schifo, te ne devi stare a casa" - Un'imprecisione: puoi anche passeggiare sul marciapiede;
  • "devi essere pronto a vendere il c..." (et come, non);
  • "devi essere pronto a vendere tua madre" Un po' mi sorprende, ma se c'è domanda, la Terry lo saprà;
  • "se vuoi 20,000 euro al mese... se no stai a casa con 2,000 euro al mese" - altra sorpresa, pensavo che per chi esercita in appartamento ci fosse più business;
  • "A sinistra è peggio perché lì sono loffi e non pagano" - nozioni di marketing.

Insomma, un buon seminario di aggiornamento professionale.

Thursday, September 22, 2011

Una interessante progressione armonica.

E' detta anche "giro di Silvio":
Si-Fa-La minore

Nota: smiley obbligatorio per gli humour-impaired :-)

Tuesday, September 13, 2011

Il resto è rumore

"Music is always migrating from its point of origin to its destiny in someone’s fleeting moment of experience—last night’s concert, tomorrow’s solitary jog." Alex Ross The Rest Is Noise: Listening to the Twentieth Century

"La musica è sempre in viaggio, dal luogo della sua origine al suo destino nella passeggera esperienza di qualcuno — il concerto di ieri sera, la corsa solitaria di domattina." Alex Ross Il resto è rumore. Ascoltando il XX secolo

Monday, September 12, 2011

He who lives by the aphorism


He who lives by the aphorism ends up dying by it.

"When someone makes a statement that this in the financial markets should happen every ten thousand years, visibly they are not making a statement based on empirical evidence, or computation of the odds, but based on what? On some model, some theory. Do you ever regard how worrisome it is, when someone makes a statement like that, ``it should happen every ten thousand years'' particularly when the person is not even two thousand years old?" - Nassim Nicholas Taleb

"In the past, most were ignorant, one in a thousand were refined enough to talk to. Today, literacy is higher, but thanks to progress, the media, and finance, only one in ten thousand." - Nassim Nicholas Taleb (from his book of aphorisms, ``The Bed of Procustes'')

"Do you ever regard how worrisome it is, when someone makes a statement like that, ``one in ten thousand people are refined enough to talk to'' when the person probably has attempted to have ``refined'' conversations with not even two thousand people?" - Me


Wednesday, August 24, 2011

Happy Birthday Jorge Luis.

El universo (que otros llaman la Biblioteca) se componte de un número indefinido, y tal vez infinito, de galerías hexagonales, con vastos pozos de ventilación en el medio, cercados por barandas bajísimas. Desde cualquier hexágono se ven los pisos inferiores y superiores: interminablemente. La distribución de las galerías es invariable. Veinte anaqueles, a cinco largos anaqueles por lado, cubren todos los lados menos dos; su altura, que es la de los pisos, excede apenas la de un bibliotecario normal. Una de las caras libres da a un angosto zaguán, que desemboca en otra galería, idéntica a la primera y a todas. A izquierda y a derecha del zaguán hay dos gabinetes minúsculos. Uno permite dormir de pie; otro, satisfacer las necesidades finales. Por ahí pasa la escalera espiral, que se abisma y se eleva hacia lo remoto. En el zaguán hay un espejo, que fielmente duplica las apariencias. Los hombres suelen inferir de ese espejo que la Biblioteca no es infinita (si lo fuera realmente ¿a qué esa duplicación ilusoria?); yo prefiero soñar que las superficies bruñidas figuran y prometen el infinito... La luz procede de unas frutas esféricas que llevan el nombre de lámparas. Hay dos en cada hexágono: transversales. La luz que emiten es insuficiente, incesante.

[...]
Yo me atrevo a insinuar esta solución del antiguo problema: La biblioteca es ilimitada y periódica. Si un eterno viajero la atravesara en cualquier dirección, comprobaría al cabo de los siglos que los mismos volúmenes se repiten en el mismo desorden (que, repetido, sería un orden: el Orden). Mi soledad se alegra con esa elegante esperanza.
-- Jorge Luis Borges (Jorge Francisco Isidoro Luis Borges Acevedo) (August 24, 1899 – June 14, 1986)

Monday, July 18, 2011

Riscoprire Pitigrilli

"Poiché siamo sulla via delle confidenze, riconosco di aver assecondato il teppismo del lettore. Mi spiego: per la strada, quando scoppia un litigio o avviene un incidente della circolazione, scaturisce improvvisamente dalle viscere della terra un individuo che cerca di dare un'ombrellata a uno dei due contendenti, che generalmente è l'automobilista. Il teppista ignoto ha sfogato il suo rancore latente. Così nei libri: il lettore che non ha idee o le ha allo stato amorfo, quando trova una frase pittoresca, fosforescente o esplosiva, se ne innamora, l'adotta, la commenta con un punto esclamativo, con un 'bene!', un 'giusto!', come se egli l'avesse sempre pensata così, e quella frase fosse l'estratto quintessenziale del suo modo di pensare, del suo sistema filosofico. Egli 'prende posizione', come diceva il Duce. Io gli offro il modo di prendere posizione senza scendere nella giungla delle varie letterature." Pitigrilli, "Dizionario Antiballistico"

Così facebook (o con internet), e i suoi stuoli di fanboys.

Rediscovering Pitigrilli

"As I am in a confidential mood, I will acknowledge I have been going along with my reader's hooliganism. Explanation: during every street side discussion, or car accident, a character appears, as if from underground, and tries to hit one of the contendents (generally the car driver) with his umbrella. This unknown hooligan does nothing else then venting his latent aggressiveness. So with books: a reader devoid of ideas (or endowed with rather amorphous ideas) reads a sentence - picturesque, striking, unusual - falls in love with it, takes it in, and comments it with an exclamation mark: 'right on!' 'my feelings exactly!'. It's as if that it had always been his thought, and that sentence the expression of his true inner feelings, his philosophy on the subject. As the Duce used to say, he 'take a position'. I offer the reader a way to 'take a position' without the inconvenience of negotiating the jungle of the various literatures." Pitigrilli, "Dizionario Antiballistico"

So it is with facebook (or the internet) and its flock of fanboys.

Tuesday, July 12, 2011

Xen hotplugging of USB devices in passthrough


Xen's management of USB devices in passthrough (especially for HVM guests, such as windows machines) sucks like a tornado. (kvm's does not shine either, for mostly the same reasons). Among other shortcomings, hotplugging does not work: unplug the device, or turn off your printer, and it disappears - for good. Plugging it in/turning it on will not bring it back into your domU.

The situation can be improved upon using udev rules and a script.

Udev file: /etc/udev/rules.d/99-zlocal:

  SUBSYSTEM=="usb", SYSFS{idVendor}=="0951", SYSFS{idProduct}=="1646", \ 
ENV{idDomU}="mosaico", ENV{idVendor}="0951", ENV{idProduct}="1646",\
RUN+="/usr/local/bin/xen-usb-hotplug mosaico 0951 1646"

(Translation:
if subsystem is usb, vendor 0951 and product 1646 - this numbers can be found with lsusb - put some stuff in the environment and insert a program in the run chain for this event)

The program goes like this::



#!/bin/bash

PROMPT="xen-usb-hotplug(ORION):"
XM=/usr/sbin/xm
logger "${PROMPT} HOTPLUGGING"
logger "${PROMPT} started with environment: $(env)"
DOMU=$1
VENDOR=$2
PRODUCT=$3
#if CLI parameters are unavailable, try to use environment

[[ x${DOMU:=$idDomU} == x ]] && { logger -p user.error "${PROMPT} DOMU is not set"; exit 0 ; }
[[ x${VENDOR:=$idVendor} == x ]] && { logger -p user.error "${PROMPT} VENDOR is not set"; exit 0 ; }
[[ x${PRODUCT:=$idProduct} == x ]] && { logger -p user.error "${PROMPT} PRODUCT is not set"; exit 0 ; }
if [[ x$ACTION != xadd ]]; then
logger "${PROMPT} ${XM} usb-del $DOMU host:${VENDOR}:${PRODUCT}"
${XM} usb-del $DOMU host:${VENDOR}:${PRODUCT}
else
logger "${PROMPT} ${XM} usb-add $DOMU host:${VENDOR}:${PRODUCT}"
${XM} usb-add $DOMU host:${VENDOR}:${PRODUCT}
fi


This sets some service variables, grabs parameters from the CLI, and - if action equals "add", uses "xm usb-add" to stuff the device in the approrpiate domU.
Note that the "remove" part is purely ornamental, because - when unplugged - the device has different information, and the rule is not triggered.
Also note that, to be complete, one would need to discriminate among devices with same vendor and prodID. This is left as an exercise to the reader.

Note: I owe part of what above (essentially the idea of using udev to run a script on usb insertion) to a - since disappeared - blog note by Lorenzo Simionato.

Thursday, June 16, 2011

Brunetta e un po' di igiene semantica

Siccome mi ostino a pensare che anche le parole abbiano un loro peso, ho messo un commento al post del ministro Renato Brunetta sull' "italia peggiore" :


"Buongiorno.


Dr. Brunetta, vorrei sapere cosa significa in concreto "Usare la rete come un manganello per agguati squadristici". Da ieri gliel'ho sentita ripetere diverse volte, ma mi pare che sia esclusivamente un espediente retorico volto a cercare di fare lo sgambetto al cosiddetto web-attivismo.


I manganelli e gli squadristi fanno morti e feriti. L'unica cosa che questo episodio ha transitoriamente ammaccato è la Sua immagine pubblica, e non avrebbe fatto nemmeno quello, se Lei avesse evitato di pronunciare la frase che, di fatto ha pronunciato. (Ci sarebbe stato un video intitolato "Brunetta non risponde etc.", e video così, ce ne sono tanti).


Tuttavia, non pronunciare frasi improvvide e gestire al meglio la propria immagine pubblica sono importanti componenti del mestiere di un politico. Così come lo sono il saper rispondere a domande scomode, anche in poco tempo e sotto pressione, e l'accettare di essere - anche duramente - contestati. O così almeno dovrebbe essere, visto che noto in tanti personaggi pubblici una crescente intolleranza alle platee critiche. Posso capire che le claque siano più gratificanti delle contestazioni, però sono anche associate a regimi che non vengono normalmente chiamati democratici.


Cordialmente,
Alessandro Forghieri
"

Wednesday, May 25, 2011

Fenomenologia di Jane Austen

Questo:

"It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife." - Jane Austen, Pride and Prejudice.

("E' un fatto universalmente riconosciuto che uno scapolo dotato di un buon patrimonio ha bisogno di una moglie")

è il passaggio "più pubblicamente sottolineato" dai possessori di Kindle. Mi chiedo se c'è una morale che mi sfugge (oltre a quella ovvia, che uno scapolo ricco è attraente oggi come ai tempi di Jane Austen)

Thursday, April 28, 2011

Non dire

"Non dire con dolore: non ci sono più, ma con riconoscenza: ci sono stati"

Riccardo Negrinelli, in memoria.





Uno sguardo al cielo


Volgendo lo sguardo a est
La luna a metà appare
Bianca di luce riflessa
Rischiara le tegole brune
Lo spazio di uno guardo accanto
Brilla di luce propria
Cintura su un tetto
Spettacolo del creato
Che ricolma lo sguardo mio



Wednesday, March 16, 2011

Ma conviene?

Da: Scienza in Rete

Nel migliore dei casi, smantellare una centrale costa (per un reattore raffreddato ad acqua da 1000 MW) circa 400 milioni di €, fino ad arrivare a circa 2 miliardi di € per i reattori inglesi raffreddati a gas. Per citare Maugeri [4], “La sottovalutazione iniziale e in itinere delle spese è stata talmente abnorme da sollevare problemi per la fiscalità di interi paesi al momento in cui, per esempio, è stata valutata la possibilità di privatizzare imprese pubbliche operanti nel nucleare, come è accaduto in Gran Bretagna e in Francia. Così, per esempio, nel 2001 la British Nuclear Fuels Limited (posseduta dallo Stato) aveva accumulato 38 miliardi di € di costi da sostenere, in gran parte dovuti a oneri di smantellamento dei suoi impianti di riprocessamento nucleare”.

Calculemus

Sento dire (e per pura carità di patria, lasciamo stare da chi):

"Smettere di fare centrali per via di Fukushima sarebbe come smettere di fare ponti tutte le volte che cade un ponte."

Nessuno di costoro ha ancora tentato di confrontare, in termini di danni, i costi di un crollo di un ponte con quello di contaminare per miglialia di anni un'area urbana abitata da 13 milioni di persone - diciamo i costi, umani e no, di evacuare per i prossimi 10,000 anni la prefettura di Tokyo dopo averla seppellita sotto una colata di cemento. (I numeri, si sa, sono scomodi).

Il primo evento è abbastanza frequente, i danni circoscritti. Il secondo rischio - dati alla mano e su base mondiale - è abbastanza raro - ma tende a presentarsi circa ogni 30 anni (Chernobyl, Fukushima). Facciamo una botta di conti?

Se pero' questo tipo di ragionamento e' ostico, vogliamo dedicare un attimo di attenzione al noto e irrazionale fazioso, nonché premio Nobel per la fisica Carlo Rubbia, che dichiarò in tempi non sospetti - e ha ripetuto in questi giorni, che il nucleare (anche di ennesima generazione) è una battagli di retroguardia, soprattutto se intrapresa oggi per coprire il 4% del nostro fabbisogno energetico fra 10 anni?

Bash script profiler

Sysadmins do not die - they just logoff.

Let's keep old tools alive.


#! /bin/bash
#
# shprof - a line profiler for shell scripts
# Usage:
# shprof.sh
# Executes and counts how many times each line is executed.
# converted and sparsely tested by Alessandro Forghieri ( alf (at) orion (dot) it) from:
# http://dev.gentoo.org/~dberkholz/scripts/shprof
# -- which did not really work and in turn claimed to come from:
# http://www.math.ias.edu/doc/bash-3.0/scripts.v2/shprof (which now 404's)
#
#
# That was in turn adapted from a similar program included in `The New KornShell' by
# Bolsky and Korn and posted to usenet by bsh20858@challenger.fhda.edu
#
# converted to bash v2 syntax by Chet Ramey
#
TMPFILE=${TMP:-/tmp}/shprof$$

trap 'rm -f $TMPFILE' EXIT

errexit()
{
echo $0: "$@" >&2
exit 1
}

# create script with profiling enabled
cat > $TMPFILE <<- \_EOF_
declare -a _line
_profend()
{
case "$1" in
/*|./*) file="$1" ;;
*) file=$(type -path "$1") ;;
esac

echo "*** line profile for $file ***"
i=1;
while read -r && [ $i -le $NLINE ]; do
count=${_line[$i]}
if [ "$count" -gt 0 ]; then
echo "[$count] $i: $REPLY"
fi
i=$((i + 1))
done <$file
_EOF_
# make the profiling script remove itself after printing line stats
echo "rm -f $TMPFILE" >> $TMPFILE
cat >> $TMPFILE <<- \_EOF_
}
_command=$1
shift
i=1
NLINE=$(wc -l < "$_command")
while [ $i -le $NLINE ]; do
_line[$i]=0
i=$((i + 1))
done
unset i
trap "_profend ${_command}" EXIT
BLN=999999
trap 'LN=$(( $LINENO - $BLN )) ; if [[ $LN -gt 0 ]]; then _line[$LN]=$(( ${_line[$LN]} + 1 )); fi;' DEBUG
BLN=$LINENO
_EOF_

case "$1" in
/*|./*) file=$1 ;;
*) file=$(type -p "$1") ;;
esac

cat "${file-$1}" >> $TMPFILE || errexit "${1}: cannot open"
chmod +x $TMPFILE

exec -a "$file" $TMPFILE "$@"

Tuesday, March 15, 2011

Caro H.G. Wells

Le vere macchine del tempo siamo noi.

"Al lago ho un vicino, uno dei sempre più numerosi pirati dell’etere, che si è fatto installare una parabola. Da noi le parabole sono fuorilegge, perché consentono di captare gratis un centinaio di canali americani a pagamento. Ma lui con un decoder da trenta dollari li becca tutti. Da un certo punto di vista mi trovo in una situazione molto simile: anch’io, nel mio crepuscolo, passo lunghe notti a ricevere dal passato un guazzabuglio di immagini cifrate, ma a differenza del mio vicino non riesco a decodificarle."
da Mordecai Richler "La Versione di Barney"

Thursday, February 3, 2011

Virtualbox and USB on Fedora 14 (FC14)

Briefly: with the indicaetd setup, all the usb devices appear to be unavailable,
as seen in:

$ VboxManage list usbhost

(they are also greyed out in all the pesky dialog boxens).

[...time passes...] Having spent several hours in the fascinating process of pulling hair out of my head, i found that you have to:
  1. add yourself to the vboxusers group that VirtualBOx creates
  2. disregard notices abour mounting usbfs and whatnot (that's for old systems apparently)
  3. run
    $ sg vboxusers VirtualBox
    or
    $ newgrp vboxusers
    $ VirtualBox

It appears that VirtualBox sets everything for the vboxusers group to work, however, it does not bother to newgrp into it. How's that for great fun.