sexta-feira, 3 de dezembro de 2021

Sobre a parcialidade de Sergio Moro no julgamento de Lula

Não vou apoiar PT. Não vou apoiar Lula. Desconfio da inocencia de Lula. Mas não significa que vale tudo para se fazer justiça.



Sobre a parcialidade de Sergio Moro e a lei LEI Nº 7.170, DE 14 DE  DEZEMBRO DE 1983

Sobre os erros dos nosso representantes e de nossa justiça, resolvi ler a lei 7170/83.

As coisas já estão bagunçadas, mas parece que os agentes publicos não ajudam...

Quando moro foi parcial com a decisão que prendeu Lula, que era candidato, percebi que ele pode se enquadrar na lei violada 7170/83. Ele praticou um crime que interferiu no desenvolvimento do processo eleitoral brasileiro.

Art. 1º - Esta Lei prevê os crimes que lesam ou expõem a perigo de lesão:
II - o regime representativo e democrático, a Federação e o Estado de Direito

Acredito que pelo fato do Brasil ser mais fraco que outros, como por exemplo os EUA (doutrina monroe), e pelo demonstrado nas gravaçoes denunciadas por Delgatti, podemos incluir que ouve também interesse por parte de nação estrangeira na parcialidade do juiz. E na mesma lei temos:

Art. 4º - São circunstâncias que sempre agravam a pena, quando não elementares do crime:
II - ter o agente:
a) praticado o crime com o auxílio, de qualquer espécie, de governo, organização internacional ou grupos estrangeiros;
b) promovido, organizado ou dirigido a atividade dos demais, no caso do concurso de agentes.


Agora observem... como eu estou muito, mas muito puto com o Moro, e os agentes americanos que participaram disso, imagino que todo mundo do país também esteja. E isso gerou descontentamento da polulação brasileira por parte do ato do juiz, portanto:

Art. 8º - Entrar em entendimento ou negociação com governo ou grupo estrangeiro, ou seus agentes, para provocar guerra ou atos de hostilidade contra o Brasil.
Pena: reclusão, de 3 a 15 anos.

E se havia conversas entre os agentes do governo estrangeiro:
Art. 13 - Comunicar, entregar ou permitir a comunicação ou a entrega, a governo ou grupo estrangeiro, ou a organização ou grupo de existência ilegal, de dados, documentos ou cópias de documentos, planos, códigos, cifras ou assuntos que, no interesse do Estado brasileiro, são classificados como sigilosos.
Pena: reclusão, de 3 a 15 anos.

Art. 14 - Facilitar, culposamente, a prática de qualquer dos crimes previstos nos art. 13, e seus parágrafos.
Pena: detenção, de 1 a 5 anos.

E se esse crime foi realizado, não apenas por motivação politica, mas também para enterrar a discussão sobre a prisão em segunda instancia, então também podemos citar:

Art. 16 - Integrar ou manter associação, partido, comitê, entidade de classe ou grupamento que tenha por objetivo a mudança do regime vigente ou do Estado de Direito, por meios violentos ou com o emprego de grave ameaça.

No caso um juiz promover tal atitude, foi grave ameaça ao Estado democrático de direito, já que utilizaou o pararato publico e se associou com outros agentes, perturbando a ordem juridica enganando o povo, alterando a opinião publica usando-se de sua fé publica como juíz.

Além disso, pelo art 95 da constituição, se ele praticou o crime com algum interesse, ele o fez violando aquilho que lhe era vedado:
I -  exercer, ainda que em disponibilidade, outro cargo ou função, salvo uma de magistério;
III -  dedicar-se a atividade político-partidária;

ver também LEI Nº 8906/94, CAPÍTULO IX, Das Infrações e Sanções Disciplinares, Art. 34. Constitui infração disciplinar:
XIV - deturpar o teor de dispositivo de lei, de citação doutrinária ou de julgado, bem como de depoimentos, documentos e alegações da parte contrária, para confundir o adversário ou iludir o juiz da causa.
No caso, o magistrado, como juiz, praticou o ato pra iludir a opinião publica.

XXV - manter conduta incompatível com a advocacia;
que foi a comunicação, de forma parcial, com apenas uma das partes.

Para reforçar:
CPP, Art. 254. O juiz dar-se-á por suspeito, e, se não o fizer, poderá ser recusado por qualquer das partes:
IV - se tiver aconselhado qualquer das partes;
fonte:
https://jus.com.br/artigos/74703/juiz-parcial-e-a-nulidade-do-processo-desde-a-primeira-intervencao-do-magistrado

Bolzonaro, ao levantar outra pauta séria, pode com sua impopularidade acabar derrubando a lei de segurança, o que permitiria Moro escapar.

Só para concluir, adiciono que foi estranho Bolsonaro avisar ao STF que o RISTF 43 iria dar problema aos ministros, pois observando que os ministros tinham obrigação de iniciar investigação por oficio quando Marco Aurelio de Melo deu HC ao André do Rap.



https://www.youtube.com/watch?v=ePNG-OaUU5Q


segunda-feira, 27 de setembro de 2021

Linguagem C: Classificando triangulos pelos pontos dados

A alguns anos fiz um exercicio em que pedia para classificar triangulos de acordo com os pontos dados como isosceles, equilatero, escaleno, retângulo, obtuso ou acutângulo.
Ver exercicio 6:
https://tivideotutoriais.blogspot.com/2020/03/exercicios-antigos-em-linguagem-c.html

Esse modelo mostra o tanto que era novato. Mas agora esse é atualizado, mas para linux:


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

typedef struct
{
    double x;
    double y;
} Ponto;

double semiPitagoras(Ponto p1, Ponto p2)
{
    return (pow(p2.x-p1.x,2) + pow(p2.y-p1.y,2));
}

void triangulo(Ponto p1, Ponto p2, Ponto p3)
{
    double A, B, C, ladoA, ladoB, ladoC;
    char *Classe;
    char *angulo;

    A = semiPitagoras(p1, p2);
    B = semiPitagoras(p2, p3);
    C = semiPitagoras(p3, p1);

    ladoA = sqrt(A);
    ladoB = sqrt(B);
    ladoC = sqrt(C);

    printf("\n");
    printf(" lado A = %.16lf\n", ladoA);
    printf(" lado B = %.16lf\n", ladoB);
    printf(" lado C = %.16lf\n", ladoC);

    if((ladoA == ladoB+ladoC)||(ladoB == ladoC+ladoA)||(ladoC ==ladoB+ladoA))
    {
        printf("\nIsso nao e um triangulo\n");
        exit(1);
    }



    if (ladoA == ladoB == ladoC)
    {
        Classe = "Equilatero";
    }
    else if((ladoA != ladoB)&&(ladoB != ladoC)&&(ladoC !=ladoA))
    {
        Classe = "Escaleno";
    }
    else
    {
        Classe = "Isosceles";
    }

    if (((B + C)==A)||((B + A)==C)||((A + C)==B))
    {
        angulo = "retangulo";
    }
    else if((A-B-C + 2*ladoC*ladoB <0)||(B-A-C + 2*ladoA*ladoB <0)||(C-B-A + 2*ladoC*ladoB <0))
    {
        angulo = "Obtusangulo";
    }
    else
    {
        angulo = "Acutangulo";
    }
    printf("\n Triangulo %s e %s.\n\n",Classe,angulo);
}

int main()
{
    // coordenadas de cada
    // ponto do triangulo
    Ponto p1;
    Ponto p2;
    Ponto p3;

    //equilatero acutangulo
    p1.x=0.0;     p1.y=sqrt(3.0)/2.0;
    p2.x=0.5;    p2.y=0.0;
    p3.x=1.0;     p3.y=sqrt(3.0)/2.0;
    triangulo(p1,p2,p3);

    //isosceles retangulo
    p1.x=0.0; p1.y=0.0;
    p2.x=0.0; p2.y=1.0;
    p3.x=1.0; p3.y=0.0;
    triangulo(p1,p2,p3);

    //isosceles obtusangulo
    p1.x=0.0; p1.y=0.0;
    p2.x=1.0; p2.y=0.0;
    p3.x=0.5; p3.y=0.2;
    triangulo(p1,p2,p3);

    //escaleno obtusangulo
    p1.x=0.0; p1.y=0.0;
    p2.x=1.0; p2.y=0.0;
    p3.x=0.6; p3.y=0.2;
    triangulo(p1,p2,p3);

    return 0;
}


domingo, 26 de setembro de 2021

C e javaScript : Sequência de Fibonacci / Soma n primeiro termos / Encontra termo na posição n

Em linguagem C:


// Em c:
// Para compilar:
// gcc phi.c -o phi -lm

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

// Phi e phi conjugados tal que Phi * phi = 1
#define Phi (1+sqrt(5))/2
#define phi (1-sqrt(5))/2

// Encontra n numero de Fibonacci onde a sequencia começa em 0
int Fib(int n)
{
    return round(( pow(Phi, n) - pow(phi, n) ) / sqrt(5));
}

// Soma dos primeiros n numeros de Fibonacci onde a sequencia começa em 0
int sumPhi(int n)
{
    return Fib(n+2)-1;
}

// Encontra a posição n onde Fib(n)=value
int FindPosition(int value)
{
    return floor(log(value*sqrt(5))/log(Phi));
}

int main()
{
    int a=Fib(7);
    int b=sumPhi(7);
    int c=FindPosition(13);
    printf("numero 7 da sequencia de Fibonacci:%i\n", a);
    printf("soma dos 7 primeiros temos da sequencia de Fibonacci:%i\n", b);
    printf("Numero 13 na posição da sequencia de Fibonacci:%i\n", c);
    return 0;
}

 

Em javaScript:


<script>
// Phi e phi conjugados tal que Phi * phi = 1
// Phi * phi = 1
var Phi= (1+Math.sqrt(5))/2;
var phi= (1-Math.sqrt(5))/2;

// Encontra n numero de Fibonacci onde a sequencia começa em 0
function Fib(n)
{
    return Math.round(( Math.pow(Phi, n) - Math.pow(phi, n) ) / Math.sqrt(5));
}

// Soma dos primeiros n numeros de Fibonacci onde a sequencia começa em 0
function sumPhi(n)
{
    return Fib(n+2)-1;
}

// Encontra a posição n onde Fib(n)=value
function FindPosition(value)
{
    return Math.floor(Math.log(value*Math.sqrt(5))/Math.log(Phi));
}
document.write("Sum = "+sumPhi(8));
</script>

Linguagem C: Método para realizar aproximações de um logaritmo

 #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

// compilar com
// gcc aproxLog.c -o aproxLog -lm
// pra executar no linux:
// ./aproxLog

#define E 2.71828182845904509080
#define radix(x, y) pow(x, 1.0/y)

typedef struct NumeroLog
{
    int *array;
    int qtInteiros; // quantidade
    double base;
    double myLog;
} NumeroLog;

int initNumeroLog(NumeroLog *numero, double b)
{
    numero->base = b;
    numero->array = malloc( sizeof(int) );
    numero->array[0]=0;
    numero->qtInteiros = 1;
    return 1;
}

void farFreeArray(NumeroLog *numero)
{
    if(numero->qtInteiros!=0)
    {
        free(numero->array);
    }
}

void calcLog(NumeroLog *numero, int limite)
{
    while(limite>0)
    {
        if(numero->myLog >= numero->base)
        {
            numero->myLog = numero->myLog/numero->base;
            numero->array = realloc(numero->array, (numero->qtInteiros+1)*sizeof(int) );
            numero->array[numero->qtInteiros]=numero->array[numero->qtInteiros-1];
            numero->qtInteiros++;
        }
        else
        {
            numero->myLog *= numero->myLog;    
            if(numero->array[numero->qtInteiros-1]==0) numero->array[numero->qtInteiros-1]=1;
            else numero->array[numero->qtInteiros-1]++;
        }
        limite--;
    }
}

int imprime(NumeroLog *numero)
{
    double resp=0;
    for(int i=0; i<numero->qtInteiros-1; i++)
    {
        resp+=1.0/pow(2,  numero->array[i]);
        printf(" + (1/pow(2,%i))",  numero->array[i]);
    }
    printf(" + log(%.16lf)/pow(2,%i) \n",  numero->myLog, numero->array[numero->qtInteiros-1]);
    resp+= log(numero->myLog) / pow(2, numero->array[numero->qtInteiros-1]) ;
    printf("resp  =  %.16lf\n" , resp);
}

int main()
{
    // metodo
    // log(A*B) = log(A) + log(B)
    // log(A/B) = log(A) - log(B)  
    // log(A^B) = B*log(A)

    // alguns numeros primos
    int primes[10]={2,3,5,7,11,13,17,19,23,29};
    int tm = sizeof(primes)/sizeof(primes[0]);
    for(int i=0; i<tm; i++)
    {
        printf(" ======================================\n");
        printf("log(%i) = \n",  primes[i]);
        NumeroLog temp;
        temp.myLog=primes[i];
        initNumeroLog(&temp, E);
        calcLog(&temp, 18);
        imprime(&temp);
        farFreeArray(&temp);
    }
    return 0;
}

domingo, 19 de setembro de 2021

Linguagem C: Trabalhando com nós / Lista encadeada

 
//
#include<stdio.h>
#include<stdlib.h>

typedef struct No
{
    int dado;
    struct No *next;
    struct No *before;
}No;

No *createNode(int val)
{
    No *newNode = malloc(sizeof(No));
    newNode->dado = val;
    newNode->next = NULL;
    newNode->before = NULL;
    return newNode;
}

No *insertInitNode(int num, No *Node)
{
    No *novo = malloc(sizeof(No));
    novo->before = NULL;
    novo->next=Node;
    novo->dado=num;
    return novo;
}

No *insertEndNode(int num, No *Node)
{
    No *aux = Node;
    No *novo;
    novo = malloc(sizeof(No));
    novo->dado=num;
    novo->next=NULL;
    while(aux->next!=NULL)
    {
        aux=aux->next;
        if(aux->next==NULL)
        {
            novo->before=aux;
        }
    }
    aux->next=novo;
    return Node;
}

void findInNode(int busca, No *Node)
{
    int contador=1;
    No *aux;
    aux = Node;
    while (aux->next!=NULL && aux->dado!=busca)
    {
        aux = aux->next;
        contador=contador+1;
    }
    if(aux->dado==busca)
    {
        printf("O valor procurado está na posição %d\n",contador);
    }
    else
    {
        printf("O valor procurado não foi encontrado\n");
    }
}

void findAllInNodes(int busca, No *Node)
{
    int contador=1;
    No *aux;
    aux = Node;
    while (aux->next!=NULL)
    {
        aux = aux->next;
        contador=contador+1;
        if(aux->dado==busca)
        {
            printf("O valor procurado está na posição %d\n",contador);
        }
    }
}

No *EditValueNode(int target, int target2, No *Node)
{
    No *aux;
    aux = Node;
    while (aux->next!=NULL && aux->dado!=target)
    {
        aux =  aux->next;
        if (aux!=NULL && aux->dado==target)
        {
            aux->dado=target2;
        }
    }
    return Node;
}

No *EditNode(int target, int value, No *Node)
{
    int contador=1;
    No *aux;
    aux = Node;
    while (aux->next!=NULL && contador!=target)
    {
        aux = aux->next;
        contador=contador+1;
    }
    if(contador==target)
    {
        aux->dado=value;
    }
    else
    {
        printf("No não encontrado\n");
    }
    return Node;
}

No *deleteValueInNode(int target, No *Node)
{
    No *aux;
    aux=Node;
    if(Node->dado==target)
    {
        if(Node->next!=NULL)
        {
            aux=Node->next;
            free(Node);
            Node->dado=aux->dado;
            Node->next=aux->next;
        }
        else
        {
            aux=Node->before;
            free(Node);
            Node->dado=aux->dado;
            Node->next=NULL;
        }
    }
    if(Node->next!=NULL)
    {
        deleteValueInNode(target, Node->next);
    }    
    return Node;
}

No *deleteAllNodes(No *Node)
{
    No *aux;
    aux=Node;
    while(aux->next!=NULL)
    {
        aux = Node->next;
        free(Node);
        Node=aux;
    }
    free(Node);
    Node=NULL;
    return Node;
}

void imprimir(No *Node)
{
    if(Node!=NULL)
    {
        if (Node->next!=NULL);
        {
            No *novo;
            novo=Node->next;
            imprimir(novo);
        }
        printf("Dado = %d\n",Node->dado);
    }
}

int main()
{
    printf("------------------------ createNode\n");
    No *node = createNode(3);
    imprimir(node);
    printf("------------------------ insertInitNode\n");

    node = insertInitNode(2, node);
    node = insertInitNode(2, node);
    node = insertInitNode(1, node);
    imprimir(node);
    printf("------------------------ insertEndNode\n");

    node = insertEndNode(4, node);
    imprimir(node);
    printf("------------------------ findInNode\n");

    findInNode(3, node);
    findInNode(6, node);
    printf("------------------------ findAllInNodes\n");

    findAllInNodes(2, node);
    printf("------------------------ EditValueNode\n");

    node = EditValueNode(2, 3, node);
    imprimir(node);
    printf("------------------------ EditNode\n");

    node = EditNode(4, 6, node);
    imprimir(node);
    printf("------------------------ deleteValueInNode\n");

    node = deleteValueInNode(3, node);
    imprimir(node);
    printf("------------------------ deleteAllNodes\n");

    node = deleteAllNodes(node);
    imprimir(node);
    printf("------------------------\n");

    return 0;
}

sexta-feira, 27 de agosto de 2021

Linguagem C: url Decode ISO-8859-1

Para quem programa em linguagem C e precisou de um urlDecode para ISO-8859-1 irá achar esse fonte útil:


char *matriz[16][16] = {   
    {"^@","^A","^B","^C","^D","^E","^F","^G","^H","^I","<br>","^K",  "^L","^M",  "^N","^O"},
    {"^P","^Q","^R","^S","^T","^U","^V","^W","^X","^Y","^Z","^[", "^\\","^]",  "^^","^_"},
    { " ", "!","\"", "#", "$", "%", "&","\'", "(", ")", "*", "+",   ",", "-",   ".", "/"},
    { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";","&lt;", "=","&gt;", "?"},
    { "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",   "L", "M",   "N", "O"},
    { "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[",  "\\", "]",   "^", "_"},
    { "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",   "l", "m",   "n", "o"},
    { "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{",   "|", "}",   "~","^?"},
    { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ",   " ", " ",   " ", " "},
    { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ",   " ", " ",   " ", " "},
    { " ", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«",   "¬", " ",   "®", "¯"},
    { "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»",   "¼", "½",   "¾", "¿"},
    { "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë",   "Ì", "Í",   "Î", "Ï"},
    { "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û",   "Ü", "Ý",   "Þ", "ß"},
    { "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë",   "í", "ì",   "î", "ï"},
    { "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û",   "ü", "ý",   "þ", "ÿ"}
};

int hex(char x)
{
    if(x=='0'){ return 0;}
    if(x=='1'){ return 1;}
    if(x=='2'){ return 2;}
    if(x=='3'){ return 3;}
    if(x=='4'){ return 4;}
    if(x=='5'){ return 5;}
    if(x=='6'){ return 6;}
    if(x=='7'){ return 7;}
    if(x=='8'){ return 8;}
    if(x=='9'){ return 9;}
    if(x=='A'||x=='a'){ return 10;}
    if(x=='B'||x=='b'){ return 11;}
    if(x=='C'||x=='c'){ return 12;}
    if(x=='D'||x=='d'){ return 13;}
    if(x=='E'||x=='e'){ return 14;}
    if(x=='F'||x=='f'){ return 15;}
    return -1;
}

char hexch(int x)
{
    if(x== 0){ return '0';}
    if(x== 1){ return '1';}
    if(x== 2){ return '2';}
    if(x== 3){ return '3';}
    if(x== 4){ return '4';}
    if(x== 5){ return '5';}
    if(x== 6){ return '6';}
    if(x== 7){ return '7';}
    if(x== 8){ return '8';}
    if(x== 9){ return '9';}
    if(x==10){ return 'A';}
    if(x==11){ return 'B';}
    if(x==12){ return 'C';}
    if(x==13){ return 'D';}
    if(x==14){ return 'E';}
    if(x==15){ return 'F';}
    return '\0';
}

char *dec(int a, int b)
{
    return matriz[a][b];
}
 
int urlDecode(char *out, char *s )
{
    int a, b;
    int tm = strlen(s);
    int remove=0;
    char c, decoded[8];
    strcpy(out, ""); //limpa tudo que tiver em out
    for(int i=0; i<tm; i++)
    {
        c = *s++;
        if (c=='%')
        {
            a = hex(*s++) ;// primeiro hexadecimal
            b = hex(*s++) ;// segundo  hexadecimal
            strcpy(decoded, "");
            strcat(decoded, dec(a,b));
            strcat(out, decoded);
            //nem todos são formados por um
            //unico caractere. Remove ecesso no final
            remove+=strlen(decoded);
        }
        else if (c == '+')
        {
            strcat(out, " ");
        }
        else
        {
            char m[2]={c,'\0'};
            strcat(out, m);
        }
    }
    out[strlen(out)-remove]='\0';
    return strlen(out);
}

void matrixDecode()
{
    printf( "\nMatriz de decodificação:\n");
    for(int i=0; i<16; i++)
    {
        for(int j=0; j<16; j++)
        {
            printf("%c%c=%s\t", hexch(i),hexch(j),dec(i,j));
        }
        printf("\n");
        for(int j=0; j<16; j++)
        {
            printf("%i=%s\t", i*16+j,dec(i,j));
        }
        printf("\n");
        printf("\n");
    }
}

void testaDecode()
{
    printf( "\nTestando decode:\n");
    char *url = "username=%C1gatha+Silva&email=agata%40dasilva.com";
    printf( "url = %s\n", url );
    int tm = strlen(url);
    printf( "tamanho url = %i\n\n", tm);
    char resp[tm];
    tm = urlDecode(resp, url) ;
    printf( "decodificado = %s\n", resp);
    printf( "tamanho do decod = %i\n", tm);
}

int main()
{
    matrixDecode();
    testaDecode();
    return 0;
}


Resultado:

Testando decode:
url = username=%C1gatha+Silva&email=agata%40dasilva.com
tamanho url = 49

decodificado = username=Ágatha Silva&email=agata@dasilva.com
tamanho do decod = 46

Melhorias:

// Melhoria sugerida pelo usuário Flávio Pedroza em
// https://www.clubedohardware.com.br/topic/1560019-existe-c-injection-assim-como-existe-sql-injection/

int hex(char x)
{
    if ((x>='0') && (x<='9')) { return x-48;}
    if ((x>='A') && (x<='F')) { return x-55;}
    if ((x>='a') && (x<='f')) { return x-87;}
    return -1;
}

char hexch(int x)
{
    if ((x>= 0) && (x <= 9)){ return x+48;}
    if ((x>=10) && (x<=15)) { return x+55;}
    return '\0';
}


segunda-feira, 2 de agosto de 2021

Planilhas e Listas em javaScript



Como gosto de desenvolver minhas proprias soluções sem depender de "Office"s, criei meu próprio modo de fazer minha contabilidade, listas de contatos e etc.

Para o uso deste programa, basta entender algumas poucas coisas:

1) Os dados são separados pelo simbolo 'pipe' (|);

2) A primeira linha deve conter os títulos das colunas e as formulas usadas;

3) se qualquer célula da primeira linha não conter colchetes '[' e ']', então ele é uma dado escrito;

4) se qualquer célula da primeira linha conter colchetes '[' e ']', então o dado da coluna é um número;
4.1) se entre o conteúdo dos colchetes for vazio, então ele é um número dado pelo usuário;
4.2) se entre o conteúdo dos colchetes não for vazio, então é um número dado pela operação;
4.2.1) Operações possiveis:
 ! soma
 % soma
 + soma
 - subtração
 * multiplicacao
 / divisão
 ^ potenciação
 r radiciacao
 log logaritmo
4.2.2) Cada operação é dependente de resultados numéricos. As formulas de dentro dos colchetes representam as colunas de onde serão retirados os valores à serem operados. Portanto, se desejar que a coluna seja resultado da soma da coluna 1 com a coluna 2, basta escrever [1+2] seguido do titulo da colula.

5) A ultima linha apresentará a somatória dos valores numéricos de cada coluna.



Exemplos:

Planilha para contabilidades

Com o exemplo de dados capturados de dentro de uma div:
Tipo Joia|[]Preço Unidade|[]Quantidade|[]Qt Vendida|[1*2]Preço*Qt|[1*3]Preço*Qt Vendida|[4-5]Valor Estoque
brinco pequeno|1.5|6|4
brinco médio|2|12|5
brinco Grande|4|18|11
anel fino|1.5|6|4
anel médio|2.5|12|5
anel Grande|4|18|11
pulseira pequena|3.5|6|4
pulseira média|5|12|5
pulseira Grande|7|18|11
colar pequeno|4.5|6|4
colar médio|5|12|5
colar Grande|8|18|11

resultando em:
https://tivideotutoriais.blogspot.com/2021/08/planilha-para-contabilidades-em.html


Lista para buscas de contatos

Nome|[]Idade|Profissão|Telefone|Cidade
Carla|32|Vendedora|0000-0001|?
Carlos|43|Confeiteiro|11 0000-0002|Sao Paulo
Sofia|11|Veterinaria|62 0000-0003|Goiânira
Lucrécia|66|Encanador|61 0000-0004|Brasília
Marco|80|Pedreiro|0000-0005|Caldas Novas

resultando em:
https://tivideotutoriais.blogspot.com/2021/08/nomeidadeprofissaotelefonecidade.html

Planilha para contabilidades em javaScript

Fonte:

<div id="dados"  style="visibility:hidden;" >Tipo Joia|[]Preço Unidade|[]Quantidade|[]Qt Vendida|[1*2]Preço*Qt|[1*3]Preço*Qt Vendida|[4-5]Valor Estoque<br />
brinco pequeno|1.5|6|4<br />
brinco médio|2|12|5<br />
brinco Grande|4|18|11<br />
anel fino|1.5|6|4<br />
anel médio|2.5|12|5<br />
anel Grande|4|18|11<br />
pulseira pequena|3.5|6|4<br />
pulseira média|5|12|5<br />
pulseira Grande|7|18|11<br />
colar pequeno|4.5|6|4<br />
colar médio|5|12|5<br />
colar Grande|8|18|11<br />
</div>

<div id="modal" style="position:fixed; visibility:hidden; font-family:Arial,Helvetica,sans-serif; top:10px;
left:10px; right:10px;"><table id="fundo" style="position:absolute;  width:100%;
border:1px solid #003366;" ><tr><td id="top_panel" valign="top" colspan="2" height=20
style="position:relative; border:1px solid #003366;"></td>   </tr>
<tr><td   valign="top"  width=320 style="position:relative; border:1px solid #003366;
" ><div id="form_titulo"  style="position:relative; top:0px;  padding:5px; left:0px; right:0px; 
font-size:10pt; font-weight:bold;"  ></div><div id="form_panel"  
style="position:relative; top:0px; bottom:0px;  left:0px; right:0px; 
font-size:10pt; overflow:scroll; width:100%;"></div></td>
<td valign="top" style="position:relative; border:1px solid #003366;" ><div id="table_titulo"
style="position:relative; top:0px;  padding:5px; left:0px; right:0px; 
font-size:10pt; font-weight:bold;"  ></div><div id="table_labels"
style="position:relative; top:0px; left:0px; right:13px; font-size:8pt;
width:100%;" ></div><div id="table_panel"  style="position:absolute; top:55px; bottom:0px; 
left:0px; right:0px;  font-size:8pt; overflow:scroll; width:100%;" ></div></td></tr>
<tr><td   id="buttons_panel" valign="top" colspan="2" height=60 style="position:relative;
border:1px solid #003366;"></td></tr></table></div>
<script>
 //======================================================================================================
 // Inicio
 //======================================================================================================
 dimensoes  = ["20%","10%","10%","15%","15%","15%", "15%"]

//======================================================================================================
 // dados
 //======================================================================================================
 var data;

 //======================================================================================================
 // cores
 //======================================================================================================
 var c0 ="#000000";
 var c1 ="#001133";
 var c2 ="#113355";
 var c3 ="#226699";
 var c4 ="#3399cc";
 var c5 ="#77bbdd";
 var c6 ="#ccddee";
 var c7 ="#FFFFFF";

 //======================================================================================================
 // formularios, tabelas, paineis
 //======================================================================================================
 var fundo  = document.getElementById("fundo");
 var top_panel  = document.getElementById("top_panel");
 var buttons_panel = document.getElementById("buttons_panel");
 var table_panel   = document.getElementById("table_panel");
 var table_titulo  = document.getElementById("table_titulo");
 var table_labels  = document.getElementById("table_labels");
 var form_panel    = document.getElementById("form_panel");
 var form_titulo   = document.getElementById("form_titulo");

 //======================================================================================================
 // acerta cores
 //======================================================================================================
 top_panel.style.backgroundColor  = c5;
 buttons_panel.style.backgroundColor = c5;
 form_titulo.style.backgroundColor = c2;
 table_titulo.style.backgroundColor = c2;
 table_labels.style.backgroundColor = c3;
 table_panel.style.backgroundColor = c4;
 form_panel.style.backgroundColor = c4;
 fundo.style.backgroundColor  = c4;

 //======================================================================================================
 // botoes e regras de modo de visualizaçao e edicao
 //======================================================================================================
 var buttons_metadados = new Array();

 buttons_metadados[0] = new Object();
 buttons_metadados[0].value = "Localizar";
 buttons_metadados[0].action = "Localizar";
 buttons_metadados[0].array_visibilidade = [1,0];

 buttons_metadados[1] = new Object();
 buttons_metadados[1].value = "Limpar";
 buttons_metadados[1].action = "Limpar";
 buttons_metadados[1].array_visibilidade = [1,1];

 buttons_metadados[2] = new Object();
 buttons_metadados[2].value = "Fechar";
 buttons_metadados[2].action = "About_Source";
 buttons_metadados[2].array_visibilidade = [1,1];

 //======================================================================================================
 // troca todas as strings (sequência de caracteres) dadas por uma outra
 //======================================================================================================
 function replaceAll(str, find, replace)
 {
    return str.replace(new RegExp(find, 'g'), replace);
 }

 //======================================================================================================
 // Fecha Botão
 //======================================================================================================
 function buttonClose()
 {
   if(document.getElementById("modal").style.visibility=="visible") 
    document.getElementById("modal").style.visibility = "hidden"
   else
    document.getElementById("modal").style.visibility="visible"
 }

 //======================================================================================================
 // encontra string dentro de outra com regex simples
 //======================================================================================================
 isContentInString = function( find, str )
 {
    return  str.match(find)
 }

 //======================================================================================================
 // converter string em dados
 //======================================================================================================
 stringToArray = function(str)
 {

str = replaceAll(str , "\\n", '\<br\>')
str = replaceAll(str , "\<br\/\>", '\<br\>')
str = replaceAll(str , "\<br\>", '\<br\>')
str = replaceAll(str , "\<br\>\<br\>", '\<br\>')


  var array_resposta = new Array();
  var array1 = str.split("\<br\>");

  //pega o nome dos campos:
  var Array_labels = array1[0].split("|");
  array_resposta.push(Array_labels);

  for(var i=1; i<array1.length-1; i++)
  {
    var array2 = array1[i].split("|");

    for(var j=0; j<Array_labels.length; j++)
    {
        if(Array_labels[j].charAt(0)=='[' && Array_labels[j].charAt(1)!=']')
        {

            var objRegex = /\[((([0-9]*)|([0-9]*\.[0-9]*))([r!%\*\+-^\/]|log)(([0-9]*)|([0-9]*\.[0-9]*))|(([0-9]*)|([0-9]*\.[0-9]*)))\]/ig ;
            var resp = ""+Array_labels[j].match(objRegex)

            resp = resp.substring(1,resp.length-1)

            var objRegex2 = /([r!%\*\+\-^\/]|log)/ig ;
            n = resp.search(objRegex2)



            if(resp.charAt(n)=='%')
            {
                var r = resp.split('%')   
                a = Number(array2[Number(r[0])])
                b = Number(array2[Number(r[1])])
                resp= a%b
            }
            if(resp.charAt(n)=='!')
            {
                var r = resp.split('!')   
                resp = Number(array2[Number(r[0])])
                for(var k=resp-1; k>0; k--)
                resp= resp*k
            }

            else if(resp.charAt(n)=='-')
            {
                var r = resp.split('-')
                a = Number(array2[Number(r[0])])
                b = Number(array2[Number(r[1])])
                resp= a-b
            }

            else if(resp.charAt(n)=='+')
            {
                var r = resp.split('+')
                a = Number(array2[Number(r[0])])
                b = Number(array2[Number(r[1])])
                resp= a+b
            }
            else if(resp.charAt(n)=='*')
            {
                var r = resp.split('*')
                a = Number(array2[Number(r[0])])
                b = Number(array2[Number(r[1])])
                resp= a*b
            }
            else if(resp.charAt(n)=='/')
            {
                var r = resp.split('/')
                a = Number(array2[Number(r[0])])
                b = Number(array2[Number(r[1])])
                resp= a/b
            }
            else if(resp.charAt(n)=='^')
            {
                var r = resp.split('^')
                a = Number(array2[Number(r[0])])
                b = Number(array2[Number(r[1])])
                resp= Math.pow(a,b)
            }
            else if(resp.charAt(n)=='r')
            {
                var r = resp.split('r')
                a = Number(array2[Number(r[0])])
                b = Number(array2[Number(r[1])])
                resp= Math.pow(a,1/b)
            }
        }

        else if(Array_labels[j].charAt(0)=='[' )
        {
            resp= Number(array2[j])
        }
        else
        {
            resp =array2[j] ;
        }
           
        array2[j]=resp
       
    }

       array_resposta.push(array2);
  }
  return array_resposta;
 }

 //======================================================================================================
 // converter dados em string
 //======================================================================================================
 dataToString = function(d)
 {
  resp=""
  for(var i=0; i<d.length; i++)
  {
   for(var j=0; j<d[i].length; j++)
   {
    if(j<d[i].length-1)
     resp+=d[i][j]+"|";
    else
     resp+=d[i][j]+"\<br\>";
   }
  }
  return resp;
 }

 //======================================================================================================
 // excluindo colunas
 //======================================================================================================
 dataToString2 = function(d)
 {
  var d_novos = [0, 2, 4, 5, 6, 9, 10, 12, 14, 15]
  var resp=""
  for(var i=0; i<d.length; i++)
  {
   for(var j=0; j<d_novos.length; j++)
   {
    if(j<d_novos.length-1)
     resp+=d[i][d_novos[j]]+"|";
    else
     resp+=d[i][d_novos[j]]+"\<br\>";
   }
  }
  return resp;
 }

 //======================================================================================================
 // executa função pelo nome
 //======================================================================================================
 function executeFunctionByName(functionName, context /*, args */)
 {
  var args = Array.prototype.slice.call(arguments, 2);
 
  var namespaces = functionName.split(".");
  var func = namespaces.pop();
  for(var i = 0; i < namespaces.length; i++)
  {
   context = context[namespaces[i]];
  }
  return context[func].apply(context, args);
 }

 //======================================================================================================
 // cria botões
 //======================================================================================================
 createButtons = function(metadados, buttons_panel)
 {
  for(var i=0; i<metadados.length; i++)
  {
   var btn = document.createElement("input");
   btn.type = "button"
   btn.style.margin = 3
   buttons_panel.appendChild(btn)
   btn.action = metadados[i].action
   btn.onclick = function(){executeFunctionByName(this.action, window)}
   btn.array_visibilidade = metadados[i].array_visibilidade
   btn.value = metadados[i].value
  }
 }

 //======================================================================================================
 // cria labels
 //======================================================================================================
 createLabels = function(labels, dimensoes)
 {
  var t=document.createElement("table");

  t.style.top                 = "0px";
  t.style.rigth               = "0px";
  t.style.width="100%";

  var row = t.insertRow(0);
  var k=0;
  for(var i=0; i<labels.length; i++)
  {
   k=i;
           var col    = row.insertCell(i);
   col.style.width   = dimensoes[i];

    if(labels[i].charAt(0)=='[')
    label = "&nbsp;"+labels[i].split("]")[1]
    else
    label = "&nbsp;"+labels[i]

   col.innerHTML   = label;

   col.style.border  = "1px solid "+c1;
   col.style.backgroundColor = c5;
   col.style.fontFamily  = "Arial,Helvetica,sans-serif";
   col.style.fontSize  = "8pt";
   col.style.height  = 25;
   col.style.color   = c0;
  }

  col = row.insertCell(k+1); 
  col.innerHTML=" ";
  col.style.width="16px";
  col.style.border="1px solid "+c3;
  col.style.backgroundColor= c4;
  col.style.fontFamily="Arial,Helvetica,sans-serif";
  col.style.fontSize="8pt";
  return t;
 }

 //======================================================================================================
 // cria table
 //======================================================================================================
 createTable = function(titulo, labels, dimensoes)
 {
  table_titulo.innerHTML=titulo;
  table_titulo.style.color=c7 


  document.getElementById("table_labels").appendChild( createLabels(labels, dimensoes)  )

  var tableDados = document.createElement("table");

  tableDados.style.position            ="absolute"; 
  tableDados.style.top                 = "0px";

  tableDados.cellSpacing="0px";
  tableDados.cellPadding="0px";
  tableDados.style.width="100%";
  tableDados.style.fontFamily="Arial,Helvetica,sans-serif";
  tableDados.style.fontSize="8pt";

  table_panel.appendChild( tableDados );

  tableDados.Limpar = function()
  {
   for(var i=0; i<data[0].length; i++)
   {

    if(data[0][i].charAt(0)=='[')
    {
     document.getElementById("input_0_"+i).value="";
     document.getElementById("input_0_"+i+"_A").value="";
     document.getElementById("input_0_"+i+"_B").value="";
    }
    else if(data[0][i].charAt(0)!='[')
    {

    document.getElementById("input_0_"+i).value="";
    document.getElementById("input_0_"+i+"_x").checked=false;
    }

   }
   tableDados.deselecionar();
  }
 
  tableDados.getSelectedRow = function()
  {
   return tableDados.selected_row;
  }

  tableDados.getIntColunName=function(str)
  {
   var j = tableTitulos.getElementsByTagName('tr')[0].getElementsByTagName('td');
   for(var i=0;i<j.length;i++)
   {
    if(j[i]==str)
    return i;
   }
  }
 
  tableDados.removeAll=function() 
  {
   for(var y=0; y<tableDados.getElementsByTagName('tr').length; y++)
   {
    for(var x=0; x<tableDados.getElementsByTagName('tr')[y].getElementsByTagName('td').length;x++)
    {
     tableDados.getElementsByTagName('tr')[y].getElementsByTagName('td')[x].innerHTML="&nbsp;";
     tableDados.getElementsByTagName('tr')[y].getElementsByTagName('td')[x].style.backgroundColor=c4;
    }
   }
  }

  tableDados.deselecionar=function()
  {
   TRs=this.getElementsByTagName('tr');
   for(var h=0;h<TRs.length;h++)
   {
    TDs=TRs[h].getElementsByTagName('td');
    for(var h2=0; h2<TDs.length; h2++)
    {
     if(TDs[0].innerHTML=="Totais")
     {
      TDs[h2].style.backgroundColor=c6;
     }
     else
     {
      TDs[h2].style.backgroundColor=c7;
     }
    }
   }
  }


tableDados.setData=function(data)
{
    var qt = this.rows.length
    while(qt>0)
    {
        this.deleteRow(qt-1);
        qt = this.rows.length
    }


    //====================================================
    //
    //====================================================
    for(var y=0; y<data.length-1; y++)
    {
        var row=tableDados.insertRow(y);
        for(var i=0; i<data[0].length; i++)
        {
            var col=row.insertCell(i);
            col.innerHTML="&nbsp;";
            col.style.width=dimensoes[i];
            col.style.padding="2px";
            col.style.borderBottom="1px solid "+c2;
            col.style.borderLeft="1px solid "+c2;
            col.style.backgroundColor=c4;
  
            //=========================================================
            // Click Linha
            //=========================================================
            col.onclick=function()
            {
                tableDados.deselecionar();
                tableDados.selected_row = this.line;
                for(var h=0; h<data[0].length; h++)
                {
                    //para todas as colunas mostro o conteúdo nas propriedades
                    //if(data[0][h].charAt(0)=='[')
                    document.getElementById("input_0_"+h).value = this.parentNode.getElementsByTagName('td')[h].innerHTML
                   
                       
                    //para todas as colunas mudo a cor do fundo da linha selecionada
                    this.parentNode.getElementsByTagName('td')[h].style.backgroundColor = c5;
                }
            }
        }
    }

    for(var y=1; y<data.length; y++)
    {
        for(var x=0; x<data[y].length; x++)
        {
            tableDados.getElementsByTagName('tr')[y-1].getElementsByTagName('td')[x].line=y-1
            tableDados.getElementsByTagName('tr')[y-1].getElementsByTagName('td')[x].innerHTML=data[y][x];
            tableDados.getElementsByTagName('tr')[y-1].getElementsByTagName('td')[x].style.backgroundColor=c7;
        }
    }

    //====================================================
    // totais
    //====================================================
    var row=tableDados.insertRow(data.length-1);
    for(var i=0; i<data[0].length; i++)
    {
        var col=row.insertCell(i);
        col.style.width=dimensoes[i];
        col.style.padding="2px";
        col.style.borderBottom="1px solid "+c2;
        col.style.borderLeft="1px solid "+c2;
        col.style.fontWeight="bold";

        if(i==0)
        {
            col.innerHTML="Totais" ;
        }
        else if(data[0][i].charAt(0)=='[')
        {
            resp=0;
            for(var q=1; q<data.length; q++)
            {
                resp+=data[q][i]
            }

            if(resp>0)
                col.style.color="000066";
            else
                col.style.color="cc0000";

            col.innerHTML=resp ;
        }
        else
        {
            col.style.textAlign = "center";
            col.innerHTML="-" ;
        }
    }


    tableDados.deselecionar(); 
}



  //======================================================================================================
  // Localizar
  //======================================================================================================
  tableDados.Localizar = function()
  {
   var str_data = document.getElementById('dados').innerHTML;
   var data = stringToArray(str_data)

   var new_data = new Array();

   //pega nome das colunas
   new_data[0] = data[0]

   //pega conteudo dos dados
   for(var y=1; y<data.length; y++)
   {
    var add = true;

    zero_data = new Array()

    for(var i=0; i<new_data[0].length; i++)
    {
     var v = document.getElementById("input_0_"+i).value
     if( v!="" && new_data[0][i].charAt(0)=='[' )
     {
      if( Number(data[y][i]) == Number(v) )
      {
       zero_data.push(data[y][i])
      }
      else
      {
       add=false;
       i = new_data[0].length
      } 
     }
     else
     {
      if(new_data[0][i].charAt(0)=='[')
      {
       var v1 = document.getElementById("input_0_"+i+"_A").value
       var v2 = document.getElementById("input_0_"+i+"_B").value
 
       if(v1=="" && v2=="")
       {
        zero_data.push(data[y][i])    
       }
       else if(v1!="" && v2=="")
       {
        if( Number(v1) < Number(data[y][i]) )
        {
         zero_data.push(data[y][i])
        }
        else
        {
         add=false;
         i = new_data[0].length
        }
       }
       else if(v1=="" && v2!="")
       {
        if( Number(data[y][i]) < Number(v2) )
        {
         zero_data.push(data[y][i])
        }
        else
        {
         add=false;
         i = new_data[0].length
        }
       }
       else if( v1!="" && v2!="" )
       {
        if( Number(v1) < Number(data[y][i]) && Number(data[y][i]) < Number(v2) )
        {
         zero_data.push(data[y][i])
        }
        else
        {
         add=false;
         i = new_data[0].length
        }
       }
      }
      else
      {
       v1 = document.getElementById("input_0_"+i).value

       if(!document.getElementById("input_0_"+i+"_x").checked)
       {

        v1 = v1.normalize("NFD").replace(/[\u0300-\u036f]/g, "")
        v2 = data[y][i].normalize("NFD").replace(/[\u0300-\u036f]/g, "")
        reg = new RegExp(v1, "i")
         if(isContentInString( reg, v2 )!=null && isContentInString( reg, v2 ))
         {
          zero_data.push(data[y][i])
         }
         else
         {
          add=false;
          i = new_data[0].length
         }
       }
       else
       {
        if( v1!="" && data[y][i].toUpperCase() == v1.toUpperCase() )
        {
         zero_data.push(data[y][i])
        }
        else if(v1=="")
        {
         zero_data.push(data[y][i])
        }
        else
        {
         add=false;
         i = new_data[0].length
        }

       }
      }
     }
    }
    if(add)
    {
     new_data.push(zero_data)
    }
   }
   tableDados.removeAll()
   tableDados.setData(new_data)
  }
  return tableDados;
 }




 //======================================================================================================
 // cria form
 //======================================================================================================
 createForm = function(titulo, labels)
 {
  form_titulo.innerHTML=titulo;
  form_titulo.style.color=c7

  for(var i=0; i<labels.length; i++)
  {
   if(labels[i].charAt(0)=='[')
   {

    var campo =document.createElement("div");
    campo.style.padding=5
    campo.style.background=c6
    campo.style.fontSize="8pt";

    label = labels[i].split("]")[1]
    campo.innerHTML="<span id='label_"+0+"_"+i+"'>"+ label +"</span> = <input type='text' id='input_"+0+"_"+i+"' style='position:absolute; font-Size:8pt; background-color:#FFFFFF; left:90px; width:90px;'></BR>"
    form_panel.appendChild(campo);

    var campo=document.createElement("div");
    campo.style.padding=5
    campo.style.background=c6
    campo.style.fontSize="8pt";
    campo.innerHTML="Ou entre:<input type='text' id='input_"+0+"_"+i+"_A' style='position:absolute; font-Size:8pt; left:90px; width:90px; background-color:#DDDDDD;'> <input type='text' id='input_"+0+"_"+i+"_B' style='position:absolute; font-Size:8pt; left:200px; width:90px; background-color:#DDDDDD;'></BR></BR>"
    form_panel.appendChild(campo);
   }

   else
   {
    var campo=document.createElement("div");
    campo.style.padding=5
    campo.style.background=c6
    campo.style.fontSize="8pt";
    campo.innerHTML="<span id='label_"+0+"_"+i+"'>"+labels[i]+"</span>:<input type='text' id='input_"+0+"_"+i+"' style='position:absolute; font-Size:8pt; left:90px; width:90px;background-color:#FFFFFF;'> <span style='position:absolute; font-Size:8pt; left:200px; '>Busca exata?</span><input type='checkbox' id='input_"+0+"_"+i+"_x' style='position:absolute; font-Size:8pt; left:270px; width:20px;'></BR></BR>"
    form_panel.appendChild(campo);
   }
  }
 }


//======================================================================================================
// eventos de botões
//======================================================================================================
Localizar = function()
{
    table.Localizar()
}

Limpar = function()
{
    table.Limpar()
}

About_Source = function()
{
    document.getElementById("modal").style.visibility = "hidden"
    alert("Produzido por Luiz Augusto Prado\nFaça uma contribuição para mais novidades.\nContato:\ntivideotutoriais.blogspot.com.br")
}


var str_dados = document.getElementById('dados').innerHTML;

data = stringToArray(str_dados)
//ou document.getElementById('dados').innerHTML = dataToString( data )
//alert( dataToString( data ) )
//alert( str_dados)

createButtons(buttons_metadados, buttons_panel)
createForm("Buscar por", data[0])
table = createTable("Lista", data[0], dimensoes)
table.setData(data)

//document.getElementById("dados").value = dataToString2(data)
</script>
<button onclick="buttonClose()">Abrir</button>