Solution for warning: Please check that your locale settings

Posted August 8th, 2012 in Bash by davide.bettio

If you get this error:

warning: Please check that your locale settings:
	LANGUAGE = "en_GB:en",
	LC_ALL = (unset),
	LANG = "en_GB"
    are supported and installed on your system.

try by adding this:

LC_ALL="en_GB.utf8"

to:

to /etc/environment

and reboot

MKMapView zoom to markers bounds

Posted October 15th, 2011 in iPhone by davide.bettio
// pad our map by 10% around the farthest annotations
#define MAP_PADDING 1.1
 
// we'll make sure that our minimum vertical span is about a kilometer
// there are ~111km to a degree of latitude. regionThatFits will take care of
// longitude, which is more complicated, anyway.
#define MINIMUM_VISIBLE_LATITUDE 0.01
 
- (void)mapZoom
{
    CLLocationDegrees minLatitude = 90.0;
    CLLocationDegrees maxLatitude = -90.0;
    CLLocationDegrees minLongitude = 180.0;
    CLLocationDegrees maxLongitude = -180.0;
   
    for (MapPoint *p in [self.mapView annotations]) {
        if (p.coordinate.latitude < minLatitude)
            minLatitude = p.coordinate.latitude;
        if (p.coordinate.latitude > maxLatitude)
            maxLatitude = p.coordinate.latitude;
        if (p.coordinate.longitude < minLongitude)
            minLongitude = p.coordinate.longitude;
        if (p.coordinate.longitude > maxLongitude)
            maxLongitude = p.coordinate.longitude;
    }
   
    MKCoordinateRegion region;
    region.center.latitude = (minLatitude + maxLatitude) / 2;
    region.center.longitude = (minLongitude + maxLongitude) / 2;
   
    region.span.latitudeDelta = (maxLatitude - minLatitude) * MAP_PADDING;
   
    region.span.latitudeDelta = (region.span.latitudeDelta < MINIMUM_VISIBLE_LATITUDE) ? MINIMUM_VISIBLE_LATITUDE : region.span.latitudeDelta;
   
    region.span.longitudeDelta = (maxLongitude - minLongitude) * MAP_PADDING;
   
    MKCoordinateRegion scaledRegion = [self.mapView regionThatFits:region];
    [self.mapView setRegion:scaledRegion animated:YES];
}

Favicon in Rails

Posted October 6th, 2011 in Rails by davide.bettio
<%= favicon_link_tag %>

Reference on rubyonrails.org

New GitHub project: DBSignupViewController

Posted July 27th, 2011 in iPhone by davide.bettio

Hi! I started a new project on GitHub

How to uninstall XCode

Posted July 27th, 2011 in XCode by davide.bettio
sudo /Developer/Library/uninstall-devtools –mode=all

Using ssh keys with Capistrano (ex: EC2 images)

Posted July 4th, 2011 in Rails by davide.bettio

add this to your config/deploy.rb

ssh_options[:keys] = [File.join(ENV["HOME"], ".ssh", "key.pem")]

How to install mysql gem on Ubuntu

Posted July 4th, 2011 in Rails by davide.bettio
sudo apt-get install libmysqlclient15-dev
sudo gem install mysql

Beautiful iPhone library

Posted March 15th, 2011 in iPhone by davide.bettio

Tapku Library

How to get the current iPhone language code

Posted March 12th, 2011 in iPhone by davide.bettio
[[NSLocale preferredLanguages] objectAtIndex:0]