Skip to content

Instantly share code, notes, and snippets.

View horacioibrahim's full-sized avatar

Horacio Ibrahim horacioibrahim

View GitHub Profile
This extension does not collect, store, or transmit any personal data. PlantUML code is processed locally and sent only to the public PlantUML server (www.plantuml.com) for diagram rendering. No user information is shared with third parties.
@horacioibrahim
horacioibrahim / videoControls.js
Created January 26, 2025 12:01
Ativa controle para vídeos VLS
// Copie cole em devtools > console
// Para a console pode-se usar Abra as DevTools do navegador (F12 ou Ctrl+Shift+I).
(() => {
// Seleciona todos os elementos <video> na página
document.querySelectorAll('video').forEach(video => {
try {
// Adiciona controles ao vídeo
video.setAttribute('controls', 'controls');
video.setAttribute('controlslist', 'nodownload'); // Impede download (opcional)
video.removeAttribute('autoplay'); // Remove autoplay
@horacioibrahim
horacioibrahim / _c_document.painless.java
Last active December 11, 2024 17:32
Normalizar documento de usuário em índices e nomes diferentes
if (doc.containsKey('event_name.keyword') && doc['event_name.keyword'].size() > 0) {
String eventName = doc['event_name.keyword'].value;
String apenasNumeros = "";
if (doc.containsKey('user_id.keyword') && doc['user_id.keyword'].size() > 0) {
String userId = doc['user_id.keyword'].value;
if (userId != null && !userId.isEmpty()) {
for (int i = 0; i < userId.length(); i++) {
char c = userId.charAt(i);
if (Character.isDigit(c)) {
@horacioibrahim
horacioibrahim / sql-elastic-sample.bash
Last active November 19, 2024 09:26
Consulta SQL no ELASTIC
POST /_sql?format=txt
{
"query": """
SELECT payload_parsed.externalId, COUNT(*) as ocurrences FROM "TABLE" // "TABLE*"
WHERE payload_parsed.type.keyword = 'MESSAGE_STATUS'
AND event_data.source.keyword = 'ZENVIA'
AND payload_parsed.channel.keyword = 'email'
AND payload_parsed.messageStatus.code.keyword = 'SENT'
AND inserted_date >= NOW() - INTERVAL 48 HOUR
GROUP BY payload_parsed.externalId HAVING COUNT(*) > 2
@horacioibrahim
horacioibrahim / jwt_token_document.java
Last active December 18, 2024 15:00
AgnosticData + Elastic Insights: JWT introspected
String token = null;
// Primeiro, verificar em params._source['utm_case']['token']
if (params._source.containsKey('utm_case') && params._source['utm_case'] != null) {
if (params._source['utm_case'].containsKey('token')) {
token = params._source['utm_case']['token'];
// Processar o JWT se o token for encontrado
int firstDot = token.indexOf(".");
@horacioibrahim
horacioibrahim / POST_Elastic_Click__Aceitar.json
Last active November 1, 2024 19:33
Get user_id from Click from Elastic "Aceitar"
// POST /events_new-dedicated-01_click/_search
{
"sort": [
{
"inserted_date": {
"order": "desc",
"format": "strict_date_optional_time",
"unmapped_type": "boolean"
}
}
@horacioibrahim
horacioibrahim / POST_Elastic_Click__Cancelar_protesto.json
Last active November 1, 2024 19:33
Get user_id from Click from Elastic "Cancelar protesta"
// POST /events_new-dedicated-01_click/_search
{
"sort": [
{
"inserted_date": {
"order": "desc",
"format": "strict_date_optional_time",
"unmapped_type": "boolean"
}
}
@horacioibrahim
horacioibrahim / POST_Elastic_Click__Detalhes.json
Last active November 1, 2024 19:33
Get user_id from Click from Elastic "Detalhes"
// POST /events_new-dedicated-01_click/_search
{
"sort": [
{
"inserted_date": {
"order": "desc",
"format": "strict_date_optional_time",
"unmapped_type": "boolean"
}
}
const fs = require('fs');
const axios = require('axios');
const { Parser } = require('json2csv');
// Função para "achatar" o JSON
function flattenObject(obj, prefix = '') {
return Object.keys(obj).reduce((acc, k) => {
const pre = prefix.length ? `${prefix}_${k}` : k;
if (typeof obj[k] === 'object' && obj[k] !== null && !Array.isArray(obj[k])) {
Object.assign(acc, flattenObject(obj[k], pre));
/* `googleAppScriptAutoBackup.js` creates copy of files
* when is opened. This script check if file already exists
* so creates the backup file.
*/
var prefixBackupName = "MyFileXYZ"; // we're gonna to use as MyFileXYZ-
var folderId = "hashFolderIdFoundInURL"; // backup folder: where file to be placed it
var principalFileId = "hashFileIdFoundInURL" // principal file that it'll be copied
var workDir = DriveApp.getFolderById(folderId);
var myGMT = "GMT-3:00"