Skip to content

Instantly share code, notes, and snippets.

View DamianSuess's full-sized avatar
👍
Enjoying every day

Damian DamianSuess

👍
Enjoying every day
View GitHub Profile
@DamianSuess
DamianSuess / VSCode-Linting.md
Last active January 23, 2024 15:02
VSCode Automatic Linting

When developing in medium to larger teams, becomes more important to be able to automatically maintain code styling throughout the project to maintain readability and clarity. This rule also applies to smaller projects as well, abiet at times easier to manage ("New guy, please remove the 5 blank lines in a row in the method. And the blank spaces after the statements.").

Below is a quick snip for configuring VSCode to automagically take care of this every time you press save (Ctrl+S). The following assumes you already have a project workspace already started in VSCode.

TL;DR Configuration

Key files:

  • .vscode/extensions.json
  • .vscode/settings.json
<UserControl.Resources>
<!--<converter:BoolStringConverter x:Key="BooleanToStringConverter" TrueValue="Yes" FalseValue="No" />
<converter:InverseBoolConverter x:Key="InverseBoolConverter" />-->
<ResourceDictionary>
<DataTemplate x:Key="GridDeviceInfo" DataType="models:DeviceInfo">
<Panel Background="Transparent">
<i:Interaction.Behaviors>
<ia:EventTriggerBehavior EventName="DoubleTapped">
<ia:InvokeCommandAction Command="{Binding $parent[Grid].((vm:AccessViewModel)DataContext).CmdCopyText}" CommandParameter="Hello" />
</ia:EventTriggerBehavior>
@DamianSuess
DamianSuess / CommandBehaviorBase.cs
Last active September 7, 2023 21:22
Avalonia Custom Behaviors
using System.Windows.Input;
using Avalonia;
using Avalonia.Xaml.Interactivity;
namespace SuessLabs.Tool.Common.Behaviors;
/// <summary>Base class for behavior command binding event on its source and executes its actions when that event is fired.</summary>
/// <typeparam name="T">Type of behavior.</typeparam>
public class CommandBehaviorBase<T>
: Behavior<T>
@DamianSuess
DamianSuess / CacheService.cs
Last active August 29, 2023 20:20
C# CacheService
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
using CacheExample.Extensions;
namespace CacheExample.Services;
@DamianSuess
DamianSuess / Remove-DotNet-Linux.md
Last active April 23, 2024 05:51
Remove DotNet From Linux (Ubuntu)

Remove .NET From Linux

This document outlines steps for performing a deep clean on your Linux (Ubuntu 20.04) machine.

An example for performing could be, if your installation does not show in dotnet --list-sdks. Performing this deep clean and reinstalling will solve it in most cases.

Install

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
@DamianSuess
DamianSuess / threads.md
Last active January 2, 2024 22:30
Awaiting a task with timeout

C# - Awaiting Task with Timeout

Source Article

Scenerio, you have an awaitable object and you want to await it with a timeout. How would you build that?

What you can do is use a when_any-like function in combination with a timeout coroutine. For C# this would be something like

await Task.WhenAny(
@DamianSuess
DamianSuess / MessageDialogView.axaml
Created February 5, 2023 01:16
Prism.Avalonia - MessageDialogView
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
MaxHeight="{Binding MaxHeight}"
MaxWidth="{Binding MaxWidth}"
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="150"
x:Class="SampleApp.Views.MessageDialogView">
<UserControl.Styles>
<Style Selector="TextBox">
@DamianSuess
DamianSuess / IJsonService.cs
Created September 14, 2022 20:27
C# Json Service
// <copyright file="IJsonService.cs" company="Xeno Innovations, Inc.">
// Copyright (c) 2022 Xeno Innovations, Inc. All rights reserved.
//
// Reproduction or transmission in whole or in part, in
// any form or by any means, electronic, mechanical, or otherwise, is
// prohibited without the prior written consent of the copyright owner.
// </copyright>
// <author>Damian Suess</author>
using System.Threading.Tasks;
@DamianSuess
DamianSuess / BuildingDotDevelop.md
Last active August 8, 2022 16:46
Building DotDevelop and MonoDevelop from scratch

Building DotDevelop

Build Steps

Ubuntu 22.04 doesn’t support .NET Core 3.1 or 2.0 since the distro only supports openSSL 3.

sudo apt update
sudo apt install wget
sudo apt install intltool fsharp gtk-sharp2
@DamianSuess
DamianSuess / asp.nlog.config
Created July 28, 2022 18:14
Sample NLog Config for ASP.NET
<?xml version="1.0" encoding="utf-8" ?>
<!--
REPLACE: "MyApp" with your app name
Logging Help:
Base log level is set by, 'internalLogLevel'. ASP.NET can override via, 'appsettings.json'
Log Levels: Off|Trace|Debug|Info|Warn|Error|Fatal
-->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"