Skip to content

Instantly share code, notes, and snippets.

View martjanz's full-sized avatar

Martín Anzorena martjanz

View GitHub Profile
@martjanz
martjanz / casos_curiosos.sql
Last active January 19, 2018 16:36
Ballotage 2015 - Casos curiosos
SELECT
*
FROM
(SELECT
vot_procodigoprovincia as provincia,
vot_depcodigodepartamento as departamento,
vot_mescodigocircuito as circuito,
vot_mescodigomesa as mesa,
votvotospartido as votos_fpv
FROM mesascandidaturapresidente
@martjanz
martjanz / gist:b69db4dce7cdccc6e3401c25b4ad3784
Created October 14, 2016 04:10
Argentina's Public Budget - Example data request
Example request to download 2015 National Budget for Buenos Aires City day by day
The service has a limit of 64800 rows so to download all data may be necessary to make a loop iterating over jurisdictions, years, months and days since 1998.
Jurisdictions are encoded like INDEC, beginning from 2 (Buenos Aires City) and incrementing in steps of 4 (2, 6, 10... 94)
http://sitiodelciudadano.mecon.gov.ar/analytics/saw.dll?Go&NQUser=usrsici_c&NQPassword=usrsici_c&SQL=SELECT "Tiempo"."Año", Tiempo.Mes, Tiempo.Dia, "Ejercicio Presupuestario"."Cod. Ejercicio Presupuestario","Ejercicio Presupuestario".Leyenda_Fecha_Act,"Sector Institucional"."Desc. Caracter","Sector Institucional"."Cod. Sector","Sector Institucional"."Cod. Subsector","Sector Institucional"."Cod. y Desc. Caracter","Institucion"."Cod. Jurisdiccion","Institucion"."Desc. Jurisdiccion","Institucion"."Cod. y Desc. Jurisdiccion",Institucion."Cod. y Desc. Subjurisdiccion","Institucion"."Cod. Subjurisdiccion","Institucion"."Desc. Subjurisdiccion","Institucion".
@martjanz
martjanz / overpass-query.txt
Created June 7, 2017 17:39
Argentina National Parks
/*
Argentina National Parks
*/
[out:json];
// gather results
area["boundary"="administrative"]["admin_level"="2"]["name"="Argentina"]->.boundaryarea;
(
// query part for: “boundary=national_park”
node(area.boundaryarea)["boundary"="national_park"];
way(area.boundaryarea)["boundary"="national_park"];
@martjanz
martjanz / Junar downloader.ipynb
Last active December 27, 2017 13:46
Junar data downloader
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@martjanz
martjanz / main.py
Created January 19, 2018 16:26
Google Cloud Storage on Python
#
# Google Cloud Storage snippet
#
# Requirements: glob, os, google-cloud-storage
#
import glob
import os
from google.cloud import storage
GCS_PROJECT = '???' # i.e. Google Cloud project name
@martjanz
martjanz / echo.py
Last active April 9, 2018 21:38
HTTP Requests reflector on Python
#!/usr/bin/env python
"""
Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
Written by Nathan Hamiel (2010)
"""
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
@martjanz
martjanz / h5_to_csv.py
Created March 1, 2018 23:38
Export HDF5 tables to CSV files
"""Export HDF5 tables to csv files
"""
import argparse
import os
import pandas as pd
parser = argparse.ArgumentParser(description='Export HDF5 tables to csv files.')
parser.add_argument('-o', '--h5', dest='h5_path', required=True,
help='Path to HDF5 file.')
parser.add_argument('-d', '--csv', dest='csv_path', default='./',
@martjanz
martjanz / downloader.ipynb
Created June 10, 2019 15:40
La Pampa, elecciones provinciales 2019 - Downloader de resultados de escrutinio provisorio a nivel de mesa
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@martjanz
martjanz / .zprofile
Created August 6, 2019 21:14
Add gcloud (Google Cloud CLI Tools) to zsh shell [MacOS]
source '/Users/martin/google-cloud-sdk/path.zsh.inc'
source '/Users/martin/google-cloud-sdk/completion.zsh.inc'
@martjanz
martjanz / progress_bar.py
Created August 13, 2019 15:43
Python Notebook progress bar
import time, sys
from IPython.display import clear_output
def update_progress(progress):
bar_length = 50
if isinstance(progress, int):
progress = float(progress)
if not isinstance(progress, float):
progress = 0
if progress < 0: