Saturday, November 26, 2011

Itaca


Quando ti metterai in viaggio per Itaca
devi augurarti che la strada sia lunga, 
fertile in avventure e in esperienze. 
I Lestrigoni e i Ciclopi
o la furia di Nettuno non temere, 
non sarà questo il genere di incontri
se il pensiero resta alto e un sentimento
fermo guida il tuo spirito e il tuo corpo. 
In Ciclopi e Lestrigoni, no certo, 
ne' nell'irato Nettuno incapperai
se non li porti dentro
se l'anima non te li mette contro.

Devi augurarti che la strada sia lunga. 
Che i mattini d'estate siano tanti
quando nei porti - finalmente e con che gioia -
toccherai terra tu per la prima volta: 
negli empori fenici indugia e acquista
madreperle coralli ebano e ambre
tutta merce fina, anche profumi
penetranti d'ogni sorta; piu' profumi inebrianti che puoi, 
va in molte città egizie
impara una quantità di cose dai dotti.

Sempre devi avere in mente Itaca -
raggiungerla sia il pensiero costante. 
Soprattutto, non affrettare il viaggio; 
fa che duri a lungo, per anni, e che da vecchio
metta piede sull'isola, tu, ricco
dei tesori accumulati per strada
senza aspettarti ricchezze da Itaca. 
Itaca ti ha dato il bel viaggio, 
senza di lei mai ti saresti messo
sulla strada: che cos'altro ti aspetti?

E se la trovi povera, non per questo Itaca ti avrà deluso. 
Fatto ormai savio, con tutta la tua esperienza addosso
già tu avrai capito ciò che Itaca vuole significare.

- Kostantin Kavafis

Tuesday, November 22, 2011

Il Viaggio

Qualche giorno fa pensavo alla bellezza di viaggiare, incontrare nuove persone e scoprire nuove culture. Poco dopo mi sono imbattuto in una copia del mio tema di maturità. Il caso?

Il turista non è il viaggiatore: le cose, e non gli esseri umani, sono oggetto della sua predilezione. Viaggiare dovrebbe essere tutt'altro: fermarsi più a lungo e girare di meno. Chi vuole davvero viaggiare dev'essere a conoscenza del fatto che è meglio un'esperienza spazialmente più limitata ma carica di emozioni e sensazioni, piuttosto che un gran numero di immagini che al termine del viaggio si affastellano l'una dietro l'altra nella memoria, senza quasi più un ordine logico. Il vero viaggiare è un'operazione complessa, che necessita della collaborazione e della consapevolezza del viaggiatore: non è cosa da poco, non è soltanto uno spostamento, è molto di più.

Tuesday, November 15, 2011

50 ways to cope with stress

Stress is everywhere around us. At work, in our homes, even on each word (yes, that's English humour!).

Here is a list of things I find useful to fight stress away. Doing all of them every day is difficult, somewhat impossibile. But if you are interested in this post, then you should definitely give them a try!

  • Get up 15 minutes earlier
  • Prepare for the morning the night before
  • Don't rely on your memory... write things down
  • Repair things that don't work properly
  • Make duplicate keys
  • Say "no" more often
  • Set priorities in your life
  • Avoid negative people
  • Always make copies of important papers
  • Ask for help with jobs that you dislike
  • Break large tasks into bite sized portions
  • Look at problems as challenges
  • Smile more
  • Be prepared for rain
  • Schedule a play time into every day
  • Avoid tight fitting clothes
  • Take a bubble bath
  • Believe in you
  • Visualize yourself winning
  • Develop a sense of humour
  • Stop thinking tomorrow will be a better today
  • Have goals for yourself
  • Say hello to a stranger
  • Look up at the stars
  • Practise breathing slowly
  • Do brand new things
  • Stop a bad habit
  • Take stock of your achievements
  • Do it today
  • Strive for excellence, not perfection
  • Look at a work of art
  • Maintain your weight
  • Plant a tree
  • Stand up and stretch
  • Always have a plan B
  • Learn a new doodle
  • Learn to meet your own needs
  • Become a better listener
  • Know your limitations and let others know them too
  • Throw a paper airplane
  • Exercise every day
  • Get to work early
  • Clean out one closet
  • Take a different route to work
  • Leave work early (with permission)
  • Remember you always have options
  • Quit trying to "fix" other people
  • Get enough sleep
  • Praise other people
  • Relax, take each day at a time... you have the rest of your life to live

Tuesday, November 8, 2011

Print Bits

I was handling a bitmap some time ago, and I came into the need to see what was the actual bit representation of the numbers I was using. So I wrote this function:

void print_bits(int number) {
        unsigned long mask = 0b10000000000000000000000000000000 ;
        char digit;

        while(mask) {
                digit = ((mask & number) ? '1' : '0');
                putchar(digit);
                mask >>= 1;
        }
}

This function accepts an integer, and prints on screen it's actual binary representation. Basically it takes a mask whit only the most significant bit set, bitwise ands it with the number and prints either 0 or 1 depending on that bit's value. Then it shifts the mask one position right and iterates, until all the bits are shown.

The 'b' in the mask is a GNU extension, which tells that the number is represented directly in binary. If you are not using gcc, or don't like that series of 0's, simply replace it with the hex counterpart: 0x80000000.

This works both in 32 and 64 bits on Intel x86, as integers there are both 32 bit wide. If you want to deal with a larger number representation, either change the initial mask, or set it to 0x1 and change the shift from >> to <<.

You can use this code to see how numbers are represented. With some minor changes, you can use it to show any representation, be that a float or a more complex struct, for example by dereferencing a pointer.

Saturday, November 5, 2011

Google e i commenti di Facebook

Qualche giorno fa è comparso su tweeter questo messaggio:


ossia: "Il robot di Google diventa sempre più intelligente. È ora in grado di eseguire AJAX/JS per indicizzare alcuni commenti dinamici", dove i commenti dinamici sono proprio quei commentini che compaiono quando si clicca su un pulsante e compare il box senza dover aggiornare la pagina (Facebook oramai è zeppo di AJAX per queste cose...)

Questo significa che Google ora è in grado di restituire nelle sue ricerche il contenuto di uno qualsiasi dei commenti che vengono scritti ogni giorno su Facebook e su qualsiasi altro social network.

È una funzionalità molto avvicente e può avere delle implicazioni utili... Occhio però che se scrivete qualcosa di compromettente (o se avete scritto in passato!!!) in qualche commento, ora sarà tutto ricercabile via Internet!