This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import requests | |
| from io import StringIO | |
| from requests.adapters import HTTPAdapter | |
| from urllib3.util.retry import Retry | |
| rows = [[1, 2, 3], [4, 5, 6]] | |
| endpoint = 'https://api.tinybird.co' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <iframe src="https://public.carto.com/kuviz/f8dcf0ef-45e5-4578-a245-af443c870ffa" height="600" width="600" /> | |
| <iframe src="https://www.youtube.com/embed/enMumwvLAug" frameborder="0" allowfullscreen="true"> </iframe> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from __future__ import print_function | |
| from math import log, tan, pi | |
| from itertools import product | |
| from argparse import ArgumentParser | |
| from os.path import join, splitext | |
| import tempfile, shutil, urllib, io, sys, subprocess | |
| tile_url = 'https://elevation-tiles-prod.s3.amazonaws.com/geotiff/{z}/{x}/{y}.tif' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import sys | |
| import argparse | |
| from carto.auth import APIKeyAuthClient | |
| from carto.maps import NamedMapManager | |
| parser = argparse.ArgumentParser(description=( | |
| 'Example of CopySQLClient usage to stream data from NEXRAD Level 2' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import sys | |
| import argparse | |
| try: | |
| from urllib2 import urlopen | |
| except ImportError: | |
| from urllib.request import urlopen | |
| try: | |
| from StringIO import BytesIO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with lines as | |
| (SELECT cartodb_id, color, ord, ST_Segmentize(ST_MakeLine(st_centroid(the_geom), lead(st_centroid(the_geom)) OVER (ORDER BY ord))::geography, 100000)::geometry as the_geom | |
| FROM world_borders_four_colors_1_adjacency_list), | |
| tosplit AS ( | |
| SELECT * FROM lines | |
| WHERE ST_XMax(the_geom) - ST_XMin(the_geom) > 180 | |
| ), | |
| nosplit AS ( | |
| SELECT * FROM lines | |
| WHERE ST_XMax(the_geom) - ST_XMin(the_geom) <= 180 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # first create a palette of the portion of the video with more colors | |
| ffmpeg -y -ss 20 -t 3 -i input.mp4 -vf fps=50,scale=640:-1:flags=lanczos,palettegen palette.png | |
| # then use the palette to obtain high quality colors | |
| ffmpeg -i input.mp4 -i palette.png -filter_complex "fps=50,scale=640:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif | |
| # -ss -> start from second | |
| # -t -> duration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE OR REPLACE FUNCTION adjacency_list(table_name regclass, user_name text) RETURNS void AS $$ | |
| BEGIN | |
| EXECUTE format('DROP TABLE IF EXISTS %s_adjacency_list; | |
| CREATE TABLE %s_adjacency_list AS | |
| SELECT DISTINCT a.cartodb_id, | |
| array_agg(b.cartodb_id) over (PARTITION BY a.cartodb_id) AS adjacent, | |
| count(b.*) over (PARTITION BY a.cartodb_id) AS valence, | |
| 0 AS color | |
| FROM %s a, | |
| %s b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| A snippet to make a query to BigQuery and import the result in CARTO using both Python client libraries: | |
| ``` | |
| #!/usr/bin/env python | |
| import argparse | |
| import time | |
| import uuid | |
| from tempfile import NamedTemporaryFile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Reacciones al #AccordDeParis</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%; |