Skip to content

Instantly share code, notes, and snippets.

@jagedn
jagedn / blogbot.adoc
Last active September 3, 2019 11:07
BlogBot

BlogBot

Un Bot de Telegram para que el usuario interaccione con tu blog

Idea

A día de hoy Telegram tiene Chats, donde la gente se subscribe y tú envías contenido. El problema es que el lector no puede interactuar al estilo de un blog en un navegador

@jagedn
jagedn / idea.adoc
Last active September 16, 2019 07:56
asciidoctor-netlify

Asciidoctor Netlify Extension

Netlify is a cloud computing company that offers hosting and serverless backend services for static websites (Wikipedia)

You can link your git (github/gitlab/…​) repo with your Netlify account and deploy your static site into it in a similar way of Github/Gitlab Pages but with the add you can use some out of the box backend features as:

  • forms: if your static content has a form you can receive an email when some user fill it

  • aws function: you can define AWS lambda functions and execute it when the user relaizes some action with your content

  • Basic auth and OAuth providers

@jagedn
jagedn / AppTest.groovy
Created September 21, 2019 13:33
Busca, extrae y guarda en Google Sheet las noticias principales sobre un tema
package scrapping.google
import geb.Page
import geb.spock.GebSpec
import org.openqa.selenium.By
import org.openqa.selenium.OutputType
import org.openqa.selenium.Point
import org.openqa.selenium.TakesScreenshot
import org.openqa.selenium.WebElement
import spock.lang.Specification
@jagedn
jagedn / Trasponer.gs
Last active October 4, 2019 09:12
Custom function para Google Sheet que traspone los valores de una columna en filas agrupando por un tamaño dado
/*
Si tienes una lista de registros en una sóla columna (por ejemplo una lista de IDs)
y los necesitas en filas puedes usar la función `=TRANSPOSE`
pero si son miles de registros la funcion dará un error.
Con esta función transpones la columna en N filas de SIZE elementos
*/
function trasponer_agrupar(input, size) {
if( !input.map )
return [];
var array = [];
@jagedn
jagedn / Code.gs
Last active May 26, 2020 21:12
Google Sheet to elevate a matrix to the n power
/*
In a Google Sheet select Tools->Script Editor and copy&paste this code and save the file
You can use this function in a cell as:
=pow_matrix(A5:C7,3)
*/
function pow_matrix(a, n) {
if( !a.map )
@jagedn
jagedn / boe.groovy
Created October 11, 2019 11:33
extraer campos del Boe formato pdf
@Grab(group='org.apache.pdfbox', module='pdfbox', version='2.0.8')
import org.apache.pdfbox.pdmodel.PDDocument
import org.apache.pdfbox.text.*
import java.awt.Rectangle
margenright = 10
def model=[:]
txtboe = new PDFTextStripper().getText( PDDocument.load( new URL("https://www.boe.es/boe/dias/2015/09/12/pdfs/BOE-A-2015-9803.pdf").bytes ) )
txtboe = txtboe.replaceAll('\n',' ')
function onOpen(e) {
var ui = SpreadsheetApp.getUi();
ui.createAddonMenu().addItem('Raffle', 'raffleUI').addToUi();
}
function getRemains(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var ret = [];
@jagedn
jagedn / Client.html
Created October 17, 2019 06:56
A more elaborate Raffle example for Google Sheet
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
<h1><?!= LanguageApp.translate('Bienvenido','',Session.getActiveUserLocale()) ?></h1>
package mn.telegram
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.annotation.Produces;
import javax.inject.Inject
import com.puravida.mn.telegram.*
@Controller("/hello")
@jagedn
jagedn / code.gs
Created February 1, 2020 11:54
feed telegram channel with google sheet
function telegram(){
var bot = 'XXXXXX:YYYYYYYYYYYYY'
var chatId = 'CHANNEL_ID'
var url = 'https://api.telegram.org/bot'+bot
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var rangeData = sheet.getDataRange();
var lastColumn = rangeData.getLastColumn();