Random snippets of all sorts of code, mixed with a selection of help and advice.
I built a website like reddit / hacker news but better
9 January 2026 @ 12:58 am
I have built a similar website to reddit / hacker news but hopefully made it a touch better without loads of adverts all over the place and AI bots hanging about. I would be interested to see what people think and for some feedback.
\> www.upvote.social
Numba-optimise class method without modifying class
9 January 2026 @ 12:26 am
Suppose I have a class force_generator defined in the following code:
import numba
import numpy as np
class force_generator(object):
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
def force(self, x):
if x > 0:
return self.a*x**2 + self.b*x + self.c
else:
return self.b*x
def simple_force(self, x):
return self.a*x**2 + self.
@numba.jit
def euler_integration(force, x_0=0, v_0=0, m=1, dt=1e-3, t=10):
steps = int(t//dt)
X, V = np.zeros(steps), np.zeros(steps)
X[0], V[0] = x_0, v_0
for i in range(1,steps):
V[i] = force(X[i-1])*dt/m
X[i] = V[i]*dt
return X, V
example_simple_force = numba.jit(lambda x: x**2 + 2*x + 1)
example_force = numba.jit(lambda x: (x**2 + 2*x + 1)*(x>0) + (2*x)*(~(x>0)))
example_generator = force_generator(1, 2, 1)
X, V = euler_integration(example_force)
print(X)
print(V)
Why are files invisible in Win32/Debug and Win32/Release?
8 January 2026 @ 11:28 pm
I recently purchased and installed Delphi 13. The .exe file, along with the .dcu files, are placed in win32/debug or win32/release. Often, however, the files are not visible and the win32/debug, win32/release folder properties show 0 folders and 0 files. But sometimes, the files are visible. I found that searching for a file known to exist, however, finds the file in win32/debug or win32/release. Sometimes on a restart, the .dcu and .exe files subsequently show up.
How can I get the files to show up after a compile or build?
Can We Save Stack Overflow with AI? A Proposal
8 January 2026 @ 11:21 pm
Can We Save Stack Overflow with AI? A Proposal
The Current Crisis
Stack Overflow is struggling. Traffic and engagement are declining due to AI tools like ChatGPT. The platform developed a reputation for being hostile toward beginners, with aggressive duplicate marking and sarcastic comments. Experts became tired of answering repetitive basic questions, and new developers started preferring ChatGPT where there's no social judgment.
My Idea: AI as First Responder
Here's how it would work:
Step 1: User asks a question (Type, Title, Body, Tags as usual)
Step 2: AI generates an immediate response, clearly marked as "AI-Generated Response"
Step 3: The community participates by:
Rating the response (upvote/downvote)
Adding alternative or complementary answers
Correcting errors in the AI response
Expanding with
sorting arrays of arrays of ints (2-d array) does not work (it sorts as strings; 1-d arrays work)
8 January 2026 @ 9:05 pm
A 1-d array of ints sorts correctly.
An array of arrays of ints does not sort as ints; it sorts as strings.
(10,2) | Sort-Object
This works and is sorted as ints.
2
10
$a1 = [int[]](10,1)
$a2 = [int[]](2,1)
$a1,$a2 | Sort-Object | ForEach-Object {'--';$_}
This does not work.
The 10 and 2 are sorted as strings, not as ints.
--
10
1
--
2
1
Does anybody have a fix or workaround?
Q Powershell GitHub issue was opened to address this behavior on Oct 25, 2022, but it was closed for housekeeping purposes after six months of inactivity on Nov 22, 2023.
https://github.com/PowerShell/powershell/issues/18389
This problem
Passing Apache-authenticated user Principal to Quarkus app
8 January 2026 @ 4:09 pm
I have a quarkus web app currently protected by Apache's form-based authentication via reverse proxy.
# conf.d/session-auth.conf.inc
AuthType form
AuthFormProvider file
AuthUserFile ...
AuthFormLoginRequiredLocation /web/login.html
...
# httpd.conf
<Location /app-name>
ProxyPreserveHost On
ProxyPass ...
ProxyPassreverse ...
Labels on
Include conf.d/session-auth.conf.inc
<RequireAll>
Require valid-user
</RequireAll>
</Location>
I had to play games to copy the authenticated user id to the request header by adding the following to the Location block above:
RewriteEngine on
RewriteCond %{REMOTE_USER} (.*)
RewriteRule .* - [E=ENV_REMOTE_USER:%1]
RequestHeader set X-Proxy-REMOTE-USER %{ENV_REMOTE_USER}e
...but what I would really like is to set the Principal from the Apache data.
The quarkus docs have lots of information about driving t
browser_use Agent runs locally instead of E2B sandbox Chrome despite browser_url parameter
8 January 2026 @ 3:05 pm
I am trying run browser_use Agent actions such as clicks, typing, and screenshots inside an E2B sandbox Chrome instance, not local Chrome.
Currently, the agent spawns local Chrome processes even though I pass browser_url=wss://e2b-chrome-endpoint.
import asyncio
import json
from e2b import Sandbox
from browser_use import Agent, ChatOpenAI
from dotenv import load_dotenv
load_dotenv()
async def main():
# E2B sandbox creates successfully
sandbox = await Sandbox.create(template="browser-chromium")
try:
# Get Chrome CDP endpoint ✓ Works
chrome_host = await sandbox.get_host(9222)
cdp_url = f"wss://{chrome_host}"
print(f"CDP URL: {cdp_url}") # Prints: wss://sandbox-abc123.e2b.dev
# Agent ignores remote browser - spawns LOCAL Chrome
llm = ChatOpenAI(model="gpt-4o-mini")
agent = Ag
Apache .htaccess should redirect only if substring NOT found in URI
8 January 2026 @ 2:12 am
Completely stumped fiddling with .htaccess in a CakePHP app. Checked a few SO posts and Perplexity.ai LLM. But still getting erroneous results. Trying to do a simple full host redirect, but skip the rule if the substring "cheezit" is found in the request. I've been able to print out the server variables like %{REQUEST_URI} so I know they have the expected input values. There is no other contents in the .htaccess file.
# .htaccess
RewriteCond %{HTTP_HOST} ^([^.]+)\.?old-legacy-host\.com$ [NC]
RewriteCond %{REQUEST_URI} !cheezit [NC]
RewriteRule ^(.*)$ https://%1.new-awesome-host.com/$1 [R=302,L]
# ... whatever other rules
# Original CakePHP framework directives
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
When I visit https://xyz.old-legacy-host.com/cheezit/45, this URI like any other redirect
Spring Boot on Tomcat 9 is returning 404 failures despite addition of SpringBootServletInitializer
7 January 2026 @ 10:23 pm
I am attempting to run a Spring Boot application from a Tomcat server, using Tomcat V9.0.
Unfortunately, while this application works when I run it as a Java application, when I attempt to run it within a Tomcat container, it
returns a "404: Not Found" failure.
After researching the differences between deploying with Tomcat and deploying with embedded Tmcat, I created the following ApplicationBuilder
class:
package net.factor3.app;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class TestApplication extends SpringBootServletInitializer
{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
{
return application.sources(TestApplication.cl
Sum of total value for all dates separately in excel based on values from a table
3 January 2026 @ 1:27 pm
I'm trying to get a report sheet based on another table that contains more data
i have succeeded in creating the date column based on the available dates in the other table using =UNIQUE(FILTER(Table13[DATE],Table13[DATE]<>"")) which listed the dates, i want to calculate the sum of these dates, i have tried =SUM(UNIQUE(FILTER(Table13[AMOUNT],Table13[AMOUNT]<>""))) but it's showing me a strange total.
sample: https://docs.google.com/spreadsheets/d/1UqcHQBSwiYVzEd0lESEqlgoHymoR08qy/edit?usp=drive_link&ouid=111206627585463999752&rtpof=true&sd=true
Thanks