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 | |
t.NAME AS TableName, | |
s.Name AS SchemaName, | |
p.rows AS RowCounts, | |
SUM(a.total_pages) * 8 AS TotalSpaceKB, | |
SUM(a.used_pages) * 8 AS UsedSpaceKB, | |
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB | |
FROM | |
sys.tables t | |
INNER JOIN |
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
declare @rowcount int = 1000 | |
declare @maxseconds int = 10 | |
declare @waitseconds int = 5 | |
declare @sql nvarchar(max) = 'delete from Log where CreatedDate<''2022-06-28'' ' | |
declare @message nvarchar(max) | |
declare @start datetime | |
declare @seconds int | |
set @start = getdate() | |
set rowcount @rowcount | |
exec sp_executesql @sql |
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
-- Run an Update statement for all tables that have a specific column. Set TenantId=69 in all tables that have that column. | |
declare @sql nvarchar(max) | |
set @sql = (select concat('update [', t.name, '] set TenantId=69; ') as [text()] | |
from sys.columns c join sys.tables t on c.object_id = t.object_id | |
where c.name = 'TenantId' for xml path('')) | |
print @sql | |
execute (@sql) | |
-- Disable all constrant checks temporarily for a specific table | |
alter table TheTableName nocheck constraint all |
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
# Start reverse SSH tunnel from internal server to external endpoint on port 443 | |
# Port 8081 on external endpoint will then be connectable to internal server localsql port 1433 | |
ssh -N -R 0.0.0.0:8081:localsql:1433 remoteuser@company-endpoint.westeurope.cloudapp.azure.com -p 443 -i ./remoteuser.pem | |
# Show certificate for SMTP server with implicit TLS | |
openssl s_client -connect smtp.some-server.com:465 -servername smtp.some-server.com | |
# Show certificate for SMTP server with explicit TLS | |
openssl s_client -connect smtp.some-server.com:587 -servername smtp.some-server.com -starttls smtp |
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
# Run sql command and store result as csv | |
Invoke-Sqlcmd -ServerInstance localhost -Database dbname -Username usr -Password rty "select top 100 * from [Log]" | ConvertTo-Csv -Delimiter "`t" > output.csv | |
# Total size of all files in all subfolders of the current folder | |
Get-ChildItem . -Recurse | Measure-Object -Property Length -Sum | |
# Store result of http request in file | |
Invoke-WebRequest -Uri "https://site.com" | Select-Object -ExpandProperty Content > site.html |
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
:: Refresh task bar icons | |
ie4uinit.exe -show | |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>CSS Grid</title> | |
<style> | |
body { | |
margin: 0px; |
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
Windows Registry Editor Version 5.00 | |
[HKEY_CLASSES_ROOT\jpegfile\shell\open\command] | |
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\ | |
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\ | |
6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\ | |
00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\ | |
25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\ | |
00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\ | |
6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\ |
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
// Startup.cs | |
using Microsoft.IdentityModel.Tokens; | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddAuthentication().AddOpenIdConnect(c => | |
{ | |
c.Authority = "https://login.microsoftonline.com/common"; | |
c.ClientId = "<insert-registered-guid>"; | |
c.TokenValidationParameters = new TokenValidationParameters |
NewerOlder