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
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
<?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
-- Table: Users | |
-- Column: Age | |
-- Constraint: auto-generated, e.g. DF__Users__Age__<random> | |
-- Find a specific constrait name assuming there is a single constraint only | |
DECLARE @ConstraintName nvarchar(100) | |
SELECT @ConstraintName = c.name FROM sys.default_constraints c | |
INNER JOIN sys.columns col ON col.default_object_id = c.object_id | |
WHERE c.parent_object_id = OBJECT_ID('dbo.Users') AND col.name = 'Age' |
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
using Microsoft.AspNetCore.Builder; | |
namespace MvcBug | |
{ | |
public static class RequestValidatorExtensions | |
{ | |
// Extensions method to simplify RequestValidatorMiddleware usage | |
public static IApplicationBuilder UseRequestValidator(this IApplicationBuilder app) | |
{ | |
return app.UseMiddleware<RequestValidatorMiddleware>(); |
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
namespace VarianceExample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
ISkinned<Fruit> skinnedFruit = null; | |
ISkinned<Banana> banana = null; | |
ICovariantSkinned<Fruit> covariantSkinnedFruit = null; |
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 Expiry date | |
<FilesMatch ".(ico|jpg|jpeg|png|gif|css|js)$"> | |
ExpiresActive On | |
ExpiresDefault "access plus 1 month" | |
</FilesMatch> | |
# END Expiry date | |
# HTTPS | |
RewriteEngine On | |
RewriteCond %{HTTPS} off |
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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.IO.Compression; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace ZipAsync | |
{ | |
public class Program |
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
# Based on # https://social.technet.microsoft.com/wiki/contents/articles/28753.powershell-trick-copy-certificates-from-one-store-to-another.aspx | |
$SourceStoreScope = 'LocalMachine' | |
$SourceStorename = 'My' | |
$CertificateSubjectPattern = '*mytestdomain' | |
Write-Host 'Looking for certificates with subject' $CertificateSubjectPattern 'in' $SourceStoreScope'\'$SourceStorename | |
$SourceStore = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Store -ArgumentList $SourceStorename, $SourceStoreScope | |
$SourceStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadOnly) |