Skip to content

Instantly share code, notes, and snippets.

View mikeplate's full-sized avatar

Mikael Plate mikeplate

View GitHub Profile
@mikeplate
mikeplate / PhotoViewerJpeg.reg
Created December 19, 2018 17:40
Registry file for Windows Server 2016/2019 to restore jpeg opening in Photo Viewer
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\jpegfile\shell\open\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
@mikeplate
mikeplate / azureauth.cs
Created December 13, 2018 11:35
Add Azure AD authentication to existing ASP.NET Core application
// Startup.cs
using Microsoft.IdentityModel.Tokens;
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication().AddOpenIdConnect(c =>
{
c.Authority = "https://login.microsoftonline.com/common";
c.ClientId = "<insert-registered-guid>";
c.TokenValidationParameters = new TokenValidationParameters
@mikeplate
mikeplate / web.config
Created August 14, 2018 09:32
ASP.NET and IIS 7+ configuration settings for upload limit
<!-- 50 MB limit -->
<system.web>
<httpRuntime maxRequestLength="51200" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="52428800" />
</requestFiltering>
</security>
@mikeplate
mikeplate / angular-recursive-sample.html
Last active July 26, 2018 16:08
Angular recursive template for tree structure
<!--
interface Organization {
name: string;
url: string;
children: Organization[];
}
org: Organization[];
-->
<div class="invid-tree">
<ng-template #recursiveList let-list>
@mikeplate
mikeplate / git-last-commit.ps1
Created November 22, 2017 08:16
PowerShell Git - show last commit date for all files in repository
git ls-files | % { "$(git log -1 --format="%ai" -- $_) $_" }
@mikeplate
mikeplate / AnimationHelpers.cs
Created March 16, 2017 18:21
WPF Animation Helpers when switching UI
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
public class AnimationHelpers
{
public static void Fade(UIElement incoming, UIElement outgoing, int seconds)
{
Storyboard story = new Storyboard();
@mikeplate
mikeplate / SharePointVersion.ps1
Created March 1, 2017 15:31
Show current version of SharePoint on-premise
# PowerShell script to display SharePoint products from the registry.
Param(
# decide on whether all the sub-components belonging to the product should be shown as well
[switch]$ShowComponents
)
# location in registry to get info about installed software
$RegLoc = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall
@mikeplate
mikeplate / Reprovision.ps1
Created December 21, 2016 09:44
Reinstall SharePoint 2013 services after upgrade Windows Server 2012 to R2
$cfg = Get-SPServiceHostConfig
$cfg.Provision()
$services = Get-SPServiceApplication
foreach ($srv in $services) {
$srv.Provision()
Write-Host $srv.Name
}
@mikeplate
mikeplate / parsecsv.js
Last active December 19, 2016 09:39
Parse Comma/Tab Delimited Text In JavaScript
function parseCSV(src, sep) {
if (!sep) {
sep = "\t";
}
var data = [];
var isQuoteEscaped = false;
var row = [];
var value = "";
for (var i = 0; i < src.length; i++) {
var chr = src[i];
@mikeplate
mikeplate / search-all.sql
Created October 3, 2016 11:01
Search all tables and columns
CREATE PROC SearchAllTables
(
@SearchStr nvarchar(100)
)
AS
BEGIN
CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))
SET NOCOUNT ON