Author: Sean Gillies Version: 1.0
This document describes a GeoJSON-like protocol for geo-spatial (GIS) vector data.
The first step is to remove older version of PostGIS if any.
sudo apt-get purge postgis
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
import com.vividsolutions.jts.geom._ | |
import com.vividsolutions.jts.geom.impl.PackedCoordinateSequence | |
import com.vividsolutions.jts.geom.util.GeometryTransformer | |
/** | |
* A custom CoordSequence based on byte arrays for compactness and speed | |
* Just 2 dimensions for now. | |
* | |
* It's an example of creating a custom CoordinateSequence. | |
* NOTE: This is much more memory efficient, but slower because of deserialization cost. |
First, install VirtualBox. Then:
brew update
brew upgrade
brew install docker boot2docker
mkdir ~/.boot2docker
curl http://static.dockerfiles.io/boot2docker-v1.1.2-virtualbox-guest-additions-v4.3.12.iso \
> ~/.boot2docker/boot2docker.iso
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
import requests | |
import lxml.html | |
page = requests.get('http://tieba.baidu.com/p/2166231880').text | |
doc = lxml.html.document_fromstring(page) | |
for idx, el in enumerate(doc.cssselect('img.BDE_Image')): | |
with open('%03d.jpg' % idx, 'wb') as f: | |
f.write(requests.get(el.attrib['src']).content) |
from math import log, floor, pow | |
class MinMaxHeap(object): | |
"""an implementation of min-max heap using an array, | |
which starts at 1 (ignores 0th element) | |
""" | |
def __init__(self, array=[]): | |
super(MinMaxHeap, self).__init__() |
from math import log, floor, pow | |
class MinMaxHeap(object): | |
"""an implementation of min-max heap using an array, | |
which starts at 1 (ignores 0th element) | |
""" | |
def __init__(self, array=[]): | |
super(MinMaxHeap, self).__init__() |