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 / prueba_sort.html
Last active July 12, 2019 09:33
Sort Tables by columns with flexbox and a little Javascript
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<style>
#container {
flex-shrink: 0;
@ntkog
ntkog / pruebaflex.html
Created May 31, 2015 11:56
Simple Accordion with FlexBox , css3 transitions, and a little javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<style>
html, body {
width: 100%;
@ntkog
ntkog / test.html
Created February 8, 2016 08:53
Filter and fix commands from a asciicast doc file
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="/asciinema-player.css" />
<script src="/asciinema-player.js"></script>
</head>
<body>
<div id="player-container"></div>
<script>
function generateCommandList(source) {
@ntkog
ntkog / codemotion.js
Created August 15, 2017 12:29
Ver de un plumazo un resumen de charlas tageadas por lenguajes de programación en la Agenda de Codemotion en Consola
var tags = Array.from([].slice.call(document.querySelectorAll('span[class*=tag-programming-language--]'))
.map((el)=>[].slice.call(el.classList)
.filter((className)=>/language--/.test(className))[0]).reduce((acc,cur)=>acc.add(cur), new Set()));
console.table(tags.map((tag) => ({ language : tag.split("--")[1] , total : document.querySelectorAll(`.${tag}`).length })));
@ntkog
ntkog / gist:ecdf83bb1e68a136435f13d9c97f51d4
Last active November 28, 2017 10:45
One-liner : Ranking Final de las charlas de CodeMotion
var talksByLikes = [].slice.call(document.querySelectorAll('.ka-td-contents')).map((talk) => ({ title : talk.querySelector('.ka-talk-title').textContent , author: talk.querySelector('.ka-username').textContent, favs : +talk.querySelector('span.ka-button-indicator').textContent, rating : +talk.querySelector('a.ka-like-link + a.ka-social-link').textContent , ratio : talk.querySelector('a.ka-like-link + a.ka-social-link').title }));
var currentDay = /5693168230072320/.test(window.location.href)
? "5649626120060928"
: "5693168230072320";
document.querySelector(`a[data-day-id="${currentDay}"]`).click();
setTimeout(function(){
talksByLikes = talksByLikes.concat([].slice.call(document.querySelectorAll('.ka-td-contents')).map((talk) => ({ title : talk.querySelector('.ka-talk-title').textContent , author: talk.querySelector('.ka-username').textContent, favs : +talk.querySelector('span.ka-button-indicator').textContent, rating : +talk.querySelector('a.ka-like-link + a.ka-social-link').textContent, ratio: ta
@ntkog
ntkog / gist:6340fb153e3d3d65e1a628a1bd657dd2
Last active November 25, 2018 19:48
Estadísticas Instántaneas de la Agenda de la Commit Conf 2018
function getData(day) {
return [...document.querySelectorAll('span.button-label + span.button-indicator,.agenda-talk-title, a.agenda-social-link[title*="votes"]')].reduce((o,c,i,a)=>{
if (i % 3 == 0) {
o.push({
day: day,
title: a[i].textContent,
bookmarked: +a[i + 1].textContent,
votes: +a[i + 2].title.split(" out of ")[1].split(" votes")[0],
rating: +a[i + 2].title.split(" out of ")[0],
ratio: +a[i + 2].title.split(" out of ")[1].split(" votes")[0] * 100 / +a[i + 1].textContent
@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" )
@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 / 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 / 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)')