Skip to content

Instantly share code, notes, and snippets.

View JKamsker's full-sized avatar

Jonas Kamsker JKamsker

View GitHub Profile
@JKamsker
JKamsker / gist:4e032e5b35183f274592fcec577846ff
Last active October 20, 2025 13:48
Spartiallite bug repro
using System;
using Microsoft.Data.Sqlite;

class Program
{
    static int Main()
    {
        try
 {
@JKamsker
JKamsker / Review.md
Last active October 4, 2025 17:09
Review #2649

LiteDB PR #2649 — Cache Profiles & On-Demand Cleanup

Scope touched: Engine/Disk/MemoryCache.cs, Engine/Structures/PageBuffer.cs, LiteDB.Tests/Internals/Cache_Tests.cs Theme: Make the in-memory page cache tunable (profiles) and keep its free list in check with an on-demand cleaner guarded by a semaphore and per-page eviction flags.


Executive summary

Promising direction: explicit cache “profiles” (Mobile/Desktop/Server) and a safer cleanup handshake (TryBeginEvict/MarkReusable) add real tuning and safety hooks. However, the current implementation wires cleanup into hot paths and repeatedly calls ConcurrentQueue.Count (which is O(n) on .NET). That risks CPU overhead and read-path tail latency. The profile defaults are conservative and may over-trim the free list, increasing LOH churn during bursts. Unit tests don’t verify behavior, only “doesn’t throw”.

@JKamsker
JKamsker / install-dotnet-parameter.sh
Last active September 24, 2025 13:56
codex-web-installscripts
#!/bin/bash
# Parameterizable .NET setup script with parallel execution, smart caching, and tool integration.
# install with eg: curl -sSL ... | bash -s -- -v 7.0 -t "dotnet-ef,dotnet-aspnet-codegenerator,dotnet-try"
set -e
# --- Default Configuration ---
DOTNET_VERSION="8.0" # Default .NET version
APP_DIR="/app" # Default application directory
# Default global tools. If a tool name is passed without a version,
# it will be automatically pinned to the major .NET version being installed (e.g., "dotnet-ef" -> "dotnet-ef:8.*").
@JKamsker
JKamsker / repro.py
Created September 17, 2025 07:47
Github cli repro
#!/usr/bin/env python3
import json
import os
import shlex
import subprocess
from datetime import datetime, timedelta, timezone
def run(cmd):
# Explicitly pass the environment, which can solve obscure issues on Windows.
@JKamsker
JKamsker / deletejules.js
Created September 8, 2025 10:10
Delete all Google Jules Tasks
/**
* This script automates the process of deleting ALL tasks, starting from the last one.
* It is designed to be run in the browser's developer console.
*/
async function deleteAllTasksReverse() {
// 1. Find all task options buttons.
const allOptionsButtons = document.querySelectorAll("swebot-task-tile > swebot-task-options > button");
if (allOptionsButtons.length === 0) {
console.log("No tasks found to delete.");
@JKamsker
JKamsker / GetDependencyTree.cs
Created April 2, 2025 17:08
IServiceProvider GetDependencyTree
using System.Reflection;
public class DependencyNode
{
public string ServiceType { get; set; } = string.Empty;
public string? ImplementationType { get; set; }
public string Lifetime { get; set; } = string.Empty;
public string RegistrationMethod { get; set; } = "Unknown"; // e.g., Type, Factory, Instance, Collection
public List<DependencyNode> Dependencies { get; set; } = new List<DependencyNode>();
public bool IsCycleDetected { get; set; } = false;
@JKamsker
JKamsker / repro.cs
Created November 14, 2024 16:52
LiteDB repro
using System.Diagnostics;
using LiteDB;
namespace LiteDBLoadTest;
internal class Program
{
private static async Task Main(string[] args)
{
var cts = new CancellationTokenSource();
@JKamsker
JKamsker / Generatorunittest.cs
Created July 26, 2024 12:48
Generatorunittest.cs
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using SourceGeneratorTestHelpers;
namespace Generator.Equals.DynamicGenerationTests;
public class UnitTest1
{
[Fact]
public void Test1()
@JKamsker
JKamsker / GenericTypeHelper.cs
Last active August 1, 2024 08:36
A collection of snippets i need every now and then and not sure if i want to create a library for atm
public record GenericArgumentResult(Type RequestedType, Type DirectSubclass, Type[] GenericArguments);
public static class GenericTypeHelper
{
/// <summary>
/// Returns <see cref="TEntity"/> of <see cref="EntityTypeBuilder{TEntity}"/>,
/// even from <see cref="EntityTypeBuilderOfEntity"/> : <see cref="EntityTypeBuilder{TEntity}"/>.
/// </summary>
/// <param name="concreteType">For e.g EntityTypeBuilderOfEntity.</param>
/// <param name="genericDefinition">for e.g typeof(<see cref="EntityTypeBuilder{}"/>).</param>
@JKamsker
JKamsker / enforce.js
Created June 26, 2024 06:51
OpenAI Chat GPT-4o enforce
// ==UserScript==
// @name OpenAI Chat GPT-4o enforce
// @version 1
// @grant none
// @description This script enforces the GPT-4o model on the OpenAI Chat website
// @match https://chatgpt.com/*
// @run-at document-end
// ==/UserScript==
(function() {