Skip to content

Instantly share code, notes, and snippets.

View khalidabuhakmeh's full-sized avatar
👻
🚀🧠🥑

Khalid Abuhakmeh khalidabuhakmeh

👻
🚀🧠🥑
View GitHub Profile
@khalidabuhakmeh
khalidabuhakmeh / HtmxExtensions.cs
Created September 18, 2024 13:26
Htmx Extension methods for Playwright Testing
using Microsoft.Playwright;
namespace HtmxPlaywrightIntegration.Tests;
public static class HtmxExtensions
{
private const string Continue = "playwright:continue";
public static Task WaitForHtmx(this IPage page)
{
@khalidabuhakmeh
khalidabuhakmeh / htmx-blazor.md
Created April 26, 2024 13:34
Why and why not to use Htmx + Blazor together

Blazor and Htmx are unique technologies with strengths and weaknesses. In this short list, we'll discuss five reasons to use the technologies together and five reasons to avoid the combination.

Reasons to use them together

ASP.NET Core and Blazor SSR are Good

ASP.NET Core, now with Blazor Server-side Rendering (SSR), is a robust backend HTML generator. You can do almost everything for UI on the server, and with Htmx, you can accomplish some commonly difficult client-side interactions with relative ease.

Less JavaScript and C# Code

@khalidabuhakmeh
khalidabuhakmeh / marten.cs
Created February 13, 2023 20:22
Marten Query with Enum Value
// See https://aka.ms/new-console-template for more information
using Marten;
using Weasel.Core;
async Task StoreUser(DocumentStore documentStore)
{
await using var session = documentStore.OpenSession();
var newUser = new User
{
@khalidabuhakmeh
khalidabuhakmeh / maui.md
Last active January 4, 2024 09:27
Installing MAUI with .NET 7 for non-VS Users on macOS

Installing MAUI with .NET 7 for non-VS Users

Clear NuGet Cache

Before continuting to the next step, let's clear some nuget caches that might get in the way.

dotnet nuget locals all --clear
@khalidabuhakmeh
khalidabuhakmeh / PlaywrightFixture.cs
Created September 9, 2022 13:54
Playwright tests with XUnit
[CollectionDefinition(nameof(PlaywrightFixture))]
public class SharedPlaywrightCollection : ICollectionFixture<PlaywrightFixture> {}
// ReSharper disable once ClassNeverInstantiated.Global
public class PlaywrightFixture : IAsyncLifetime
{
public async Task InitializeAsync()
{
PlaywrightInstance = await Playwright.CreateAsync();
Browser = await PlaywrightInstance.Chromium.LaunchAsync();
@khalidabuhakmeh
khalidabuhakmeh / Dockerfile
Last active October 24, 2023 20:59
JetBrains Rider / Gateway Container
FROM mcr.microsoft.com/dotnet/sdk:6.0
# SSHD port
EXPOSE 2222
ENV DEBIAN_FRONTEND=noninteractive
ENV LC_ALL=C.UTF-8
RUN apt-get update && apt-get install -y apt-utils apt-transport-https
@khalidabuhakmeh
khalidabuhakmeh / deck.cs
Created June 17, 2021 19:23
Implement Deck
public interface IDeck<T>
{
/// <summary>
/// Draw as many T as the count
/// will draw the most it possibly can, which may be 0
/// </summary>
/// <param name="count"></param>
/// <returns></returns>
IEnumerable<T> Draw(int count);
@khalidabuhakmeh
khalidabuhakmeh / gist:78b6e789e9298a60e0484b1577187343
Created June 15, 2021 14:24
Template Entry Missing ConfigMounPointId
{
"MountPointUri": "/usr/local/share/dotnet/templates/3.1.16/microsoft.dotnet.winforms.projecttemplates.4.8.1-servicing.21213.7.nupkg",
"Author": "Microsoft",
"Classifications": [
"Common",
"WinForms"
],
"DefaultName": "WinFormsApp1",
"Description": "A project for creating a .NET Core Windows Forms (WinForms) Application",
"Identity": "Microsoft.Common.WinForms",
public static class PropertyNameDataCollector
{
public static async Task Scan(this Assembly assembly, string outputFilePath, bool includeHeader = true)
{
var properties = assembly
.GetTypes()
.SelectMany(x => x.GetProperties())
// only want BCL types
.Where(x => x.PropertyType.Namespace != null && x.PropertyType.Namespace.StartsWith("System"))
.Select(x => new
using System;
using System.Collections.Generic;
using System.Linq;
public static class Program
{
public const int TotalTips = 61;
private static void Main()
{
const int year = 2020;