Skip to content

Instantly share code, notes, and snippets.

View AldeRoberge's full-sized avatar
💛
.

Alexandre D. Roberge AldeRoberge

💛
.
View GitHub Profile
@AldeRoberge
AldeRoberge / net-aspire-serilog-colors-in-console.md
Last active April 28, 2025 17:57
Fix colors in .NET Aspire console and Serilog

Black and white .NET Aspire console? Worry no more. Use this :

applyThemeToRedirectedOutput: true

Full code example, taken from ADG's Logging helper method :

@AldeRoberge
AldeRoberge / OllamaVisionDemo.cs
Created April 18, 2025 02:46
Captures an image from the webcam and quickly analyzes whether a person is present.
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.AI;
using OpenCvSharp;
using AForge.Video.DirectShow;
namespace ADG.Playground.Vision
{
internal class VisionResponse
{
@AldeRoberge
AldeRoberge / ConsoleSpiner.cs
Created April 15, 2025 19:56
Just a cute little spinner that looks great 😎👍
using System.Text;
namespace ADG.ConsoleSpin;
public static class ConsoleSpinner
{
private static int counter;
private static readonly string[] SpinnerChars = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]; // Braille characters that work reliably
@AldeRoberge
AldeRoberge / daily-schedule-graph.py
Created March 27, 2025 13:48
A graph of my daily schedule, written in python (matplotlib)
import matplotlib.pyplot as plt
import numpy as np
def time_to_hours(time_str, start_hour=None):
"""
Convert a time string "HH:MM" to a float representing hours.
If the time is "00:00" and start_hour is provided and greater than 0,
assume that it represents midnight at the end of the day (i.e., 24:00).
"""
h, m = map(int, time_str.split(":"))
@AldeRoberge
AldeRoberge / Program.cs
Created February 18, 2025 15:52
Automatically publish projects to Nuget, ensure that their versions match
using System.Diagnostics;
using System.Text;
using System.Text.Json;
using System.Xml.Linq;
using AGX.Common.Logging.Serilog;
using Serilog;
namespace AGX.Common.Publishing
{
internal class Program
@AldeRoberge
AldeRoberge / Program.cs
Created February 17, 2025 15:15
Scan all open ports in local LAN subnet, gets their title
using System.Collections.Concurrent;
using System.Text.RegularExpressions;
namespace ADG.Playground._2;
internal static class Program
{
private static readonly HttpClient Client = new() { Timeout = TimeSpan.FromMilliseconds(500) };
private static readonly ConcurrentQueue<string> Results = new();
private static readonly SemaphoreSlim Semaphore = new(50); // Limits concurrent requests
@AldeRoberge
AldeRoberge / ChatRowDrawer.cs
Created February 10, 2025 20:18
Allows to wrap long lines in Unity IMGUI TextArea
GUIStyle myStyle = new GUIStyle(EditorStyles.textField)
{
wordWrap = true
};
chatRow.Text = EditorGUILayout.TextArea(chatRow.Text, myStyle, GUILayout.Height(100));
@AldeRoberge
AldeRoberge / OpenInTerminal.cs
Last active February 7, 2025 18:47
Right click Project folder to open in terminal. Supports Linux, Mac and Windows.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using UnityEditor;
using UnityEngine;
using Debug = UnityEngine.Debug;
namespace ADG.Scripts.Editor
@AldeRoberge
AldeRoberge / ObsService.cs
Created February 7, 2025 16:06
Set the OBS output file name
using FluentResults;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OBSStudioClient;
using OBSStudioClient.Enums;
using Polly;
namespace ADG.Recording.OBS
{
public class ObsServiceOptions
@AldeRoberge
AldeRoberge / IsPointerOverGameObjectUtils.cs
Created January 14, 2025 01:21
Allows to check if a pointer is over a UI (works on touch devices too)
using UnityEngine;
using UnityEngine.EventSystems;
namespace Wikwemot_AR.Modules.Input.Runtime.Scripts
{
// See : https://discussions.unity.com/t/ispointerovergameobject-not-working-with-touch-input/155469/3
public static class IsPointerOverGameObjectUtils
{
/// <returns>true if mouse or first touch is over any event system object ( usually gui elements )</returns>
public static bool IsPointerOverGameObject()