Skip to content

Instantly share code, notes, and snippets.

View jeppevammenkristensen's full-sized avatar

Jeppe Roi Kristensen jeppevammenkristensen

View GitHub Profile
[InterpolatedStringHandler]
public ref struct LogInterpolatedStringHandler
{
private int index = 0;
public readonly StringBuilder _builder = new StringBuilder();
public readonly (string name,object)[] Parameters;
public LogInterpolatedStringHandler(int literalLength, int formattedCount)
{
Parameters = new (string, object)[formattedCount];
@jeppevammenkristensen
jeppevammenkristensen / DeleteOprhan.ps1
Created March 16, 2022 09:25
Delete orphan branches Git
# A minor modification of the script here https://www.mehmetseckin.com/posts/clean-up-git-branches-that-do-not-exist-on-origin/
function Remove-DeletedGitBranches
{
$null = (git fetch --all --prune);
$branches = git branch -vv | Select-String -Pattern ": gone]" | ForEach-Object { $_.toString().Split(" ")[2] };
if ($branches.Count -gt 0)
{
Write-Host "Found the following orphan branches: " -ForegroundColor Green
// Define other methods and classes here
public class Rewriter : CSharpSyntaxRewriter
{
private string LastGroup = null;
private int? Index = null;
public override SyntaxNode VisitPropertyDeclaration(PropertyDeclarationSyntax node)
{
var display = node.AttributeLists.SelectMany(x => x.Attributes.Where(y => y.Name.ToString() == "Display")).FirstOrDefault();
@jeppevammenkristensen
jeppevammenkristensen / UnitTestEnricher.cs
Last active May 14, 2020 21:36
Dotnet Source Generator to create an InitSubject method in a UnitTest (that will have defined and initalised parameters for the constructor)
/// <summary>
/// Very opinionated Source generator that tries to match a class to test and generates a InitSubject method
/// that can return the class being tested. If there are parameters those are initialized with mocking setup
/// (using NSubstitute) and injected. The parameters will be exposed as fields
/// </summary>
[Generator]
public class UnitTestEnricher : ISourceGenerator
{
Get-Clipboard | Out-File -FilePath thesql.sql
@jeppevammenkristensen
jeppevammenkristensen / cloudSettings
Created September 30, 2016 20:18
Visual Studio Code Sync Settings GIST
{"lastUpload":"2016-09-30T20:18:17.349Z"}
@jeppevammenkristensen
jeppevammenkristensen / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
Import-Module webadministration
$managedRuntime = "v4.0"
$Name = "Madplan"
# This is of cause a dependency on Powershell version 3.0
$webPath = join-path $PSScriptRoot $Name
Write-Host $webPath
@jeppevammenkristensen
jeppevammenkristensen / Profile.ps1
Created March 20, 2014 10:05
Addition to the powershell profile to make it easy to navigate to the psychical location of one-drive files. Only optimized for windows 8.1
function Cd-OneDrive()
{
$userPath = Join-Path $env:UserProfile 'onedrive'
Write-Warning "Testing ->$userPath"
if (Test-Path -Path $userPath)
{
cd $userPath
}
$userPath = Join-Path $env:UserProfile 'skydrive'