This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Safety check | |
$CLEAN_MODE_ON = false; | |
$WORM_SIGNATURE = "2351,36,5581,28,1864,50,2418,35,1827,37,3770,62,3104,41,3975,39,5703,40,3950,25,2004,59,2739,32,1187,37,1914,30,2922"; | |
echo "<div>IMPORTANT! Make sure you take your site offline and make a BACKUP of ALL files before switching on clean mode!</div>"; | |
echo "<div>Listing all PHP files.</div>"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestDataService | |
{ | |
private readonly IHttpContextAccessor _httpContextAccessor; | |
// Inject IHttpContextAccessor into constructor | |
public TestDataService(IHttpContextAccessor httpContextAccessor) | |
{ | |
_httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# new-selfsignedcertificateex.ps1 Downloaded from | |
# https://gallery.technet.microsoft.com/scriptcenter/Self-signed-certificate-5920a7c6 | |
. ".\new-selfsignedcertificateex.ps1" | |
New-SelfsignedCertificateEx ` | |
-Subject "CN=mytestdomain" ` | |
-EKU 'Server Authentication', 'Client Authentication' ` | |
-SAN "mytestdomain", "localhost" ` | |
-FriendlyName 'Local Dev Self Signed Cert' ` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT so.name as TableName, ddps.row_count as [RowCount] | |
FROM sys.objects so | |
JOIN sys.indexes si ON si.OBJECT_ID = so.OBJECT_ID | |
JOIN sys.dm_db_partition_stats AS ddps ON si.OBJECT_ID = ddps.OBJECT_ID AND si.index_id = ddps.index_id | |
WHERE si.index_id < 2 AND so.is_ms_shipped = 0 | |
ORDER BY ddps.row_count DESC | |
-- https://ignas.me/tech/sql-quick-row-count/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [dbo].[Maintenance_RefreshViews] | |
AS | |
--Refresh the underlying metadata of all views | |
DECLARE @viewName AS VARCHAR(255) | |
DECLARE listOfViews CURSOR FOR | |
SELECT [name] FROM sysobjects WHERE xtype = 'V' ORDER BY [name] | |
OPEN listOfViews |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET NOCOUNT ON; | |
DECLARE @rows int = 1; | |
DECLARE @now datetime = GETDATE(); | |
WHILE @rows > 0 | |
BEGIN | |
BEGIN TRANSACTION; | |
DELETE TOP (500) [ASPState].dbo.ASPStateTempSessions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN | |
BEGIN TRY | |
SET NOCOUNT ON | |
SET XACT_ABORT ON | |
-- Code Which Doesn't Require Transaction | |
-- e.g. initialize variables | |
BEGIN TRANSACTION | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE YourDatabaseName | |
GO | |
PRINT 'Checking for the existence of this procedure' | |
IF (SELECT OBJECT_ID('sp_generate_inserts','P')) IS NOT NULL | |
BEGIN | |
PRINT 'Procedure already exists. So, dropping it' | |
DROP PROC sp_generate_inserts | |
END | |
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- CPU intensive queries | |
SELECT TOP 50 | |
qs.total_worker_time/qs.execution_count as [Avg CPU Time], | |
SUBSTRING(qt.text,qs.statement_start_offset/2, | |
(case when qs.statement_end_offset = -1 | |
then len(convert(nvarchar(max), qt.text)) * 2 | |
else qs.statement_end_offset end -qs.statement_start_offset)/2) | |
as query_text, | |
qt.dbid, dbname=db_name(qt.dbid), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE master | |
ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE | |
DROP DATABASE YourDatabaseName | |
-- https://ignas.me/tech/force-drop-database-when-in-use/ |