Skip to content

Instantly share code, notes, and snippets.

David De Sloovere DavidDeSloovere

Block or report user

Report or block DavidDeSloovere

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@DavidDeSloovere
DavidDeSloovere / upload.cs
Created Nov 17, 2016
SFTP upload with SSH.NET
View upload.cs
const string host = "domainna.me";
const string username = "chucknorris";
const string password = "norrischuck";
const string workingdirectory = "/highway/hell";
const string uploadfile = @"c:\yourfilegoeshere.txt";
Console.WriteLine("Creating client and connecting");
using (var client = new SftpClient(host, port, username, password))
{
client.Connect();
@DavidDeSloovere
DavidDeSloovere / _Layout.cshtml
Last active Nov 9, 2018
Config HTTP headers. Adds X-Content-Type-Options and remove X-Powered-By for every request and X-UA-Compatible for views.
View _Layout.cshtml
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
</head>
</html>
@DavidDeSloovere
DavidDeSloovere / vsts-build-custom-var-creation.ps1
Last active Aug 13, 2018
Create a custom variable in VSTS build powershell task
View vsts-build-custom-var-creation.ps1
#output to stdout in special format
Write-Host ("##vso[task.setvariable variable=ThisIsMyVariable;]somevalue")
# reuse in subsequent tasks
$Env:ThisIsMyVariable
View boxstarter_apps
#####################
# BEGIN CONFIGURATION
#####################
Update-ExecutionPolicy Unrestricted
Set-WindowsExplorerOptions -DisableShowHiddenFilesFoldersDrives -DisableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Disable-InternetExplorerESC
Disable-UAC
# Disable defrag (no need when having an SSD)
@DavidDeSloovere
DavidDeSloovere / pimp-my-powershell.md
Last active Mar 2, 2018
Make PowerShell prettier and display Git status
View pimp-my-powershell.md

Install Scoop

http://scoop.sh/ A command-line installer for Windows

iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

Install concfg

https://github.com/lukesampson/concfg concfg is a utility to import and export Windows console settings like fonts and colors.

@DavidDeSloovere
DavidDeSloovere / run.csx
Created Nov 17, 2016
AzureFunction-OctopusToMicrosoftTeams
View run.csx
// full repo at https://github.com/DavidDeSloovere/AzureFunction-OctopusToMicrosoftTeams
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log)
{
log.Info("Webhook was triggered!");
string jsonContent = await req.Content.ReadAsStringAsync();
log.Info(jsonContent);
dynamic data = JsonConvert.DeserializeObject(jsonContent);
@DavidDeSloovere
DavidDeSloovere / dump-env-variables.ps1
Last active Feb 5, 2017
TEAM BUILD PowerShell: Output all documented environment variables
View dump-env-variables.ps1
# Team Foundation Build environment variables
# http://msdn.microsoft.com/en-us/library/hh850448.aspx
Write-Host "TF_BUILD : $Env:TF_BUILD "
Write-Host "TF_BUILD_BINARIESDIRECTORY : $Env:TF_BUILD_BINARIESDIRECTORY "
Write-Host "TF_BUILD_BUILDDEFINITIONNAME : $Env:TF_BUILD_BUILDDEFINITIONNAME "
Write-Host "TF_BUILD_BUILDDIRECTORY : $Env:TF_BUILD_BUILDDIRECTORY "
Write-Host "TF_BUILD_BUILDNUMBER : $Env:TF_BUILD_BUILDNUMBER "
Write-Host "TF_BUILD_BUILDREASON : $Env:TF_BUILD_BUILDREASON "
Write-Host "TF_BUILD_BUILDURI : $Env:TF_BUILD_BUILDURI "
@DavidDeSloovere
DavidDeSloovere / gist:6277610
Last active Dec 21, 2015
System.Net.HttpResponseMessage set custom status code like 429
View gist:6277610
var response = new HttpResponseMessage
{
StatusCode = (HttpStatusCode)429,
ReasonPhrase = "Too Many Requests",
Content = new StringContent(string.Format(CultureInfo.InvariantCulture, "Rate limit reached. Reset in {0} seconds.", data.ResetSeconds))
};
response.Headers.Add("Retry-After", data.ResetSeconds.ToString(CultureInfo.InvariantCulture));
actionContext.Response = response;
@DavidDeSloovere
DavidDeSloovere / JsonNetResult
Created Jun 1, 2013
JsonNetResult for ASP.NET MVC - correct formatting of dates and camel cased properties Got most of the code from Stack Overflow.
View JsonNetResult
using System;
using System.Web;
using System.Web.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
public class JsonNetResult : JsonResult
{
public override void ExecuteResult(ControllerContext context)
{
@DavidDeSloovere
DavidDeSloovere / CopyChmLocalAndOpen.ps1
Created Jan 4, 2013
Open up an old school .CHM help file from a network path. Put the Powershell in the folder of the .CHM file and any user can launch the help file via right-click on the .PS1 and selecting 'Run with Powershell'. (Set-ExecutionPolicy might need to be set first)
View CopyChmLocalAndOpen.ps1
$tempfolder = $env:TEMP
$chmfile = Get-ChildItem | Where-Object {$_.Extension -match "chm"}
"Copying to local temp folder: $tempfolder"
Copy-Item $chmfile $tempfolder
"Opening $chmfile"
Start-Process $tempfolder\$chmfile
You can’t perform that action at this time.