Skip to content

Instantly share code, notes, and snippets.

View devlead's full-sized avatar

Mattias Karlsson devlead

View GitHub Profile
@devlead
devlead / ConsoleBufferToHtml.ps1
Last active January 30, 2024 22:24
ConsoleBufferToHtml.ps1 - Powershell script to dump console buffer as html to file.
<#
.SYNOPSIS
This is a Powershell script to dump console buffer as html to file.
.DESCRIPTION
This Powershell script will iterate over the current console buffer and
output it as html preserving colors.
.PARAMETER FilePath
@devlead
devlead / azure.xml
Created October 17, 2015 08:18
Add new file types under system.webserver
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
@devlead
devlead / parsegitlog.ps1
Created October 29, 2015 17:30
Example working with git log in PowerShell
# Get last 100 log entries as a PowerShell object
$gitHist = (git log --format="%ai`t%H`t%an`t%ae`t%s" -n 100) | ConvertFrom-Csv -Delimiter "`t" -Header ("Date","CommitId","Author","Email","Subject")
# Now you can do iterate over each commit in PowerShell, group sort etc.
# Example to get a commit top list
$gitHist|Group-Object -Property Author -NoElement|Sort-Object -Property Count -Descending
# Example do something for each commit
$gitHist|% {if ($_.Author -eq "Mattias Karlsson") {"Me"} else {"Someone else"} }
@devlead
devlead / git-random-tip.ps1
Last active November 9, 2015 15:08
PowerShell scrips that displays random GIT tips
(irm https://raw.githubusercontent.com/git-tips/tips/master/tips.json)|sort {random}|select -First 1|% {"$($_.title)`r`n$($_.tip)" }
@devlead
devlead / keybase.md
Last active April 11, 2016 14:20
keybase.md

Keybase proof

I hereby claim:

  • I am devlead on github.
  • I am devlead (https://keybase.io/devlead) on keybase.
  • I have a public key whose fingerprint is 477F E77B F054 8C1F C0CE A7F1 F678 07BF C550 2BA9

To claim this, I am signing this object:

@devlead
devlead / build.cake
Created October 31, 2016 14:07
Example of a custom Cake tool utilizing the in Cake built on tool classes, settings and tool resolution
#load "./customtool.cake"
#load "./mytools.cake"
GitStatus();
GitBranch(new CustomToolSettings { ToolPath = "/bin/git.exe" });
@devlead
devlead / a.cake
Created November 2, 2016 22:59
Sample Cake Inject Task dependency
var taskA = Task("A")
.Does(()=>Information("Hello from A"));
@devlead
devlead / DynamicTest.csproj
Last active August 21, 2020 19:10
Example .NET Core app create objects from type name
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
</ItemGroup>
@devlead
devlead / csc.cake
Created May 18, 2017 07:17
Example utilize csc.exe from cake
DirectoryPath projectPath = MakeAbsolute(Directory("./cscTest"));
DirectoryPath outputPath = projectPath.Combine("bin/Debug");
FilePath asssemblyPath = outputPath.CombineWithFilePath("Test.dll"),
symbolsPath = outputPath.CombineWithFilePath("Test.pdb");
FilePath[] references = new FilePath[0]; // add any assembly dependencies
Task("Clean")
.Does(() => {
@devlead
devlead / Async.cake
Created July 9, 2017 18:43
Sample of using async await in a cake script using a AsyncHelper class to work with all async scenarios, currently needs "--Experimental" flag or to use the Cake.CoreCLR runner as a newer version of Roslyn is required for async to be recognized. Example invocation: cake .\AsyncHelper.cake -Experimental
#load "AsyncHelper.cake"
#r "System.Net.Http"
using System.Net.Http;
using System.Net.Http.Headers;
string url = "https://icanhazdadjoke.com/";
var result = AsyncHelpers.RunSync(
async ()=> {
using(var client = new HttpClient())