Skip to content

Instantly share code, notes, and snippets.

View alasarr's full-sized avatar

Alberto Asuero alasarr

View GitHub Profile
@alasarr
alasarr / index.html
Created August 28, 2017 14:37
Valencia hexagon grid
<html>
<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>Postal Codes</title>
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.js"></script>
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<link rel="stylesheet" href="main.css" />
@alasarr
alasarr / index.html
Last active August 28, 2017 12:22
Postal codes
<html>
<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>Postal Codes</title>
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.js"></script>
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<link rel="stylesheet" href="main.css" />
@alasarr
alasarr / index.html
Last active August 23, 2017 14:30
CARTO template
<html>
<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>Document</title>
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.js"></script>
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<link rel="stylesheet" href="main.css" />
@alasarr
alasarr / index.html
Last active August 28, 2017 12:05
CARTO Mapnik reserved word
<html>
<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>Document</title>
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.js"></script>
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<link rel="stylesheet" href="main.css" />
@alasarr
alasarr / functions.sql
Last active June 8, 2017 18:50
HOW TO access to a private table in CARTO and get rid of NAMED MAPS.
---
-- HOW TO access to a private tabled in CARTO and get rid of NAMED MAPS.
-- It uses SECURITY DEFINER
-- tesla_supercharger is a privated table .
---
CREATE table user_tokens (token text, user_id integer, expiration timestamp);
INSERT INTO user_tokens VALUES ('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ',1,now()+'10 years'::interval);
----------
@alasarr
alasarr / template.html
Created May 30, 2017 15:51
Infowindow CARTO
<div class="cartodb-popup v2">
<a href="#close" class="cartodb-popup-close-button close">x</a>
<div class="cartodb-popup-content-wrapper">
<div class="cartodb-popup-content">
<% if (data.terrunit!='no_unit') { %>
<h4><%= data.terrunit=='delegaciones' ? Utils.tr('Delegación') : Utils.tr('Colonia') %></h4>
<p><%= data.name %><p>
<% } %>
<h4><%= data.indicator %></h4>
<p class="big"><%= Utils.nbf(data.do_value,{decimals: 0}) %></p>
@alasarr
alasarr / OldKernelsRemover.md
Last active April 11, 2017 09:44
Remove old kernels commandline

Remove old kernels

apt-get remove --purge $(dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+' | grep -Fv $(uname -r) |awk '{print $2}')
apt-get remove --purge $(dpkg -l | tail -n +6 | grep -E 'linux-image-extra-[0-9]+' | grep -Fv $(uname -r) |awk '{print $2}')

### Bash script

#!bin/bash
@alasarr
alasarr / PostgreSQL.md
Last active August 31, 2017 14:42
Useful commands PostgreSQL

PostgreSQL

Useful commands for PostgreSQL

Size

SELECT *, pg_size_pretty(total_bytes) AS total
    , pg_size_pretty(index_bytes) AS INDEX
    , pg_size_pretty(toast_bytes) AS toast
@alasarr
alasarr / docker.md
Last active April 11, 2017 07:20
Docker useful commands

Docker

Cleaning

docker images -qf dangling=true | xargs docker rmi
docker volume ls -f dangling=true
docker volume rm $(docker volume ls -qf dangling=true)
@alasarr
alasarr / CARTO batch API Node sample
Created March 14, 2017 17:31
CARTO batch API sample script
var request = require("request");
var api_key = "XXXX";
var url = "https://{{account}}.carto.com/api/v2/sql/job";
var options = {
method: "POST",
url: url,
qs: {
"api_key": api_key