Skip to content

Instantly share code, notes, and snippets.

View lomholdt's full-sized avatar

Jonas Lomholdt lomholdt

View GitHub Profile
namespace DaprKafkaDemo.Shared;
public class ConfluentKafkaOptions
{
public const string ConfluentKafka = "ConfluentKafka";
public SchemaRegistry SchemaRegistry { get; set; } = new SchemaRegistry();
}
public class SchemaRegistry
fn main() {
let result = is_palindrome("racecar"); // Should be true
println!("{}", result);
}
fn is_palindrome(name: &str) -> bool {
let half = name.len() / 2;
name
.bytes()
.take(half)
using System;
using System.Linq;
using static System.Text.Encoding;
public static class Program {
public static void Main()
{
var result = IsPalindrome("racecar");
}
@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);
}
@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>
prompt_kubectl() {
local current_context=$(kubectl config current-context 2> /dev/null)
if [[ $current_context ]]; then
"⚙️ $current_context"
fi
}
# 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
@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)
@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 / 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 $_}
}