A few weeks ago I wrote about running Claude in a container because I really don’t want it to have access to my computer. I mount a directory on my host into the container, and Claude can read and write files in that directory. Some of the applications I had Claude create for me use Node, and I had it lock down the versions of the dependencies. To do this, it created a .npmrc that looks like…
Last night I ran a normal update, Open Office, some other stuff, and a few kernel related updates. Nothing out of the ordinary. I continued to use my computer normally, and everything seemed fine, and then turned it off. After booting my laptop this morning, I got no further than the Kernel Panic screen and a suggestion to reboot. I tried that a couple of times to no avail. What I didn’t…
This is mainly for myself when I forget how to this. I use netcat, nc , to test connectivity between two hosts from time to time, often with containers in Docker compose, but I don’t do it often enough to remember the syntax. So here it is. To start the listener, run this - nc -l -p 9999 And to connect to the listener, run this - nc <listener-host> 9999 When the listener is in a container,…
I recently wrote a post about running GUI applications in a Docker Desktop container in Linux. This is more challenging than it should be because I use Docker Desktop instead of the Docker Engine. You can read about it here . The post got the bones of what I wanted in place, but my final goal was to run VS Code in a container and forward the X11 display from the container to the host. Why, you…
Oh boy, this was much harder than I expected. I found guides and articles and blog posts on how to do this, but none of them worked for me. What I wanted to do I like running applications in containers; I wrote a post about running Claude Code in a container . For a while, I’ve wanted to run GUI applications in a container and forward the X11 display from the container to the host. Why do…
There are a lot of opinions about running Claude Code and other AI tools on your personal computer. Some are in favor, some against. I don’t want to do it, I want Claude isolated away from my personal files. One option is to create a full virtual machine, this is heavy, and will be slower to start and use. A faster, lighter option is to use a Docker container. It is extremely fast to start,…
I install VS Code in Ubuntu using snap. This has generally been fine, but with the new-ish dotnet run app.cs , I hit an interesting problem. When I try to run some .NET CLI applications using a terminal within VS Code, I get an error that looks like this - Unhandled exception: An error occurred trying to start process…
This post is a follow-up to my previous fast .NET CLI downloader with the additional feature of ISO integrity validation. Just point it at the ISO you want to download, and it will look in the usual spot for the SHA sum file. I often download versions of Linux distributions to try out. These are very large and usually come with a checksum file that you have to manually check after downloading. The…
I’ve been using the dotnet run app.cs CLI applications for a little while. Until now, I had no problem with arguments passed in, but today I added a -v option to my application to print out the version number. Something like this - # !/ usr / bin / dotnet run foreach ( string arg in args ) { switch ( arg ) { case '-v' : case '--version' : Console . WriteLine ( 'Simple Application: Version…
There are plenty of GUI download managers, but I wanted a simple one that I can call from the command line. With the newish dotnet run app.cs style, it became easier to do this. Here is the full source code. Make sure the file is executable, and then you can run it with downloader.cs someLargeFile.iso and it will download the file, in parts, to the current directory, then it stitches them…
Locally, I’ve been running some simple HTML, CSS, and JavaScript websites, as well as the static output of Hugo (my blog engine). When I wanted to serve these sites, I used to call python -m http.server in the directory where the files were. It’s easy, but in the last few months, I’ve been writing more of the dotnet run app.cs style applications, and it is perfect for a web…
I was chatting to a friend a few weeks ago when he told me that he couldn’t install .NET on a Windows computer where he doesn’t have admin access. When he tried to run the MSI installation files, he was prompted for an admin password, which he doesn’t have. Here is a simple guide to installing and running .NET on a Windows computer without administrative privileges. Get the zip…
I wrote a couple of blog posts this month about running Kafka commands in C# because the CLI from Confluent seems to have changed its authentication requirements. These changes make it difficult for me to use a Docker based Kafka with no authentication. Why no authentication? Because it’s on my local machine and I don’t want to have to set up authentication just to test things out. The…
I have read a bunch of blog posts talking about synchronous and asynchronous API calls, but I found that most of them mix the idea of an API call being synchronous or asynchronous with the idea of the language supporting asynchronous programming. So here it is, with no discussion of asynchronous programming in any language. Preamble Before I get into the difference between synchronous and…
CockroachDB’s Change Data Capture (CDC) feature lets you stream changes from the database to multiple external locations, known as sinks. In this post, I’m going to show the most basic setup to get it going. In subsequent posts, I’ll show slightly more complex scenarios. I have written plenty of blog posts on using CockroachDB and Kafka separately, so I won’t go into the…
I recently wrote a post about using a simple Command Line Interface (CLI) consumer for Kafka in C#. You can find that post here . Here is a simple CLI producer in C#. Again, it uses the dotnet run app.cs approach. Here is the code - 1 # !/ usr / bin / dotnet run 2 # : package Confluent . Kafka @ 2.5 . 0 3 using Confluent.Kafka ; 4 5 if ( args . Length != 2 ) 6 { 7 Console . WriteLine ( 'Usage: url…
When I started working with Kafka, I installed it locally on Docker and used a combination of the Confluent Command Line Interface (CLI) and C# programs I wrote. One of the CLI tools from Confluent let me produce and consume messages on a Kafka topic by specifying the topic name and broker address. It was an easy way try things out. But when I used this more recently, I couldn’t get it to…
Download full source code. I was recently talking with a friend about the factory and strategy patterns, how they could be used together. He was familiar with the factory, but not the strategy. The factory lets you create the kind of object you want on the fly without explicitly calling new on a concrete class. The strategy pattern lets you execute some method defined in an interface without…
I often run services like databases or messaging systems in Docker and connect to them from my host computer, where I have a .NET application using them. But sometimes I want to run the application in a container too. In this case, I have to connect the two containers over a Docker network. In this post, I’ll show how to do it without Docker Compose, and in a follow-up post, I’ll use…
I wanted to run a couple of Alpine containers with Docker Compose to test out network communication between them. But the containers immediately exited after starting because there was nothing running on them. I needed the equivalent of running docker run -it alpine but in Docker Compose. I found two ways of doing this. git The first is to use stdin_open: true in the Docker Compose file. The…
Download full source code. In this post, I will show you how to run two .NET applications in Docker containers and have them communicate with each other. I will use Docker Compose to create the network, build the images, and run the containers. The first application is a .NET Web API with an endpoint that returns a random number when called. The second application is a .NET Worker Service that…
I’ve written a few posts about [CockroachDB]/tag/cockroachdb, and in most of them you can run the database in insecure mode. But, there are a few things you can only do in secure mode. One is creating other users, but there are probably others. To use secure mode, there are a number of steps. Create the certs First, you need to create several certificates, actually quite a few. # create two…
If you have been using Blazor, you are probably familiar with .razor files that contain both the UI markup and the code to support it. The template from Microsoft for a new Blazor Server application creates a Pages/Counter.razor file that looks like this - @page '/counter' @rendermode InteractiveServer < PageTitle > Counter </ PageTitle > < h1 > Counter </ h1 > < p role = 'status' > Current count…
Download full source code. This is the third in a series of posts on locking rows and CockroachDB. The first post showed how rows or whole tables could be locked, and how to avoid/minimize this. The second showed how to identify transaction that are locking rows. This post will show how to terminate transactions locking rows. Create some locks First, we need to create some locks. Run the following…
Download full source code. Occasionally, I want to build and run a .NET application within a Docker container. I use VS Code on Linux, so I don’t have the easy option to add a Dockerfile that is in the full Visual Studio. And I can never remember exactly what to do, so here it is for my future reference. There are samples on the dotnet/dotnet-docker/ GitHub repo. But it feels a bit…
This is part 2 of a series on locking in CockroachDB. The first post showed how you can end up with locked rows or tables, and how to keep your locks to the fewest number of rows by using indexes. But even with the best use of indexes, you can still end up with rows that get locked. This can be worsened if you have some other issue, like a statement or transaction that is slow or doesn’t…
Locking rows in a database is a common way to prevent other transactions from modifying the data you are working on. But a transaction can hold onto rows for too long, or you can lock a whole table accidentally. These locks can be brief or indefinite if something has gone very wrong. I have written about locking and timeouts in CockroachDB in previous posts - CockroachDB and Postgres SELECT FOR…
Download full source code. Every once in a while I get a simple idea that I want to implement just because it will be fun and I enjoy programming. Here is a simple C# program that encodes Morse code messages and plays them on Windows and Linux. For Linux, you need to add the mpg321 package. sudo apt-get install mpg321 Or whatever package manager you use in your Linux. I’m using two NuGet…
Occasionally, I want to clear cookies for a specific site, usually because the site is misbehaving and I want to start fresh. I’ve had this happen with some financial sites, where I could not log in from one browser, but could from another. Clearing cookies for the site fixed the problem. In Firefox, it is easy. Go to Settings, Privacy & Security, Cookies and Site Data, Manage Data. Then…
This post is an update to an earlier post on caching Tasks and only executing them when first accessed. In that post, I used Task.Start() to start the task when it was first accessed. This works, but there is another way, as suggested by Steven Cleary in the comments on that post. It stores Lazy<Task<string>> in the cache, and when the value is first accessed, the Value property of the Lazy<T> is…
Over the years, I’ve written a few posts about Actions, Funcs, and how they work with lambdas. Simple Action and Action Examples Simple Func and Func<T1, T2, TResult> Examples C# Lambdas Part 1, a Quick Overview with Examples C# Lambdas Part 2, a Few More Complicated Examples If you are struggling to understand how lambdas, Actions, and Funcs work, I recommend reading those posts first. This…
Download full source code. This is one of those posts that there may not be any “good” practical application for, but it might be helpful in some edge cases. And I learned something interesting about web browser behavior, more on that later. The idea What if you wanted to acquire an exclusive lock on a resource while executing a Web API action method? Generally speaking, this is not a…
One of the worst day-to-day things you can do in a database is lock a table or rows for too long. This will cause other requests to wait or fail. In some cases, you will need a DBA to step in and kill the offending session to release the locks. There are three timeouts on Postgres and CockroachDB to help prevent this from happening - statement_timeout - the maximum time a single statement can run.…
This is a very short post, but it will likely save some people a little time. If you have been using CockroachDB locally, it is very easy to connect to via the command line - cockroach sql --insecure No username, no password, no certs. When I went into DataGrip, I added a CockroachDB connection and tried with no username, no password, and got an error. The very simple fix is to use the username…
Download full source code. I recently started playing with InfluxDB, and as with many of these things, it took a little longer to get going than expected. So, to save the next person some time, here is how to do it. Docker Setup It starts with Docker. I love Docker for this kind of thing. Get the image, start it, use it, stop it when done, and delete it later. No need to install it to the…
For the past few months, I’ve been using OBS Studio to record my podcasts. It is not a traditional podcast recording tool, but it is free and easier than some alternatives. Background I’ve been making podcasts since 2014, long before they became as popular as they are today. Back then, there weren’t any of the polished websites you can use now to make the recording. I used to use…
Here is a short post on something that can catch people out at times when sorting strings. If you have a list of strings that contain numbers like - {"item2", "item4", "item1", "item3", "item11", "item12"} , and you perform a simple order by on them, you will get - {"item1", "item11", "item12", "item2", "item3", "item4"} Not what you want. To resolve this, you need to isolate the number, convert…
I wrote a post about enabling pinch to zoom in Chrome, Chromium, and Brave on Ubuntu. But that method does not work for Microsoft Edge. The particular flag that you need to set is not available in Edge. But there is another way. Edge needs to be launched with the following arguments - --enable-features = UseOzonePlatform --ozone-platform=wayland But I don’t want to launch Edge from the…
I have been using Linux for a very long time, and in recent years I have been doing all my .NET work in Ubuntu . Firefox has been my default browser for most of this time, but I also like having some variant of Chromium installed. And for the past few months, that has been Brave . With Firefox, by default, I can use the touchpad or screen to pinch to zoom in and out of web pages. But with…
Download full source code. Just for fun, I thought I would try out Oracle with Entity Framework Core. It’s not something I would recommend, in the short time I played with it I found it had difficulty with .Any() , produced exceptions that lacked any useful information and I struggled with documentation. Docker First, I got Oracle running in a Docker container. It is an extremely large…
Download full source code. Here is the next in my series of posts showing how to use various databases with Entity Framework Core. This time it’s the turn of SingleStore , a distributed SQL database that is designed for high performance and scalability. SingleStore is compatible with MySQL, so you can use the MySQL library for Entity Framework to connect to it. Docker First, get SingleStore…
Recently I was trying out Aeron on .NET while using Linux. One of the steps required me to extract the contents of the Aeron.Driver NuGet package. But there is no nuget executable for Linux. To get it working I would need to install Mono, but I didn’t want to do that. I know the package is just a ZIP file, so I could extract it with unzip . NuGet packages are zip archives But I wanted to see…
Download full source code. As I have discussed before, there are some deficiencies with the Confluent .NET Kafka client. The first was its lack of support for async message consumption, I show how to overcome that here . The second is its lack of batch message consumption, i.e. consume some preset number of messages or whatever arrives in some timeframe. This post will show how to implement batch…
For many years while using VS Code there was a .vscode directory with a tasks.json and a launch.json file. These files were used to configure the build and debug process. I have edited these files to start the browser to a specific URL , and to pass arguments to the application being debugged . But in more recent versions of VS Code, these files are not automatically created. I have sometimes…
I wrote another the version of the code using Lazy<Task > as suggested by Stephen Cleary in a comment on different post. Most of the time when I cache a value it is something that I pull from a slower data source like a database or an API. Other times the value to store is something that takes significant work to compute, so I don’t want to recompute it each time it is requested. Normally…
I was working on something recently where I wanted to define a task, but not run it immediately. I couldn’t find much useful information about this, so I decided to write about it, once I figured it out. In the end, it took quite a bit of time to get this working the way I wanted, so it should save time for the next person. What I want to do I want to create a task that will call a method,…
I use Docker to run many services I don’t want to install on my computer - databases, queues, caches, etc. But sometimes I want to know exactly how the container is started, see the script or binary inside the container that is executed. To get this information you can get the original Docker file but that can be tricky sometimes, but there is another way. In Docker Desktop, go to the…
Download full source code. Over the past few months, I’ve been writing posts about using various databases with .NET and in particular Entity Framework. Not it’s the turn of MySQL. I may be wrong on this, but I recall a time when MySQL was more popular. If you were on Linux it was part of the popular LAMP stack. But it seems to have declined in popularity with Postgres taking its…
Download full source code. There is something a little strange about the Worker Service template and its BackgroundService in .NET. You can create a new Worker Service project using - `dotnet new worker -n MyWorker The Problem The Worker class uses a BackgroundService as its base class. The Worker has an ExecuteAsync(...) method that is called when the service is started, and it takes a…
Download full source code. If you have an application that runs a BackgroundService or maybe a few BackgroundService s, you may want to stop the host application and all the other services from one of the BackgroundService s . The first approach I tried was to pass a CancellationTokenSource to the service using dependency injection and then call Cancel() on it. The host application monitors the…