Skip to content

Instantly share code, notes, and snippets.

View DanielAdeniji's full-sized avatar

Daniel Adeniji DanielAdeniji

View GitHub Profile
BEGIN TRANSACTION;
GO
CREATE TABLE [AspNetRoles] (
[Id] nvarchar(450) NOT NULL,
[Name] nvarchar(256) NULL,
[NormalizedName] nvarchar(256) NULL,
[ConcurrencyStamp] nvarchar(max) NULL,
CONSTRAINT [PK_AspNetRoles] PRIMARY KEY ([Id])
);
@spaghettidba
spaghettidba / testPFCLNT.ps1
Created August 26, 2019 14:54
Trace DLLs
#
# RUN THIS CODE IN Powershell x86 !!!!!
#
$dllPath = "C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\PFCLNT.DLL"
$typeName = "Microsoft.SqlServer.Management.Trace.CTraceObjectsFileController"
try {
#
# this is the code found in Microsoft.SqlServer.Management.Trace.TraceFile.InitializeAsReader (thanks DotPeek...)
/*
* Creates an XEvent session utilizing the 'Trace' event added to SQL 2016
* This event will capture the protocol negotiation details of all TLS connections
* This allows you to capture how many connections are being made and with what
* protocol version and cipher.
* This information can be used to predict the impact of disabling a given
* protocol version or cipher suite before taking such actions.
*/
CREATE OR ALTER PROCEDURE usp_get_tls_connection_stats
@RulerOf
RulerOf / get-sshfingerprint.ps1
Created January 31, 2019 20:49
Get SSH host key fingerprint using PowerShell. Requires the WinSCP .Net assembly.
function Get-SshFingerprint {
param( [string]$ssh_server )
# Load WinSCP .NET assembly
Add-Type -Path "${env:ProgramFiles(x86)}\WinSCP\WinSCPnet.dll"
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = $ssh_server
@LitKnd
LitKnd / Execution-Cache-Single-Use-Plans-Explore.sql
Created January 31, 2017 17:50
TSQL to do a quick and dirty look at single-use plans in the execution plan cache of a SQL Server.
/***********************************************************
TSQL to do a quick and dirty look at single-use plans in
the execution plan cache of a SQL Server.
************************************************************/
/* Size of single use adhoc plans in execution plan cache */
SELECT
objtype,
cacheobjtype,
SUM(size_in_bytes)/1024./1024. as [MB]
@AlbertoMonteiro
AlbertoMonteiro / readme.md
Last active August 17, 2021 02:50
AWS Importing and Exporting SQL Server Databases
-- List enabled server specifications
SELECT audit_id,
a.name as audit_name,
s.name as server_specification_name,
d.audit_action_name,
s.is_state_enabled,
d.is_group,
d.audit_action_id,
s.create_date,
s.modify_date
@PeteGoo
PeteGoo / Send-UdpDatagram.ps1
Last active December 29, 2023 00:07
Sending UDP datagrams in powershell
function Send-UdpDatagram
{
Param ([string] $EndPoint,
[int] $Port,
[string] $Message)
$IP = [System.Net.Dns]::GetHostAddresses($EndPoint)
$Address = [System.Net.IPAddress]::Parse($IP)
$EndPoints = New-Object System.Net.IPEndPoint($Address, $Port)
$Socket = New-Object System.Net.Sockets.UDPClient
@sebastianwebber
sebastianwebber / generate_series.sql
Last active July 28, 2019 00:12
SQL Server generate_series
-- http://blog.jooq.org/2013/11/19/how-to-create-a-range-from-1-to-10-in-sql/
IF EXISTS (SELECT *
FROM dbo.sysobjects
WHERE id = object_id (N'[dbo].[generate_series]')
AND OBJECTPROPERTY(id, N'IsTableFunction') = 1)
DROP FUNCTION [dbo].[generate_series]
GO
CREATE FUNCTION [dbo].[generate_series] ( @p_start INT, @p_end INT)
@ricardobeat
ricardobeat / git-find
Created July 14, 2014 16:00
File search using git ls-files with relative path output.
git ls-files | grep $1 | sed s%`git rev-parse --show-prefix`%%