Skip to content

Instantly share code, notes, and snippets.

View alasarr's full-sized avatar

Alberto Asuero alasarr

View GitHub Profile

Create an API using CARTO as a backend

Imagine you're going to build a backend to analyze the air quality of a region in Madrid.

You've the following two public datasets ready to be consumed:

@alasarr
alasarr / instructions.md
Created June 26, 2020 09:29
Backend test

Choosing what to do during your next vacation

It’s summertime and we have decided we are going to Madrid for our vacation! However, we don’t know what to do when we get there. Thankfully, we’ve got a list of activities, so all that’s left is to write a program to help us decide where to go.

The goal of this project is to write a web API to help select activities to do in Madrid. We’re ambitious, and we’re thinking of expanding it to include data about multiple cities in the future, and adding more complicated planning, e.g: taking into account the transportation between different activities. In this exercise we’ll focus in the first steps towards that goal, but think of it as the first milestone in a bigger project.

We estimate this test should take around a day of work. Don’t worry if you finish faster, or if it takes you a little longer, as it can vary a lot depending on how you approach the project.

Keep in mind the following:

  • Please include a document with your code explaining your thought process
@alasarr
alasarr / index.html
Last active November 5, 2019 11:39
Fetch data by random polygon
<!DOCTYPE html>
<html>
<head>
<title> Filter data on map | CARTO</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,600,700|Open+Sans:300,400,600" rel="stylesheet">
<!-- Include Leaflet -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
@alasarr
alasarr / copyfrom.py
Created July 28, 2018 07:54
COPY from CARTO
# create table trans_amt_rank_201805(
# region_type text,
# region_id text,
# month text
# industry_code text,
# industry_name text,
# trans_amt_share text,
# trans_amt_rank integer
#
# )
@alasarr
alasarr / deploy.sh
Created April 24, 2018 11:52
Easy script to deploy a website in Google Cloud. It's optimized for Angular or any other HTML 5 application who manages URLs
#!/bin/bash
# CNAME -> c.storage.googleapis.com
bad_usage(){
echo 'Bad parameters:'
echo "Usage: $0 <init|update> <domain> <folder_to_upload>"
exit 1
}
init(){
@alasarr
alasarr / index.html
Created January 11, 2018 07:45
Manhattan 3D building filling
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>MapboxGL CARTO Building</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.40.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.40.1/mapbox-gl.css' rel='stylesheet' />
<script src='https://cdnjs.cloudflare.com/ajax/libs/nanoajax/0.4.3/nanoajax.min.js'></script>
<style>
@alasarr
alasarr / index.html
Last active January 11, 2018 07:45
Manhattan 3D building extrusion
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>MapboxGL CARTO Building</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.40.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.40.1/mapbox-gl.css' rel='stylesheet' />
<script src='https://cdnjs.cloudflare.com/ajax/libs/nanoajax/0.4.3/nanoajax.min.js'></script>
<style>
@alasarr
alasarr / batch.py
Last active December 5, 2017 08:37
CARTO Batch API sample
from longitude.models.cartomodel import CartoModel
from longitude.config import cfg
cfg['CARTO_USER'] = 'XXX'
cfg['CARTO_API_KEY'] = 'XXXX'
cm = CartoModel()
q = '''
select pg_sleep(10)
'''
@alasarr
alasarr / index.html
Created November 23, 2017 21:53
Salesquest Iframe sample
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Sample Iframe</title>
<style>
body,iframe,html{
width:100%;
@alasarr
alasarr / curl.sh
Last active September 15, 2017 17:21
Topology exception isolines
curl -d @data.json -X POST https://posterscope-admin.carto.com/api/v2/sql --header "Content-Type:application/json"