Skip to content

Instantly share code, notes, and snippets.

View jmwenda's full-sized avatar

Jude Mwenda jmwenda

View GitHub Profile
@jmwenda
jmwenda / index.html
Last active September 1, 2016 04:42
<!DOCTYPE html>
<html>
<head>
<title>Named Maps Tutorial | CartoDB</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<style>
html, body, #map {
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<style>html, body, #map { height: 100%; padding: 0; margin: 0 }</style>
</head>
<body>
<div id="map"></div>
<!-- include cartodb css -->
var markersLayerSource = {
user_name: 'nation',
type: 'cartodb',
sublayers: [{
sql: "WITH hgridA AS (SELECT CDB_HexagonGrid(ST_Expand(!bbox!, greatest(!pixel_width!,!pixel_height!) * 48), greatest(!pixel_width!,!pixel_height!) * 48) as cell), bigs AS (SELECT * FROM (SELECT ST_Centroid(ST_Collect(i.the_geom_webmercator)) as the_geom_webmercator, count(i.cartodb_id) as points_count, 1 as cartodb_id, array_agg(cartodb_id) AS id_list FROM hgridA, (select * from reports WHERE published = true) i where ST_Intersects(i.the_geom_webmercator, hgridA.cell) GROUP BY hgridA.cell) t WHERE points_count > 100 ), hgridB AS (SELECT CDB_HexagonGrid(ST_Expand(!bbox!, greatest(!pixel_width!,!pixel_height!) * 36), greatest(!pixel_width!,!pixel_height!) * 36) as cell), mids AS (SELECT * FROM (SELECT ST_Centroid(ST_Collect(i.the_geom_webmercator)) as the_geom_webmercator, count(i.cartodb_id) as points_count, 1 as cartodb_id, array_a
box[box.find("(")+1:box.find(")")]
>>> box = 'BOX(-71.1608660012332 42.3537910000038,-71.1237350012334 42.3727380000039)'
>>> print box
BOX(-71.1608660012332 42.3537910000038,-71.1237350012334 42.3727380000039)
>>> print box[s.find("(")+1:box.find(")")]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 's' is not defined
>>> print box[box.find("(")+1:box.find(")")]
MULTIPOLYGON(((-71.1281240012333 42.3573690000038,-71.1280270012331 42.3572610000039,-71.1295170012331 42.3567230000039,-71.1302330012332 42.3564780000039,-71.1307380012331 42.3563600000039,-71.1312760012332 42.3561580000039,-71.1313960012331 42.3561050000038,-71.1328940012333 42.3563480000039,-71.1341920012332 42.3565310000038,-71.1354910012333 42.3567270000038,-71.1379460012332 42.3570670000038,-71.1381980012332 42.3570930000037,-71.1381890012333 42.3571340000037,-71.1381400012334 42.3572780000038,-71.1380800012332 42.3574190000038,-71.1378360012332 42.3578800000038,-71.1375860012334 42.3583340000038,-71.1374660012332 42.3585780000038,-71.1373690012332 42.3587610000038,-71.1372870012333 42.3588610000037,-71.1371740012332 42.3589610000038,-71.1370980012333 42.3590560000038,-71.1369610012333 42.3593150000038,-71.1364390012332 42.3592310000038,-71.1358920012333 42.3591040000038,-71.1351570012333 42.3589500000038,-71.1337000012332 42.3586660000038,-71.1333030012333 42.3585810000038,-71.1330830012332 42.35855600
class User(db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True)
email = db.Column(db.String(120), unique=True)
phone_number = db.Column(db.String(120), unique=True)
timestamp = db.Column(db.DateTime)
messages = db.relationship('Messages', backref='user', lazy='dynamic')
function get_infowindow(data) {
var list = data['cdb_list'].split(',');
var the_data;
if (list.length == 1) {
var myobjects;
//var templateData = [];
var sql_link = "http://nation.cartodb.com/api/v1/sql?q=select cartodb_id, to_char(reported_date, 'DD Mon YYYY') reported_date, post_id from reports WHERE cartodb_id = " + data['cdb_list']+"";
<?xml version="1.0" encoding="UTF-8"?>
<!-- Solr managed schema - automatically generated - DO NOT EDIT -->
<schema name="example-data-driven-schema" version="1.5">
<uniqueKey>id</uniqueKey>
<fieldType name="ancestor_path" class="solr.TextField">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/"/>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--Edit the title of the page-->
<title>CartoDB Point Clustering</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" />
@jmwenda
jmwenda / index.html
Last active May 5, 2016 13:15
pointclustering
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--Edit the title of the page-->
<title>CartoDB Point Clustering</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" />