Skip to content

Instantly share code, notes, and snippets.

View MovGP0's full-sized avatar

Johann Dirry MovGP0

View GitHub Profile
SELECT MIN(CustomerNumber + 1)
FROM Customer
WHERE NOT EXISTS (SELECT * FROM Customer WHERE CustomerNumber = MIN(CustomerNumber) + 1)
@MovGP0
MovGP0 / Find double lines.regex
Created December 14, 2022 08:15
Helpful Regex strings
^(.+)\n(?=.*^\1$)
@MovGP0
MovGP0 / Get-InternetTime.ps1
Created April 23, 2021 12:25
Get the time from an NTP server
function Get-InternetTime
{
param($NtpServer = 'time.windows.com')
try
{
$address = [Net.Dns]::GetHostEntry($NtpServer).AddressList[0];
}
catch
{
@MovGP0
MovGP0 / Configure-Site.ps1
Last active April 19, 2021 16:08
Administrate IIS via Powershell
# source: https://adamtheautomator.com/powershell-iis/
New-Item -ItemType Directory -Name 'MyWebsite' -Path 'C:\inetpub\wwwroot';
New-IISSite `
-Name 'MyWebsite' `
-PhysicalPath 'C:\inetpub\wwwroot\MyWebsite';
New-IISSiteBinding `
-Name 'MyWebsite' `
-BindingInformation "*:443:" `
-CertificateThumbPrint "D043B153FCEFD5011B9C28E186A60B9F13103363" `
@MovGP0
MovGP0 / Install Docker.ps1
Created November 13, 2020 15:48
Install Docker on Windows Server 2019
# install dependencies
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart
Install-WindowsFeature RSAT-Hyper-V-Tools -IncludeAllSubFeature
Restart-Computer –Force
# install provider
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Restart-Computer –Force
@MovGP0
MovGP0 / Visual Studio Named Instance.ps1
Created November 13, 2020 09:37
Visual Studio Named Instance
.\vs.exe --nickname Reports --installPath 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Reports\'
@MovGP0
MovGP0 / Get_changes_on_table_schema.sql
Created November 4, 2020 13:53
Analyze SQL Server Transaction logs
DECLARE @fileName NVARCHAR(MAX) = N'c:\foo.trn';
SELECT
SUSER_SNAME (l.[Transaction SID]) AS [User],
l.*
FROM sys.fn_dump_dblog(NULL,NULL,N'DISK',1, @fileName,
DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,
DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,
DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,
@MovGP0
MovGP0 / Move-FilesByYear.ps1
Last active July 1, 2020 11:21
Copy Files into folder by year
[int]$year = 2019;
ls * -File | where { $_.lastwritetime.year -eq $year } | mv -Destination ".\${$year}\"
@MovGP0
MovGP0 / create_index.sql
Last active November 28, 2019 10:03
Database Maintanance
-- a) List the equality columns first (leftmost in the column list).
-- b) List the inequality columns after the equality columns (to the right of equality columns listed).
-- c) List the include columns in the INCLUDE clause of the CREATE INDEX statement.
-- d) To determine an effective order for the equality columns, order them based on their selectivity; that is, list the most selective columns first.
-- TODO: determine required index type
CREATE NONCLUSTERED INDEX [IDX_TEST] ON [dbo].[MYDB]
(
-- equality_columns; start with most distinctive
[TYPE] ASC,
@MovGP0
MovGP0 / Startup.cs
Created September 11, 2018 09:51
Configure NodaTime for NewtonSoft.Json
using NodaTime.Serialization.JsonNet;
namespace MyApp
{
public sealed class Startup
{
public Startup(IHostingEnvironment env, IConfiguration configuration)
{
Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
HostingEnvironment = env ?? throw new ArgumentNullException(nameof(configuration));