Skip to content

Instantly share code, notes, and snippets.

View patriksvensson's full-sized avatar

Patrik Svensson patriksvensson

View GitHub Profile
@patriksvensson
patriksvensson / Program.cs
Created May 29, 2023 19:16
Implementation of a IAnsiConsole that writes to a StringBuffer
using Spectre.Console;
using Spectre.Console.Rendering;
using System.Text;
namespace SpectreVirtual;
public static class Program
{
public static void Main(string[] args)
{
@patriksvensson
patriksvensson / Program.cs
Created May 29, 2023 18:46
How to create a Spectre.Console console that doesn't use Console.Out and similar
using Spectre.Console;
using System.Text;
// Create the output
var output = new StringWriter();
// Create the console
var console = AnsiConsole.Create(new AnsiConsoleSettings
{
Ansi = AnsiSupport.Yes,
@patriksvensson
patriksvensson / Spectre.Console.xml
Created July 4, 2022 10:13
Spectre.Console SBOM
<?xml version="1.0" encoding="utf-8"?>
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://cyclonedx.org/schema/bom/1.4">
<metadata>
<tools>
<tool>
<vendor>Spectre Systems AB</vendor>
<name>Hades CLI</name>
<version>1.0.0.0</version>
</tool>
</tools>
@patriksvensson
patriksvensson / DownloadedColumn.cs
Created January 12, 2021 03:44
A progress column for Spectre.Console that shows download progress
/// <summary>
/// A column showing download progress.
/// </summary>
public sealed class DownloadedColumn : ProgressColumn
{
private static readonly string[] _suffixes = new[] { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
private static readonly int _base = 1024;
/// <summary>
/// Gets or sets the <see cref="CultureInfo"/> to use.
@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"
@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 / 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 / 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 / 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 / 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