All posts by ephestione

Le “subitate” (i contatti più pazzi ricevuti su Subito.it e eBay annunci)

Dopo l’ennesima offerta folle ricevuta per un oggetto in vendita, ho deciso di aprire questo post per riportare tutti i contatti assurdi ricevuti, come venditore, tramite Subito.it ed eBay annunci, i due siti di compravendita gratuiti più usati in Italia.

La più gettonata in assoluto, per qualunque oggetto:

ancora disponibile?

dopodiché nel 95% dei casi non si fanno più vivi (a questo punto penso sia un modo come un altro per fare phishing di indirizzi email)

Segue breve sezione con tutti i messaggi chiaramente di phishing di indirizzi email:

  • è la vostra voce ancora in vendita? quanto vuoi per la vendita? Vorrei conoscere la condizione di questo oggetto ora ..
  • sella salut est ce point encore disponibles à la vente
  • ciao buon giorno sono interessato a questo tuo bene, se è disponibile
  • hallo Verkäufer sind d Versandbereitschaft 4 sale wenn ja freundlicherweise mailen Sie mir jetzt ……
  • Hi is this item still available??? holla back asap Sent From My virgin Mobile®
  • Voglio comprare questo articolo da voi e sono pronto a pagare
  • Ciao,
    Il mio nome è Samuel Ezechiele.
    Il tuo tuo oggetto ancora disponibili per vendita??
    Sono molto interessato ad acquistare immediatamente.
    Mi ha gentilmente risposto nel più breve tempo possibile.
    Grazie.
    Il capitano Richard.
  • ditemi se questa voce è ancora disponibile per la vendita
  • è la vostra voce ancora in vendita e in buone condizioni.
  • ww45149 , Ciao! Sembra un buon affare, posso contattarti?
  • vorrei comparare

Di tutto un po’ (le voci più recenti saranno aggiunte mano a mano in cima a questa lista):

  • si ma nuovi le vendono a 200 accetti 100 euro? (condizionatore proposto a 400€, mai utilizzato ed imballato da qualche anno, e che vendevo al 70% del costo più basso trovato su internet per lo stesso modello)
  • 200 in contrassegno (vedi sopra)
  • facciamo 200 euro e lo passo a prendere anche domaniii (desktop completo a 250€, scritto chiaro e tondo “non mi chiedete sconti”)
  • ciao, il telefono con il problema auricolare è difficilmente vendibile, 40€ mi sembra un po troppo se per te va bene per liberartene posso offrirti 20€ fammi sapere (cellulare Android  a 40€, con l’auricolare interno difettoso, ma perfettamente funzionante con auricolare a filo o bluetooth)
  • 20 euro ritiro ad albano (vedi sopra)
  • Salve, a me potrebbe interessarmi il tubo, sa dirmi forse il prezzo per il trasporto a siracusa??? Grazie (quantità considerevole di tubature da irrigazione, ad un ottimo prezzo, ma assolutamente non spedibili per il volume occupato)
  • salve il prezzo e per tuto ? e puoi spedire ? sempre a mio carico perche abbito a milano si puoi fammi sapere quanto costa spedizione (vedi sopra)
  • 20 euro (telegrafico; era una stufa a gas svenduta a 30€)
  • interessatro acquisto prezzo 50 euro compreso trasporto pagamento postapay saluti (PC a 60€)
  • fa schifo buttala è meglio (sedia a rotelle)
  • Ma si può mettere l’annuncio di una sedia a rotelle ( e che sedia…) nella categoria delle bici? Ignorante!!! (il represso di turno… e non c’erano categorie più appropriate tra cui scegliere, incredibile ma vero)
  • Salve..8 comprese spese? GRAZIE (scheda audio a 10€)
  • ti pago il passaggio di proprietà (vecchia auto funzionante a 200€)
  • ciao mi chiamo Paolo non ho lavoro da offrirti, sono sincero, però ho visto la foto del tuo annuncio e sono rimasto colpito sei davvero molto bella, mi farebbe piacere conoscerti se me lo permetti, ti lascio la mia mail (risposta ad un annuncio per ripetizioni di matematica inserito per conto della mia ragazza)
  • salve con 30 euro + spedizione me lo vende (portatile funzionante da 50€)
  • BUTTALOOOOOOO!!!!! (portatile di cui sopra)
  • 270 euro e vengo a ritirarlo io…di piu nn interessa (pc superaccessoriato a 350€)
  • me ne serve uno….che ci faccio con tre computer ? (3 pc venduti “in blocco”)
  • buona sera se facciamo 15 euro me la vengo a prendere puoi farmi sapere (lavatrice funzionante svenduta a 30€)
  • ciao sono stefano!!15 euro e me lo vengo a prendere (disco esterno 2.5″ da 60GB a 25€)
  • Salve, posso offrire 10€ massimo, capisco che l’offerta sia al di sotto della richiesta ma l’hd è un pò piccolino come capienza (vedi sopra)
  • CIAO SENTI D OVE ABITI
  • senti se tela seti chiamami queste è il mio numero
  • Ciao e BUON ANNO. La macchina è molto vecchia e considerando l’età da un giorno all’altro potrebbe non funzionare più. Ciò premesso al max potrei arrivare a 50 Euro con spedizone in contrassegno. So già che dirai che è una cifra ridicola e piuttosto lo regali o lo butti. Al posto Tuo farei anche io così. Concludo suggerendo che se non lo vendi, NON REGALARLO, piuttosto buttalo, perché sia amici, sia parenti, se qualcosa va storto il meno che Ti può capitare è … bella macchina che mi hai regalato, ho perso tutti i dati che avevo caricato … della serie “CURNUTO e MAZZIATO” … ciao e SCUSA per mio suggerimento Roby (portatile datato ma perfettamente funzionante, a 70€)
  • offro 30 euro. (cellulare con TV da 60€)
  • salve, le mie finanze non mi permettono di spendere più di 40 euro (come sopra)
  • *Conclusioni* Forse è meglio se lo tieni per te. Gli utenti come te purtroppo stanno rovinando il retrocomputing ;-( Buona serata (pc storico IBM… lo voleva regalato per preservare la gloria del retrocomputing?)
  • ti offro 20 euro ok? (scheda madre integrata Atom, venduta a 50€)
  • buona sera,se soni ancora disponibili ,posso offrire non piu’ di € 200,00.grazie. (due poltrone capitonné d’epoca a 500€)
  • senti sono interessato alcquisto di entrambi a 50 euro, non intendo chiederti sconti solo di regalarmi la spedizione (due dischi esterni da 500GB, 70€)
  • Ciao, volevo poporti di vendercelo a 50euro più le sp dato che ho gia’ la maggior parte del corso (corso completo originale Fabbri, 100€)
  • compro tutto prezzo foufee

Android suonerie notifiche sveglia perse o cambiate dopo il reboot

Avete appena aggiunto qualche suoneria personalizzata sul vostro telefono Android, ma dopo ogni riavvio le perdete e sono reimpostate a qualche suoneria diversa, o non suonano affatto? Come se qualcosa le reimpostasse ogni volta, o non venissero salvate correttamente?

Molto probabilmente avete copiato gli MP3 sulla scheda SD, in

  • /ringtones
  • /alarms
  • /notifications

o magari in

  • /media/audio/ringtones
  • /media/audio/alarms
  • /media/audio/notifications

(funzionano tutti allo stesso modo).

Dopo un reboot, potrebbe accadere che per qualche ragione la vostra scheda SD impkiega troppo per essere montata o scansionata, quindi Android non riesce a trovare nulla nelle cartelle specificate, perché non si sono ancora rese disponibili.

Non so se ci sono soluzione per far montare la SD più rapidamente da Android, comunque una soluzione alternativa per aggirare il problema consiste nel copiare direttamente i file nella memoria interna del telefono. Brutta scorciatoia, perché ruba spazio alle applicazioni, comunque funziona.

Quindi, prendete i vostri MP3, e copiateli (usando un file explorer root, come ES File Explorer) nella memoria interna, rispettivamente in

  • /system/media/audio/ringtones
  • /system/media/audio/alarms
  • /system/media/audio/notifications

in questo modo verranno trattati come suonerie di sistema (vedrete le altre suonerie di default in quelle cartelle, ed anzi potete cancellarle siccome sono comunque inutili, per aumenare lo spazio libero).

Android ringtones notifications alarms resetting reverted or lost after reboot

You just added a few ringtones of your own to your android device, but after each reboot you lose them and they are set to something else, or muted altogether? Just like something was resetting them, or they were not saved correctly?

Well, most probably it’s because you copied the MP3’s on your SDcard, under

  • /ringtones
  • /alarms
  • /notifications

or even under

  • /media/audio/ringtones
  • /media/audio/alarms
  • /media/audio/notifications

(they all work as they should).

After a reboot, it may happen that for some reason your sd card takes too long to be mounted/scanned, hence Android cannot actually find anything in the specified folders, because they aven’t become available yet.

I wouldn’t know if there are any solutions to make Android mount your SD any faster, but a pretty workaround consists in copying those files directly in the internal memory. Ugly workaround if you ask me, since you’re taking away precious space for applications, still…

So, just take your desired MP3’s, and drop them in the internal memory (using a root file explorer, like ES file explorer), respectively in

  • /system/media/audio/ringtones
  • /system/media/audio/alarms
  • /system/media/audio/notifications

this way they will be treated just like builtin ringtones (you will actually notice the system ringtones in those folders, which you can delete since they are useless anyway, to save some space), and will be available right after boot.

Why Android sucks at managing battery drain and discharge

So here is my second rant about disliking Android.

I should mention now that I am a happy user of this OS on my HD2 since a while ago, after discovering that CalenGoo is a great substitute for Microsoft’s Pocket Outlook calendar, and that HanDBase in its Android version can be tricked into doing the same things of its Windows Mobile counterpart even if a key feature is missing.

So well, what I’m ranting about today is battery management, or should I say “Battery stats what the hell”?

Just a short anecdote: I went to sleep yesterday at 0:30am, battery percentage reading 58%, I woke up this morning at 8am (in the middle there was a scheduled Titanium Backup of modified data, followed by a reboot, and half an hour of scheduled WiFi with 15′ checks of 6 mailboxes, and obviously mobile network on). When I woke up, battery was at only 14%. Astonished, I deleted the battery stats and rebooted, after that it was reading 2% (!!!). To be noted, battery history, reported by Battery Monitor Widget, tells me that the battery voltage at the moment of getting in the bed was 3.85V, and when I woke up it was 3.79V. Also, the battery current output (which has an exact reading on this HD2, since HTC cares for stuff like this, unlike Samsung), is in a 4-7mA figure all night long, except only when Titanium Backup and mail checks kicked in.

All in all, considering the 2% charge reboot, my phone is telling me, or at least Android is, that it drained 56% of battery in a 7.5hrs period, without doing practically anything. Let’s shave off 10% due to the Titanium Backup and the WiFi checking (I’d say 3-4% is a more realistinc estimate, but oh well), it’s still almost 50% of the battery that disappeared for no reason.

Also to be noted that I put this battery in yesterday morning, it was 98%, and I used it all day long for some calls, a little web browsing in the morning, agenda activity, budget monitoring, and so on. It didn’t drain as much in a 16 hours span, than it did in 7.5hrs of inactivity during the night.
Now, obviously it DID drain more during the day, but Android tells me the other way around. My question is: WHY?

I have 4 batteries, I just swap them out when they are at 10% or so, and put in another charged one. This has led me to up to 4days uptime on Windows Mobile; sure these batteries have aged, but not so much to not even last a couple days with mild usage. Now I understand better what I wrote in this post, calibration does make sense, but only because of a HUGE Android shortcoming (and only if you, unlike me, ever use just one battery). Windows Mobile on this phone never failed reading proper battery, with no “stats” whatsoever.

Now, regarding mV: nominal voltage of a Li-Ion battery is 3.7V, but the charging voltage is 4.2V, so actually a 100% charged LiIon battery has a voltage of 4.2V (or rather 4199mV). That means, for the phone, that the battery was fully charged. As so, the discharged voltage is obviously not 3.7V, but lower than that. What the device (or software?) decides to be 0% is up to the manifacturer, a fact is that most LiIon batteries have a cutoff at 3.0V to prevent damage to the battery, some of them have a cut-off even lower, at 2.5V.

Let’s say it’s not safe to assume that 3000mV is our 0%, let’s say our “0% charge” voltage is 3400mV.

Now, please tell me, WHY is Android reporting 4% battery left (I just briefly attached it to the USB to sync calendar) when the voltage right now is greater than 3700mV? This would mean higher than 50% residual charge, which is just reasonable, since it was 58% before going to bed, and it did no more than 7% worth of stuff during the night, but Android will still insist for it to be 4%. This reminds me of something I read somewhere on XDA, about this user who had two batteries for his phone, a “vanilla” one with normal capacity, and an extended one with almost double capacity. Android would insist reporting 0% on that second extended battery based on the “statistics” of the first battery, thus forcedfully shutting down the device when the residual charge of the extended battery was at least 40%.
This is the stupidest thing I can conceive about a modern operating system.

And yes, I know the battery state of charge cannot be determined by voltage alone, because it is influenced also by temperature and kind of usage until that moment, but surely enough 3700mV is NOT 4% residual charge, it surely enough is more like 50%. We are not talking precise, 1% step-by-step measurement, but wide-range precision measurement. And there is a hell lot of difference between 50% and 4%, it’s called 46%.

The programmer at Google who coded these routines must be a guy affected by a severe form of OCD, and who throws away his gingerbread cookies 6 months before the expiration date, just to be on the safe side (pun intended). But you know, OCD guy, I like my batteries to last all they can instead of having your OS shut down my device a lot sooner than needed.

Which brings us back on track: “battery statistics”: what ARE they? Do they even make sense? How can a discharge cycle affect in any way the subsequent one? Maybe I was bored at work and read some manga keeping the screen on, maybe I was busy like hell and didn’t have time to play with the phone, maybe I was on a trip and out of boredome started watching an episode of Sex And The City after another. So what.
Again, Windows Mobile had no battery stats whatsoever, but never failed to read battery charge properly. Nor any 10-years-old Nokia phone had battery stats, but they still had LiIon batteries.

Yes, I also know what “battery lookup tables” are, and how they are useful in determining battery state of charge more precisely. But it’s clear they are not working at all on Android, and actually are anti-productive for those like me who swap out discharged batteries rather tan charge them inside the phone. I despise you, OCD google guy.

Subito.it e kijiji, il regno dei perditempo

Aggiornamento del 4/4/2019: per caso oggi pensavo che è ormai da tanto che non ricevo più messaggi idioti dai visitatori di subito… cos’è che sarà successo? E’ successo che gli sviluppatori hanno scoperto l’uovo di colombo! Adesso bisogna registrarsi per contattare gli autori degli annunci, quindi tutti quei perditempo che approfittavano del “messaggio facile” adesso sono stati tagliati fuori, e gli altri imperterriti che si registrano appositamente per rompere i cactus al prossimo, molto rapidamente vengono segnalati e quindi segati fuori dal sito. Grazie sviluppatori di subito.it, per esservi aggiornati all’anno 2000! 🙂

Da qualche parte lessi che ai tempi di ARPAnet, quando la posta elettronica era uno degli avveniristici strumenti appena nati, se non rispondevi ad una mail nel giro di poche ore veniva considerata maleducazione.

Adesso che chiunque ha la casella di posta piena di tutto e di più, ed è anche iscritto a tre o quattro social network, non fa niente se per caso rispondi il giorno dopo, anzi.

Ma c’è un’occasione in cui le risposte “in tempi ragionevoli” sono un dovere, e sono le transazioni di compravendita, anche tra privati.

eBay ormai è diventato costosissimo, e le alternative gratuite sono sempre più popolate dai venditori, e di conseguenza anche dai compratori. Anch’io ne approfitto, e mi trovo a mettere in vendita di tutto, dall’elettronica ai mobili alle scarpe comprate, messe due volte e ferme nel ripostiglio.

Ormai sono anni che vendo, e come qualunque venditore so che almeno il 90% della gente che circola è perditempo, ma con la mia esperienza io ormai i perditempo li ho anche classificati.

  1. I ciecati. Vivo in provincia, lontano dal caos cittadino, e lo specifico sempre bene in ogni annuncio. Il ciecato ti chiede “dove ti trovi?” La tua reazione è per l’appunto, “ma sei ciecato?
    A volte vanno oltre, “ok fai mai un salto in città così ci vediamo dalle mie parti e mi porti sotto casa questo oggetto che vendi a 5€?” La tua reazione è un più moderato “ma sei scemo?
  2. Le facce di bronzo. Il prezzo di vendita che stabilisco è il risultato di una rapida indagine di mercato in cui vedo quanto costa il nuovo, a quanto viene venduto l’usato, e quindi metto un valore un po’ inferiore a quello che secondo me è il giusto. In sostanza non faccio come quei deficienti che hanno comprato un PC 5 anni fa, e pretendono di rivenderselo al 70% di quello che hanno pagato allora perché non lo hanno mai usato. Vaglielo a spiegare che il loro PC adesso vale poche decine di euro. Specifico inoltre che “non faccio sconti nel primo mese”. La faccia di bronzo ignora tutto ciò, e ti dice, “se me lo fai alla metà me lo prendo subito“. Sì, grazie al…
  3. I cittadini del mondo. Detesto spedire, perdo tempo a imballare ed a prenotare il corriere. L’acquirente si aspetta di pagare ovviamente solo le spese di spedizione, ma chi mi rimborsa del tempo perso? Per questo specifico che voglio vendere solo a mano, e accetto di spedire solo a spese dell’acquirente. Il cittadino del mondo ti chiede direttamente “Mi fai uno sconto di 10 euro compresa la spedizione?
  4. Gli epistolari, ovvero i Corinzi, ovvero quelli a cui piace scrivere. I più ovvi li riconosci: sono quelli che, anche se nel tuo annuncio ci sono luogo preciso, fotografie dettagliate, specifiche tecniche complete, loro ti scrivono “dove ti trovi? mi mandi qualche foto? mi spieghi questa cosa che è già chiaramente spiegata nell’annuncio ma non mi andava di leggere?” e in quel caso li ignori direttamente. Ce ne sono altri invece, quelli apparentemente educati e considerati, che ti chiedono foto aggiuntive, trattano ragionevolmente sul prezzo, ti fanno prendere misure, ti rispondono rapidamente, che poi, alla fine, una volta che praticamente bisogna solo stabilire giorno e ora perché il luogo è fissato, spariscono nel nulla. E’ legittimo dire “Scusa ci ho ripensato perché…“, ma addirittura scomparire?
  5. I finti offesi. Il finto offeso è uno che ti scrive “Ho letto l’annuncio, mi interesserebbe l’oggetto e l’avrei comprato, ma il modo con cui hai scritto che non vuoi perdere tempo è offensivo, quindi non lo compro“. Oppure ti chiede uno sconto scandaloso, gli rispondi laconico di no (dovrebbe ringraziare solo per il fatto che ti sei degnato di rispondere) e lui “Per me andava bene anche il prezzo originale ma la poca cortesia con la quale mi hai risposto di no mi ha fatto cambiare idea“.
  6. I vandali. Sono quelli che hanno in assoluto più tempo da perdere di tutti. Scelgono un annuncio a caso, un motivo a caso, e insultano il venditore ovviamente inserendo una mail di risposta falsa, quindi se gli rispondi per le rime non arriva da nessuna parte, o magari peggio ancora arriva ad un ignaro innocente.

Se avete “esperienze” interessanti da raccontare, abusate dei commenti!

Cache PHP to gzipped static html pages using htaccess redirect

No matter the server performance, the fastest kind of website for a visitor is the one with static HTML pages; this way the server just has to upload existing data to the browser instead of starting the PHP compiler, open a connection to MySQL, fetch data, format the page and only after that send it. Less CPU, less memory, less processing time, more users served in a smaller amount of time.

Avoiding PHP and MySQL execution altogether is the key, and my project was to create something similar to WPSuperCache to be implemented in a generic PHP website, so my thanks go to said plugin’s developers for the source code that gave me precious tips.

DISCLAIMER: this guide presumes you are “fluent” with PHP and .htaccess coding, and is meant to just give directions as of how to obtain a certain result. This guide will not give a pre-cooked solution to just copy/paste into your website, you need to change/add code to adapt it to your need; I am not the person who can help you if you need a tailored solution, simply because I have no time to give away free personalized help!

Here’s our logical scheme:

  1. Visitor comes to website and asks for page X;
  2. Webserver checks via .htaccess (avoiding PHP execution) if there is a static cached version of page X already, and in this case either serves the gzipped file (if the client supports it), or falls back to the uncompressed HTML version… at which point our scheme ends; otherwise, if no cached version exists, continue to next step;
  3. PHP builds the page and serves it to the visitor as “fresh”, but at the same time saves the HTML output as both gzipped and uncompressed version so the next visitor will directly download that one.

This is a very bare procedure, which needs to be perfected by the following conditions:

  • Not all pages need to be cached (those that by their very nature change very often, like real time statistics, a poll, whatever)… in fact, some pages must NOT be cached (those that only moderators can view, both for secutiry reasons and consistency); PHP must avoid caching those pages, so that htaccess will always serve the “fresh” PHP page.
  • Pages that do get cached still need to be refreshed, because sometimes they can change (articles or posts that are modified/updated with time, or where comments get posted).
  • Some pages, even if the corresponding cached version exists, must NOT be served from cache, for instance when POST data is submitted (sometimes, also with GET, you as the webmaster should know if this is the case), that requires PHP to be handled.

Define “caching behaviour” in PHP

This section is where you set the variables that the PHP caching routine will check against to know when and how to do its job.

$cachepath=$_SERVER["DOCUMENT_ROOT"]."/cache/";
$cachesuffix="-static";
$nocachelist=array(
    "search"=>1,
    "statistics"=>1,
    "secretcodes"=>1,
    "..."=>1,
 );

And explained:

  • $cachepath is the folder where you want the static (HTML and gzip) files to be stored (the website I use this caching routine on, has all the pages accessible from root folder with rewrite URLs, in other words the only slash in the URL is the one after the domain name, and I have no need to reproduce any folder structure; if you do, you’re on your own);
  • $cachesuffix is a string I need to add to the URL string (for example if address is domainname.com/pagename then in this case the cachefile will be named pagename-static), this is useful if you want to cache the homepage which is not named index.php but is just domainname.com/ because in that case, the cachefile name would be empty and .htaccess won’t find it;
  • $nocachelist is an associative array where you have to add as many keys (pointing to a value of 1) as the pages you don’t want (for whatever reason) to cache; in the key name you have to put the string the user would write in the URL bar after the domain name slash to get to the page, for example if you don’t want to cache domainname.com/statistics you would be using “statistics”=>1 in there, as already is.

Have PHP actually save to disk the cached pages

     if (
        !isset($nocachelist[$_GET["page"]]) &&
        !$_SESSION["admin"] &&
        !count($_POST) &&
        !$_SERVER["QUERY_STRING"]
    ) {
        //build the uncompressed cache
        if (!file_exists($cachepath.$url.$cachesuffix.".html")) {
            $cached=str_replace("~creationtime","cached",$html);
            $fp=fopen($cachepath.$url.$cachesuffix.".html","w");
            fwrite($fp,$cached);
            fclose($fp);
        }
        //build the compressed cache
        if (!file_exists($cachepath.$url.$cachesuffix.".html.gz")) {
            $cachedz=str_replace("~creationtime","cached&gzipped",$html);
            $cachedz=gzencode($cachedz,9);
            $cachedzsize=strlen($cachedz);
            $fp=fopen($cachepath.$url.$cachesuffix.".html.gz","w");
            fwrite($fp,$cachedz);
            fclose($fp);
        }
    }

Pretty much self explanatory, isn’t it.
No seriously, do you really want me to elaborate?

Ok, you got it.

  • The $_GET[“page”] is a GET value I set early in the code to know where we are in the website, you can use any variable here as long as you can check it against the $nocachelist array;
  • The other conditions in the first if should be clear, they avoid building the page’s cache if the CMS’s admin is logged (security) or if POST data is submitted or if there is a query string appended to the URL (consistency/stability);
  • $url is a variable that I define early in the code, and contains the string after the domain name slash and before the query string question mark, basically the kind of string you fill the $nocachelist array with (if you were paying attention, you may now think I have a redundant variable since $url and $_GET[“page”] should be the same, but this is not the case for other reasons);
  • $html is the string variable that, across the whole CMS, defines the raw HTML code to echo at the end of the PHP execution; you can either do like I do and define such string, or use an output buffer to obtain HTML if you instead print the HTML directly to screen during PHP execution;
  • ~creationtime is a “hotkey” I use in my template to plug in the time in seconds that was needed to create the page in PHP; since I am creating a cached version now, the creation time of the page is zero, because it’s already there to be downloaded from the browser instead of having to be compiled by the server, so in there I print either “cached&gzipped” for clients that support gzip, or only “cached” when the browser doesn’t not; you can safely strip out this part, as this is more of a eyecandy/nerdy/debug thing.

Let .htaccess send the cached files before starting the PHP compiler

AddEncoding x-gzip .gz
<FilesMatch "\.html\.gz$">
    ForceType text/html
</FilesMatch>

#GZIP CMS
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{REQUEST_URI} !/forum/
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(isadmin|nocache).*$
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond /full/path/to/your/htdocs/cache/$1-static.html.gz -f
RewriteRule ^(.*) /cache/$1-static.html.gz [L,T=text/html]

#UNCOMPRESSED CMS
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{REQUEST_URI} !/forum/
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(isadmin|nocache).*$
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond /full/path/to/your/htdocs/cache/$1-static.html -f
RewriteRule ^(.*) /cache/$1-static.html [L]

This is the code you need to plug in .htaccess, preferably after everything else, but before defining the custom error pages; anyway, since you should be .htaccess-fluent, you shouldn’t need to be told where this fits best.

Some detailing for the curious:

  • First bit is needed (at least I needed it) to serve the gzipped files in a way that the browser knows to handle, otherwise I just got gibberish (the gzip was being sent to output without being uncompressed by the browser first);
  • if the cookies “isadmin” or  “nocache” exist, the cache version of the page will not be served even if it exists; easy explanation, if an admin is logged, and there is special content on a page that only admins can see, you don’t want them to see the “vanilla” cached version of the pages instead; so it’s your duty in this case to set a “isadmin” cookie when an admin logs in, and remove it when the admin logs out;
  • choosing the correct full path on the webserver was a bit tricky in my case, I can’t quite remember where the issue was, but depending on the method I used to get it I had different paths; I kind of remember I had to choose between $_SERVER[“DOCUMENT_ROOT”] and dirname(__FILE__) because only one was working with .htaccess;
  • you don’t really have to change much in this code snippet unless you have particular needs; the /forum/ path exclusion could be irrelevant in your case;
  • thanks go to WPSuperCache developers for their .htaccess code that I stole to build this snippet!

Last but not least

The cache is there to help you, not to give an handicap to your website. You choose what the cache performance should be, and how many times it should get served instead of the dynamic page, before considering it paied off, but you have to clear the cache from time to time to make sure you’re not serving outdated stuff to your visitors.

In my case I use an external cronjob provider (setcronjob.com) to trigger a PHP routine every night which includes the following:

$handle=opendir("cache");
while (($file = readdir($handle))!==false) @unlink("cache/".$file);
closedir($handle);

so that everyday the website starts off with a fresh cache. Not less important, you should clear the cache of a single page as soon as you know that page changed, unless you’re ok with the changes being visibile only the next day after all the cache is cleared anyway. Example: you edit a page while logged as admin, or a user posts a comment, or anything happens that you have control over that alters in any way the page’s HTML: simply use unlink() to delete both the gzipped and uncompressed caches and the website will recreate them with the updated content.

 

Have fun with pimping up this draft!

Why Android sucks for professional use

UPDATE at the end of this post.

I tried many, many times to switch from Windows Mobile to Android, and every and each time I went back to Windows Mobile. Honestly, I would like to upgrade, because my HD2 won’t be enough forever, and no new phone gets shipped with a shiny Windows Mobile 6.5 OS anymore. Funny enough though, Windows Mobile allows me to do a better job.

Lt’s start with the calendar:

  1. Builtin calendar app is pretty much useless, under certain aspects even more useless than the primitive calendar found in old-ass Nokia phones. You cannot either jump to an arbitrary date of your liking, but have to interminably scroll through months, and you cannot search through entries for a name, a number or a place (at this point I might as well get myself a paper agenda, at least that’s got a vintage sexy feel to itself);
  2. Half-hour time separation is out of the question, unless you’re using the paid Pocket Informant, each and every calendar defaults to whole hour appointments and starts appointments at o’clock’s;
  3. Search is, all round, an impossible function, I couldn’t even find it inside Pocket Informant (it relies on the OS builtin search function in Windows Mobile, too); a couple of free apps from the same developer should provide it, either Searchify that hooks onto the builtin search widget, but I couldn’t make it work, or Touch Calendar, which is a viewer only, and sports a -working- search function, that alas won’t get you any results before the few past months, even if you have records of appointments dating back to 2005;
  4. Calendar access is slow, no matter the application, when you load a month you could be counting up to 1 second for the “busy days” to get displayed depending on the application, and we’re talking about a 1GHz CPU with 576MB of RAM (my oh so old Casio Cassiopeia was instaneous on that aspect);
  5. Maybe I’m forgetting something, but the bottomline is that Pocket Oulook had a better calendar on PocketPC 2002 than any app for Android can offer, and that’s a heavy fact, so try and tell me I’m wrong.
  6. UPDATE: I discovered that Android *chooses* in your place to simply discard anything in the calendar which is more than 2 months old; no setting, no option, no nothing to let you choose to keep your frigging data on the phone even if it dates back 10 years. Do I need to say more?

Let’s go on to office suits, and more notably to Excel support:

  1. Google gives NO builtin spreadsheet support, unless you have a data plan, the area you’re in is covered by your carrier, and you’re totally fine with sharing your private data with google apps;
  2. There are several free alternatives to a commercial spreadsheet: some just don’t read XLS unless in the paid version, some will open it read-only, some have no XLS support altogether;
  3. NONE of the spreadsheet applications in the market (I tried them all, free and commercial) has the ability to immediately show the SUM of the values inside a selected column inside the statusbar, like we are used to with desktop applications, and like I’ve been used to since (again) PocketP C2002;
  4. Again, also in this aspect the bottomline is that no spreadsheet app whatsoever keeps up to the Pocket Excel bundled wih PocketPC 2002.

This may be for a small group of users, but no application can do half what can do HanDBase on Windows Mobile, not even HanDBase’s native version for Android, and that’s for certain it will stay forever like this.

But don’t falther readers: if you want to count the meters you travel in a workday, or manage your own virtual cafeteria, or just slingshoot birds with anger management problems against a castle full of mutated legless green pigs with moustaches and helmets, then Android just shines at that, and will do it gloriously while passing all your private information to Google for free.

Windows Phone 7 may be the alternative, too bad you just can’t synch offline, but need to again send your private data to Microsoft’s servers, while there’s a workaround on Android for this.

UPDATE (6 Oct 2011): so here I am, writing while finally using Android as my main platform. I had to go far until I managed to do all I needed, but overall I have a platform I don’t really loathe anymore:

  1. Calendar: CalenGoo manages to do all I need, notably has a good search function and a nifty time-separation default set; having DroidWall block everything except those things that absolutely need an internet connection, I prevented old calendar events to be deleted, and this way I can also avoid my data going to the cloud, while keeping it in synch with MyPhoneExplorer; it’s still a tad slower than PocketOutlook, but I can manage.
  2. DocumentsToGo is decent enough in handling XLS files, even without any “sum on column select” function, but I added a formula somewhere in the sheet.
  3. HanDBase finally returned as good as new when I implemented some additional calculated field in the rows, enabling me to see stats that I couldn’t calculate otherwise.
  4. Stock phonebook is ugly enough, but GO Contacts EX is promising, even if hella slow to start.

Redirect degli utenti mobili e desktop al corretto file CSS tramite .htaccess

La soluzione vincente per un sito compatibile con i dispositivi mobili è avere una singola struttura HTML per qualunque visitatore, e scegliere semplicemente quale foglio di stile far caricare al browser per visualizzare la pagina nel modo migliore; non sto quindi parlando di usare una sottocartella /mobile/ nella struttura del sito, né di parametri nella stringa query come ?mobile, ma mi riferisco all’utilizzare lo stesso medesimo URL per tutti, che visualizzerà ricami e fiocchetti ai browser da desktop, mentre caricherà la versione compatta e rapida per i browser degli smartphone.

Come si fa?

Prima di tutto, scrivete due differenti fogli di stile per i browser desktop e mobili, o piuttosto, come faccio io, preparate un set di CSS, dove c’è un file “common.css” che viene sempre caricato, e poi dei file “desktop.csss” e “mobile.css” che sono caricati quando opportuno. Inoltre, scaricate e installate minify per comprimere i fogli di stile e definire un gruppo “desk” e uno “mobi” da caricare con un semplice URL (la procedura che uso in un altro sito).

Quindi aggiungete nel vostro file .htaccess, abbastanza presto dopo le righe che avviano il RewriteEngine:

RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC]
RewriteCond %{HTTP_user_agent} !^(w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-).* [NC]
RewriteRule ^stylesheets\.css$ /min/index.php?g=cssdesk [L]
RewriteRule ^stylesheets\.css$ /min/index.php?g=cssmobi [L]

Prima cosa, queste righe non considerano l’iPad un dispositivo mobile, perché secondo me ha abbastanza spazio su schermo per visualizzare la normale versione desktop; se la pensate diversamente, basta aggiungere la stringa “ipad” in mezzo alle varie definizioni.

Ed ora qualche spiegazione: prima di tutto i riconoscimenti per le direttive RewriteCond vanno agli sviluppatori di WP Supercache, che è un modello che sto usando per scrivere il mio sistema di caching privato (il prossimo articolo infatti parlerà proprio di questo).

Quelle righe RewriteCond fanno eseguire la direttiva RewriteRule subito successiva solo se il visitatore usa un pc (perché escludono tutti gli user agent associati a dispositivi mobili), per cui la prima RewriteRule che leggete redirige a /min/index.php?g=cssdesk cioè il gruppo dei CSS compresso per i desktop (cambiate questo URL in base alle vostre necessità). La [L] alla fine della riga dice a .htaccess di ignorare qualunque cosa venga dopo. Quando le condizioni delle RewriteCond non sono verificate, e cioè se il browser è un dispositivo mobile, la prima regola RewriteRule è ignorata, e viene usata la successiva, che invece redirige ai fogli di stile mobile.

Come vedete, reindirizzo le richieste che arrivano al file “stylesheets.css”. Sorpresa delle sorprese, questo file non esiste da nessuna parte sul sito, ed è semplicemente un riferimento posto all’interno del template HTML, mentre è .htaccess che si occupa di intercettare queste richieste e fornire i dati corretti. In questo caso, nel vostro codice HTML dovrete richiamare i fogli di stile in questo modo:

<link rel="stylesheet" href="/stylesheets.css" type="text/css" media="screen" />

I vantaggi? Il sistema è più veloce. Una operazione simile fatta da PHP (esiste un codice apposito anche via PHP) vi costerebbe sicuramente l’esecuzione di codice più lento (l’interpretazione delle direttive .htaccess è più rapida della compilazione del PHP) ed eventualmente l’inclusione di un file PHP esterno che a sua volta brucia del tempo. Inoltre questo approccio è indispensabile se volete implementare un sistema di caching che salta del tutto il PHP, perché in quel caso appunto non potreste avvalervi di codice PHP per indirizzare le richieste ai fogli di stile.

Redirect mobile and desktop users to the correct CSS via .htaccess file

The winning solution for a mobile compliant website is to have a single HTML structure for every visitor, and just choose the appropriate CSS to render the page correctly for both worlds; so, I’m not speaking here about a /mobile/ folder under your website root, nor any ?mobile query string, but about the exact same URL, that has all the candy when viewed by a desktop browser, while is super-compact and sleak if the browser is running on a smartphone.

How do you do that?

First, get yourself two stylesheets suited for desktop and mobile, or rather, like I did, prepare a set of CSS files, where there is a “common.css” always used, and a “desktop.css” and “mobile.css” that get loaded when needed. Also, get yourself minify in order to define a “desk” and a “mobi” group of files to load with a simple URL (I use this procedure on another website).

Then add this to your .htaccess file, fairly early after the start of the RewriteEngine:

RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC]
RewriteCond %{HTTP_user_agent} !^(w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-).* [NC]
RewriteRule ^stylesheets\.css$ /min/index.php?g=cssdesk [L]
RewriteRule ^stylesheets\.css$ /min/index.php?g=cssmobi [L]

First of all, these directives do not consider the iPad as a mobile device, since it has plenty of screen space in my opinion to just work as a desktop browser; if you do not agree, just insert an “ipad” string in there together with the rest.

Some explaining is in order: credit for the RewriteCond’s goes to the creators of WP Supercache, which has been a model to write my own caching system on another website of mine (next article is coming about the caching routine itself).

Those RewriteCond lines tie the next RewriteRule directive only to desktop browsers (since they exclude all user agents that can be associated to mobile devices), so the first RewriteRule redirects to the /min/index.php?g=cssdesk minified CSS set tailored for desktops (change it as needed). The [L] directive right after it tells .htaccess to ignore everything else after that. When the RewriteCond’s are not met, it means a mobile device is coming to your site, so the first RewriteRule is ignored, and the one after that is used that redirects to the mobile CSS set instead.

You see that I redirect requests for a file named “stylesheets.css”. Guess what, this file doesn’t exist on my website, and it just references from the template’s HTML: it’s .htaccess that deals with giving the browser the correct data. In this case all you have to do is reference the stylesheets in your HTML code like this:

<link rel="stylesheet" href="/stylesheets.css" type="text/css" media="screen" />

The advantages? This is faster if compared to the same operation done with PHP, since a webserver processes .htaccess directives faster than it compiles PHP code, plus you may be saving an additional include operation on an external PHP file. Also, an approach of this type is absolutely needed if you want to implement a no-PHP-execution caching system, because then there would be no PHP code to use to address browsers to the desktop or mobile CSS, would it.

La simpatica politica degli interessi sul conto corrente FinecoBank

Ho già scritto un post in questo blog riguardante, indirettamente, Fineco, dove comunque chiudevo con un indiretto elogio per la banca.

Oggi invece mi lamento anche della banca, perché ritengo di esser stato preso per i fondelli assieme a tutti gli altri clienti; insomma di essere stato trattato da Fineco come un’altra banca qualunque tratterebbe un suo cliente.

Questa la cronistoria degli interessi sul deposito liquidità di Fineco:

  1. Inagurazione: condizioni vantaggiosissime, tasso pari a quello della Banca Centrale Europea, quindi oscillante sopra il 3%, senza alcun costo se non quello, stabilito per legge, del bollo statale, allora di 25 euro;
  2. Manovra legittima ma giustificata insensatamente “per avere un margine“, come se la banca rischiasse di fallire regalandoci dei soldi (casomai è il contrario), viene applicata una ritenuta sul tasso BCE pari a 0.25 punti percentuali (all’epoca, e se ricordo bene, a fronte di un BCE del 3%, l’interesse creditore era del 2.75%, sempre e comunque il migliore sul panorama italiano); inoltre, sui primi 2000 euro e passa in deposito non vengono calcolati gli interessi pieni, ma ridotti ad una percentuale irrisoria;
  3. Il conto, prima di allora completamente gratuito, inizia a costare nientemeno che 6 euro mensili (72 euro annui, mica pochi! Almeno è possibile abbatterli progressivamente fino ad annullarli eseguendo alcune operazioni nel corso dell’anno); il bollo statale aumentato da 25 a 31 euro non facilita la cosa;
  4. Fineco decide che il tasso BCE non va più bene, e che l’Euribor 1 mese “rispecchia più fedelmente l’andamento del mercato“; guardacaso l’Euribor 1 mese è sempre inferiore al BCE; in questa occasione gli interessi riprendono ad essere calcolati come tali sull’intera liquidità del conto, ma tanto i tassi sono scesi così tanto che praticamente sono uguali all’irrisorio interesse applicato sulle prime migliaia di euro;
  5. Un mese fa giunge ai correntisti una mail che avvisa di un cambio nel metodo di calcolo della trattenuta: non si sottraggono più 0.25 punti percentuali all’Euribor 1 mese, ma lo stesso viene decurtato del 25%, “tanto non vi preoccupate, non cambia nulla, adesso l’Euribor 1 mese è pari all’1%, quindi sia in un modo che nell’altro l’interesse nominale sulla vostra liquidità è sempre dello 0.75%”.

Ad un mese di distanza, come era ovvio succedesse, l’Euribor 1 mese è salito, fino a 1.5 punti percentuali, quindi ora l’interesse creditore non è più 1.25% come sarebbe stato calcolato una volta, ma 1.125%, e la differenza sarebbe ancora maggiore se l’Euribor continuasse a salire, come è auspicabile.

Con questi numeretti si potrebbero fare tanti calcoli, per esempio quanto ci guadagna in più Fineco evitando di corrispondere ai propri correntisti, oggi come oggi, lo 0.125% di interessi, e un domani chissà quanto.

Calcolando il 27% di ritenuta statale sugli interessi inoltre, 1.125% è pari, al netto, allo 0.82%; facciamo un altro calcolo: il costo del conto corrente, oggi, è di 72 euro annui di canone, più 31 di bollo, ovvero 103€ annui per possedere un conto corrente bancario su Fineco; gli interessi percepiti sulle somme depositate sul conto dovrebbero coprire almeno questi costi, altrimenti i nostri soldi, solo stando fermi in banca (banca che investendoli per conto suo ci guadagna fantastiliardi) diminuirebbero col tempo anche senza toccarli; ebbene, con un interesse netto dello 0.82%, per rifarsi di 103 euro in un anno servirebbero in deposito 103€/0.0082, cioè più di 12500€; quanti ce li hanno, al giorno d’oggi, tutti questi soldi da parte? In pratica per la stragrande maggioranza della popolazione, avere un conto bancario significa solo buttare soldi dalla finestra, ed il materasso continua ad essere l’alternativa migliore.

Per quanto mi riguarda, non appena Zopa avrà finalmente ripreso l’attività in Italia, Fineco potrà salutare le mie somme, che andranno ad aiutare gente bisognosa e frutteranno finalmente come dovrebbero.