Skip to content

Instantly share code, notes, and snippets.

Hannes Hapke hanneshapke

Block or report user

Report or block hanneshapke

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View redis.config
packages:
yum:
gcc-c++: []
make: []
sources:
/home/ec2-user: http://download.redis.io/releases/redis-2.8.4.tar.gz
commands:
redis_build:
command: make
cwd: /home/ec2-user/redis-2.8.4
@hanneshapke
hanneshapke / flask_m2m_problem.py
Created Jun 11, 2015
Lightning Talk: SQLAlchemy question for PUB (June 2015)
View flask_m2m_problem.py
'''
This code example is a little gist example of the m2m problem
I am facing with flask and sqlalchemy. The purpose of this short
code sample is to select one or many grocery lists (List) based
on the grocery items (Grocery).
All query examples return either an empty list or all lists which contain
any of the items (OR selection instead of AND)
Below I have listed three approaches I have tried without any luck.
View install_postgis_osx.sh
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@hanneshapke
hanneshapke / query.shell
Created Apr 15, 2013
PostGreSQL/PostGIS query for closest point to giving location > raw SQL Django query
View query.shell
data_point = WindData.objects.raw('SELECT * FROM meteo_winddata ORDER BY location <-> ST_SetSRID(ST_MakePoint(%s, %s),4326) LIMIT 1', [location.x, location.y])[0]
@hanneshapke
hanneshapke / query_comparison.shell
Created Apr 15, 2013
Query comparison between Point and Polygon geometries
View query_comparison.shell
In [1]: data_point = WindData.objects.raw('SELECT * FROM meteo_winddata ORDER BY geom <-> ST_SetSRID(ST_MakePoint(%s, %s),4326) LIMIT 1', [foo.location.x, foo.location.y])[0]
DEBUG (0.282) SELECT * FROM meteo_winddata ORDER BY geom <-> ST_SetSRID(ST_MakePoint( -0.12574, 51.50853),4326) LIMIT 1; args=[-0.12574, 51.50853]
In [2]: data_point = WindDataPolygon.objects.get(geom__intersects = foo.location)
DEBUG (0.003) SELECT "meteo_winddatapolygon"."id", "meteo_winddatapolygon"."lat", "meteo_winddatapolygon"."lng", "meteo_winddatapolygon"."windspeed", "meteo_winddatapolygon"."geom" FROM "meteo_winddatapolygon" WHERE ST_Intersects("meteo_winddatapolygon"."geom", ST_GeomFromEWKB('\x0101000020e6100000f146e6913f18c0bf7784d38217c14940'::bytea)); args=(<django.contrib.gis.db.backends.postgis.adapter.PostGISAdapter object at 0x11080f810>,)
You can’t perform that action at this time.