This file contains 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
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>,) |
This file contains 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
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] |
This file contains 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
# 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 |
This file contains 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
''' | |
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. |
This file contains 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
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 |
This file contains 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
### Try it out with JSBin | |
(JSBin)[http://jsbin.com/dijefajalo/edit?html,js,console,output] |
This file contains 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 time | |
from memory_profiler import memory_usage | |
import logging | |
celery_logger = logging.getLogger('celery') | |
def track_celery(method): | |
""" |
This file contains 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
/* Useful celery config. | |
app = Celery('tasks', | |
broker='redis://localhost:6379', | |
backend='redis://localhost:6379') | |
app.conf.update( | |
CELERY_TASK_RESULT_EXPIRES=3600, | |
CELERY_QUEUES=( | |
Queue('default', routing_key='tasks.#'), |
This file contains 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
# Keras==1.0.6 | |
from keras.models import Sequential | |
import numpy as np | |
from keras.layers.recurrent import LSTM | |
from keras.layers.core import TimeDistributedDense, Activation | |
from keras.preprocessing.sequence import pad_sequences | |
from keras.layers.embeddings import Embedding | |
from sklearn.cross_validation import train_test_split | |
from keras.layers import Merge | |
from keras.backend import tf |
This file contains 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
# Keras==1.0.6 | |
from keras.models import Sequential | |
import numpy as np | |
from keras.layers.recurrent import LSTM | |
from keras.layers.core import TimeDistributedDense, Activation | |
from keras.preprocessing.sequence import pad_sequences | |
from keras.layers.embeddings import Embedding | |
from sklearn.cross_validation import train_test_split | |
from keras.layers import Merge | |
from keras.backend import tf |
OlderNewer