Skip to content

Instantly share code, notes, and snippets.

View baywet's full-sized avatar
On medical leave until at least the 20th included

Vincent Biret baywet

On medical leave until at least the 20th included
View GitHub Profile
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 / 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 / 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 / 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 / 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 / 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
baywet /
Created March 20, 2018 20:27
two samples to solve situations where repositories have been imported instead of forked
git remote add downstream UrlOfImportedRepo
#foreach branch you want to bring back
git fetch downstream/branchname
git checkout branchname
git merge downstream/branchname #hopefully your history is not a mess and you don’t have conflicts to handle
git push origin
#end of foreach
git remote remove downstream
View office365clirefactor.ts
private mapNpmCommand(command: string, packagesDevExact: string[],
packagesDevInexact: string[], packagesDepExact: string[], packagesDepInexact: string[],
packagesDepUn: string[], packagesDevUn: string[]): void {
const npmReduceRegex: RegExp = /npm\s+(i|un)\s+([\w\d\@\/\.-]+)\s+(-D|-S)?\s?(-E)?/gm;
const npmReduceMatch: RegExpExecArray | null = npmReduceRegex.exec(command);
const packageNameGroupId: number = 2;
const installCommandGroupId: number = 1;
const dependencyCategoryGroupId: number = 3;
const exactGroupId: number = 4;
if (npmReduceMatch) {