Skip to content

Instantly share code, notes, and snippets.

View danicarrion's full-sized avatar

Dani Carrión danicarrion

  • Valladolid, Spain
View GitHub Profile
@danicarrion
danicarrion / README.md
Last active August 29, 2015 14:21
Reverse geocoding after adding a point to a table on CartoDB
View README.md

Requirements

  • A table on PostgreSQL/PostGIS (tested with CartoDB) with the following text fields: address, city, country, zipcode.
  • Python functions are enabled.
  • pygeocoder is available to the python function

Usage

Once the function has been created, the trigger must be created like this (assuming the geometry column is called the_geom:

@danicarrion
danicarrion / startpy
Created June 11, 2015 10:35
Starts/stops a python script, storing its PID in /var/run, so that it can be run from monit
View startpy
#!/bin/bash
#
# startpy: starts/stops a python script, storing its PID in /var/run,
# so that it can be run from monit
#
# Scripts must be placed in a folder under /home/sm/scripts. Startpy
# will look in that folder for a script named after the folder (plus
# .py extension).
#
# (In the following example we'll assume a script test.py exists in
@danicarrion
danicarrion / index.html
Last active August 29, 2015 14:23
Map with image overlay (GMaps)
View index.html
<!DOCTYPE html>
<html>
<head>
<!-- See Javier Arce's original for Leaflet: http://bl.ocks.org/javierarce/e7ec4b39013aa03ebd5e -->
<title>Map with image overlay | 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 {
@danicarrion
danicarrion / export.conf.example
Created September 2, 2015 11:01
Export tables from CartoDB as CSV, the_geom being converted to latitude/longitude
View export.conf.example
[cartodb]
account_name=
api_key=
table_name=
columns=
[file]
name=
@danicarrion
danicarrion / README.md
Last active January 12, 2016 15:08
Script that reads from a CartoDB table, geocode each row with Google's geocoder and put them back into CartoDB
View README.md

This script reads a table fom CartoDB using the SQL API, geocodes one of its fields using Google's geocoder and updates the data on CartoDB.

If no valid credentials are provided for Google's geocoder, the free limits will apply.

TODO: multithread support

@danicarrion
danicarrion / index.html
Created May 20, 2015 18:33
createLayer with torque category layer
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>Torque category selector</title>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.14/themes/css/cartodb.css" />
<style type="cartocss/text" id="cartocss">
Map {
@danicarrion
danicarrion / index.html
Created August 18, 2016 16:18
CARTO + Tangram + GeoJSON example
View index.html
<!doctype html>
<!--
Tangram: real-time WebGL rendering for OpenStreetMap
http://github.com/tangrams/tangram
http://mapzen.com
-->
<html lang="en-us">
<head>
<meta charset="utf-8">
@danicarrion
danicarrion / index.html
Last active September 6, 2016 15:14
CARTO + Tangram + MVT example
View index.html
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>CARTO + Tangram + MVT example</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.3/leaflet.css" />
<style>
@danicarrion
danicarrion / index.html
Last active October 17, 2016 15:46
CARTO + Openlayers + MVT example
View index.html
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>CARTO + Openlayers + MVT example</title>
<link rel="stylesheet" href="https://openlayers.org/en/v3.18.2/css/ol.css" type="text/css" />
<script src="https://openlayers.org/en/v3.18.2/build/ol.js"></script>
@danicarrion
danicarrion / index.html
Created November 21, 2016 07:57
Forward-all proxy for CARTO's password/token-protected named maps
View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.js"></script>
<title>Password-protected named map example</title>
</head>
<body>
<div id="map" style="height: 500px"></div>