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 / 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-._@+ ";
});
}
}
import { NgModule } from '@angular/core';
import { Http, ConnectionBackend, XHRBackend } from '@angular/http';
import { MiniProfilerHttp } from './mini-profiler-http';
@NgModule({
providers: [
{
provide: Http,
useClass: MiniProfilerHttp
},
@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 / Sample.Tests.csproj
Last active April 18, 2018 16:52
Sample code for continuous integration testing and code coverage in Jenkins for .Net (Core) with xUnit and OpenCover
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net47;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170106-08" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0" />
<PackageReference Include="xunit" Version="2.3.0" />
@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)
@GeorgDangl
GeorgDangl / TestsAndCoverage.ps1
Created October 11, 2017 16:31
ReportGenerator to visualize Code Coverage with xUnit in a .Net Core project for publishing it in Jenkins
$testProjects = "ReportGeneratorExample.Tests"
# Gets the path of a file in the most recent NuGet package
function getFrameworkNameFromFilename {
Param($package, $file)
$nugetOpenCoverPackage = Join-Path -Path $env:USERPROFILE -ChildPath "\.nuget\packages\$package"
$latestOpenCover = Join-Path -Path ((Get-ChildItem -Path $nugetOpenCoverPackage | Sort-Object Fullname -Descending)[0].FullName) -ChildPath $file
return $latestOpenCover;
}
@GeorgDangl
GeorgDangl / TransformWebConfigForProduction.ps1
Last active January 6, 2020 15:01
Deploying Asp.Net Core Applications from Jenkins to IIS or Azure via WebDeploy
$environmentName = "Production"
# Applying web.config transformations
$webConfigTransformatorPackages = Join-Path -Path $env:USERPROFILE -ChildPath "\.nuget\packages\WebConfigTransformRunner"
$latestWebConfigTranformator = Join-Path -Path ((Get-ChildItem -Path $webConfigTransformatorPackages | Sort-Object Fullname -Descending)[0].FullName) -ChildPath "Tools\WebConfigTransformRunner.exe"
$webConfigDirs = Get-ChildItem -Path "$PSScriptRoot\publish" -Recurse -Filter "web*.config" | Select -Property Directory -Unique
ForEach ($directory in $webConfigDirs.Directory){
$transformationSource = (Get-ChildItem -Path $directory -Filter ("web." + $environmentName + ".config"))
if ($transformationSource) {
$guid = [Guid]::NewGuid().ToString()
@GeorgDangl
GeorgDangl / HackyReportPage.xaml
Created October 31, 2017 20:14
Displaying graphs and charts in a Xamarin WebView with Chart.js
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
x:Class="App.Mobile.Views.HackyReportPage"
Title="Hacky Chart.js Report">
<WebView VerticalOptions="FillAndExpand">
<WebView.Source>
<HtmlWebViewSource Html="{Binding ReportHtml}" />