Skip to content

Instantly share code, notes, and snippets.

View patriksvensson's full-sized avatar

Patrik Svensson patriksvensson

View GitHub Profile
@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 [email protected]. 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

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 / 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%",
@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 / 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 / EmbeddedResourceDataAttribute.cs
Created November 10, 2017 23:58
EmbeddedResourceDataAttribute.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Xunit.Sdk;
namespace MyProject.Tests
{
public sealed class EmbeddedResourceDataAttribute : DataAttribute
{
@patriksvensson
patriksvensson / build.cake
Created September 25, 2016 22:54
Cake and FAKE sample
Task("Test").Does(() => {
Information("Testing stuff...");
}
Task("Deploy").IsDependentOn("Test").Does(() => {
Information("Heavy deploy action");
}
RunTarget("Deploy");
@patriksvensson
patriksvensson / Get-NuGetPackage.ps1
Created September 15, 2016 09:38
Download NuGet package
Function Get-NuGetPackage(
[string]$Source = "http://nuget.org",
[string]$Package,
[string]$Version)
{
$Url = "$Source/api/v2/package/$Package/$Version"
$Output = Join-Path (Get-Location) "$Package.$Version.nupkg"
(New-Object System.Net.WebClient).DownloadFile($Url, $Output)
}
@patriksvensson
patriksvensson / project.json.lock
Created September 14, 2016 21:29
Lock file for project.
{
"version": 2,
"targets": {
".NETCoreApp,Version=v1.0": {
"Cake.Common/0.16.0-alpha0084": {
"type": "package",
"dependencies": {
"Cake.Core": "0.16.0-alpha0084",
"System.ComponentModel.TypeConverter": "4.1.0",
"System.Runtime.Serialization.Json": "4.0.2",
@patriksvensson
patriksvensson / project.json.lock
Created September 14, 2016 21:28
Lock file for Cake.Frosting.CLI.
{
"version": 2,
"targets": {
".NETCoreApp,Version=v1.0": {
"Cake.Common/0.16.0-alpha0084": {
"type": "package",
"dependencies": {
"Cake.Core": "0.16.0-alpha0084",
"System.ComponentModel.TypeConverter": "4.1.0",
"System.Runtime.Serialization.Json": "4.0.2",