Skip to content

Instantly share code, notes, and snippets.

View devlead's full-sized avatar

Mattias Karlsson devlead

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / ValidateCountry.ps1
Created May 13, 2015 09:17
ValidateScript is very powerful to validate script / fucntion parameters, example below validate country based on rest service
Param(
[ValidateScript(
{
$countries = ((Invoke-RestMethod -Uri https://raw.githubusercontent.com/devlead/ISO-3166-Countries-with-Regional-Codes/master/all/all.json)| % Name)
if ( $countries -contains $_)
{
$true
}
else
{
DROP TABLE dbo.Events
DROP TABLE dbo.Streams
CREATE TABLE dbo.Streams(
StreamId CHAR(40) NOT NULL,
StreamIdOriginal NVARCHAR(1000) NOT NULL,
StreamIdInternal INT IDENTITY(1,1) NOT NULL,
IsDeleted BIT NOT NULL DEFAULT ((0)),
CONSTRAINT PK_Streams PRIMARY KEY CLUSTERED (StreamIdInternal)
);
@devlead
devlead / README.md
Created April 1, 2015 14:02
Windows 10 aware app.manifest

OSVersion

In windows 8.1 Environment.OSVersion underlying Win32 GetVersionEx function changed to for compatibility reasons report latest version app is compiled for.

The code

Console.WriteLine(
    System.Environment.OSVersion
    );
@devlead
devlead / NewAzureMachine.ps1
Created January 20, 2015 10:44
PowerShell Script to easily provision a dev environment in Azure using Chocolatey
Param(
[string]$SubscriptionName = ((Get-AzureSubscription|?{$_.SubscriptionName -like "*MSDN*"})[0].SubscriptionName),
[string]$AzureVMImageName = "03f55de797f546a1b29d1b8d66be687a__Visual-Studio-2013-Ultimate-Update4-AzureSDK-2.5-Win8.1-x64"
)
function InstallWinRMCert($serviceName, $vmname)
{
$winRMCert = (Get-AzureVM -ServiceName $serviceName -Name $vmname | select -ExpandProperty vm).DefaultWinRMCertificateThumbprint
$AzureX509cert = Get-AzureCertificate -ServiceName $serviceName -Thumbprint $winRMCert -ThumbprintAlgorithm sha1