Feeling Black
Monday, January 27, 2014
WTF-of-the-day: jQuery + iOS + click event
According to this discussion jQuery won't detect click events on iOS until a "pointer" cursor is applied to the clickable elements via CSS.
Saturday, January 4, 2014
CSS cursor property "not working"
If the CSS cursor property isn't working it might be not your fault.
Check instead whether you have opened your browser's developer tools, because when viewing the page with them switched on the cursor shown is always the default one.
This little issue had me scratch my head for some minutes with Chrome.
Check instead whether you have opened your browser's developer tools, because when viewing the page with them switched on the cursor shown is always the default one.
This little issue had me scratch my head for some minutes with Chrome.
Monday, December 30, 2013
Da piccoli c'era la giornata degli alberi
La Sardegna, la mia e la tua terra, è la regione più inquinata d'Italia.
Non è più tempo di tentennare e dire l'ennesimo "non è colpa mia".
È colpa prima di tutto di noi Sardi che non abbiamo vigilato (o che, peggio, siamo stati spesso conniventi) e solo dopo è colpa di chi ci ha avvelenato con i suoi rifiuti, le sue scorie, il suo cemento, il suo amianto.
Ecco perchè tocca a noi iniziare il cambiamento. E dobbiamo iniziare da noi stessi, dal nostro popolo.
Solo dopo aver cambiato noi stessi potremo chiedere conto a chi ha approfittato della nostra incapacità di vigilare. E state tranquilli: sarà un conto salato.
Ma prima di questo, molto prima della giustizia delle aule di tribunale e delle Istituzioni, prima è necessario ristabilire la cultura dell'Ambiente e della sua salvaguardia, partendo fin dalle scuole per arrivare fino alle associazioni e passando, ovviamente, per la politica.
È necessario impartire a noi stessi, quotidianamente, la lezione del vero Ambientalismo, vale a dire quello delle piccole cose che noi tutti possiamo fare, ogni giorno. Quello che sfrutta i piccoli contributi di tutti per arrivare al risultato più grande.
È per questo necessario per ciascuno di noi imparare cosa sia il rispetto verso l'Ambiente e la Natura, in tutte le loro incarnazioni.
È necessario investire nelle economie Green: quelle vere, non quelle della speculazione e dell'opportunismo dei grandi interessi che tutto sono salvo che interessi dei Sardi e della Sardegna.
È necessario vigilare e insegnarci l'un l'altro quello che sappiamo: come si fa la raccolta differenziata, cosa fare con i propri rifiuti quando si è al mare, in montagna, nella propria tanca, Come comportarsi quando si ha in mano una sigaretta, una busta di plastica vuota, una lattina, l'olio esausto della propria automobile, persino come si cura un giardino.
È necessario diventare delle persone migliori per poterci meritare delle Istituzioni migliori, una terra migliore, un turismo migliore, un'economia migliore.
È necessario impegnarsi e fare impegnare gli altri.
Quando ci guarderemo indietro, quando avremo fatto questi piccoli passi e terminato questo grande viaggio sarà tutto diverso. E migliore. Noi Sardi per primi e la nostra Sardegna insieme a noi.
Thursday, October 17, 2013
Pulsarjs
Here's my new pet project: Pulsarjs.
I realized it to solve a simple problem: scheduling recurrent javascript functions can already be achieved with "setTimeout()/setInterval()" but this way the code becomes a mess very quickly.
Functions and the timers that schedule them get tossed around your code-base and self-imposed conventions aren't too much of an help.
Pulsarjs is a centralized organizer for your functions that stores them across restarts of your app, thanks to nedb.
I'm done implementing the main features of the module and some "getting-started" documentation. Next steps are intensive testing and more docs.
Pulsarjs is already listed as an NPM package.
I realized it to solve a simple problem: scheduling recurrent javascript functions can already be achieved with "setTimeout()/setInterval()" but this way the code becomes a mess very quickly.
Functions and the timers that schedule them get tossed around your code-base and self-imposed conventions aren't too much of an help.
Pulsarjs is a centralized organizer for your functions that stores them across restarts of your app, thanks to nedb.
I'm done implementing the main features of the module and some "getting-started" documentation. Next steps are intensive testing and more docs.
Pulsarjs is already listed as an NPM package.
Wednesday, July 17, 2013
Bagarino: what is it good for?
Have I ever told you about bagarino, a ticketing system I created?
Last time I wrote some code for it I added multi-CPU support to its existing nodejs-, expressjs-powered core.
It uses Redis as its backend store and sports some simple Javascript code I wrote during a few sleepless nights.
But, "what is it good for?"
Well, let's pretend you want to grant, secure and govern access to a certain content one of your users rented/bought/subscribed-to/won on your system (e.g. a game item, or a picture, an illustration, a book or even an entire movie hosted on a CDN).
You may need to establish how many times (or how long) that good can be accessed by that user.
You may also need to enforce these rules in a simple, predictable manner.
Unique, alphanumerical, tickets that "mark" your content come to the rescue.
And bagarino allows you to manage them using different policies that establish when exactly a ticket expires.
Some of these policies are as simple as time-based counters. Some of them are a bit more complicated (but not too much, don't worry).
Give it a try and let me know.
... By the way, after "what is it good for?" I hope you didn't jump right to the "absolutely nothing" line ;-)
Photo courtesy of Sam Howzit
Last time I wrote some code for it I added multi-CPU support to its existing nodejs-, expressjs-powered core.
It uses Redis as its backend store and sports some simple Javascript code I wrote during a few sleepless nights.
But, "what is it good for?"
Well, let's pretend you want to grant, secure and govern access to a certain content one of your users rented/bought/subscribed-to/won on your system (e.g. a game item, or a picture, an illustration, a book or even an entire movie hosted on a CDN).
You may need to establish how many times (or how long) that good can be accessed by that user.
You may also need to enforce these rules in a simple, predictable manner.
Unique, alphanumerical, tickets that "mark" your content come to the rescue.
And bagarino allows you to manage them using different policies that establish when exactly a ticket expires.
Some of these policies are as simple as time-based counters. Some of them are a bit more complicated (but not too much, don't worry).
Give it a try and let me know.
... By the way, after "what is it good for?" I hope you didn't jump right to the "absolutely nothing" line ;-)
Photo courtesy of Sam Howzit
Saturday, April 20, 2013
RIP. Di sicuro.
Con Bersani si chiude l'era delle buone intenzioni condite da nessuna azione. A volte persino da azioni stupidamente e volutamente cattive ed autolesioniste.
Di sicuro si chiude un ciclo disastroso per il PD, un partito ormai in cenere.
Un partito che avrebbe dovuto "salvare" l'Italia e che invece ha contribuito in maniera preponderante all'immobilità che ci sta oggi condannando.
Di sicuro per il PD non c'è un futuro in Renzi, nè nell'attuale dirigenza.
Di sicuro l'unico partito italiano che non aveva intenti palesemente truffaldini (ma che in compenso aveva cento altri difetti) è da reinventare totalmente, da zero.
Di sicuro chi oggi sorride felice delle disavventure del PD non ha ben capito che, insieme al PD, ieri è stata anche la Democrazia italiana a subire l'ennesimo, disastroso colpo.
Chi oggi ride felice delle disavventure di Bersani e di Prodi è peggio di quel furbacchione di Renzi che ieri avrà pure guadagnato un partito, ma di sicuro ha perso un altro pezzo di Paese.
Chi oggi ride felice neppure immagina che ha contribuito ad arrecare altri terribili danni al Paese.
Nel bene, ma soprattutto nel male, il PD si è dimostrato uno specchio impietoso e quantomai accurato dei peggiori mali e difetti dell'Italia tutta.
RIP PD. RIP Italia.
Di sicuro si chiude un ciclo disastroso per il PD, un partito ormai in cenere.
Un partito che avrebbe dovuto "salvare" l'Italia e che invece ha contribuito in maniera preponderante all'immobilità che ci sta oggi condannando.
Di sicuro per il PD non c'è un futuro in Renzi, nè nell'attuale dirigenza.
Di sicuro l'unico partito italiano che non aveva intenti palesemente truffaldini (ma che in compenso aveva cento altri difetti) è da reinventare totalmente, da zero.
Di sicuro chi oggi sorride felice delle disavventure del PD non ha ben capito che, insieme al PD, ieri è stata anche la Democrazia italiana a subire l'ennesimo, disastroso colpo.
Chi oggi ride felice delle disavventure di Bersani e di Prodi è peggio di quel furbacchione di Renzi che ieri avrà pure guadagnato un partito, ma di sicuro ha perso un altro pezzo di Paese.
Chi oggi ride felice neppure immagina che ha contribuito ad arrecare altri terribili danni al Paese.
Nel bene, ma soprattutto nel male, il PD si è dimostrato uno specchio impietoso e quantomai accurato dei peggiori mali e difetti dell'Italia tutta.
RIP PD. RIP Italia.
Wednesday, February 13, 2013
Dreams of the perfect habitat
The product I've always dreamed on realizing came true thanks to Inkling Habitat.
And you still don't know the best part: they are also making it public!
And you still don't know the best part: they are also making it public!
Habitat is a digital publishing platform based on standards and hosted on the cloud.
Starting Tuesday (today n.d.r) they are releasing it for public access.
They are proposing legacy contents import, the possibility of a full Google indexing of the books created with their platform, the ability to export as EPUB and a bunch of big names of the industry as their partners (O'Reilly, Pearson, Time Inc. and Lonely Planet, just to name a few).
I'm both sad and happy about it: sad because I was starting to design a similar solution; happy because now I know I took the right path in designing it. It's the path of open-standards and the path of the better web.
It's like Inkling is really creating a completely new habitat for digital publishing, by simply using the foundations of the World Wide Web (HTML and its complimentary technologies) and finally detaching the digital publishing from the old, paper-based, publishing industry (that's still only able to mimic the paper magazines on an electronic device and propose them as "the future").
Well, Inkling, with Habitat, built that digital publishing of the future and they did it powerful, standards-based, open and beautiful.
They didn't kill paper. They simply extended it until it reached the web and the mobile world.
Wednesday, December 5, 2012
Ignore single-tap before double-tap on Windows 8 apps
The new development platform for Windows 8 has been released too early. The number of dirty tricks I had to resort to in just a few months working with it made it pretty clear to me.
One of the most infamous bugs I found affects all the versions of the platform (x86, x64 and ARM) and it's an erroneous sequence of events that is propagated after a double-tap. I found it propagating from a ScrollViewer control, but I'm pretty sure other controls may behave this way as well.
When a user double-tapped on the screen I was expecting a single call to my double-tap event handler to be made, but with a bit of sadness a single-tap event was called immediately before it... with no fucking reason, if you ask me.
My code needs to be certain about which one of the two is called, because I need to react in two different, alternative ways to them. So I was stuck, trying to find a clever way to figure out when a single tap erroneously fired by the framework. And obviously when it's not.
With the help of my collegues we found a really simplicistic way of dealing with it, but it's actually a trick that mitigates the issue, not a definitive cure.
Here it is:
// Here's the part I hate the most: heuristics...
private const int DOUBLETAP_DELAY_MILLIS = 190;
private DateTime singleTapTime;
private bool singleTapCancelled;
private async void scrollViewer_Tapped(object sender,
TappedRoutedEventArgs args)
{
// Save the moment the single tap
// has been detected...
this.singleTapTime = DateTime.Now;
// ... but wait some time to be sure
// that no double-tap event follows
await Task.Delay(Viewer.DOUBLETAP_DELAY_MILLIS + 10);
// A double-tap event will cancel our single- one
// before we reach this point...
if (!this.singleTapCancelled)
{
// ...
}
this.singleTapCancelled = false;
}
private void scrollViewer_DoubleTapped(object sender,
DoubleTappedRoutedEventArgs args)
{
TimeSpan tapsDelay =
DateTime.Now - this.singleTapTime;
// If we are between the configured timespan,
// we cancel the previously fired single-tap event
this.singleTapCancelled = (tapsDelay <= TimeSpan.FromMilliseconds(Viewer.DOUBLETAP_DELAY_MILLIS));
// ...
}
An improvement would be protecting the boolean variable with a lock.
Also would be better to be tolerant on the number of milliseconds we wait. E.g. we could wait Viewer.DOUBLETAP_DELAY_MILLIS +/- some time.
But the only improvement should be done by Microsoft I guess...
Thursday, November 15, 2012
Dead On Arrival
Riassumendo cosa ne penso, vorrei mettere una pietra tombale sui miei commenti alle recenti vicende del Movimento 5 Stelle e del suo lider maximo.
Procedo.
Il Movimento 5 Stelle mi è sempre stato più che simpatico ma ultimamente lo vedo purtroppo ostaggio di un vecchietto con le solite manie di potere e dei suoi scaltri amici.
Mi spiace per tutte quelle persone che ci hanno creduto (e continuano a crederci), che gli hanno dato l'anima e il proprio impegno, che lo hanno sostenuto, accolto o anche solo ascoltato (oggigiorno non è poco).
Ma la sostanza è che Grillo sta rovinando una speranza di rinnovamento (il M5S) come ce n'erano state veramente poche finora.
Ideali splendidi e pessima sostanza dietro. Connubio forse nato sano, ma arrivato già morto al pronto soccorso della "Democrazia dal basso".
[Photo courtesy of Wikimedia http://en.wikipedia.org/wiki/File:Dissent_develops_democracy_sticker.jpg [Which in turn credits Jason Wilson http://www.flickr.com/people/hive/ ]]
Thursday, August 9, 2012
A tale of two twins
"Once upon a time an unfortunate poor design decision in Windows Metro class library had two brave classes named the same: "Uri".
One of them lived in the village of "System" while the other had a gracious hut in the "Windows.Foundation" hood."
Wait! What?!?
Does it mean that there are two different classes both named "Uri" classes in two basic namespaces?
Do I look like one old mage that goes around mumbling some non-sense fairy-tale? No; hence this is exactly what I meant: two classes, same name, same job, two different basic namespaces, both have an one-argument constructor with the same parameter type (string).
No need to say that you'll eventually end up using System.Uri instead of Windows.Foundation.Uri or viceversa (like I did).
And you can trust this old man when I say that you will ("Metro-style .NET application"... does it ring any bell?).
Now, this wouldn't be such a big issue and I will be no putting such a scene up since they are in two different namespaces.
After all namespaces are supposed to be born in this era to support exactly this behavior.
At least to support classes named the same way but that perform different tasks.
But that's not the case: the do exactly the same things.
Well, the story has a happy ending, you know: you end up on this post, know that the world is full of tricky tricks in the shape of class named the same and you return to your code sound and safe.
But I'd like to add an epilogue.
Please, dear Microsoft architect, consider the following two options:
One of them lived in the village of "System" while the other had a gracious hut in the "Windows.Foundation" hood."
Wait! What?!?
Does it mean that there are two different classes both named "Uri" classes in two basic namespaces?
Do I look like one old mage that goes around mumbling some non-sense fairy-tale? No; hence this is exactly what I meant: two classes, same name, same job, two different basic namespaces, both have an one-argument constructor with the same parameter type (string).
No need to say that you'll eventually end up using System.Uri instead of Windows.Foundation.Uri or viceversa (like I did).
And you can trust this old man when I say that you will ("Metro-style .NET application"... does it ring any bell?).
Now, this wouldn't be such a big issue and I will be no putting such a scene up since they are in two different namespaces.
After all namespaces are supposed to be born in this era to support exactly this behavior.
At least to support classes named the same way but that perform different tasks.
But that's not the case: the do exactly the same things.
Well, the story has a happy ending, you know: you end up on this post, know that the world is full of tricky tricks in the shape of class named the same and you return to your code sound and safe.
But I'd like to add an epilogue.
Please, dear Microsoft architect, consider the following two options:
- Either provide ONLY ONE class to perform the same job
- Or provide ONLY ONE class to perform the very same job
Choose one.
The End
Subscribe to:
Posts (Atom)