Skip to content

Instantly share code, notes, and snippets.

View lomholdt's full-sized avatar

Jonas Lomholdt lomholdt

View GitHub Profile
@lomholdt
lomholdt / example.cs
Created September 11, 2018 18:28
Overriden == operator
if (person == null) {
throw new ArgumentNullException(nameof(person));
}
@lomholdt
lomholdt / example.cs
Created September 11, 2018 18:35
Overriden == operator
if (person is null) {
throw new ArgumentNullException(nameof(person));
}
if (!(person is null)) {
throw new ArgumentNullException(nameof(person));
}
if (person is null == false) {
throw new ArgumentNullException(nameof(person));
}
@lomholdt
lomholdt / Remove-AllGitBranches.ps1
Last active September 8, 2021 09:52
Remove all git branches besides master and the current in powershell
function Remove-AllGitBranches {
,@(git branch | Select-String -Pattern "((\*\s)?master|main)|(\*\s).+" -NotMatch) | ForEach-Object{$_.Line.Trim()} | ForEach-Object{git branch -D $_}
}
@lomholdt
lomholdt / afact.snippet
Created October 5, 2018 15:49 — forked from bvli/afact.snippet
Fact snippets
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>A Fact</Title>
<Shortcut>afact</Shortcut>
<Description>Code snippet for an async xUnit fact</Description>
@lomholdt
lomholdt / Ensure.cs
Last active November 5, 2020 20:48
Ensure not null
using System;
namespace Tools.Internal
{
internal static class Ensure
{
public static T NotNull<T>(T obj, string paramName)
where T : class
{
if (obj is null)
# get the current branch
function get_branch {
value=$(cd $current_path; git rev-parse --abbrev-ref HEAD)
echo $value
}
# # Determine if we are in a git repo
# function is_git_repo {
# if [ -d $current_path/.git ]; then
# return 1
prompt_kubectl() {
local current_context=$(kubectl config current-context 2> /dev/null)
if [[ $current_context ]]; then
"⚙️ $current_context"
fi
}
@lomholdt
lomholdt / Directory.Build.props
Last active January 4, 2022 20:19
Make internals visible to other projects (eg. test projects)
<Project>
<Target Name="InternalsVisibleToTask" BeforeTargets="GenerateAdditionalSources" Condition="@(InternalsVisibleTo) != ''">
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>%(InternalsVisibleTo.Identity)</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Target>
@lomholdt
lomholdt / Program.cs
Last active October 5, 2020 11:31
Recursive IsPalindrome implementation
using System;
public static class Program
{
public static void Main()
{
var word = "tenet";
var result = IsPalindrome(word);
}