Skip to content

Instantly share code, notes, and snippets.

View lawrence-laz's full-sized avatar
👋
Hi there!

Laurynas Lazauskas lawrence-laz

👋
Hi there!
  • Lithuania, Vilnius
View GitHub Profile
@lawrence-laz
lawrence-laz / nuget-examples.md
Last active June 27, 2023 11:21
Various examples for common things to do when authoring NuGet packages

Nuget

File build/MyNugetPackage.targets is injected into the MSBuild project that references this nuget package. Here is an example to copy *.dll files and reference them.

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
        <NativeLibs Include="$(MSBuildThisFileDirectory)**\*.dll" />
        <None Include="@(NativeLibs)">
@lawrence-laz
lawrence-laz / self-signed-pfx.sh
Last active November 6, 2023 10:24
Generate public/private keys and self signed pfx using opensll
# If .pem
openssl genrsa -out private-key.pem 3072
openssl rsa -in private-key.pem -pubout -out public-key.pem
# If .pfx
openssl genrsa -out private.key 1024
openssl req -new -x509 -key private.key -out publickey.cer -days 365
winpty openssl pkcs12 -export -out public-private-key.pfx -inkey private.key -in publickey.cer
# For signing .dll

Get commits that were not cherry picked to release branch:

git cherry -v release develop > gitlog.txt

Commits starting with + were not cherry picked yet, the ones starting with - are already in release branch.

public record TestTreeCollection<T>(T[] Values, TestTreeCollection<T>[] Children);
public class EnumerableExtensions
{
[Fact]
public void SelectManyDescending_WithSimpleTree_ShouldReturnAllElementsInSingleCollection()
{
// Arrange
var tree = new TestTreeCollection<int>[]
{
<Project>
<!-- https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1047?view=msvc-170 -->
<PropertyGroup>
<!-- Disabling this allows to keep binary compatibility between different c++ compiler versions. -->
<WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<!-- Disabling this allows to keep binary compatibility between different c++ compiler versions. -->
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
if (-not $?) {
Write-Host "Errors encountered during last command, see the logs above."
exit 1
}
# Print file system contents
- powershell: |
Write-Host "Show all folder content"
Get-ChildItem -Path $(Agent.WorkFolder)\*.* -Recurse -Force
errorActionPreference: continue
displayName: 'PowerShell Script List folder structure'
continueOnError: true
@lawrence-laz
lawrence-laz / kill-locks.sql
Created October 14, 2021 12:59
Query and kill sessions with locks in SQL server.
DECLARE @DatabaseName NVARCHAR(MAX) = 'your_database_name'
SELECT DISTINCT('KILL ' + CONVERT(varchar(10), request_session_id))
FROM sys.dm_tran_locks
WHERE resource_database_id = DB_ID(@DatabaseName)
-- Adapted from https://blog.sqlauthority.com/2016/05/25/sql-server-fix-error-1807-not-obtain-exclusive-lock-database-model-retry-operation-later-part-2/
@lawrence-laz
lawrence-laz / query-schema.sql
Last active August 17, 2021 06:13
Query MS SQL Server database schema
select schema_name(tab.schema_id) as schema_name,
tab.name as table_name,
col.column_id,
col.name as column_name,
t.name as data_type,
col.max_length,
col.precision
from sys.tables as tab
inner join sys.columns as col
on tab.object_id = col.object_id
@lawrence-laz
lawrence-laz / AspNetCoreIntegrationTest.cs
Created March 25, 2021 10:02
Hosting a test application for automated integration tests.
[Theory]
[InlineData("Development")]
public async Task CallSwaggerEndpoint_ShouldReturnHttpOk(string environment)
{
// Arrange
using var sut = await Program.CreateHostBuilder(null)
.UseEnvironment(environment)
.UseDefaultServiceProvider((context, options) =>
{