Skip to content

Instantly share code, notes, and snippets.

View baywet's full-sized avatar
🏬
Working from home

Vincent Biret baywet

🏬
Working from home
View GitHub Profile
@baywet
baywet / pfxtosnk.cs
Created October 4, 2014 00:39
sample on how to convert a pfx to snk visual studio assembly signing certificate
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
baywet / FeatureVersionIncrementer.ps1
Last active August 17, 2016 08:15
adding support of incrementation of upgrade ranges
[System.Reflection.Assembly]::Load("Microsoft.VisualStudio.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
[System.Reflection.Assembly]::Load("Microsoft.VisualStudio.SharePoint.Designers.Models.Features, Version=14.0.0.0, 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
baywet / gittfsmigrationcleanup.ps1
Last active April 21, 2024 21:11
small powershell script which allows you to quickly clean your repo during the migration
param([string]$targetPath)
$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
baywet / PublishAspNet5Website.ps1
Last active April 22, 2016 06:47
Fix of PublishAspNet5Website given by microsoft to support slots
param($websiteName, $packOutput, $slot)
#fix for the script provided here https://msdn.microsoft.com/en-us/Library/vs/alm/Build/azure/deploy-aspnet5?f=255&MSPPError=-2147217396
$website = $null;
$baseUrl = $websiteName;
if($slot -eq $null){
$website = Get-AzureWebsite -Name $websiteName
} else {
$baseUrl += "-" + $slot
$website = Get-AzureWebsite -Name $websiteName -Slot $slot
}
@baywet
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
&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}
# 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
if($globalJson)
{
$dnxVersion = $globalJson.sdk.version
}
else
@baywet
baywet / Startupupdate.cs
Created March 2, 2016 22:54
This file will allow you to pass a connection string as a parameter in powershell
using Microsoft.Data.Entity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace YourDbContextNameSpace
{
public class Startupupdate
{
public Startupupdate()
{
@baywet
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
param([string]$connectionString)
&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}
# 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
if($globalJson)
{
$dnxVersion = $globalJson.sdk.version
}
@baywet
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
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
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
ArgumentNullException\("(\w+)"\);
ArgumentNullException(nameof($1));
@baywet
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
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
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