Random snippets of all sorts of code, mixed with a selection of help and advice.
SQL join using BETWEEN, but I need to find GREATER THAN Val1 and LESS THAN or EQUAL TO Val2
16 January 2026 @ 6:57 pm
I need to join 2 tables based on a column named TRANS_ID. The problem is, one table has all available TRANS_IDs and the other table only has SOME of the available TRANS_IDs.
For instance, take this example
Table 1:
Trans_ID Next TRANS_ID Keys
9201014 9999999 194
9188244 9201014 137
9182489 9188244 179
9182248 9182489 124
9171439 9182248 371
9170746 9171439 294
Table 2:
ACCT ACCT_CD ST_DT TRANS_ID EXP_CD APPT_CD
3312392 HDHPI 2026-10-01 9182489 Y KLM
3312392 HDHPI 2026-10-01 9171439 N STP
3312392 HDHPI 2025-10-01 9170746 Y STP
What I need to get is something like:
ACCT ACCT_CD ST_DT TRANS_ID EXP_CD APPT_CD Keys
3312392 HDHPI 2026-10-01 9201014 Y KLM 194
3312392 HDHPI 2026-10-01 9188244 Y
Eigen3, setup for Macos and cmake, to compile the CGAL Samples
16 January 2026 @ 6:47 pm
This is on Macos 26
I'm trying to compile the examples from from cgal
https://github.com/CGAL/cgal/releases/tag/v6.1
Cmake has troubles finding a eigen3 installation
The output of brew is:
build brew info eigen@3
==> eigen@3: stable 3.4.1 (bottled) [keg-only] C++ template library for linear algebra https://gitlab.com/libeigen/eigen Installed
/usr/local/Cellar/eigen@3/3.4.1 (546 files, 8.9MB)
Also, they live here:
➜ build
ls /usr/local/share/eigen3/cmake/
Eigen3Config.cmake Eigen3ConfigVersion.cmake Eigen3Targets.cmake
The error is:
In ccmake, I have:
Eigen3_DIR Eigen3_DIR-NOTFOUND
and it complains with:
Targeting Unix Makefiles
Using /usr/bin/c++ compiler.
Running in macOS DARWIN_VERSION=25
NOTICE: T
Slack API: Can a SaaS app provide full user-level Slack experience without users opening Slack?
16 January 2026 @ 6:41 pm
I am building a SaaS platform with a master dashboard and multiple white-label tenants, and I want to deeply integrate Slack so that users never need to open the Slack app itself.
Functional requirement
A user logs into a white-label SaaS
That user joins a Slack workspace
The master platform can see that user
The white-label user can:
See channels they belong to
See other members
Send and receive messages
Messages must appear under the user’s real Slack identity
All of this should be handled entirely inside our SaaS UI, not inside Slack
In short, I want to provide a fully functional Slack-like experience inside my app, backed by Slack’s API, but without redirecting users to
Error with mgcv::gam df in R - fewer combinations than max. df
16 January 2026 @ 6:36 pm
I am constructing a gam for acoustic index data collected daily (with some various gaps by site) over two years: one year at one set of 10 paired sites (one restored site and one unrestored site per pair), and one year at another set of 10 paired sites. In addition to seasonal and yearly trends in the acoustic indices, I am interested in how both restoration and invasion (two levels of invasion) impact the indices. My dataset has around 8000 observations.
> str(Acoustic_Daily)
gropd_df [7,994 × 13] (S3: grouped_df/tbl_df/tbl/data.frame)
$ Site : Factor w/ 20 levels "BOH","BRC","DIV",..: 1 1 1 1 1 1 1 1 1 1 ...
$ TRT : Factor w/ 2 levels "R","U": 1 1 1 1 1 1 1 1 1 1 ...
$ DATE : num [1:7994] 14 15 16 17 18 19 20 21 22 23 ...
$ Year : num [1:7994] 2 2 2 2 2 2 2 2 2 2 ...
$ NDSI : num [1:7994] 0.527 0.374 -0.203 -0.298 -0.325 ...
$ ACI : num [1:7994] 156 152 154 157 158 ...
$ ADI : num [1
Find strings with longest common prefix
16 January 2026 @ 5:50 pm
I have a list of strings, for example:
["apple", "apply", "ape", "banana", "bank", "bat"]
Given an input string (e.g. "app"), I want to:
Compare it with each string in the list
Find the length of the common prefix they share
Return all strings that have the longest common prefix with the input
For example, "apple" and "apply" would match "app" more closely than "ape".
I’m not sure how to correctly compare prefixes character by character or how to keep track of the longest match. What is a simple way to approach this in Python?
Python: find index of list with highest average
16 January 2026 @ 5:48 pm
I’m learning Python and working with a list of lists where each inner list contains numeric values.
Example:
scores = [
[80, 90, 85],
[75, 88, 92],
[90, 85, 80]
]
Each inner list represents values for one item, and I want to:
Compute the average of each inner list
Find which inner list has the highest average
Return its index (0-based)
If two or more averages are the same, I want to return the smallest index.
I know how to calculate an average, but I’m not sure what the cleanest way is to compare all of them while keeping track of the index. Any beginner-friendly approach would be appreciated.
ISTIO - Virtual service to virtual service routing
16 January 2026 @ 5:44 pm
I'm trying to have one ISTIO virtual service (VS) route to another (downstream) VS, but can't get the upstream VS to resolve and route traffic to the downstream VS. Fully qualifying the hostname of the downstream VS makes no difference. I receive a 503 response code without a body from 'istio-envoy' server when directly routing, and 'istio analyze' results in an error of 'Referenced host not found'.
If I add a ServiceEntry for the referenced/downstream VS, fully qualified as '{downstream-virtual-service}.{ns}.svc.cluster.local', I clear up the 'istio analyze' error, and then receive a 503 response code with the addition of a body of 'no healthy upstream'.
Is there a way to route traffic from one VS directly to another VS?
Below is a simple hello-world yaml, w/ ServiceEntry included which reproduces the 503 response code with 'no healthy upstream' body.
apiVersion: v1
kind: Namespace
metadata:
name: hello-world-app
labels:
How to split a string based on a delimiter that appears more than once?
16 January 2026 @ 5:01 pm
I have a table in a DB2 database that contains some URLs - it looks like this:
ID | URL
---|-----------------------------------------------------------------------------
A | https://website-name.com/something/53b/251038?list=1&split=M&source=123456
B | https://website-name.com/something/53b/250926?list=1&typ=2&source=AbcdA2abcA
The bit at the end (after the final equals sign) is unique to each URL. I want to have this as a separate column to the ID column. So the output should look like this:
ID | URL_end
---|-----------
A | 123456
B | AbcdA2abcA
Does anyone know how to do this please?
Batch custom tee function redirect to file is inconsistent
16 January 2026 @ 4:59 pm
I am trying to implement a minimal "tee" function in batch.
I followed an example as the base for my code, which uses tee_nt.txt as its source.
I've written a simple test to understand the code. This is the batch that I run:
@echo off
echo HelloWorld | call tee.bat outfile.txt
This calls my tee.bat:
@echo off
SET "File=%1"
SETLOCAL
FOR /F "tokens=1* delims=]" %%A IN ('FIND /N /V ""') DO (
> CON ECHO.%%B
>> %File% ECHO.%%B
)
ENDLOCAL
The output to the console looks ok:
S:\batch\snippets\tee\tee>test_tee.bat
Hello World
The output to the file should also be Hello World, but instead it is t
Find maximum value per group from CSV file
16 January 2026 @ 4:44 pm
I have a CSV file with columns like:
student_id,subject,score
S001,Math,85
S001,Physics,92
S001,Chemistry,78
S002,Math,88
What I want to do is:
Filter rows by a given student_id
Find the highest score for that student
Get the corresponding subject
I’m able to read the CSV file, but I’m not sure about the best way to track the maximum score and return the related value.
What would be a clean and beginner-friendly way to do this in Python?
update:
this is what i've got after 2 hours, is there anything i'm still missing and could improve on?
# QUESTION: Highest Score Finder
# Goal: Find which subject a student did best in
# Step 1: Import the csv module to read CSV (Comma-Separated Values) files
import csv
# Step 2: Define a FUNCTION - a reusable block of code
# Functions