Petar Strinic

and all those sorts of things…

I’m my VERY superficial search, I didn’t find an obvious example of zebra striping with/for/in DustJS, so I wrote this little helper that will return “altRow” or nothing, for alternating rows.



May 11th, 2014

Posted In: Misc

Tags: , ,

Leave a Comment

While playing around with a weather widget, the other day, I though to myself why not use HTML5’s geolocation capabilities to show the user the weather for their current location automatically. This turns out to be exceedingly easy, if you’re willing to live with a couple of small assumptions, such as it’s safe to use a regular expression to parse the zip code out of Google Maps API’s formatted_address. Although they do offer a more specific “postal code” field as part of the address object, this is just a little quicker to get to, if you’re willing to assume a format like “, IL 60601”.

In easy steps…

1. Get the user’s latitude and longitude, we can do something like this:

2. Get the address information from Google maps and do the regex hack to get the zip out of the formatted_address.

Shady demo:


April 7th, 2012

Posted In: Misc

Tags: , , ,


I was looking for a quick way to copy and paste an address and get its longitude and latitude, so obviously I looked to Google maps for the answer.
If you have a Google map instantiated you can use it to geocode of an address, with the GClientGeocoder class, but what if you don’t want a map at all?
Of course there is an HTTP API to do it, which seemed a bit more like what I needed.
Here’s a pretty simple class that will make an AJAX request to the Google Geocode API and return the address and longitude and latitude in a standard object, rather than the hierarchical mess that the API itself returns.

As you should have noticed, it uses the jQuery javascript framework. The key piece of information in the class above is dataType: ‘jsonp’ which allows you to get JSON data from another domain, without violating the same domain origin policy.
Below is a simple usage example of the GoogleGeocode class.

Download: GoogleGeocode.js


March 20th, 2009

Posted In: Misc

Tags: , , , ,


Next Page »