Skip to content

Instantly share code, notes, and snippets.

View ramiroaznar's full-sized avatar

Ramiro Aznar ramiroaznar

View GitHub Profile
@ramiroaznar
ramiroaznar / test_is_in_null_island.sql
Created July 1, 2022 09:19
dbt spatial test macros
{% test is_in_null_island(model, column_name) %}
with validation as (
select
st_x({{ column_name }}) as lng,
st_y({{ column_name }}) as lat
from
{{ model }}
@ramiroaznar
ramiroaznar / created_dbt_project.py
Last active February 22, 2022 14:56
Create a dbt project from a project name and a list of data model names
import os
import click
import logging
import time
# create a logger function
def get_logger():
logging.basicConfig(
level=logging.INFO,
@ramiroaznar
ramiroaznar / get_aggs_geochicas.py
Created May 14, 2021 07:03
Get aggregated metrics from lascallesdelasmujeres geochicas project
import os
import pandas as pd
import json
# clone lascallesdelasmujeres github repository
# cd /lascallesdelasmujeres
json_list = []
for root, dirs, files in os.walk(os.getcwd() + '/data'):
for file in files:
if file == 'stats.txt':
@ramiroaznar
ramiroaznar / Histogram.js
Last active May 7, 2020 10:58
Vega Lite React Component
import React, { useContext } from 'react'
import { VegaLite } from 'react-vega'
import { VEGA_SPEC, HISTO_STYLE } from './constants'
const Histogram = ({metrics}) => {
/// dummy data
const dummyData = [
{x: 'Bulls', y: 128, z: 'red'},
{x: 'Lakers', y: 100, z: 'yellow'}
@ramiroaznar
ramiroaznar / normalize.sql
Last active March 23, 2020 15:07
Cómo normalizar en SQL
SELECT *,
variable/population as var_norm,
variable*1000/population as var_norm_1000hab
FROM table
@ramiroaznar
ramiroaznar / cities.js
Last active June 22, 2019 17:36
CARTO VL & Airship with GeoJSON data source
const cities = {"type": "FeatureCollection", "features": [{"type":"Feature","geometry":{"type":"Point","coordinates":[2.450021,41.539957]},"properties":{"latitude":41.5399566844,"longitude":2.45002070986,"name":"Mataro","country":"Spain","pop":183293}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-0.980028,37.60043]},"properties":{"latitude":37.6004297069,"longitude":-0.98002832173,"name":"Cartagena","country":"Spain","pop":201274}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-5.67,43.530016]},"properties":{"latitude":43.530016092,"longitude":-5.67000044903,"name":"Gijon","country":"Spain","pop":335972}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-15.429999,28.099976]},"properties":{"latitude":28.0999760122,"longitude":-15.4299990249,"name":"Las Palmas","country":"Spain","pop":378495}},{"type":"Feature","geometry":{"type":"Point","coordinates":[-1.698512,37.688564]},"properties":{"latitude":37.6885638621,"longitude":-1.6985115981,"name":"Lorca","country":"Spain"
@ramiroaznar
ramiroaznar / index.html
Last active May 29, 2019 08:19
CARTO JS & Planet Basemaps
<!DOCTYPE html>
<html>
<head>
<title>CARTO JS + Planet Basemaps</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- Include Airship -->
<link rel="stylesheet" href="https://libs.cartocdn.com/airship-style/v2.0.5/airship.css">
@ramiroaznar
ramiroaznar / index.html
Last active May 28, 2019 13:49
CARTO VL & Planet Basemaps
<!DOCTYPE html>
<html>
<head>
<title>CARTO VL + Planet Basemaps</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- Include Airship -->
<link rel="stylesheet" href="https://libs.cartocdn.com/airship-style/v2.0.5/airship.css">
@ramiroaznar
ramiroaznar / index.html
Created May 28, 2019 08:56 — forked from jsanz/index.html
CARTO VL - Basemap Switcher
<!DOCTYPE html>
<html lang="en">
<head>
<title>CARTO VL: Switch the basemap</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="shortcut icon" href="https://carto.com/favicon.ico">
@ramiroaznar
ramiroaznar / index.html
Created February 27, 2019 15:34
CARTO VL + Interactivity + SVG Pie Chart
<!DOCTYPE html>
<html>
<head>
<title>CARTO VL + Interactivity + Vega Pie Chart</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">
<script src="https://libs.cartocdn.com/carto-vl/v1.1.1/carto-vl.min.js"></script>
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.js"></script>