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 / 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:3438086
Created August 23, 2012 16:06 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@saleiva
saleiva / rasters.sql
Created September 14, 2012 13:28 — forked from andrewxhill/rasters.sql
Rasters to polygons for CartoDB
--Upload your new raster data
--In my case the data goes into a table, night_light
--In some cases, I find it useful to downsample the total number of variables in a band, or in some cases merge data from multiple bands into one.
--Here is an example how one such process would work
UPDATE night_light SET rast = ST_MapAlgebraExpr(rast,'8BUI','CASE WHEN [rast] = 0 THEN 10 WHEN [rast] = 255 THEN 11 ELSE floor([rast]/32)::int END');
--Create a new table, light_polygons
--Add a numeric column called, rast_value
var a = new Array();
var n;
var posicion = 0;
// Crear una función que, al enviarle el número de diapositivas (ej:15), devuelva un array ordenado con ej(15) diapositivas.
function crearPresentacion(n){
for (var i=0; i<=n; i++){
a[i]=i;
}
return "creado";
//Crear simulador numérico de presentaciones
var a = new Array();
var posicion = 0;
var n = 20;
var t;
// Crea una lista de diapositivas
function lista(_n){
n = _n;
for (i=0; i<= _n; i++){