Skip to content

Instantly share code, notes, and snippets.

View patriksvensson's full-sized avatar

Patrik Svensson patriksvensson

View GitHub Profile
@patriksvensson
patriksvensson / version.cake
Created February 13, 2018 08:40
Poor man's alternative to GitVersion
public static class CakeVersion
{
public static string Calculate(ICakeContext context)
{
var branch = GetBranch(context);
if(string.IsNullOrWhiteSpace(branch)) {
throw new InvalidOperationException("Could not retrieve branch from Git.");
}
var tag = GetTag(context);
@patriksvensson
patriksvensson / Register.ps1
Created October 10, 2018 22:57
Argument completer for Spectre.Cli
Register-ArgumentCompleter -Native -CommandName myapp -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
$split = $wordToComplete.ToString().Split()
$command = [system.String]::Join("_", $split[1..$split.Length])
$position = ($cursorPosition-$split[0].Length - 1);
myapp complete --position $position "$command" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
@patriksvensson
patriksvensson / profile.json
Last active May 23, 2019 08:40
My Windows Terminal profile
{
"defaultProfile": "{36bc5ffe-68fe-41b6-bc15-e64146552d34}",
"initialRows": 30,
"initialCols": 120,
"alwaysShowTabs": true,
"showTerminalTitleInTitlebar": false,
"experimental_showTabsInTitlebar": false,
"profiles": [
{
"startingDirectory": "%USERPROFILE%",
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Ghostly.Utilities
{
// Emoji list borrowed from https://github.com/lunet-io/markdig/blob/25959174d521c7f4458fa7b340d58a4ac136fa30/src/Markdig/Extensions/Emoji/EmojiParser.cs
public static class EmojiReplacer
{
private static Regex _regex;
private static Dictionary<string, string> _lookup;
@patriksvensson
patriksvensson / Spectre_CLA.md
Last active January 4, 2022 01:22
CLA for Spectre Systems

Spectre Systems Individual Contributor License Agreement

Thank you for your interest in contributing to open source software projects (“Projects”) made available by Spectre Systems AB or its affiliates (“Spectre Systems”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to Spectre Systems in respect of any of the Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact hello@spectresystems.se. You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions.

Copyright License. You hereby grant, and agree to grant, to

@patriksvensson
patriksvensson / Output.txt
Last active September 24, 2019 09:11
Can someone explain this like you would to a 4 year old? 😅
Doing stuff
Doing more stuff
Task cancelled (Cancellation requested: False) -> No task exception, No inner exception
@patriksvensson
patriksvensson / boxstarter.ps1
Last active December 3, 2021 23:15
Boxstarter script for a new computer
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# Run script:
# Install-BoxstarterPackage -PackageName <URL-TO-RAW-GIST> -DisableReboots
##########################################################################
# Disable UAC (temporarily)
##########################################################################
@patriksvensson
patriksvensson / Duck_CLA.md
Last active April 20, 2020 15:46
Duck CLA

Contributor Agreement - Individual Contributor Non-Exclusive License Agreement Thank you for your interest in contributing to Duck ("We" or "Us").

The purpose of this contributor agreement ("Agreement") is to clarify and document the rights granted by contributors to Us.

How to use this Contributor Agreement If You are an employee and have created the Contribution as part of your employment, You need to have Your employer approve this Agreement. If You do not own the Copyright in the entire work of authorship, any other author of the Contribution should also sign this – in any event, please contact Us at patrik@patriksvensson.se.

1. Definitions

"You" means the individual Copyright owner who Submits a Contribution to Us.

@patriksvensson
patriksvensson / ConsoleBuffer.cs
Last active March 31, 2021 05:28
Double Buffering Console
private static int _bufferHeight;
private static int _bufferY;
public static async Task Main()
{
_bufferWidth = Console.WindowWidth;
_bufferHeight = Console.WindowHeight;
_bufferY = _bufferHeight;
Console.SetBufferSize(_bufferWidth, _bufferHeight * 2);
@patriksvensson
patriksvensson / Oh-My-Posh.ps1
Last active August 3, 2023 10:12
Oh-My-Posh helper
[CmdletBinding()]
Param(
[switch]$Install,
[switch]$ListThemes,
[switch]$Force
)
$OhMyPosh = "$env:LOCALAPPDATA\Oh-My-Posh"
$OhMyPoshExe = Join-Path $OhMyPosh "oh-my-posh.exe"
$OhMyPoshThemes = "~\.poshthemes"