Skip to content

Instantly share code, notes, and snippets.

Working from home

Vincent Biret baywet

Working from home
View GitHub Profile
baywet / pfxtosnk.cs
Created October 4, 2014 00:39
sample on how to convert a pfx to snk visual studio assembly signing certificate
View pfxtosnk.cs
X509Certificate2 cert = new X509Certificate2(@"KEY.pfx", "pfxPassword", X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
RSACryptoServiceProvider provider = (RSACryptoServiceProvider) cert.PrivateKey;
byte[] array = provider.ExportCspBlob(!provider.PublicOnly);
using (FileStream fs = new FileStream("FileName.snk", FileMode.Create, FileAccess.Write))
fs.Write(array, 0, array.Length);
baywet / FeatureVersionIncrementer.ps1
Last active August 17, 2016 08:15
adding support of incrementation of upgrade ranges
View FeatureVersionIncrementer.ps1
[System.Reflection.Assembly]::Load("Microsoft.VisualStudio.SharePoint, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
[System.Reflection.Assembly]::Load("Microsoft.VisualStudio.SharePoint.Designers.Models.Features, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
$featureFiles = get-childitem -Filter "*.feature" -Recurse;
$featureTemplateFiles = get-childitem -Filter "*.Template.xml" -Recurse | Where-Object {$_.Directory.Name -ne "Package"}
$featureRegex = [Regex]"(?<buildnumber>\d{1,4}\.\d{1,4}\.\d{1,4}\.\d{1,4})";
$templateRegex = [Regex]'EndVersion=\"(?<buildnumber>\d{1,4}\.\d{1,4}\.\d{1,4}\.\d{1,4})\"';
function getVersionObject($stringVersion)
baywet / gittfsmigrationcleanup.ps1
Last active July 17, 2020 13:40
small powershell script which allows you to quickly clean your repo during the migration
View gittfsmigrationcleanup.ps1
$targetSearchPath = $targetPath+"\*"
remove-item $targetSearchPath -Recurse -include *.vspscc,*.vssscc -Verbose
$slnRegexPattern = 'GlobalSection\(TeamFoundationVersionControl\)[:\w\d\s\\.=\/{}-]*EndGlobalSection'
$slnFiles = get-childitem -Path $targetSearchPath -Recurse -Filter *.sln
foreach($slnFile in $slnFiles)
$content = get-content $slnFile.FullName -Raw
if($content -match $slnRegexPattern)
baywet / PublishAspNet5Website.ps1
Last active April 22, 2016 06:47
Fix of PublishAspNet5Website given by microsoft to support slots
View PublishAspNet5Website.ps1
param($websiteName, $packOutput, $slot)
#fix for the script provided here
$website = $null;
$baseUrl = $websiteName;
if($slot -eq $null){
$website = Get-AzureWebsite -Name $websiteName
} else {
$baseUrl += "-" + $slot
$website = Get-AzureWebsite -Name $websiteName -Slot $slot
baywet / RunTests.ps1
Last active March 3, 2016 02:34
this script allows you to run DNX tests projects (xUnit) with Visual Studio Team Services
View RunTests.ps1
&{$Branch='dev';iex ((new-object net.webclient).DownloadString(''))}
# load up the global.json so we can find the DNX version
$globalJson = Get-Content -Path $PSScriptRoot\global.json -Raw -ErrorAction Ignore | ConvertFrom-Json -ErrorAction Ignore
$dnxVersion = $globalJson.sdk.version
baywet / Startupupdate.cs
Created March 2, 2016 22:54
This file will allow you to pass a connection string as a parameter in powershell
View Startupupdate.cs
using Microsoft.Data.Entity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace YourDbContextNameSpace
public class Startupupdate
public Startupupdate()
baywet / UpdateDatabase.ps1
Created March 2, 2016 22:57
This file will allow you to run the db update for a dnx project from powershell
View UpdateDatabase.ps1
&{$Branch='dev';iex ((new-object net.webclient).DownloadString(''))}
# load up the global.json so we can find the DNX version
$globalJson = Get-Content -Path $PSScriptRoot\global.json -Raw -ErrorAction Ignore | ConvertFrom-Json -ErrorAction Ignore
$dnxVersion = $globalJson.sdk.version
baywet / sharepointlibrarynewexperience.js
Created June 14, 2016 21:07
code sample to determine if the current document library is being used with new experience or not
View sharepointlibrarynewexperience.js
function getIsLibraryNewExperience(){
var keyPairs = document.cookie.split('; ');
for(var kpIdx in keyPairs){
var parts = keyPairs[kpIdx].split('=');
if(parts[0] === 'splnu' && parts[1] === '1'){
return true;
return false;
baywet / ArgumentNullRefExceptionReplace.cs
Created August 5, 2016 18:33
small sample to quickly replace the string names of variables when doing defensive programming exceptions by nameof operator usage
View ArgumentNullRefExceptionReplace.cs
baywet / forceDeletionOfSharePointProviderHostedAddIn.ps1
Created August 19, 2016 15:50
powershell script to remove SharePoint provider hosted add-ins that have an app uninstall event which fails
View forceDeletionOfSharePointProviderHostedAddIn.ps1
Function Get-ClientContext([string]$Url,[string]$UserName,[string]$Password)
$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
$context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
return $context