Thursday, December 1, 2011

Integrating HTML5 and UPnP

I posted a really good link I found about integrating HTML5 and UPnP:
https://plus.google.com/u/0/112160333465217123290/posts/EKYW1wh8Wwd

Altough it seems still a bit rough this is a good idea.
If interested leave comments here or on my Google+ account.
I'm definitely studying it and I hope it will evolve and be implemented.

Monday, November 7, 2011

Vala compile error: cannot infer generic type argument for type parameter `GLib.Thread.create.T'

Today I tried to work with Vala and threads.
Turned out that documentation, even the official sources, is still sketchy and young.
E.g. I tried to build the following, taken from here:
void* thread_func()
{
    stdout.printf("Thread running.\n");
    return null;
}

int main(string[] args)
{
    if (!Thread.supported())
    {
        stderr.printf("Cannot run without threads.\n");
        return 1;
    }

    try
    {
        Thread.create(thread_func, false);
    }
    catch (ThreadError exc)
    {
        return 1;
    }  

    return 0;
}
It will give up compiling with the following error:
$ valac --thread main.vala
 main.vala:19.9-19.21: error:
 cannot infer generic type argument
  for type parameter `GLib.Thread.create.T'
        Thread.create(thread_func, false);
        ^^^^^^^^^^^^^
 Compilation failed: 1 error(s), 0 warning(s) 
The compiler does complain about an actual lack in my code. Infact the declaration of "Thread.create()" is:
Thread<T> create<T>(ThreadFunc<T> func, bool joinable)
The culprit is the generic type "T" to be passed to the create method.

But the type of what I need to provide?
Thread.create<?>(thread_func, false)
It's the return type of the thread function "thread_func" passed as the first parameter to the create method.
Hence I need to call it this way instead:
Thread.create<void*>(thread_func, false)
In the case thread_func had returned bool:
Thread.create<bool>(thread_func, false)
And so on.

Here's the incomplete documentation for the create method that led me to the initial impasse.
Here is where I found the solution (thanks to Abderrahim Kitouni) instead.
Yeah, a bit of Googling helped me as well.

Tuesday, October 4, 2011

MAC to IP address resolution

Today I couldn't find a way to resolve an host's IP starting from its MAC address, without using RARP (which isn't supported by some kernels ("This kernel does not support RARP"...)).
The solution I came up with is the following: given that two hosts already "know" (i.e. pinged) each other at least once you can perform the command
ping `arp -n | grep -i 00:17:C8:3B:81:94 | grep -o -E "\b[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\b"`

The only issue here is that the two hosts MUST have already "met" at least once.
This is because of the kernel ARP cache used by the "arp" command.

Useful?

Friday, September 30, 2011

Suppress "unused parameter" warnings

Here's a way to suppress the annoying "unused parameter" warning given by the following code:
void aFunction(int unusedParameter)
{
    // Do something but ignore the 'unusedParameter'
}

I use this define:
#define CHECKED_UNUSED(x) (void)x

And then I surround unused parameter with it, right after the opening bracket of the function (so I can easy find and modify the parameter if I start using it):
#define CHECKED_UNUSED(x) (void)x

void aFunction(int unusedParameter)
{
    CHECKED_UNUSED(unusedParameter);
}


I looked at the generated assembly before and after and it didn't change:
                  aFunction(int):
00000000004007d4:   push %rbp
00000000004007d5:   mov %rsp,%rbp
00000000004007d8:   mov %edi,-0x4(%rbp)
15                }
00000000004007db:   pop %rbp
00000000004007dc:   retq
18                {


Disclaimer: use it only after you carefully checked that you really not need to use that parameter.
Unused parameters (and all the warnings in general) could really lead to a bug (or simple misunderstandings) in your code.

Sunday, September 11, 2011

Gnome3 e GnomeShell. I miei due centesimi.

Uso Gnome3 e la Shell da quando è uscito dalla fase di testing in Arch Linux. Effettivamente l'inizio è stato un pò ostico perchè molte cose sono cambiate, ma successivamente ho apprezzato il design tutto sommato lineare e pulito: sembra fatto bene e, soprattutto, pensato bene.

Ok, la status-bar è stata pensata male e realizzata peggio, ma tutto il resto se la cava piuttosto bene, tranne che per l'aspetto "configurazione".

Su quel versante Gnome3 mostra molto il fianco; in particolare è davvero troppo poco configurabile (sembra un prodotto Apple) e le extensions sono ancora troppo poco diffuse e, spesso, realizzate male.
Ma ciò che mi spaventa di più è che la configurazione del sistema sembra essere stata realizzata in modo così spartano e semplice di proposito. Se così fosse allora Gnome avrebbe perso un'occasione di quelle d'oro. Diciamo solo che hanno tempo di recuperare e spero sinceramente che lo facciano. Per loro.

Vogliamo parlare poi di stabilità? Stabilissimo e anche molto reattivo. Anche qua traspare l'impressione di buona realizzazione e buon design iniziale e, come bonus, i crash e i difetti sono lontani da un ambiente pulito e funzionante giusto un "ALT+F2 r".


In definitiva sono molto soddisfatto e propenso a credere che successivi rilasci portino ulteriori miglioramenti anche sotto questo aspetto.

Vorrei infine porre l'accento ancora una volta sulle extensions, stavolta con una nota molto positiva: sono realizzabili in Javascript... cosa mai avrei potuto desiderare di più (se non un'Aston Martin la mattina di Natale).

Friday, September 2, 2011

Bug after updating to ruby 1.9.2 on Arch Linux

If you ever encountered the following error in your ArchLinux box:
$ gem install <your_gem_name_here>
/usr/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:62:in `installed_spec_directories':
  undefined method `path' for Gem:Module (NoMethodError)
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:52:in `from_installed_gems'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems.rb:914:in `source_index'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/gem_path_searcher.rb:83:in `init_gemspecs'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/gem_path_searcher.rb:13:in `initialize'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems.rb:873:in `new'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems.rb:873:in `searcher'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems.rb:495:in `find_files'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems.rb:1034:in `load_plugins'
from /usr/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:84:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/bin/gem:9:in `<main>'
You can use these commands to solve the issue:
$ sudo pacman -U /var/cache/pacman/pkg/ruby-1.9.1_p429-1-x86_64.pkg.tar.xz
[or equivalent 1.9.1 version]
$ sudo gem update --system
$ sudo pacman -S ruby

[to return to the new ruby (1.9.2 in my case)]

Thursday, August 4, 2011

Cronaca nera

Oggigiorno in Italia molti giornalisti non si lamentano (anzi!) di esser proni al potere. Va bene così un po a tutti.

Per tanti scrivono anche troppo. Suvvia, qualche bella foto dalle spiagge dei VIP! Che l'estate è calda e non mi va di sudare freddo per qualche brutto editoriale che predica austerità.
L'aria condizionata è mia e ci faccio quello che voglio io!
Molta gente poi li vorrebbe placidi racconta-favole, che non venga disturbata l'immagine del Paese con ritratti poco lusinghieri dei suoi massimi (!) esponenti, dei suoi apparati e dei vari famosi da copertina.

I potenti? Loro in fondo chiedono poco: un giornalista dovrebbe essere solo la grancassa della loro opulenza.
Poche parole di elogio quanto basta, diciamo una pagina di sperticate lodi al giorno (e poesie per i dotati del raro dono della rima baciata).
D'altronde che li paghiamo a fare questi benedetti concentrati di fogli se poi non li si riempie di buone notizie e di faccioni truccati e sorridenti?

Loro, i giornalisti? Beh, molti di se pensano di fare un gran bel lavoro. I miei articoli/editoriali/tweets vengono elogiati pubblicamente a più riprese.
Elogiato ergo sum.
Alcuni altri, musoni, non dicono niente: per loro è pur sempre un bel lavoro. Ma meno semplice di quanto lo dipingano quelli di prima. Certa gente proprio non si sa divertire...

Io? Guardate, non saprei proprio che dire. Io sono un po musone, ma non faccio il giornalista. Mi basterebbe che lo facesse chi lo deve fare. E bene. Che facesse il suo lavoro insomma.
Che andasse anche un po meno in televisione, magari.
Che scrivesse; giornale o web per molti ha poca importanza.
Ma, come dicevo, sono un musone. Sicuramente mi sbaglio.


E poi, detto fra noi, di che mi lamento? Alla fine della fiera, qui in Italia è da un pezzo che, in generale, siamo in pochi a fare il nostro lavoro.
Perchè dovrei iniziare proprio io o qualche altro povero Cristo?


Buona giornata gente, finchè dura.

Tuesday, July 12, 2011

Google Analytics PDF Reports

This is how a Google Analytics report looks like. This one is from this very blog and gets sent to me via mail as a PDF.
Powerful enough, easy to use and with tons of customizations possible, it is so far the best analytics tool I've seen. Well, it's free too.

Monday, May 30, 2011

Achtung Baby. UDEV is changing.

Seen today when upgrading to UDEV 171:
ATTENTION UDEV:
---------------
Kernel 2.6.32 or newer is now required.
OSS emulation modules are not loaded by default, add to rc.conf if needed.
Arch specific cd symlinks are now no longer created.
cd and net persistent rules will no longer be autogenerated,
see <https://wiki.archlinux.org/index.php/Udev> for details.
Errors are now logged (possibly to the console) by default.

Given that I'm developing a system based on UDEV...
Arch Linux is an amazing distribution to develop with!

Tuesday, March 15, 2011

La coscienza nucleare

Mi sono rotto le palle perchè è da sempre che lo dico: mi da fastidio chi dice "niente centrale nucleare in Sardegna".
Non ci deve essere nessuna centrale in Italia, non solo qui da noi!

Quand'è che siamo diventati così meschini ed egoisti?
È proprio vero che l'Italia non è ancora unita se non riusciamo ad unirci nemmeno su queste fondamentali questioni.

Neanche quello che sta accadendo in Giappone riuscirà a svegliare le coscienze di noi italiani?
E dobbiamo sempre aspettare che accada qualche disastro per svegliarci?

Senza contare che stiamo a discutere di questo quando invece dovremmo inviare tecnici e protezione civile in Giappone... io personalmente sono davvero stanco di quanto sia diventata meschina questa umanità.

Friday, February 18, 2011

Shout it loud

"Il compenso di Benigni per la partecipazione a Sanremo (250.000 Euro) è stato interamente devoluto all'ospedale Meyer di Firenze."

QUI

Thursday, February 3, 2011

[SOLVED] Kernel 2.6.37 : No temperature info for CPU

After the update to kernel 2.6.37 on my Arch-powered notebook I found my AWN temperature applet was showing GPU data only and no sensors could be detected for the CPU.

I solved by installing lm_sensors and modprobe-ing coretemp module.

Just in case someone is stuck on it, too.

Monday, January 31, 2011

Stamani pensavo ai concorsi a premi del Belpaese

L'homo italicus medio non cessa un solo attimo di lamentarsi delle tasse.
È diventato così bravo che riesce a elencarti tutte quelle che paga (o che riesce ad evadere) per filo e per segno, come uno scolaro diligente fa con la tabellina del 10.

Dimentica però quasi sempre di citare le tasse "volontarie"; vale a dire superenalotto, "win4life", scommesse sportive, poker online, "Gratta e Vinci" e via discorrendo; che si potrebbe continuare per un bel pò con un lungo e triste elenco di cose che, tra l'altro, hanno anche dei nomi che fanno (quasi) ridere.

E poi ce la prendiamo con Berlusconi e le sue Puttane: siamo noi quelle puttane.

(E detto tra noi, per ironia della sorte paghiamo pure, per esserlo)

My Desktop as of 31-01-2011



Snapshot of my desktop.
Powered by Arch Linux, Gnome, AWN and Elegant-Awoken icon-set.
At this moment I don't have time to write a post longer than this...