Skip to content

Instantly share code, notes, and snippets.

View DamianSuess's full-sized avatar
🙃
BeepBoop(); Execute();

Damian DamianSuess

🙃
BeepBoop(); Execute();
View GitHub Profile
@DamianSuess
DamianSuess / AwaitNonAsyncMethods.cs
Created March 25, 2021 22:00
Await in a Non-Async Method
// Sample 1 - Non-Helper Function Method
public bool HardReset()
{
return HardResetAsync().GetAwaiter().GetResult();
}
public async Task<bool> HardResetAsync()
{
// Real code goes here
await Task.Yield();
@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 / Bash-Readme.md
Last active May 20, 2024 16:05
C# Linux BASH

About C# BASH Sample

The example code here references Docker and IoT Edge as an example. The user/pass is Base64 encoded as part of the Bash class in this example.

By no means should you keep the admin user/pass hard-coded in the production class, this is an example piece.

What's The Difference?

The Bash class has both RunAs(..) and Command(..), and each allows you to run using sudo. The difference is, the RunAs(...) method does not require your app to be started with elevated privledges. Where as, Command(..) requires you to start the app with elevated privledges in order to execute commands using sudo.