Skip to content

Instantly share code, notes, and snippets.

View GeorgDangl's full-sized avatar
😎
Coding

Georg Dangl GeorgDangl

😎
Coding
View GitHub Profile
@GeorgDangl
GeorgDangl / ApiModelStateValidationFilter.cs
Created December 19, 2016 19:57
Validation filter to automatically return BadRequest respones for invalid models and IsEqualToAttribute for comparing Password and ConfirmPasswords in models
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
namespace Filters
{
public class ApiModelStateValidationFilter : IActionFilter
{
public void OnActionExecuting(ActionExecutingContext context)
{
@GeorgDangl
GeorgDangl / copyGeometryInteropDlls.ps1
Last active February 2, 2017 18:21
Copy xBim Geometry Interop Dlls in the new project format in .Net
$xBimGeometryPackages = Join-Path -Path $env:USERPROFILE -ChildPath "\.nuget\packages\Xbim.Geometry"
$latestxBimGeometryPackage32 = Join-Path -Path ((Get-ChildItem -Path $xBimGeometryPackages | Sort-Object Fullname -Descending)[0].FullName) -ChildPath "build\x86\Xbim.Geometry.Engine32.dll"
$latestxBimGeometryPackage64 = Join-Path -Path ((Get-ChildItem -Path $xBimGeometryPackages | Sort-Object Fullname -Descending)[0].FullName) -ChildPath "build\x64\Xbim.Geometry.Engine64.dll"
if (!(Test-Path "$PSScriptRoot\Dependencies")){
New-Item -ItemType Directory -Path "$PSScriptRoot\Dependencies"
}
Copy-Item -Path $latestxBimGeometryPackage32 -Destination "$PSScriptRoot\Dependencies\Xbim.Geometry.Engine32.dll"
Copy-Item -Path $latestxBimGeometryPackage64 -Destination "$PSScriptRoot\Dependencies\Xbim.Geometry.Engine64.dll"
@GeorgDangl
GeorgDangl / Index.cshtml
Last active February 21, 2017 21:13
Angular 2 in Visual Studio Webpack Configuration and Dependencies
<!DOCTYPE html>
<html>
<head>
<title>NetCoreHeroes</title>
<link rel="icon" type="image/png" href="/favicon.png">
<base href="@ViewData["AngularBase"]" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
@GeorgDangl
GeorgDangl / ConvertPasswordToSecureString.ps1
Last active April 27, 2017 20:05
Securely storing strings in PowerShell scripts and setting VPN Shared Secrets in Windows Server 2016
param([string]$password)
$encrypted = ConvertTo-SecureString $password -AsPlainText -Force
ConvertFrom-SecureString $encrypted
@GeorgDangl
GeorgDangl / MigrateMSTestToXUnit.ps1
Created May 25, 2017 12:42
Migrating MSTest to xUnit
Param(
[string ]$ProjectDir
)
get-childitem $ProjectDir -recurse -include *.cs |
select -expand fullname |
foreach {
( Get-Content $_ ) -replace '\[TestMethod\]','[Fact]' `
-replace 'Assert.AreEqual' , 'Assert.Equal' `
-replace 'Assert.AreNotEqual' , 'Assert.NotEqual' `
-replace 'Assert.IsTrue' , 'Assert.True' `
@GeorgDangl
GeorgDangl / Startup.cs
Last active July 5, 2017 22:23
Validating usernames in an Angular frontend with Asp.Net Core Identity
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddIdentity<ApplicationUser>(identityConfig =>
{
identityConfig.User.AllowedUsernameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+ ";
});
}
}
@GeorgDangl
GeorgDangl / ANTLR.csproj
Last active August 12, 2017 00:06
Using ANTLR4 C# MSBuild tasks
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Antlr4.Runtime" Version="4.6.4" />
<PackageReference Include="Antlr4.CodeGenerator" Version="4.6.5-beta001">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
@GeorgDangl
GeorgDangl / Dangl.Common.csproj
Created September 1, 2017 20:26
Project configuration for continuous development NuGet package deployment
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<VersionPrefix>1.4.1</VersionPrefix>
<VersionSuffix Condition=" '$(GIT_BRANCH)' == 'origin/dev'">build-$(BUILD_NUMBER)</VersionSuffix>
<GeneratePackageOnBuild Condition="'$(Configuration)'=='Release'">True</GeneratePackageOnBuild>
<Authors>Georg Dangl</Authors>
<TargetFramework>netstandard1.3</TargetFramework>
<PackageId>Dangl.Common</PackageId>
<PackageProjectUrl>https://github.com/GeorgDangl/Dangl.Common</PackageProjectUrl>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;netcoreapp1.1;netcoreapp1.0;net47;net461;net46</TargetFrameworks>
<AssemblyName>Dangl.Common.Tests</AssemblyName>
<PackageId>Dangl.Common.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">1.1.1</RuntimeFrameworkVersion>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
@GeorgDangl
GeorgDangl / AppendxUnitFramework.ps1
Last active October 2, 2017 10:57
PowerShell scripts to run unit tests with xUnit and Dotnet CLI and to include target framework in test name for Jenkins CI visualization
Param(
[string]$globPattern = "results_*.testresults",
[string]$searchDirectory = $PSScriptRoot
)
# Find all files matching the glob pattern
$testResultFiles = Get-ChildItem -Path $searchDirectory -Filter $globPattern -Recurse
function getFrameworkNameFromFilename {
Param($file)