Build Geos and Collectstatic

was originally using these buildpacks:

https://github.com/GramercyStudios/heroku-geo-buildpack.git#1.1

https://github.com/heroku/heroku-buildpack-python.git#v40

got this error when i pushed: Collectstatic configuration error. To debug, run …..

when i ran: heroku run …. collectstatic everything was fine!!!

so i had to patch the python buildpack: https://github.com/mattharley/heroku-buildpack-python/commit/807ac1344b01daa8ccc5da0774adeb55fae3b6f5

then i got when i pushed:

—–> Preparing static assets Traceback (most recent call last):

….

django.core.exceptions.ImproperlyConfigured: Could not import user-defined GEOMETRY_BACKEND “geos”.

so i found a newer fork of heroku-geo-buildpack which had two newer commit to fix everything:https://github.com/Tekco/heroku-geo-buildpack/commits/master

Thanks

To this stack overflow post Heroku/Django: Could not import user-defined GEOMETRY_BACKEND “geos”

Backups are as easy as 1-2-3

I like Leo Laporte‘s idea of 1-2-3 backup solutions.

  1. Local Copy – I keep anything local that i need to access quickly. every time i format the hard drive or buy a new computer, i only copy across the bare essentials. everything else, i grab from the external drive when needed.
  2. Cloud Copy – I use Backblaze for unlimited backup including external drives!
  3. Different Hard Drive – I use a simple rsync script, triggered nightly by a cron job, to backup to my external hard drive (which I plug in every night). The rcync script goes something like this:
#!/bin/sh
rsync --progress --recursive -a --exclude="*.Trash*" --exclude="Downloads/*" /Users/matt/ "/Volumes/laptop-2tb/matt-2013/"

Pretty simple hey?

Using Google Maps API

I’ve just started playing with the Google Maps Javascript API for a web version of Hpflsk. So far so good, but there are a few little quirks that have left me a bit baffled. I’ve also thrown in some examples that fit our use case.

 Include the Libraries You Need

Firstly, if you jump directly into the API Reference, wherever you see the word library after the heading in the table of contents, e.g. Places Library, you need to make sure you load that library when you load the API.

https://maps.googleapis.com/maps/api/js?key=XXXXXXX&sensor=false&libraries=places

I spend way too long in the javascript console writing google.maps.pl… and hitting the tab key and couldn’t work out why places was missing!

Geocoding versus Places Search

Geocoding is the process of turning an address – e.g. 123 Fake Street – into a geographic point (latitude/longitude). If you want to search for a location by name – e.g. Lucky Donut Shop – similar to what you can do in the search box on Google Maps, you need to use TextSearchRequest in the Places Library. Here’s how I implemented a text search for places near the user’s current location:

// HTML
...
<div id="map-modal-inner"></div>
...
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=XXXXXXX&sensor=false&libraries=places"></script>

// JS
// Find the venue location by searching on the venue name
// Get client's location using HTML5 navigator.geolocation
var venueLocation;
navigator.geolocation.getCurrentPosition(function(position) {
  var latitude = position.coords.latitude;
  var longitude = position.coords.longitude;
  var myLocation = new google.maps.LatLng(latitude, longitude);
  // Search for places nearby and take the first result
  // First make a temporary map object
  var mapOptions = {
    center: myLocation,
    zoom: 16,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("map-modal-inner"), mapOptions);
 
  // Then search for places matching the venue name
  var places = new google.maps.places.PlacesService(map);
  var placesRequest = {
    query: "Lucky Donut Shop",
    location: myLocation,
    // favour results within 50km of currrent location
    radius: '50000'
  };
  
  places.textSearch(placesRequest, function(results, status) {
    if (status == google.maps.places.PlacesServiceStatus.OK) {
      // for some reason jb = latitude, kb = longitude
      var loc = results[0].geometry.location;
      venueLocation = new google.maps.LatLng(
        results[0].geometry.location.jb, 
        results[0].geometry.location.kb);
    }
  });
});
</script>