Skip to content

Instantly share code, notes, and snippets.

View brunotdantas's full-sized avatar
🏠
Working from home

Bruno Dantas brunotdantas

🏠
Working from home
View GitHub Profile
@brunotdantas
brunotdantas / test.js
Last active March 4, 2020 14:24
To test https://github.com/typicode/lowdb #Json #database #local #storage #localstorage #localdb
'use strict'
/* steps to use this test file:
1- install package lowdb : npm install lowdb
2- create a file empty data.json
3- manipulate the variable option to test the scenarios you want
*/
@brunotdantas
brunotdantas / server-info.sql
Created March 9, 2020 14:18
SQL INFORMATION SERVER SCRIPT
--https://docs.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql?view=sql-server-2017
-- 07/06/2019
SELECT
SERVERPROPERTY('BuildClrVersion') AS BuildClrVersion,
SERVERPROPERTY('Collation') AS Collation,
SERVERPROPERTY('CollationID') AS CollationID,
SERVERPROPERTY('ComparisonStyle') AS ComparisonStyle,
SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS ComputerNamePhysicalNetBIOS,
@brunotdantas
brunotdantas / script.sql
Last active January 27, 2025 18:52
Hash SQL SERVER table row
-- https://stackoverflow.com/questions/11186183/hash-a-sql-row/54789730#54789730
drop table if exists #table1;
create table #table1 (
campo varchar(10)
,campo1 varchar(10)
)
drop table if exists #table2;
create table #table2 (
@brunotdantas
brunotdantas / PIVOT_exemplo.sql
Last active September 21, 2021 15:47
[T-SQL] - PIVOT tabela dinâmica SQL T-SQL exemplo #SQL SERVER
USE INTEGRADOR
GO
SELECT Dia, [Linx Venda] as Linx,[Integ. Venda] as Integrador,[L1 Venda OK] as Protheus,
[Linx Venda]-[Integ. Venda] as 'Linx - Integrador',
[Integ. Venda]-[L1 Venda OK] as 'Integrador - Protheus',
[Linx Venda]-[L1 Venda OK] as 'Linx - Protheus'
FROM (select Dia, Origem, QtdDoc from [VW_ConsultaIntegracao] where Dia > GETDATE()-3) as consulta
Pivot
(
@brunotdantas
brunotdantas / getdate.bat
Last active September 27, 2021 18:30
get date bat file
rem Primeiro descubra o formato que o servidor está rodando o comando echo %date%
rem e aplique uma das funcionalidades abaixo
rem para PT-br
rem Transforma data em formato dd/mm/YYYY em YYYYmmDD, ou seja, 27/09/2021 em 20210927
rem a ténica abaixo é basicamente um substring
set year=%date:~6,4%
set month=%date:~3,2%
set day=%date:~0,2%
set pt_br_today=%year%%month%%day%
@brunotdantas
brunotdantas / identity.sql
Created September 29, 2021 20:02
Add coluna id após criar a tabela, normalmente é util em situações que você precisa fazer um looping pela tabela criada
DROP TABLE IF EXISTS #VENDEDORES_ATIVOS;
SELECT Distinct
B.COD_VENDEDOR
,B.CODIGO_FILIAL
,A.CPF
INTO #VENDEDORES_ATIVOS
FROM #TMP_VENDEDORES_ATIVOS A
INNER JOIN TB_AUX_LNX_VENDEDOR B ON LTRIM(RTRIM(B.CPF)) = LTRIM(RTRIM(A.CPF))
WHERE
-- REGRAS CPFs VALIDOS
@brunotdantas
brunotdantas / BotTelegram.py
Created October 6, 2021 17:36
BotTelegram
#fonte https://devaprender.com/como-criar-um-bot-no-telegram/
import requests
import time
import json
import os
class TelegramBot:
def __init__(self):
token = 'seutoken'
@brunotdantas
brunotdantas / gist:58fe9180ec4c5528e5318516877ac503
Created November 19, 2021 01:03
POWER BI - Tabela calendário DAX
dCalendario =
ADDCOLUMNS(
CALENDARAUTO();
"Ano";FORMAT([Date];"yyyy");
"Trimestre";FORMAT([Date];"q");
@brunotdantas
brunotdantas / mapsqlserver.sql
Last active December 23, 2021 17:46
SQL SERVER - MAP PROCEDURES AND FUNCTIONS COLUMNS AND TABLES
-- 23/12/2021 - Bruno
drop table if exists #resouce_mapping ;
select distinct
s.name as schema_name
,o.type_desc as resource_type
,p.name as resource_name
,t.name as table_name
,c.name as column_name
,ty.name as type
,c.max_length
@brunotdantas
brunotdantas / MSSQL_RepetitiveReplace_fn.sql
Created January 28, 2022 14:59 — forked from jkdba/MSSQL_RepetitiveReplace_fn.sql
Simple function to recursively replace a pattern in a string.
CREATE FUNCTION dbo.RepetitiveReplace_fn
(
@P_String VARCHAR(MAX),
@P_Pattern VARCHAR(MAX),
@P_ReplaceString VARCHAR(MAX),
@P_ReplaceLength INT = 1
)
RETURNS VARCHAR(MAX)
BEGIN
DECLARE @Index INT;