Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

pfelipm

🎯
Focusing
View GitHub Profile
View gist:13a455e08ddffb2c1bee7fe1bf290ef1
<form action="https://script.google.com/macros/s/AKfycbzlDk0jJzHB5zIeb78PEWRYb_TOi5wY7RfTdDe3c3Oyac_S2Is/exec" method="get" target="_blank">
<label>DNI</label><br />
<input name="DNI" required="" type="text" /><br /><br />
<label>Correo electr&oacute;nico</label><br />
<input name="EMAIL" required="" type="email" /><br><br>
<button>Buscar</button>
</form>
@pfelipm
pfelipm / Traducción.gs
Last active Feb 7, 2021
A simple and straightforward way to manage message translations in Google Apps Script projects
View Traducción.gs
// This object stores text strings in several languages inside sub-objects {ES}, {EN_US}...
const TRANSLATIONS = {
ES: {
MSG_HELLO: 'Hola',
MSG_GOODBYE: 'Adiós'
},
EN_US: {
MSG_HELLO: 'Hello',
MSG_GOODBYE: 'Goodbye'
}
@pfelipm
pfelipm / Consolidar HdCs.gs
Last active Feb 9, 2021
Consolida los datos del intervalo indicado procedentes de todas las HdC dentro de la carpeta designada en la HdC actual
View Consolidar HdCs.gs
/**
* Importa intervalos de datos idénticos procedentes de todas
* las hdc que se encuentran en la carpeta indicada
* y los consolida en la actual.
* No realiza ningún control de errores.
* El orden de importación no está garantizado.
* Demo: https://drive.google.com/drive/folders/1BZNT5TNcOpKaP5Hy3BuvVZhT_FhtrWjr?usp=sharing
*/
const ID_CARPETA_ORIGEN = '1bqlCmxWaL-LCNb6T7vOWNtPky3bK99K-';
@pfelipm
pfelipm / Código.gs
Last active Mar 16, 2021
Una fx personalizada (ESPROTEGIDA) para hdc de Google que determina si una celda está afectada por una regla de protección.
View Código.gs
/**
* Determina si la celda indicada está protegida (no es editable por el usuario)
* @param {A1} celda Referencia a celda en formato A1 o R1C1 entre comillas dobles ("..")
* @returns VERDADERO | FALSO
* @customfunction
*
* MIT License
* Copyright (c) 2020 Pablo Felip Monferrer(@pfelipm)
*
* @OnlyCurrentDoc
@pfelipm
pfelipm / generated.photos.gs
Last active Apr 28, 2021
Get faces generated from scratch by AI using generated.photos API
View generated.photos.gs
/**
* generated.photos API demo >> Faces generated from scratch by AI
*
* 1. Get API key at https://generated.photos/api
* 2. Make a copy of https://docs.google.com/spreadsheets/d/1RkLy6e0h1QURtsOj1gsAfWGzvAUua0yIky_THy8ut1Q
* 3. Write your API key inside cell C3 (don't share!)
*
* Please, note:
* - Just 50 API calls/month! (API free plan)
* - Some trait combinations apparently fail to return results :-?
@pfelipm
pfelipm / ButtonLock.gs
Last active May 9, 2021
Using LockService to avoid concurrent executions, specially relevant when invoking GAS code from buttons in a spreadsheet.
View ButtonLock.gs
/**
* Simple demonstration of LockService...
* https://developers.google.com/apps-script/reference/lock
* ...to prevent concurrent executions of a GAS function,
* for example when invoked by a button in a Spreadsheet (rather likely).
* Demo: https://docs.google.com/spreadsheets/d/1n_7nZIi5QtN9URzsKdFW6WtSxPM9uUK3QhQSbzbltHg
*
* @OnlyCurrentDoc
*/
@pfelipm
pfelipm / Text2GzipBlob.gs
Last active May 10, 2021
From UNICODE text to gzipped blob encoded as text and back using Apps Script
View Text2GzipBlob.gs
/**
* These two functions:
* 1. Transform a UNICODE string to blob, compress and encode it as text using two different methods (base64 or JSON.stringify)
* 2. Reverse de process
*/
function testTextoGzipBlob() {
// Method 1: base64Encode (better compression):
// Text >> Blob >> gzip >> getBytes Byte[] >> *base64Encode* text >> [cache key/value] >> *base64Decode* Byte[] >> Blob >> ungzip >> Text 😅
@pfelipm
pfelipm / fxRepetirFilas.gs
Last active May 23, 2021
Función personalizada para HdC repetirFilas()
View fxRepetirFilas.gs
/**
* Repite cada fila un nº indicado de veces
* @param {A2:C4} intervaloDatos Intervalo de datos cuyas filas se van a repetir
* @param {D2:D4} colRepeticiones Vector columna que indica el nº de veces a repetior cada fila
* @customfunction
*/
function repetirFila(intervaloDatos, colRepeticiones) {
// ⚠️ ¡Se debería realizar un control de errores sobre los parámetros de la función!
@pfelipm
pfelipm / GlobalTextSubst.gs
Last active Jun 6, 2021
Multiple <placeholder> text substitutions using a JS map and reduce() with initial value (+other methods).
View GlobalTextSubst.gs
/**
* Multiple <placeholder> text substitutions
* using a JS map data type and reduce() with initial value (+other methods)
*/
function globalTextSubst(){
// Some sample data
const alumno = 'Juan Rebote';
const ciclo = 'Gestión de ventas y espacios comerciales';
View TOC custom fx.gs
/**
* Builds a TOC in the spreadsheet.
*
* Pablo Felip (@pfelipm).
*
* @param {true} includeId Include sheet ID
* @param {true} includeUrl Include link to sheet
* @return List of [Sheet name, Sheet ID, Sheet URL]
* @customfunction
*/