Thursday, December 04, 2008

sd reader on hp laptop

Check what you have


~ $ /usr/sbin/lspci |grep "Card Reader"
02:06.2 Mass storage controller: Texas Instruments 5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD)


make menuconfig and enable


Device Drivers --->
[*] Misc devices --->
-*- TI Flash Media interface support
<*> TI Flash Media PCI74xx/PCI76xx host adapter support

Device Drivers --->
<*> MMC/SD card support --->
<*> MMC block device driver
<*> TI Flash Media MMC/SD Interface support


then re-compile the kernel, reboot. When I insert
a SD card I see (dmesg)


tifm_core: MMC/SD card detected in socket 0:1
mmc0: new SD card at address b368
mmcblk0: mmc0:b368 SD 1997312KiB
mmcblk0: p1


finally


mount /dev/mmcblk0p1 /mnt/floppy/

Wednesday, November 12, 2008

Access to serial port

In order to get rid of the error

you don't have +rw permission to access serial port

you need to add your user to the uucp group

> ls -l /dev/ttyS0
crw-rw---- 1 root uucp 4, 64 Nov 12 18:44 /dev/ttyS0

/usr/sbin/usermod -a -G uucp my_username

Monday, October 27, 2008

dual monitor on my laptop

Using xrandr and the monitor sitting on my desk.

Edit xorg.conf and add the "virtual" line (if there is no xorg.conf and it's
using the guess-mechanism, copy the guess from /var/log/Xorg.0.log )


Section "Screen"
...
Subsection "Display"
...
Virtual 1280 1824
EndSubSection
EndSection

Then create the script "switchDual"

$ cat bin/switchDual
#!/bin/bash

if [ -e /var/lock/subsys/gerbaudo/dualOn ]
then
echo "turning off VGA screen..."
xrandr --auto --output LVDS --mode 1280x800 --output VGA --off
rm /var/lock/subsys/gerbaudo/dualOn
else
echo "turning on VGA screen..."
xrandr --auto --output VGA --mode 1280x1024 --above LVDS
touch /var/lock/subsys/gerbaudo/dualOn
fi


As root create the dir where the lockfile is stored


# mkdir /var/lock/subsys/gerbaudo
# chown gerbaudo:gerbaudo /var/lock/subsys/gerbaudo


and add an icon for it on the desktop


$ cat ~/Desktop/startDual.desktop
[Desktop Entry]
Comment=
Comment[en_US]=
Encoding=UTF-8
Exec[$e]='/home/gerbaudo/bin/switchDual'
GenericName=startDual
GenericName[en_US]=startDual
Icon=
MimeType=
Name=startDual
Name[en_US]=startDual
Path[$e]=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DCOP-ServiceType=
X-KDE-SubstituteUID=false
X-KDE-Username=


Voila

Saturday, October 25, 2008

gentoo - fuse

install the "fssh" stuff that you got from Justace--thanks man!

emerge sys-fs/sshfs-fuse

mkdir /rooms
mkdir /work

chmod /rooms --reference=/mnt/cdrom
chmod /work --reference=/mnt/cdrom

At this point--works as root--something wrong with permissions

groupadd fuse

usermod -a -G fuse gerbaudo

Try to reboot: still not working. Google around and try this:

chown gerbaudo:gerbaudo /rooms
chown gerbaudo:gerbaudo /work/


Now it works :-)

gentoo install root (disable cintex+reflex)

Something is wrong with compiling root5.20.00 on gentoo
(see this bug report)

add in /etc/portage/package.keywords

sci-physics/root ~x86

Then following this link
gerbaudo-hp ~ # ls /usr/portage/sci-physics/root/
ChangeLog files root-3.05.04.ebuild root-5.18.00d.ebuild root-5.20.00.ebuild
Manifest metadata.xml root-5.16.00.ebuild root-5.20.00-r1.ebuild
gerbaudo-hp ~ # mkdir /usr/local/portage
gerbaudo-hp ~ # mkdir /usr/local/portage/sci-physics
gerbaudo-hp ~ # mkdir /usr/local/portage/sci-physics/root
gerbaudo-hp ~ # cp /usr/portage/sci-physics/root/root-5.20.00.ebuild /usr/local/portage/sci-physics/root/
gerbaudo-hp ~ # cp -rp /usr/portage/sci-physics/root/files /usr/local/portage/sci-physics/root/

add one line in make .conf

gerbaudo-hp ~ # emacs -nw /etc/make.conf
gerbaudo-hp ~ # diff /etc/make.conf /etc/make.conf~
< PORTDIR_OVERLAY="/usr/local/portage"

gerbaudo-hp ~ # cd /usr/local/portage/sci-physics/root/

disable cintex and reflex from the ebuild

gerbaudo-hp root # emacs -nw root-5.20.00.ebuild
gerbaudo-hp root # diff root-5.20.00.ebuild root-5.20.00.ebuild~
142c142
< --disable-cintex \ --- > --enable-cintex \
148c148
< --disable-reflex \ --- > --enable-reflex \

and finally digest

gerbaudo-hp root # ebuild root-5.20.00.ebuild digest

Then

gerbaudo-hp root # emerge -av =root-5.20.00

Friday, October 24, 2008

wifi on gentoo

This is the wireless HW I have:

gerbaudo@gerbaudo-hp ~ $ /usr/sbin/lspci -v | grep Wireless
10:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG Network Connection (rev 02)

First of all you need to enable the drivers in your .config
(or use the .config you have, or create it automagically).
These are the flags I have

#
# Wireless LAN
#
CONFIG_WLAN_80211=y
CONFIG_IWL3945=m
CONFIG_IWL3945_QOS=y
...
#
# Wireless
#
CONFIG_CFG80211=y
CONFIG_NL80211=y
CONFIG_WIRELESS_EXT=y
CONFIG_MAC80211=y

then build the kernel and try some debugging

ifconfig wlan0 up

then copy your old wpa_supplicant.conf and then

add in /etc/conf.d/net

config_wlan0=("dhcp")
modules=( "wpa_supplicant" )
mode_wlan0="managed"
wpa_supplicant_wlan0="-Dwext"


cd /etc/init.d ; ln -s net.lo net.wlan0


One further thing that I did (but I don't know whether
or not it's necessary) is :

wpa_supplicant -B -Dwext -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf

At the next reboot it tried eth0, timed-out, and connected on wlan0 :-)

Tuesday, October 14, 2008

split multiple-pages pdf in multiple files

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=epswrite -sOutputFile=result-%02d.eps /tmp/infile.pdf

then eps2pdf

Monday, October 13, 2008

skype on SLC4

Tried to install skype on SLC4.
Can only get the latest version (2.0.0.72) from skype.com (cannot find older versions around).
Download the statically linked package from http://www.skype.com/go/getskype-linux-static
Unpack in /usr/local/share/skype; it complains about

/skype: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.4' not found

Need more recent stdc++ library (using gcc version 3.4.6 from /usr/bin/gcc);
get gcc-4.2.1 from http://gcc.gnu.org. Then configure; make; make install.
Change the symbolyc link so that it points to the new library

/usr/lib/libstdc++.so.6 -> /usr/local/lib/libstdc++.so.6.0.9

Now skype starts without much complaining. I can hear sounds, but
cannot speak. Kill artsd (don't know, might not be the problem),
change settings with alsamixer. Then from the skype settings switch
from the default audio device to the 4th one (otherwise
"Call Failed: Problem with Audio Playback" ).
Now it seems to work (can hear my voice back during test call), but I might
have to adjust the mic volume.

Note: set audio device different from the default one for input/output/ringing, not only for output

Friday, August 29, 2008

find and grep

few ways to see which files contain a string

find . -name \*config -print -exec grep "sam:" {} \; > /tmp/find_out

grep -H -r "sam:" ./
grep -lir "text to find" *
grep -i -n ‘text to search' *
grep --with-filename --line-number `find -type f`

Monday, May 26, 2008

how to concatenate pdf

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf in3.pdf

Friday, May 09, 2008

emacs text mode menubar

On text-only terminals with no mouse, you can use the menu bar by typing M-' or (these run the command tmm-menubar).

from
http://linux.about.com/od/emacs_doc/a/emacsdoc317.htm

Saturday, April 19, 2008

connect to fnal from SLC4 laptop

kinit -A -f user@FNAL.GOV
ssh -2 -Y user@cmslpc.fnal.gov

Wednesday, April 09, 2008

convert std::iterator to int index

#include <vector> ;
#include <algorithm> ;

std::vector<double> a;
a.push_back(3.); a.push_back(5.); a.push_back(9.);
std::vector::iterator it = std::find(a.begin(),a.end(),9.);
int index = it - a.begin();

Thursday, April 03, 2008

funny behavior TTree with vectors

while working with CMSSW_1_7_5 I noticed one funny thing.
I am trying to store a vector of double in a tree (created within an analyzer etc.).
The relevant lines are

--------------------------------------------------
TTree *tree_;
std::vector < double > *ptr_vect ;

// assign the pointers to smth valid

tree_->Branch("mybranch","std::vector <double>",&ptr_vect); // opt. 1)

tree_->Branch("mybranch","std::vector < double >",&ptr_vect); // opt. 2)
--------------------------------------------------

The only difference is the whitespaces in the second option.
When I use opt. 1) everything is fine; when I use opt. 2) everything compiles
fine, but then it crashes when it reaches the TTree::Branch line.
I guess the problem is that root doesn't manage properly white spaces when
parsing the option classname in

TTree::Branch(const char* name, const char* classname, void*** addobj, Int_t bufsize = 32000, Int_t splitlevel = 99)

The same code in a standalone app gives the following message,
which is easier to understand than " Generating stack trace..."

$ g++ -o test.exe test.C `root-config --cflags --libs`
$ ./test.exe
Error in : The class requested (vector >double<:) for the branch "branch0" refer to an stl collection and do not have a compiled CollectionProxy. Please generate the dictionary for this class (vector>double<)

two options to force the loading of the dictionary:

// opt 1
#ifdef __MAKECINT__
#pragma link C++ class vector >double< ;
#endif

// opt 2

gROOT->ProcessLine("#include >vector<");

Sunday, March 16, 2008

Religion and science

I have read this book by Bertrand Russel in the last few weeks, and I am jotting here my impressions about it. This book is short (which most of the times is a good thing, as long as there is enough content) and dense (which is usually good, as long as the contents are well expressed and understandable). Well, in this case, I think both of these characteristics can be considered as qualities, and highly considered ones. In ten chapters, the author goes through the historical and and philosophical events and issues which have marked this long dialogue/conflict. I found this book to be so good and rich, that I cannot summarize it in few sentences. Also, I have so much stuff underlined, that it is hard to pick few excerpts from it. Anyway, I'll try to write here the sentences that I liked the most from each chapter...
1)The grounds of conflict. Creeds are the intellectual source of the conflict between religion and science, but the bitterness of the opposition has been due to the connection of creeds with Churches and with moral codes. [...] Secular rulers, therefore, as well as Churchmen, felt that they had good reason to fear the revolutionary teaching of the men of science. (pg.9)
A religious creed differs from a scientific theory in claiming to embody eternal and absolutely certain truth, whereas science is always tentative, expecting that modifications in its present theories will sooner or later be found necessary, and aware that its method is one which is logically incapable of arriving at a complete and final demonstration.
2)The Copernican revolution. Galileo Galilei (1564-1642) was the most notable scientific figure of his time, both on account of his discoveries and through his conflict with the Inquisition. (pg.31) There can be no question that the clergy, if they had had the power, would have used it to prevent the spread of Copernicanism. (pg.43)
3)Evolution. But on the subject of animal life theology had a number of very definite views, which it was found increasingly difficult to reconcile with science.[...] all animals now existing belong to species represented in the ark[...] This opinion was not without difficulties. St.Augustine confessed himself ignorant as to God's reason for creating flies. Luther, more boldly, decided that they had been created by the Devil, to distract him when writing good books. The latter opinion is certainly plausible. (pg.65)
4)Demonology and medicine. The scientific study of the human body and its diseases has had to contend--and to some extent still has to contend--with a mass of superstition, largely pre-Christian in origin, but supported, until quite modern times, by the whole weight of ecclesiastical authority. Disease was sometimes a divine visitation in punishment of sin, but more often the work of demons. (pg.82) The harm that theology has done is not to create cruel impulses, but to give them the sanction of what professes to be a lofty ethic, and to confer an apparently sacred character upon practices which have come down from more ignorant and barbarous ages. The intervention of theology in medical questions is not yet at an end; opinions on such subjects as birth control, and the legal permission of abortion in certain cases, are still influenced by Bible texts and ecclesiastical decrees. (pg.106) The consequent improvement in health and increase of longevity is one of the most remarkable and admirable characteristics of our age. Even if science had done nothing else for human happiness, it would deserve our gratitude on this account. Those who believe in the utility of theological creeds would have difficulty in pointing to any comparable advantage that they have conferred upon the human race.
5)Soul and body. Thus "true" freedom, as opposed to mere caprice, was identified with obedience to the moral law. (pg.126) The question of "consciousness" is perhaps rather more difficult. (pg.130)
6)Determinism. [...]such matters, it is now held, are inessential. But there are three central doctrines--God, immortality, and freedom--which are felt to constitute what is of most importance to Christianity, in so far as it is not connected with historical events. (pg.144) We can now state the hypothesis of determinism[...]: There are discoverable causal laws such that, given sufficient (but not superhuman) powers of calculation, a man who knows all that is happening within a certain sphere at a certain time can predict all that will happen at the centre of the sphere during the time that it takes light to travel from the circumference of the sphere to the centre.[...] For the first time in history, determinism is now being challenged by men of science on scientific grounds. (pg.151) People imagine that, if the will has causes, they may be compelled to do things that they do not wish to do. This, of course, is a mistake; the wish is the cause of action, even if the wish itself has causes. (pg.163)
7)Mysticism. I cannot admit any method of arriving at truth except that of science, but in the realm of the emotions I do not deny the value of the experiences which have given rise to religion. Through association with false beliefs, they have led to much evil as well as good; freed from this association, it may be hoped that the good alone will remain. (pg.189)
8)Cosmic purpose. Many questions are raised by this theory. Let us begin with the most definite: in what sense, if any, is biology not reducible to physics and chemistry, or psychology to biology? (pg.199) As for the view that God's eternal blessedness should be a comfort to the poor, it has always been held by the rich, but the poor are beginning to grow weary of it. Perhaps, at this date, it is scarcely prudent to seem to associate the idea of God with the defence of economic injustice. (pg.210) And even if we accept the rather curious view that the Cosmic Purpose is specially concerned with our little planet, we still find that there is reason to doubt whether it intends quite what the theologians say it does. (pg.217)
9)Science and ethics. [...] science has nothing to say about "values". This I admit; but when it is inferred that ethics contains truths which cannot be proved or disproved by science, I disagree. (pg.223) But in fact conscience is a product of education, and can be trained to approve or disapprove, in the great majority of mankind, as educators may see fit. (pg.227)
10)Conclusions. We have seen that, in the period since Copernicus, whenever science and theology have disagreed, science has proved victorious. We have seen also that, where practical issues were involved, as in witchcraft and medicine, science has stood for the diminution of suffering, while theology has encouraged man's natural savagery. (pg.244) New truth is often uncomfortable, especially to the holders of power; nevertheless, amid the long record of cruelty and bigotry, it is the most important achievement of our intelligent but wayward species.

Sunday, February 10, 2008

Appunti partigiani '44-'45

Il mattino del primo gennaio 2008, in un freddo e silenzioso Limone, ho trovato questo libro di Beppe Fenoglio(1922-1963) in una edicola. Ne avevo già sentito parlare e così, incuriosito, l'ho comprato e cominciato a leggere subito.
Questi testi sono stati fortunosamente ritrovati in una cantina negli anni novanta, e costituiscono il primo racconto sulla resistenza scritto da Beppe Fenoglio. Gli appunti in sè sono già una chicca: scritti sui registri della macelleria del padre, tra le colonne di "data/carne/prezzo/importo", rappresentano la prima esperienza dell'autore nel mettere su carta le sue vicende partigiane ancora a sangue caldo, poco dopo la fine della guerra (presumibilmente sono stati scritti nel 1946). Si può chiaramente vedere che nel racconto c'è una gran parte di materiale autobiografico (il protagonista si chiama Beppe, ha la stessa età, la stessa famiglia, e gli stessi ideali dello scrittore). La storia si svolge "tra i giorni successivi al 2 novembre 1944 (quando Alba viene ripresa dai fascisti dopo i famosi ventitre giorni) e il 23 dicembre, a quindici giorni dall'Immacolata (quando il racconto si interrompe, con parola spezzata, alla fine del quarto taccuino)."
Le avventure narrate sono quelle del protagonista con i suoi due compagni partigiani Cervellino e Piccàrd, e riguardano "processi ed esecuzioni sommarie, ripiegamenti nella boscaglia ed improvvise avanzate, cadaveri e desolazione", rastrellamenti e scappate giù in città. I vari episodi possono sembrare a tratti disconnessi tra loro, ma rappresentano secondo me molto bene quanto a volte le cose succedano caoticamente e senza connessioni logiche tra di loro--e riesco a malapena ad immaginare come questo possa essere esasperato in tempo di guerra. Una cosa che mi ha colpito è di come l'autore sia onesto nel presentare i fatti; per esempio la punizione dei partigiani Blister e Jack per aver rubato, è un avvenimento che certamente sarebbe stato evitato da un libro di propaganda filo-partigiana...Riporto qua alcuni dei passaggi che mi hanno colpito di più.
"Cascina della Langa [...] E' il feudo di un noto commerciante della mia città, già commilitone di mio padre. Quando gli capita di parlarne con i suoi amici cittadini, questi d'istinto raggricciano le spalle, perchè Cascina della Langa porta un'idea di tramontana e di solitudine. Se è destino che io torni borghese [...] voglio presentarmi [...] a chieder loro di vendermela. Una volta che sarà mia ci passerò tre mesi d'ogni anno che mi resterà." (pg.22)
"Stasera che torno alla Langa, punto su Baffo e attacco briga con lui in ogni modo. Solo perchè ricordo che oggi ha gridato che noi si andava a puttane. Non saprei dire come questo c'entri, ma sento che c'entra." (pg.32)
"Moretto non è certo quello che aspetta e fa la raffica, bella spessa. [...] La gente trema come un bosco sotto il vento. E qualcuno se la batte, tutto gobbo e gli occhi storti. [...] E adesso una donna grida da lontano, poi da più vicino, e la gente si fende come a lasciar passare questo grido. [...] la donna si getta sul morto e lo bacia e gli parla, e non vede che il parroco le si è inginocchiato accanto, nella polvere. [...] La donna striscia sempre sul morto, gli netta il viso dalla polvere, gli passa una mano dietro la nuca per raccorgliergli i capelli, e geme che lei glielo diceva sempre, eri troppo cattivo, Carlo, e non ti avrebbero più perdonato." (pg.42)
Sarà perchè a Fenoglio sono affezionato, ma questo libro mi è piaciuto tantissimo. Anche nella frammentarietà del racconto si trovano un sacco di vicende e immagini che sono toccanti, sempre descritte con "occhio lineare". Occhio lineare, ma che sa capire quel poco che c'è da capire, e cogliere quei due o tre particolari che rendono ogni singola vicenda viva e piena di significato in sè. Se dovessi fare un paragone con qualche altra opera che trasmette una tale drammaticità con altrettanta schiettezza ed onestà, mi verrebbe in mente "Guernica" di Picasso.

Sunday, February 03, 2008

Cosmology - A very short introduction

Over winter break I've read this book by Peter Coles, so I am writing here what my impressions about it. First of all I must say I am again impressed by the good quality of the collection "A very short introduction..." by Oxford University Press. These books are able to provide a good introduction and overview on many different topics, providing just enough details to get an idea, and avoiding obscure jargon. That said let's talk business, the book.
It opens with an historic overview of our conception of the cosmos, and of the methods used by mankind to investigate it. Then it presents in one chapter the main ideas of general relativity: Eistein's revolution, the equivalence principle, the curvature of space and its connection with gravity, completing the chapter with a paragraph on black holes. Chapter 3 ("First principles") introduces the cosmological principles (i.e. the universe is assumed to be homogeneous and isotropic on large scales), and--by using the Friedmann models to unravel the evolution of the universe--the idea of singularities and the open/flat/closed universe. Chapter 4 ("The expanding universe") describes Hubble's law (v=H_0 * d) and its observation with the Doppler's (red)shift. Then he explains why the measurement of H_0 is difficult, and how one can infer from its value the age of the universe (around 15 billion years). Chapter 5 is fully dedicated to the Big Bang theory, and its experimental evidence from the cosmic microwave background. The CMB also provides insight for the understanding of nucleosynthesis and bariogenesis (when considered along with our knowledge of the standard model of particle physics...). In chapter 6 ("what's the matter with the universe?") Coles introduces the main role played by Omega in cosmology (Omega = "ratio of the actual density of matter in the universe to the critical value that marks the line dividing between eternal expansion and ultimate recollapse"). Omega and H_0 are not provided by the Friedmann's model or by the BigBang theory: equations work for whatever values they assume. Their determination is still nowadays a hot topic, related to old (cosmological constant) and new (dark energy) topics. The origin of "Cosmic structures" (chapter 7) or large-scale structures (i.e. how galaxies are distributed) can be investigated by studying the CMB precious insights about their formation. "So why is the microwave background not smooth after all? The answer is intimately connected to the origin of large-scale structures and, as ever in cosmology,gravity provides the connection." The concluding chapter 8 ("A theory of everything?") illustrates how crucial has been quantum mechanics in all this picture, and how the link between standard model and gravity is still missing.

Monday, January 21, 2008

Il pellegrino dalle braccia d'inchiostro

Durante le vacanze di natale, tra aerei e divani, ho letto questo libro di Enrico Brizzi.
La storia è quella di quattro pellegrini che sono in cammino da Canterbury a Roma; il romanzo in sè si svolge nel tratto Losanna agli Appenini (nelle ultime pagine si fa un accenno a Siena, ma non ne sono sicuro). I quattro compagni di avventura--non pellegrini nel senso religioso, ma piuttosto amici/conoscenti che per vari motivi hanno deciso di mettersi in strada e vivere l'affascinante esperienza del viaggio--percorrono l'antico sentiero dei viandanti che passa dal Gran San Bernardo. I quattro personaggi camminando si raccontano le storie che hanno alle loro spalle, ed in questo modo l'autore cerca di dare loro una certà solidità--cosa che secondo me non riesce appieno.
Ad ogni modo, lungo il loro cammino incontrano un personaggio strano, che inizialmente compare quasi di strascico, e man mano si intromette (letteralmente) nel loro viaggio. Il pellegrino dalle braccia d'inchiostro (dai tatuaggi che ricoprono tutto suo corpo viene il titolo) è un personaggio un po' strano, a metà strada tra il mistico e quello che si è bruciato con LSD, che afferma di aver dialogato con i santi (i protettori dei pellegrini) e con Hoffman (il protettore dell'LSD). A parte le sue bizzarie, il personaggio di Bern (questo è il suo nome) si dimostra essere non dei più simpatici: misogino, perseguita gli omosessuali, ed in generale si comporta da fanatico cristiano. Caccia nei guai una prima volta i quattro compagni di viaggio e, dopo attaccarsi a loro come un perseguitatore, li caccia nei guai una seconda volta. La narrazione di queste vicende crean un crescendo abbastanza piacevole, che incurioscisce e rende il libro avvincente. Alla fine si scoprirà che il secondo pasticcio non è stato causato da Bern, ma che lui ne è stato la vittima. I quattro quindi si ricredono e lo aiutano a raggiungere la sua meta. Il libro mi è piaciuto abbastanza anche se non mi ha entusiasmato troppo. I personaggi avrebbero potuto essere dipinti con un po' più di tratti caratteristici (l'unico a spiccare un po' è forse Bern), ed alcune volte le descrizioni dei paesaggi sono un po' troppo rigogliose (probabilmente conseguenza del fatto che l'autore li abbia veramente visti e sperimentati). Altra cosa che non mi è piaciuta molto è che alla fine un personaggio fanatico e violento come il tatuato venga alla fine fatto sembrare quasi simpatico, che mi sembra un po' troppo. Magari è solo la vena anticlericale/antireligiosa che mi ha preso in questi giorni.