Skip to content

Instantly share code, notes, and snippets.

@recalde
recalde / KubernetesPodLogFileWriterService.cs
Created November 14, 2024 03:47
Kubernetes Pod Log Watcher
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
public class KubernetesPodLogFileWriterService : IHostedService, IDisposable
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using k8s;
using k8s.Models;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
public class KubernetesPodWatcherService : BackgroundService
@recalde
recalde / Program.cs
Created November 14, 2024 03:19
OpenShift OAuth
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie()
.AddOpenIdConnect(options =>
{
options.Authority = "https://<openshift-auth-server>";
@recalde
recalde / DirectoryBrowser.cshtml
Created November 14, 2024 02:49
Directory Browser
@page "{*path}"
@model DirectoryBrowserModel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Directory Browser</title>
<link rel="stylesheet" href="~/css/retro-style.css">
</head>
using ScottPlot;
using System;
using System.Collections.Generic;
using System.Linq;
var plt = new Plot(600, 400); // Fixed width, initial height
// Example data for bars
List<DateTime> startTimes = new List<DateTime>() { /* populate with start times */ };
List<DateTime> endTimes = new List<DateTime>() { /* populate with end times */ };
using System;
using System.Collections.Generic;
using ScottPlot;
public class ConcurrencyPlotter<TLog> where TLog : LogEntry
{
private readonly List<TConcurrency<TLog>> _concurrencyTimeline;
public ConcurrencyPlotter(List<TConcurrency<TLog>> concurrencyTimeline)
{
@recalde
recalde / ConcurrencyTracker.cs
Created November 12, 2024 02:19
ConcurrencyTracker<TLog>
using System;
using System.Collections.Generic;
using System.Linq;
public class LogEntry
{
public DateTime Timestamp { get; set; }
public TimeSpan Duration { get; set; }
public string Host { get; set; }
}
using Microsoft.AspNetCore.Mvc;
using SkiaSharp;
[Route("api/status/badge")]
[ApiController]
public class StatusBadgeController : ControllerBase
{
[HttpGet]
public IActionResult GetStatusBadge()
{
@recalde
recalde / DirectoryFileMerger.cs
Created November 9, 2024 02:44
Merge logs by pod
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ParquetSharp;
public class DirectoryFileMerger
{
private readonly string _directoryPath;
private readonly string _outputFilePath;
@recalde
recalde / DirectoryFileMerger
Created November 9, 2024 02:34
Parquet DirectoryFileMerger
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ParquetSharp;
public class DirectoryFileMerger
{
private readonly string _directoryPath;
private readonly string _outputFilePath;