Skip to content

Instantly share code, notes, and snippets.

@rochoa
rochoa / speed.sql
Last active August 29, 2015 14:27 — forked from javisantana/speed.sql
speed from a track table
WITH deltas as (
SELECT
st_distance(the_geom::geography, lag(the_geom::geography, 1) over(order by timestamp)) as ddist,
timestamp - lag(timestamp, 1) over(order by timestamp) as dt
from out_2 offset 1000
)
select avg(ddist/dt) as speed from deltas
@rochoa
rochoa / app.js
Last active March 16, 2017 13:01
[CARTO] Maps API Sandwich
var map = L.map('map', {
scrollWheelZoom: false,
center: [54.09806018306312, -3.80126953125],
zoom: 6
});
//var mapConfigEditor = CodeMirror.fromTextArea(document.getElementById('map_config_editor'), {
// theme: 'monokai',
// lineNumbers: true,
// mode: "javascript",
@rochoa
rochoa / CartoDB Surrogate Keys.md
Last active January 13, 2016 15:02
CartoDB Surrogate Keys.md
@rochoa
rochoa / app.js
Last active March 16, 2017 13:00
[CARTO] Named maps viewer
document.getElementById('map').style.height = window.innerHeight + 'px';
var map = L.map('map', {
scrollWheelZoom: false,
center: [45, 0],
zoom: 3
});
L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
attribution: '<a href="http://cartodb.com">CartoDB</a> © 2014',
@rochoa
rochoa / index.html
Last active March 16, 2017 13:00 — forked from rochoa/index.html
[CARTO] CartoDB.js + Leaflet interactivity example
<!DOCTYPE html>
<html>
<head>
<title>CartoDB + Leaflet interactivity example | CartoDB.js</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 {
height: 100%;
@rochoa
rochoa / app.js
Last active March 16, 2017 13:00
[CARTO] Static Maps API examples
var mapConfigEditor = CodeMirror.fromTextArea(document.getElementById('map_config_editor'), {
theme: 'monokai',
lineNumbers: true,
mode: "javascript",
height: "200px",
lineWrapping: true,
foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
});
@rochoa
rochoa / app.js
Last active May 22, 2017 09:39
[CARTO] Raster demos
var map = L.map('map', {
scrollWheelZoom: false,
center: [-18, -46],
zoom: 8
});
L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
attribution: '<a href="http://cartodb.com">CartoDB</a> © 2014',
maxZoom: 18
}).addTo(map);
@rochoa
rochoa / urldecode
Created December 16, 2014 11:48
urldecode from stdin
#!/usr/bin/python
import sys
import urllib
print urllib.unquote_plus(sys.stdin.read())
@rochoa
rochoa / urlencode
Created December 16, 2014 11:47
urlencode from stdin
#!/usr/bin/python
import sys
import urllib
print urllib.quote_plus(sys.stdin.read())
@rochoa
rochoa / index.html
Last active March 16, 2017 12:59
[CARTO] Named maps + templates
<!DOCTYPE html>
<html>
<head>
<title>Leaflet multilayer example | CartoDB.js</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 {
height: 100%;