Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Voyce voycey

View GitHub Profile
@voycey
voycey / geospatialtest.sql
Created Jan 2, 2020
example Geospatial query
View geospatialtest.sql
SELECT count(distinct(id)) from datatable d
LEFT JOIN polygons p ON ST_DWITHIN(ST_MAKEPOINT(d.lon,d.lat), p.geom, 0.1)
WHERE p.place_cat IN ('beauty', 'sports')
@voycey
voycey / pip.c
Created Dec 31, 2019
Point in Polygon CUDA C code
View pip.c
int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
{
int i, j, c = 0;
for (i = 0, j = nvert-1; i < nvert; j = i++) {
if ( ((verty[i]>testy) != (verty[j]>testy)) &&
(testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
c = !c;
}
return c;
}
View join.sql
SELECT m.id, d.name, d.brand, d.wkt from dealerships d
LEFT JOIN movement m ON ST_CONTAINS(d.wkt, ST_POINT(m.lng, m.lat))
WHERE d.brand IN ('AUDI', 'BMW')
View csv2orc.py
%%time
ddf.to_orc('/data/Data Files/Vegas/datafiles/orc/')
View csv2orc.py
%%time
ddf = ddf.repartition(npartitions=3000)
View csv2orc.py
%%time
import dask_cudf as dc
ddf = dc.read_csv('/data/Data Files/Vegas/datafiles/csv/*.csv.gz', compression='gzip')
View routes
$subdomain = substr( env("HTTP_HOST"), 0, strpos(env("HTTP_HOST"), ".") );
Configure::write('captacion', '');
if( strlen($subdomain)>0 && $subdomain != "m" ) {
Router::connect('*',array('controller'=>'private','action'=>'promote'));
// Router::connect('/foo', array('controller'=>'mobiles','action'=>'foo'));
Configure::write('captacion', $subdomain);
}