This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import os | |
import requests | |
def get_prj_wkt(srid): | |
url = 'http://epsg.io/%s.wkt' % srid | |
r = requests.get(url) | |
r.raise_for_status() | |
return r.text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with | |
numbers as | |
(select 10 as _top, 50 as num_of_subscriptions, 28404 as unique_subscribers, 290 as number_of_lists), | |
people as | |
(select st_point(random() * 99 + 1, random() * 99 + 1) as g, 'special subscribers'::text as ty | |
from numbers n, generate_series(1,n._top)), | |
unique_people as | |
(select st_point(random() * 99 + 1, random() * 99 + 1) as g, 'unique subscribers'::text as ty | |
from numbers n, generate_series(1,n.unique_subscribers-n._top)), | |
subs as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, timedelta | |
def group_by_months(since, until): | |
"""Group a datetime range into month-based ranges with breaks at midnight. | |
>>> a = datetime(2015,11,5,3,12,5) | |
>>> b = datetime(2016,3,7,4,32,10) | |
>>> for i, (since, until) in enumerate(group_by_months(a, b)): | |
... print i, | |
... print since.strftime('%Y.%m.%d %H:%M:%S'), |
NewerOlder