Skip to content

Instantly share code, notes, and snippets.

View davepermen's full-sized avatar
🐢

David Spörri davepermen

🐢
View GitHub Profile
using OpenMeteo;
OpenMeteoClient client = new();
try
{
if (await client.QueryAsync("Menziken", new() { Current = CurrentOptions.All, Daily = DailyOptions.All }) is WeatherForecast weatherForecast)
{
Console.WriteLine($"found Menziken at {weatherForecast.Latitude} & {weatherForecast.Longitude}");
Console.WriteLine();
<section>
@if (NotSelectedItems().Any())
{
<select @bind="@currentIndex" @bind:after="@AddItem">
<option selected hidden disabled value="-1"></option>
@foreach (var item in NotSelectedItems())
{
<option value="@item.Index">@item.Item</option>
}
</select>
using HomeTests;
using JsonTests;
using System.Text.Json;
using WebDeviceTests;
var options = JsonSerializerOptions.Web.WithPolymorphicTypesFor<Event>(configure =>
{
configure
.IncludeTypesFromNamespaceWith<WebButtonEvent>()
.IncludeType<HomeStateEvent>()
using System;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Metadata;
/* demo */
var options = JsonSerializerOptions.Web.WithPolymorphictypeInfoFor<Event>();
static class ErrorLogger
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static internal void LogError(string message, params object[] parameters) => logError(message, parameters);
internal delegate void LogErrorDelegate(string message, params object[] parameters);
static readonly LogErrorDelegate logError = DontLogError;
private static void DontLogError(string message, params object[] parameters) { }
static ErrorLogger()
using Conesoft.Files;
using Conesoft.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading;
using System.Threading.Tasks;
using Walterlv.WeakEvents;
namespace Conesoft.Plugin.AdminPage.Features.ServiceWatcher.Services;
@davepermen
davepermen / devicesetup.cpp
Created January 21, 2025 14:13
basic web-device setup routine
const char *ssid;
const char *ssidpass;
const char *webrequest;
bool loadsettings() {
if(FS.exists("/ssid") == false && FS.exists("/ssidpass") == false && FS.exists("/webrequest") == false) {
return false;
}
ssid = FS.read("/ssid");
ssidpass = FS.read("/ssidpass");
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace ProcessTracking;
// From https://stackoverflow.com/a/37034966/1528847
class ProcessTracker(bool closeOnExit = true)
{
ChildProcessTracker? current = closeOnExit ? new() : null;
using Microsoft.AspNetCore.Server.Kestrel.Https;
using System.Diagnostics;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using Yarp.ReverseProxy.Forwarder;
var demo = new
{
port = 5005,
* {
border-radius: 0 !important;
/* youtube */
--yt-spec-base-background: black;
/* twitch */
--color-background-body: black;
--color-background-base: black;
--color-background-alt: black;
--border-radius-small: 0;
--border-radius-medium: 0;