Skip to content

Instantly share code, notes, and snippets.

View doeringp's full-sized avatar
🏠
Working from home

Peter Doering doeringp

🏠
Working from home
  • Liebherr
  • Germany
  • 05:39 (UTC +01:00)
View GitHub Profile
@doeringp
doeringp / .vimrc
Created July 2, 2020 11:17
My VIM settings
syntax on " Erlaubt Syntax-Highlighting.
set tabstop=4 " Tabs entsprechen 4 Leerzeichen.
set shiftwidth=4 " Einrückungen mit Shift entsprechen 4 Leerzeichen.
set expandtab " Alle Tabs werden durch Leerzeichen ersetzt.
set autoindent " Automatische Einrückungen.
set incsearch " Inkrementelle Suche
@doeringp
doeringp / Dockerfile
Last active November 1, 2019 19:18
Run IdentityServer4 Admin UI (Community Edition) as a Docker container. Update build arg base_url in docker-compose.yml. Use "docker-compose up" to build and run. Open http://localhost:5000/admin to get the dashboard.
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 as build-env
WORKDIR /app
RUN dotnet new -i identityserver4.templates
RUN dotnet new is4admin
RUN dotnet restore
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0
WORKDIR /app
@doeringp
doeringp / Program.cs
Created September 17, 2019 12:40
ASP.NET Core: Run EF Migrations from the command line
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Web;
using System;
namespace MyApp
{
@doeringp
doeringp / Startup.cs
Created August 30, 2019 09:11
Custom content-type provider for JavaScript/CSS files which always adds the charset parameter.
namespace SampleProject
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
@doeringp
doeringp / detect-useragent.js
Last active April 1, 2019 08:55
Detect the user agent by JavaScript
const isIE = navigator.userAgent.indexOf('Trident/') > -1 || navigator.userAgent.indexOf('Edge/') > -1;
if (isIE) {
document.body.classList.add('internetExplorer');
}
const isEdge = navigator.userAgent.indexOf('Edge') > -1;
if (isEdge) {
document.body.classList.add('edge');
}
@doeringp
doeringp / get-access-token.ps1
Last active December 20, 2022 10:43
Get an access token from a OpenID Connect Provider with username and password or client credentials only.
<#
.SYNOPSIS
Get an access token from an OpenID Connect Provider using the passwort grant type
or the client credentials grant type (without user context).
First, you need an client id and client secret.
The Password Grant Type enables the OpenID Connect client to send a username and password directly
to the OpenID Authority to obtain an access token for the user without user interaction.
@doeringp
doeringp / guid.ps1
Created August 22, 2018 05:43
PowerShell-Skript to generate GUIDs
<#
.SYNOPSIS
Get a random GUID as string.
.PARAMETER short
Print the GUID without hyphens.
.PARAMETER uppercase
Transform the GUID to uppercase letters.
#>
@doeringp
doeringp / tail.ps1
Created August 1, 2018 12:18
Monitor textfiles with PowerShell (tail alternative)
Workflow Tail
{
Param([string[]] $files)
foreach -parallel ($file in $files)
{
Get-Content -Path $file -Tail 1 -Wait
}
}
@doeringp
doeringp / backup_volume.sh
Created July 23, 2018 18:38
Backup a Docker volume
#!/bin/bash
# This script allows you to backup a single volume from a container
# Data in given volume is saved in the current directory in a tar archive.
VOLUME_NAME=$1
BACKUP_PATH=$2
usage() {
echo "Usage: $0 [volume name] [backup path]"
exit 1
}
@doeringp
doeringp / Startup.cs
Created January 24, 2018 14:11
Challenge authentication using a custom middleware (no mvc).
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System.IdentityModel.Tokens.Jwt;
namespace AspNetCoreAuthTest
{
public class Startup