Skip to content

Instantly share code, notes, and snippets.

View ntkog's full-sized avatar

Jorge Barrachina Gutiérrez ntkog

View GitHub Profile
@ntkog
ntkog / descarga.sh
Last active March 24, 2024 02:37
Lista de Entidades publicadas en INVENTE
mkdir entidades_json
parallel -j+0 --eta --delay 1 --retries 3 --joblog parallel.log ./igae.sh {} "entidades_json/{}.json" :::: <(cat ids.txt)
@ntkog
ntkog / get_issues.sh
Last active March 20, 2024 15:31
Utilidad sencilla para recorrer los issues de los Observatorios y generar un json a partir de los issues.
parallel -j+0 --eta curl -sSLk -o "files/issues_{}.json" "https://api.github.com/repos/JaimeObregon/observatoriospublicos.es/issues?page={}&q=is%3Aissue+is%3Aopen" :::: <(seq 1 6)
cat *.json | jq -s 'add' - > all_issues.json
@ntkog
ntkog / covid19.sh
Created March 19, 2020 15:05
Bash function para descargarse el último informe de COVID-19 en España y convertir los datos a CSV
function covid19 () {
# Descargar informe
curl -sS -k $1 -O
PDF_FILENAME=`echo "$1" | cut -d'/' -f 10`
CSV_FILENAME=`echo $PDF_FILENAME | sed -r 's/\.pdf//'`
NOW=`date +%d_%m_%Y_%Hh`
# Convertir a texto
pdftotext -f 1 -l 1 -layout ${PDF_FILENAME}
# Convertir a CSV
@ntkog
ntkog / keybase.md
Created March 14, 2020 11:29
keybase.md

Keybase proof

I hereby claim:

  • I am ntkog on github.
  • I am ntkog (https://keybase.io/ntkog) on keybase.
  • I have a public key ASCJCwrSDSTmbpY1fbLUJbV-v2zM2buBDM5J0EUjCoyujQo

To claim this, I am signing this object:

@ntkog
ntkog / now.json
Last active December 16, 2020 10:14
IVOOX RSS feed fixer for Spotify
{
"version": 2,
"builds": [{ "src": "server.js", "use": "@now/node-server" }],
"routes": [
{
"src": "/",
"dest": "/server.js",
"methods": ["GET"]
}
]
@ntkog
ntkog / index.js
Last active January 3, 2020 17:33
Scraping Tweets from a user
const puppeteer = require('puppeteer');
const {writeFile} = require('jsonfile');
const TWITTER_USER = process.argv[2] || "congosto";
const TWEETS_TO_FETCH = process.argv[3] || 100;
function extractItems() {
return [...document.querySelectorAll('.tweet')]
.map(el => ({
metadata : {...el.dataset},
@ntkog
ntkog / podcast_download_all
Last active December 28, 2019 13:16
One-Liner para bajarse todos los episodios del podcast "Más platón y menos whatsapp"
parallel --dry-run --colsep '#' curl "{1}" -o {2}.mp3 :::: <(curl -sS "https://fapi-top.prisasd.com/podcast/playser/1_playser/itunes/la_ventana_mas_platon_y_menos_whatsapp/audios.xml" | xml2js | fx '.rss.channel.item.map(({title,enclosure,...rest}) => ({ title : /[|-]/.test(title) ? title.split(/[|-]/)[1].trim() : title, url : enclosure["@_url"]})).map(({title,url}) => ({ title : title.replace(/(&#039;|"|&quot;)/g, ""), url : url}))' | jq -r '.[] | (.url) + "#" + (.title)')
@ntkog
ntkog / Get all geojson countries
Last active November 19, 2019 15:57
GeoGrep - Para cuando quieres filtrar csv's espacialmente por países sin una geodatabase.
cd data/countries
time parallel -j+0 curl -sS -o '{}.json' '"https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/World__Countries_Generalized_analysis_trim/FeatureServer/0/query?where=ISO_3DIGIT+%3D+%27{}%27&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=ISO_3DIGIT&returnGeometry=true&returnCentroid=false&featureEncoding=esriDefault&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=4326&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnQueryGeometry=false&returnDistinctValues=false&cacheHint=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=geojson&token="' :::: <(cat list.txt)
@ntkog
ntkog / propuestas.js
Created April 18, 2019 09:57
Propuestas Partidos políticos según newtral
function propuestas(partido) {
let lista = [...document.querySelectorAll('.e-module div[data-option]')].map(el=>({
partido: el.dataset.option,
texto: [...el.querySelectorAll('p')].reduce((old,cur)=>old + cur.textContent, "")
})).filter(obj=> (partido === "all" ? true : obj.partido === partido) && obj.texto.length > 0);
partido === "all" ? console.table(lista) : console.table(lista,["texto"]);
let csv = lista.map(r => `"${r.partido}"|"${r.texto.replace(/\n/g, " ")}"`);
csv.unshift(`"partido"|"texto"`);
// Copia al portapapeles todos los datos a un CSV
@ntkog
ntkog / presupuestos.js
Created December 19, 2018 20:09
Resalte de los conceptos a 0 de los presupuestos del distrito de Vallecas 2017
// Carga esta url
// https://presupuestosabiertos.madrid.es/es/inversiones/213/puente-de-vallecas#year=2017
// Expande todos los conceptos
[...document.querySelectorAll('tr > td >a.toggle')].map( el => el.click() )
// Resalta en amarillo todos los conceptos cuya ejecución presupuestaria es 0
[...document.querySelectorAll('td:nth-child(3)')].filter(el => el.textContent === "0 €").map( el => el.style.backgroundColor = "yellow" )