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
// Create a query where the result must match or contain the given query | |
// and the subset of properties and filters. | |
descriptor.Query( | |
q => q.Bool( | |
b => b.Must( | |
mu => | |
mu.MultiMatch( | |
m => m.Fields(propertyExpressions) // Search within these properties or all. | |
.Query(searchTerm) // For this query | |
.Operator(Operator.Or))) // In any of the properties. |
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
static void RegisterDbContext<TContext>(IServiceCollection services) | |
where TContext : DbContext | |
{ | |
services.AddSingleton<SqlInstance<TContext>>(p => new SqlInstance<TContext>(builder => (TContext)ActivatorUtilities.CreateInstance<TContext>(p, builder.Options))); | |
services.AddScoped<SqlDatabase<TContext>>(p => | |
{ | |
SqlInstance<TContext> sqlInstance = p.GetRequiredService<SqlInstance<TContext>>(); | |
// Safe excecution of async via dedicated factory and unwrapping. |
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
git rm -r --cached . | |
git add . |
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
#!/usr/bin/env bash | |
set -eu | |
declare -a build_projects=('./src/My.Extensions.ApiVersioning/') | |
declare -a test_projects=('./tests/IntegrationTests/' './tests/UnitTests/') | |
pwsh -NoProfile -ExecutionPolicy Bypass -Command "& '.\build.ps1' -projects " "${build_projects[@]}" "-tests " "${test_projects[@]}" | |
if [ $# -ne 0 ]; then | |
echo "Failed to build." |
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
--Microsoft.EntityFrameworkCore.Database.Command:Information: Executed DbCommand (176ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] | |
SELECT CASE | |
WHEN EXISTS ( | |
SELECT 1 | |
FROM [Customers] AS [x]) | |
THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) | |
END | |
--Microsoft.EntityFrameworkCore.Database.Command:Information: Executed DbCommand (185ms) [Parameters=[], CommandType='Text', CommandTimeout='30'] |
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
@echo Off | |
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '.\build.ps1'" | |
if not "%errorlevel%"=="0" goto failure | |
:success | |
ECHO successfully built project | |
REM exit 0 | |
goto end |
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
// A very simple service example contract with an event. | |
// Using an interface ensures that every implementation has same events. | |
public interface IContentService | |
{ | |
event EventHandler Saved; | |
} | |
// Our component contract | |
public interface IComponent : IDisposable | |
{ |
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
void Main() | |
{ | |
Matrix4x4 yawPitchRoll = Matrix4x4.CreateFromYawPitchRoll(25, 32, 67); | |
Matrix4x4 translateM4 = Matrix4x4.CreateTranslation(new Vector3(3, 6, 0)); | |
Matrix3x2 translate = Matrix3x2.CreateTranslation(new Vector2(3, 6)); | |
Vector2 target = Vector2.Zero; | |
// All three of the following methods yield the correct transform vector <3,6> | |
Vector2.Transform(target, translate).Dump(); |
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 static Guid Xor(Guid a, Guid b) | |
{ | |
unsafe | |
{ | |
Int64* ap = (Int64*)&a; | |
Int64* bp = (Int64*)&b; | |
ap[0] ^= bp[0]; | |
ap[1] ^= bp[1]; | |
return *(Guid*)ap; |
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
private void ProcessScanlineFromPalette<TPixel>(ref byte scanlineRef, ref TPixel rowRef) | |
where TPixel : struct, IPixel<TPixel> | |
{ | |
ReadOnlySpan<Rgb24> palettePixels = MemoryMarshal.Cast<byte, Rgb24>(this.palette); | |
ref Rgb24 palettePixelsRef = ref MemoryMarshal.GetReference(palettePixels); | |
if (this.paletteAlpha?.Length > 0) | |
{ | |
// If the alpha palette is not null and has one or more entries, this means, that the image contains an alpha | |
// channel and we should try to read it. |