Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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

Robson Alves robsonalves

🏠
Working from home
View GitHub Profile
with TotalSolicitacoes as (select * from cesuh.tb_solicitacao sol where
((:DE IS NULL) OR
(TRUNC(sol.DT_SOLICITACAO) >= TO_DATE(:DE, 'DD/MM/YYYY') AND
TRUNC(Sol.DT_SOLICITACAO) <= TO_DATE(:ATE,'DD/MM/YYYY')))
AND ((sol.CD_DIRETORIA = :CD_DIRETORIA) or (:CD_DIRETORIA is null)))
,
TotalAtestadosEnsinoFund as (select Count(1) Qtd from TotalSolicitacoes where cd_tipo_documento = 3 and (CD_TIPO_ENSINO = 1))
,
TotalAtestadoEnsinoMedio as (select Count(1) Qtd from TotalSolicitacoes where cd_tipo_documento = 3 and CD_TIPO_ENSINO = 2)
,
@robsonalves
robsonalves / instanceof
Last active August 29, 2015 14:19
instanceof Practice
function ValidException(number, message) {
this.message = message;
this.name = "Teste prático";
this.number = number;
}
function LogicException(number, message) {
this.message = message;
this.name = "Teste prático";
this.number = number;
@robsonalves
robsonalves / sql
Created October 6, 2015 15:10
SELECT XLSX
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
GO
<!doctype html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>GetUserMedia HTML5 with Photo :D Smile!</title>
</head>
<body>
<button id="takePicture">Sorria! e clique</button><br />
<video id="videoWebCamera"></video>
<canvas id="canvas" style="display:none;"></canvas>
@robsonalves
robsonalves / nodejs-tcp-example.js
Created October 15, 2015 12:36 — forked from tedmiston/nodejs-tcp-example.js
Node.js tcp client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@robsonalves
robsonalves / gist:931eb5f0ac42c148b758
Last active October 20, 2015 17:51
Rotinas de sql para aprimorar performance na VM Azure
--====================================================================
-- DAC Connection em caso de emergência e o banco ficar travado, o usuário Admin não trava --
--====================================================================
/*
sp_configure 'remote admin connections', 1;
GO
RECONFIGURE;
GO
*/
@robsonalves
robsonalves / gist:69d389f57925cb217d63
Last active October 21, 2015 13:22
Retorna os planos de execução em cache
set transaction isolation level read uncommitted
SELECT TOP 20
st.text as [SQL]
, cp.cacheobjtype
, cp.objtype
, COALESCE(DB_NAME(st.dbid), db_name(cast(pa.value as int))+ '*', 'Resource') as DataBaseName
, cp.usecounts as [Plan Usage]
, qp.query_plan
from sys.dm_exec_cached_plans cp
@robsonalves
robsonalves / IndexesNaoUtilizados.sql
Last active October 21, 2015 13:22
Indexes não utilizados
select
db_name() as DataBaseName
,SCHEMA_NAME(O.schema_id) as SchemaNAme
,OBJECT_NAME(I.object_id) as TableName
,I.Name as IndexName
from sys.indexes I
inner join sys.objects O on I.object_id = O.object_id
left outer join sys.dm_db_index_usage_stats S on S.object_id = I.object_id
and I.index_id = S.index_id and database_id = DB_ID()
where OBJECTPROPERTY(o.object_id,'IsMsShipped') = 0
@robsonalves
robsonalves / indiceseconversao.sql
Last active October 21, 2015 13:34
Encontrar Falta de Indices e Conversão Implicita
SET TRANSACTION isolation level READ uncommitted
SELECT TOP 20 ST.text AS [PARENT QUERY],
Db_name(ST.dbid) AS [ DATABASENAME ],
CP.usecounts AS [USAGE COUNT],
QP.query_plan
FROM sys.dm_exec_cached_plans CP
CROSS apply sys.Dm_exec_sql_text(CP.plan_handle) ST
CROSS apply sys.Dm_exec_query_plan(CP.plan_handle) QP
WHERE Cast(QP.query_plan AS NVARCHAR(max)) LIKE '%<MissingIndexes>%' or
@robsonalves
robsonalves / Remover All Columns.sql
Last active October 21, 2015 15:57
Remover All Columns
declare @query varchar(max) = ''
DECLARE @Remove nvarchar(1000)
select 'ALTER TABLE '+ a.name + ' drop column ' + b.name + '' as Remove
into #temp
from sys.tables a
inner join sys.columns b on b.object_id = a.object_id
where b.name like '%ROW%'