Skip to content

Instantly share code, notes, and snippets.

View alrocar's full-sized avatar

alrocar alrocar

View GitHub Profile
<!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%;
@alrocar
alrocar / carto-python-bigquery
Created April 18, 2018 05:11
This is a sample snippet to ingest data from BigQuery into CARTO by using both Python SDKs
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
@alrocar
alrocar / high quality gif
Last active May 26, 2018 15:13
high-quality-gif
# 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
@alrocar
alrocar / animate lines script
Last active July 5, 2018 10:21
animate lines script
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
@alrocar
alrocar / facebook_invite_all
Created October 11, 2014 14:05
How to invite all your friends to your Facebook page
// Open the Javascript console of your favourite browser
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type.
jQuery.noConflict();
//Go to Facebook, search for your page, Go to 'Invite friends'. Scroll to make visible all your friends
@alrocar
alrocar / facebook_accept_friends
Created October 11, 2014 14:03
How to accept all Facebook friends request
// Open the Javascript console of your favourite browser
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type.
jQuery.noConflict();
//Go to Facebook friends request page (https://www.facebook.com/friends/requests/?split=1&fcref=ft)
@alrocar
alrocar / index.html
Last active September 27, 2018 18:50
WIX iframe
<html>
<head>
</head>
<style type="text/css">
.topad {
height: 26px;
position: absolute;
z-index: 999999999;
top: 0;
import os
import sys
import argparse
try:
from urllib2 import urlopen
except ImportError:
from urllib.request import urlopen
try:
from StringIO import BytesIO
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
#!/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'