Skip to content

Instantly share code, notes, and snippets.

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

Daniel Fisher lennybacon

🏠
Working from home
View GitHub Profile
@lennybacon
lennybacon / CredentialManager.xml
Created September 21, 2017 09:12
CredentialManager.msbuild
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="GetCredentials" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask
TaskName="CredentialManager"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
<ParameterGroup>
<Target ParameterType="System.String" Required="true" />
<UserName ParameterType="System.String" Output="true" />
<Password ParameterType="System.String" Output="true" />
@lennybacon
lennybacon / TellIfBranchIsPullRequest.xml
Created August 3, 2017 08:11
Tell if the branch is a pull request
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="TellIfBranchIsPullRequest" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BUILD_SOURCEBRANCH>refs/pull/1/merge</BUILD_SOURCEBRANCH>
<IsPullRequest Condition="$(BUILD_SOURCEBRANCH.IndexOf(`/pull/`)) != -1">true</IsPullRequest>
<IsPullRequest Condition="$(BUILD_SOURCEBRANCH.IndexOf(`/pull/`)) == -1">false</IsPullRequest>
</PropertyGroup>
<Target Name="TellIfBranchIsPullRequest">
@lennybacon
lennybacon / keybase.md
Created July 31, 2017 06:36
Keybase authentication

Keybase proof

I hereby claim:

  • I am lennybacon on github.
  • I am lennybacon (https://keybase.io/lennybacon) on keybase.
  • I have a public key ASA16UO09lZtVNlUgJ6ZBwhCPv0a9WnCypehkdhNFdyFmAo

To claim this, I am signing this object:

@lennybacon
lennybacon / GetLatestVersionOfTargets.xml
Created June 16, 2017 14:04
MsBuild property with the latest version of a file
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<NugetFixUpTaskPaths>$([System.IO.Directory]::GetFiles("$(UserProfile)\.nuget\packages\nugetfixuptasks", "*.targets", SearchOption.AllDirectories))</NugetFixUpTaskPaths>
<LatestNugetFixUpTaskImport>$(NugetFixUpTaskPaths.Remove(0, $([MSBuild]::Add( $(NugetFixUpTaskPaths.LastIndexOf(";")), 1 )) ))</LatestNugetFixUpTaskImport>
</PropertyGroup>
<Import Project="$(LatestNugetFixUpTaskImport)" />
<Target Name="Build">
<Message Text="LatestNugetFixUpTaskImport: $(LatestNugetFixUpTaskImport)" />
</Target>
</Project>
@lennybacon
lennybacon / Get-LatestMsBuild.ps1
Created June 2, 2017 07:15
Get latest MSBuild on x64 with Powershell
function Get-LatestMsBuild{
$msbuild = Get-ChildItem -Path "C:\Program Files (x86)\Microsoft Visual Studio" |
? { !$PsIsContainer -and $_.Name.StartsWith("20") } |
% { @([System.IO.Path]::Combine($_.FullName, "Enterprise", "MsBuild"), [System.IO.Path]::Combine($_.FullName, "Professional", "MsBuild"), [System.IO.Path]::Combine($_.FullName, "Community", "MsBuild"))} |
? { (Test-Path -Path $_) } |
% { Get-ChildItem -Path $_ | ? { !$PsIsContainer -and $_.Name.StartsWith("1") } | Select-Object -Expand FullName } |
% { Get-ChildItem -Path $_ -Recurse | ? { !$PsIsContainer -and $_.FullName.EndsWith("amd64\msbuild.exe", "OrdinalIgnoreCase") } } |
Select-Object -First 1
if($msbuild -ne $null){
@lennybacon
lennybacon / Tail.ps1
Created May 4, 2017 07:50
Tail with PowerShell
Get-Content -Path <Path> -Wait -Tail 10
# Print whole file and wait for appended lines and print them
cat <Path> -Wait
# Print last 10 lines and wait for appended lines and print them
cat <Path> -Tail 10 -Wait
@lennybacon
lennybacon / sql_2016_ssms_unattended.ps1
Created February 6, 2017 14:41
Install Microsoft SQL Server 2016 Management Studio unattended
$setupPath = [System.IO.Path]::Combine($installLocation, "SQL2016", "SSMS-Setup-ENU.exe");
$argumentList = `
"/install " +`
"/quiet " +`
"/norestart"
$process = Start-Process $setupPath -ArgumentList $argumentList -PassThru -NoNewWindow -Wait -RedirectStandardOutput $pwd\ssms_stdout.txt -RedirectStandardError $pwd\ssms_stderr.txt
@lennybacon
lennybacon / sql_2016_unattended.ps1
Last active February 6, 2017 14:43
Install Microsoft SQL Server 2016 unattended
$serviceAccount = "";
$serviceAccountPassword = "";
$key = "";
$instanceName = "MSSQLSERVER";
$sqlRootDir = "";
$setupPath = [System.IO.Path]::Combine($installLocation, "SQL2016", "Setup.exe");
$argumentList = `
"/Q " +`
"/ACTION=`"Install`" " +`
@lennybacon
lennybacon / ES6DateCtorTest.js
Created December 22, 2016 09:55
Check ES6/ISO8601 compliance
class TimeTest {
constructor(name) {
this.name = name;
}
start() {
var x = new Date('2016-01-29T14:00:00');
return "Project " + this.name + ": " + x.getTime();
}
}
@lennybacon
lennybacon / juncrion.cmd
Created August 16, 2016 08:46
Junctions with DOS Command
cmd /c mklink /D M:\Library F:\Music\