Reading books and commenting on them with ChatGPT

I just finished reading Paul Auster’s The New York Trilogy1. On this occasion, I discovered a new use for ChatGPT and LLMs. ChatGPT and I chatted about the themes, especially the correlations and connections between the three short novels that comprise the volume. It was an alienating and revealing experience. For the first time, I am reasoning about a book with a machine, not a person. Because it knows everything about the text and draws on the shared global knowledge, it can give more satisfaction than most people do (also, it’s not easy to find someone around with whom I can talk about all the books I read!) Yes, it is wordy and repetitive, but it can stimulate and enrich my analysis2. ...

November 26, 2024

Under ASP.NET 8, NGINX returns 502 Bad Gateway after authentication by IdentityServer

Today, I learned the hard way that NGINX has default buffer sizes, which can cause trouble in specific scenarios like mine.

September 12, 2024

ShellCheck

Today I learned about ShellCheck, a static analysis tool that “finds bugs in your scripts”. It can and should be run on the command line, but an online version is also available. It catches most style and syntax errors and has plenty of options, like ignoring specific errors and warnings, which is helpful in CI scenarios.

July 24, 2024

Bash-Oneliner: a collection of terminal tricks for Linux

Bash-Oneliner is an excellent resource for Bash/Linux users. Most of the “tricks” are well-known, but there is always something to learn. More importantly, finding them all well organized in one file is rare. I use the reverse lookup of bash-history (Ctrl+R) daily. Still, only today (thanks to an HN comment on Bash-Onliner) did I learn that it also preserves one’s comments, which can be exploited to invoke complex commands quickly: $ mv -n ~/Desktop/*.pdf ~/Documents/PDF_Archive/ #pdfsync Then, you simply Ctrl-R and type “pdfsync” to recall the above command when needed. Neat. ...

July 22, 2024

How to handle custom claims in an Open ID Connect-authenticated ASP.NET Core app

Today, I learned how to handle custom claims in an Open ID Connect authenticated ASP.NET Core app. The scenario goes like this. I have an ASP.NET Core app that authenticates with Open Id Connect. It receives a bearer token from the authentication server. Besides OIDC claims, this token has been forged with additional custom claims for use in the app. However, only ODIC claims exist when I parse HttpContext.User.Identity.Claims in my middleware. If I retrieve the token with HttpContext.GetTokenAsync and decode it, I confirm it contains all the claims I need. Where have my custom claims gone? Or, how can I get User.Identity to provide them along with the OIDC ones? ...

May 31, 2024

ChatGPT is the perfect Linux assistant

I spent the day doing remote maintenance on multiple Linux machines via ssh. The revelation is that ChatGPT is the bomb for these tasks: What does that command option do? I am trying to remember. What syntax is to install that peculiar and rarely used package on Debian? I am getting this locale configuration error; what was the fix again? All this stuff is answered much sooner than searching online, no matter the search engine. ...

March 29, 2024

SQLite foreign key constraints are disabled by default

Today, I learned that SQLite only enforces foreign-key constraints if explicitly instructed. I imagine this is well-known and trivial for the SQLite initiated, but we’re a Postgres shop; I have used SQLite sporadically, primarily for experiments like today’s, and this one amenity was certainly unexpected. Anyways. I had all my ON DELETE CASCADE constraints nicely configured, but related records in child tables were not being deleted when I deleted the parent. Perplexed, I looked it up. ...

February 22, 2024

Default ASP NET Core 8 port changed from 80 to 8080

Today, I learned the hard way that the default port for ASP.NET Core 8 container images has been updated from port 80 to 8080, quite a remarkable breaking change. We upgraded our web application from .NET 7 and let the CI pipeline do its work. Finally, we checked the application in the browser to ensure everything was okay, but unfortunately, we got a 502 Bad Gateway error. The Nginx logs revealed that the app was rejecting connections, which was unexpected because we didn’t make any changes there. Further investigation showed that the web app listened on port 8080 while Nginx was reverse-proxied to 80. So that was the problem. But why did the port change? ...

February 20, 2024

GitHub Wikis don't allow edits or pull requests

Today I learned that GitHub wikis are not editable online and do not support pull requests. You can clone and edit a wiki locally but not return your change to the original repository. I don’t use wikis in my projects; I prefer documentation to stay with the project, usually in a dedicated directory, and publish it on a dedicated site through GitHub Pages. But today was different as I opened a pull request for PaperMod, the Hugo theme I use on this website. Someone asked if I could update the documentation too. Right, too bad it’s impossible to do that. ...

February 9, 2024

pg_dump and pg_restore can backup and restore single Postgres schemas

Today I learned that pg_dump can make a copy of a Postgres schema instead of the whole database. Likewise, if needed, pg_restore can restore the schema in either the original database or a different one. Backup of a Postgres schema: pg_dump -h host -d source_database -U user -n schema_name -F c -f schema_dump_file.dump Restore of a Postgres schema: pg_restore -h host -d dest_database -U user -n schema_name schema_dump_file.dump All primary and shared knowledge, I am sure. Another item of note: the DB name is hard-coded in pg_dumpall files, so if one wants to restore on a database named differently, one must go into the dump file and edit it by hand. ...

January 30, 2024