Monday 15 June 2020

Autolavaggi

Se non ci fosse un'app per gli autolavaggi bisognerebbe proprio inventarla.

Tuesday 9 April 2013

Mysql email validator

This is a pretty simple, yet powerful, regexp to find invalid emails with mysql

SELECT `email`
FROM `users`
WHERE `email`
NOT REGEXP '[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}'
GROUP BY `email`

As seen here: http://stackoverflow.com/questions/2247266/mysql-valid-unique-e-mail

Friday 26 November 2010

How to make grayscale png images with GraphicsMagick

If you have a color PNG image with transparency don't do this:
gm mogrify -type grayscale image.png
as it will lose the alpha channel.


You can get a similar result by just desaturating it:
gm mogrify -modulate 100,0 image.png

Wednesday 30 December 2009

Photo Geotag

One program to write them
http://www.geosetter.de/en/
and one program to read them

Tuesday 13 October 2009

GPS coordinates digit precision

Since Earth equatorial circumference is around 40000 km and longitude spans 360 degrees, it follows that near the equator 1 degrees is equivalent to about 110 km.

Thus:
0 digit precision: ±110 km
1 digit precision: ±11 km
2 digit precision: ±1.1 km
3 digit precision: ±110 m
4 digit precision: ±11 m
5 digit precision: ±1.1 m
6 digit precision: ±11 cm
7 digit precision: ±1.1 cm
However, the closer you move to the Poles, the smaller the lenghts of the parallels becomes.
For example near Rome, which has a latitude of 42 degrees 1 degree is equivalent to cos(90-42)*110= 74 km.

Thus:
0 digit precision: ±74 km
1 digit precision: ±7.4 km
2 digit precision: ±0.74 km
3 digit precision: ±74 m
4 digit precision: ±7.4 m
5 digit precision: ±0.74 m
6 digit precision: ±7.4 cm
7 digit precision: ±0.74 cm

Friday 25 September 2009

iPhone voice dialing improvements

Dear Apple Support, I can think of two ways of doing voice dialing: first one is when I'm in a rush and I don't want to spend time going through my contacts, second one while I am driving and I can use the iPhone only as a hand free device (holding the home button is reasonable, however).

The problem is that in the first case I don't like the iphone playing back the name to call through loudspeakers: I'm holding the iphone next to my ear, so it should use the earspeaker. Otherwise what happen is that if I whisper the name to call, the iPhone will play it back too loud.

In the second case I'm not looking at the iphone, so i'd like to have the whole call through loudspeakers, without having to touch the icon "speakers". My concern is just with voice dialing, if I initiate the call by going through the contacts I don't mind pressing the "spekers" icon.

Did I make myself clear enough? Any response is very well appreciated.

Stefano

Sunday 13 September 2009

Test di Medicina 2009

I test di medicina del 2009 sono stati pubblicati online in modo tale che la risposta corretta fosse sempre la prima.
Ho mischiato le risposte in modo tale da permettere a tutti di provare a rispondere senza barare.

Monday 24 August 2009

How to search text within php files

find . -iname '*.php' -exec grep -l pattern '{}' \;

Wednesday 19 August 2009

New Project

Guess what: I've registered a new domain: www.bagnirimini.com

Sunday 10 February 2008

Bacari in Venice

Using my gps logger and my camera, this time I realized an overview of where me and by friends have been.

Saturday 22 December 2007

OpenStreetMap

Since I own a GPS logger and I've tracked a lot of my car movements, I thought it could have been a good idea to collaborate to a new project I found online. It's called OpenStreetMap.
This is the mapping of Padova before I started working on it.

Thursday 29 November 2007

Latitude / longitude distance in mysql

This is the best function I've found for calculating the distance from two different locations using their latitude / longitude coordinates expressed in degrees. The number of km is returned.

Note that the IF-ENDIF part is not optional, since round-off errors could make tmp bigger than 1 or smaller than -1.

For those values ACOS is not defined and will return a NULL value.

DELIMITER //
DROP FUNCTION IF EXISTS km_from_deg //
CREATE FUNCTION km_from_deg (latA DOUBLE, longA DOUBLE, latB DOUBLE, longB DOUBLE)
RETURNS DOUBLE
BEGIN
DECLARE tmp DOUBLE;
SET tmp =
COS(RADIANS(longA - longB)) * COS(RADIANS(latB))*COS(RADIANS(latA)) +
SIN(RADIANS(latB))*SIN(RADIANS(latA));
IF tmp > 1 THEN set tmp = 1;
ELSEIF tmp < -1 THEN set tmp = -1;
END IF;
return 6372 * ACOS(tmp);
END;
//
DELIMITER ;

Monday 29 October 2007

Diet progress: 74 kg

A bit slower that expected, but I reached 74 kg.
I guess now it will take another month from now to lose another kilogram and reach the target.

Sunday 7 October 2007

Diet progress: still 75 kg

This week I have to admit it, I didn't follow the diet in a strict way.
Too much beer on Wednesday, Friday and last night.

The results are pretty clear, no progress.