Skip to content

Instantly share code, notes, and snippets.

View tcurvelo's full-sized avatar
🏠

Thiago Curvelo tcurvelo

🏠
View GitHub Profile
[{"state": "PR", "zipcode": "705", "city": "AIBONITO", "lat": "18.14", "lng": "-66.26"}, {"state": "PR", "zipcode": "610", "city": "ANASCO", "lat": "18.28", "lng": "-67.14"}, {"state": "PR", "zipcode": "612", "city": "ARECIBO", "lat": "18.45", "lng": "-66.73"}, {"state": "PR", "zipcode": "729", "city": "CANOVANAS", "lat": "18.37", "lng": "-65.90"}, {"state": "PR", "zipcode": "647", "city": "ENSENADA", "lat": "17.96", "lng": "-66.94"}, {"state": "PR", "zipcode": "707", "city": "MAUNABO", "lat": "18.00", "lng": "-65.90"}, {"state": "NJ", "zipcode": "7675", "city": "WESTWOOD", "lat": "40.98", "lng": "-74.03"}, {"state": "NJ", "zipcode": "7885", "city": "WHARTON", "lat": "40.89", "lng": "-74.58"}, {"state": "NJ", "zipcode": "7095", "city": "WOODBRIDGE", "lat": "40.55", "lng": "-74.28"}, {"state": "NJ", "zipcode": "8802", "city": "ASBURY", "lat": "40.67", "lng": "-75.02"}, {"state": "NJ", "zipcode": "7827", "city": "MONTAGUE", "lat": "41.29", "lng": "-74.74"}, {"state": "NJ", "zipcode": "8201", "city": "ABSECON",
import jmespath
def remap_fields(fieldmap, data, loader=None, *, jmes=True, **defaults):
'''Map data.
>>> remap_fields({'price': 'productPrice'}, {'productPrice': 5.00})
{'price': 5.00}
>>> remap_fields({'price': ['producPrice', 'finalPrice']}, {'finalPrice': 5.00})
@tcurvelo
tcurvelo / jupyter_splash.sh
Created September 19, 2020 21:30
Run container with Splash, Jupyter and GUI support
#!/bin/bash
xhost +local:docker
docker run \
-e DISPLAY=unix$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $XAUTHORITY:$XAUTHORITY \
-v $(pwd)/notebooks:/notebooks \
-e XAUTHORITY=$XAUTHORITY \
-p 8888:8888 \
@tcurvelo
tcurvelo / takeout.js
Created April 18, 2018 00:46
WIP: Automating Google Takeout Download
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.goto('https://takeout.google.com/');
const input = await page.evaluate(() => {
const next = document.querySelector('#identifierNext');
@tcurvelo
tcurvelo / Pipfile
Last active February 8, 2018 01:40
google maps playground
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[dev-packages]
ipython = "*"
@tcurvelo
tcurvelo / xmlsplit.py
Created September 3, 2017 01:19
Cli utility for spliting a big XML file into smaller parts.
#!/usr/bin/env python3
"""
Cli utility for spliting a big XML file into smaller parts.
The breakpoint will be the element of depth 1 (below root) that does not
fit in the specified maximum size. Each part created will have the same
root element.
Usage:
$ xmsplit size prefix [filename]
@tcurvelo
tcurvelo / all_crontabs.sh
Created July 18, 2017 19:00
Get all contrabs jobs
for user in $(getent passwd | cut -f1 -d: ); do
crontab -u $user -l && echo $user && printf '=%.0s' {1..100} && echo ;
done 2> /dev/null
@tcurvelo
tcurvelo / homologacao.js
Last active February 19, 2017 04:55
Inclui faixa de 'versão de homologacao'
document.addEventListener("DOMContentLoaded", function(event) {
const faixa = document.createElement('div');
const estilo = document.createElement('style');
faixa.id='faixa-homologacao';
faixa.textContent = 'Versão de Homologação';
estilo.textContent = `
#${faixa.id} {
margin: 0;
@tcurvelo
tcurvelo / numbers_only.js
Last active July 21, 2016 13:30
Restricting keys allowed to an input
document.getElementById('numbersonly').addEventListener(
'keypress',
function() {
var allowed_keys = {
48: true, // 0
49: true, // 1
50: true, // 2
51: true, // 3
52: true, // 4
53: true, // 5
@tcurvelo
tcurvelo / belman_ford.c
Created May 11, 2014 06:24
Bellman-Ford's shortest path
#include <stdio.h>
#define INFINITO 32766
#define TRUE 1
#define FALSE 0
#define NN 150
typedef unsigned char BOOL;