Skip to content

Instantly share code, notes, and snippets.

View saleiva's full-sized avatar
🤓

Sergio Álvarez Leiva saleiva

🤓
View GitHub Profile
@saleiva
saleiva / index.html
Created January 14, 2011 18:24 — forked from mbostock/.block
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://github.com/simplegeo/polymaps/raw/v2.2.0/polymaps.min.js"></script>
<script type="text/javascript" src="http://github.com/mbostock/polymaps/raw/586fbb0346548a5559b6edea8aab76ac51334da5/lib/crimespotting/crimespotting.js"></script>
<style type="text/css">
@import url("http://github.com/simplegeo/polymaps/raw/v2.2.0/examples/example.css");
html, body {
@saleiva
saleiva / gist:1217402
Created September 14, 2011 18:47
JSON example
{
time: 0.049
total_rows: 5
rows: [
{
updated_at: "2011-09-06T14:20:05.721Z"
created_at: "2011-09-06T14:20:05.669Z"
cartodb_id: 1
name: "Hawai"
address: "Calle de Pérez Galdós 9, Madrid, Spain"
@saleiva
saleiva / twitter_cdb
Created December 18, 2011 13:24
Twitter Streaming API and CartoDB
var twitter = require('ntwitter');
var http = require('http');
var cartodb_username = '' // your CartoDB username
, cartodb_password = '' // your CartoDB password
, cartodb_consumer_key = '' // Your CartoDB API Key ('YOUR KEY')
, cartodb_consumer_secret = '' // Your CartoDB API Secret ('YOUR SECRET')
, cartodb_private_query = '' // An SQL query to run eg. 'SELECT cartodb_id FROM cables LIMIT 20'
, cartodb_request_url = 'https://' + cartodb_username + '.cartodb.com/oauth/request_token'
, cartodb_access_url = 'https://' + cartodb_username + '.cartodb.com/oauth/access_token'
@saleiva
saleiva / colorstyles.css
Created February 8, 2012 11:36
Color styles
#simplified_ecorgions{
line-width:0;
line-opacity:1;
polygon-opacity:0.7;
polygon-fill:transparent;
}
#simplified_ecorgions[wwf_mhtnum=1] {
polygon-fill:rgb(0,128,0);
line-width:1;
@saleiva
saleiva / bounding circle on cartodb
Created February 23, 2012 16:29 — forked from andrewxhill/bounding circle on cartodb
Creates a bounding circle from the_geom_webmercator on cartodb
SELECT
ST_Buffer(
st_centroid(ST_Union(the_geom_webmercator)),
st_distance(
st_centroid(ST_Union(the_geom_webmercator)),
ST_EndPoint(ST_LongestLine(
ST_Union(the_geom_webmercator),
ST_Union(the_geom_webmercator)
))
)
@saleiva
saleiva / bounding circle on cartodb
Created February 23, 2012 16:29 — forked from andrewxhill/bounding circle on cartodb
Creates a bounding circle from the_geom_webmercator on cartodb
SELECT
ST_Buffer(
st_centroid(ST_Union(the_geom_webmercator)),
st_distance(
st_centroid(ST_Union(the_geom_webmercator)),
ST_EndPoint(ST_LongestLine(
ST_Union(the_geom_webmercator),
ST_Union(the_geom_webmercator)
))
)
@saleiva
saleiva / labels.cartodb
Created February 23, 2012 16:45 — forked from tokumine/labels.cartodb
carto to use labels in CartoDB maps
Just a quick sketch to explain how to use labels in CartoDB:
http://dl.dropbox.com/u/193220/CartoDB/labels.png
Something like this should work while we sort out exactly how to release this:
#populated_places_points_2{
marker-fill:#0099FF;
marker-line-color:white;
marker-line-width:1;
@saleiva
saleiva / CartoDB code
Created March 5, 2012 10:58
11870.com hotels density map in Madrid
SELECT count(cartodb_id) as ct, ST_Transform(ST_Buffer(ST_SnapToGrid(the_geom,0.002),0.001, ‘quad_segs=2 endcap=square’),3857) as the_geom_webmercator FROM hoteles_playground GROUP BY ST_SnapToGrid(the_geom,0.002)
#hoteles_playground{
polygon-fill:#FF6600;
polygon-opacity:.7;
}
#hoteles_playground[ct<=40]{
polygon-fill:#BD0026}
#hoteles_playground[ct<=20]{
polygon-fill:#F03B20}
@saleiva
saleiva / carto.css
Created March 5, 2012 10:59
11870.com with CartoDB
#hoteles_madrid_11870 {
marker-fill:#0099FF;
marker-line-color:white;
marker-line-width:0;
marker-opacity:1;
marker-line-opacity:1;
marker-placement:point;
marker-type:ellipse;
marker-allow-overlap:true;
}
@saleiva
saleiva / gist:2422193
Created April 19, 2012 16:38
points to geom (buffer)
SELECT ST_Transform(ST_Union(ST_Buffer(the_geom::geography,100000)::geometry),3857) as the_geom_webmercator FROM nuclear_plants_spain