Skip to content

Instantly share code, notes, and snippets.

ignas-sakalauskas / InvokeLambdaViaSdk.cs
Created June 7, 2020 11:03
View InvokeLambdaViaSdk.cs
var request = new InvokeRequest
FunctionName = "1-direct-invocation",
InvocationType = InvocationType.RequestResponse, // synchronous
Payload = "Your JSON payload"
var result = await client.InvokeAsync(request);
ignas-sakalauskas / Program.cs
Created February 12, 2019 20:22
TPL Dataflow Example in .NET Core 2.1
View Program.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
namespace TplDataFlowPlayground
ignas-sakalauskas / CurrentIsolationLevel.sql
Created February 5, 2019 07:49
MS SQL DB Isolation Levels
View CurrentIsolationLevel.sql
DBCC useroptions
-- or
WHEN transaction_isolation_level = 1
WHEN transaction_isolation_level = 2
AND is_read_committed_snapshot_on = 1
View CopySslCertToTrustedRoot.ps1
# Based on #
$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
ignas-sakalauskas / Program.cs
Created October 11, 2018 07:51
ZipArchive Async Playground
View Program.cs
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
ignas-sakalauskas / .htaccess
Created February 4, 2018 12:01
WordPress .htaccess with static files expiration tweak, HTTPS redirect, and SEO friendly URLs
View .htaccess
# BEGIN Expiry date
<FilesMatch ".(ico|jpg|jpeg|png|gif|css|js)$">
ExpiresActive On
ExpiresDefault "access plus 1 month"
# END Expiry date
RewriteEngine On
RewriteCond %{HTTPS} off
View CustomAuthorizeFilter.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization.Policy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
ignas-sakalauskas / VarianceExample.Program.cs
Last active January 6, 2018 16:26
Covariance and Contraviarance
View VarianceExample.Program.cs
namespace VarianceExample
class Program
static void Main(string[] args)
ISkinned<Fruit> skinnedFruit = null;
ISkinned<Banana> banana = null;
ICovariantSkinned<Fruit> covariantSkinnedFruit = null;
ignas-sakalauskas / RequestValidatorExtensions.cs
Last active June 23, 2019 15:22
Multipart Content-Type request results in IOException
View RequestValidatorExtensions.cs
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>();
ignas-sakalauskas / ChangeAutoNamedConstraint.sql
Last active August 27, 2017 19:40
Change auto-named SQL constraint
View ChangeAutoNamedConstraint.sql
-- 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 = 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 = 'Age'