Skip to content

Instantly share code, notes, and snippets.

View DavidDeSloovere's full-sized avatar

David De Sloovere DavidDeSloovere

View GitHub Profile
@DavidDeSloovere
DavidDeSloovere / Microsoft.PowerShell_profile.ps1
Last active June 14, 2022 02:42
My PowerShell profile (code $PROFILE)
#oh-my-posh --init --shell pwsh --config ~/jandedobbeleer.omp.json | Invoke-Expression
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" | Invoke-Expression
# needs Install-Module -Name Terminal-Icons -Repository PSGallery
Import-Module -Name Terminal-Icons
# https://devblogs.microsoft.com/powershell/announcing-psreadline-2-1-with-predictive-intellisense
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
@DavidDeSloovere
DavidDeSloovere / Startup.cs
Created May 12, 2022 14:23
ASP.NET Core - Only use compression for some endpoints
app.UseWhen(
context => context.Request.Path.StartsWithSegments("/api"),
builder => builder.UseResponseCompression());
@DavidDeSloovere
DavidDeSloovere / readme.md
Last active March 8, 2024 18:51
Self executing Snowflakes as a JS module

Home Assistant

  • Create snowflakes.js under config\www folder.
  • Add content from the gist
    • Choose to run always (remove all below line 4),
    • Or by date (remove line 4, optionally editing the dates you want the snowflakes to trigger)
    • and save.
  • In HA, go to Configuration > Lovelace Dashboards > Resources.
  • Click 'Add Resources' and enter local/snowflakes.js (it's a JavaScript module)
  • Save it
  • Enjoy the holidays
@DavidDeSloovere
DavidDeSloovere / fetch.ps1
Created September 29, 2020 16:08
git fetch over all subfolders with PowerShell
gci | foreach { write-host $_.fullname; push-location $_; & git fetch }
@DavidDeSloovere
DavidDeSloovere / cards.yaml
Created February 8, 2020 08:14
Home Assistant automation for Magic Cards
- 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 March 2, 2018 09:29
Make PowerShell prettier and display Git status

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 November 17, 2016 20:17
AzureFunction-OctopusToMicrosoftTeams
// 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 November 17, 2016 14:13
SFTP upload with SSH.NET
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 December 9, 2021 06:41
Create a custom variable in VSTS build powershell task
#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 November 9, 2018 15:36
Config HTTP headers. Adds X-Content-Type-Options and remove X-Powered-By for every request and X-UA-Compatible for views.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
</head>
</html>