Skip to content

Instantly share code, notes, and snippets.

Avatar

David De Sloovere DavidDeSloovere

View GitHub Profile
@DavidDeSloovere
DavidDeSloovere / fetch.ps1
Created Sep 29, 2020
git fetch over all subfolders with PowerShell
View fetch.ps1
gci | foreach { write-host $_.fullname; push-location $_; & git fetch }
@DavidDeSloovere
DavidDeSloovere / cards.yaml
Created Feb 8, 2020
Home Assistant automation for Magic Cards
View cards.yaml
- alias: Play Station from Magic Cards
trigger:
- platform: event
event_type: magic_card_scanned
event_data:
card_type: station
action:
# - service: notify.group_deef
# data_template:
# title: "Magic Cards {{ trigger.event.data.card_code }}"
@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 / 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 / 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
@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 / 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 / getversioninfo.cs
Last active Aug 29, 2015
Get the 3 versions that can be attached to an assembly via AssemblyInfo. Can be used in ASP.NET MVC to output the version in the footer.
View getversioninfo.cs
var assembly = Assembly.GetExecutingAssembly();
var fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
model.FileVersion = string.Format(CultureInfo.InvariantCulture, "v{0}", fvi.FileVersion);
model.ProductVersion = string.Format(CultureInfo.InvariantCulture, "v{0}", fvi.ProductVersion);
model.AssemblyVersion = string.Format(CultureInfo.InvariantCulture, "v{0}", assembly.GetName().Version);
@DavidDeSloovere
DavidDeSloovere / web.config
Created Sep 3, 2014
Add caching for favicon in web.config
View web.config
<location path="favicon.ico">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="90.00:00:00" />
</staticContent>
</system.webServer>
</location>
You can’t perform that action at this time.