Random snippets of all sorts of code, mixed with a selection of help and advice.
Google Sheets formula changes when an outside process inserts data into one of the sheets referenced in the formula [duplicate]
28 January 2026 @ 10:46 pm
I added some logging of home automation data to a google sheet. Every 5 minutes a script inserted three row at LogData:A2. The data is {timestamp, name, value}. I want the most recent data at the top so I insert rather than append. In a separate sheet, I have a formula:
=XLOOKUP("xyzzy", LogData!$B$2:$B, {LogData!$A$2:$A,LogData!$C$2:$C}}, "Not Found", 0, 1)
Later, when I returned, the formula was reporting the wrong data. Investigation revealed the formula had been changed to:
=XLOOKUP("xyzzy", LogData!$B$47:$B, {LogData!$A$47:$A,LogData!$C$47:$C}}, "Not Found", 0, 1)
Apparently, the insert operation found and "fixed" the formula references as if I had manually inserted the rows.
Does anyone have an alternative but equivalent formula that would not have the references “fixed” by the data inserts done by the script?
Reconciliation from DB -> Kubernetes or DB as a caching layer
28 January 2026 @ 10:33 pm
I have encountered this very non-trivial problem of managing state drift and was wondering what your opinions were.
Basically I am trying to create a managed-hosting provider (Gameservers) and I'd like to do it in kubernetes. A user creates a server -> A new deployment is created in my k8s cluster.
My model maps quite nicely to k8s primitives and handling that state is not really difficult at all. The problem is etcd is not made for customer facing data.
When my users refresh their control-panel I shouldn't ask etcd to list all deployments/stateful sets in a namespace. That's slow (and unreliable afaik because my application should be able to run even when k8s is self-updating.)
Now the solution I came up with is using a normal database and using locking and a `k8s_state_applied` boolean to sync my database to kubernetes. The issue is that deleting resources in the database, and then also deleting them in k8s is very difficult. If a deletion fails in k
c++ write to memory mapped file and read, different result in debug and release
28 January 2026 @ 10:26 pm
I have a code to write a string to a MMF and read it
This code run perfectly in debug profile, but not in release profile
#include <iostream> //for cout
#include <regex> //split + to_string
#include <windows.h> //MMF + GetModuleFileName
#define BUF_SIZE 256
HANDLE hMapFile;
LPCWSTR pBuf; //LPCSTR
LPCWSTR szName;
#include <tchar.h> //pour utiliser _tcslen
bool init_error = false;
int get_TCHAR_length(std::string str)
{
size_t size = str.length();
TCHAR* wArr = new TCHAR[size + 1];
//wArr[size] = '\0';
return (_tcslen(wArr) * sizeof(TCHAR));
}
TCHAR* convert_string_to_TCHAR(std::string str)
{
size_t size = str.length();
TCHAR* wArr = new TCHAR[size + 1];
for (size_t i = 0; i < size; ++i)
wArr[i] = str[i];
wArr[size] = '\0';
return wArr;
}
std::string convert_wstring_to_string(std::wstring wstr)
{
std::string str(wstr.begin(),
How to Install Astropy Python package on iOS?
28 January 2026 @ 10:26 pm
I am trying to run a Python script on my iPhone and iPad that uses the Astropy package. I have installed both Pythonista and Juno. Juno supposedly has it installed but I get errors from it. The script I am trying to run is pretty straight forward and below. It does run on a desktop so there are no bugs in it.
import astropy.units as u
from astropy.coordinates import EarthLocation, SkyCoord, AltAz
from astropy.time import Time
import requests
def get_equatorial_coords():
# 1. Define the Observer's Location: Roseville, California
# Lat/Lon for Roseville, CA
# location = EarthLocation(lat=38.7521*u.deg, lon=-121.2859*u.deg, height=50*u.m)
try:
# Use ip-api.com (free, no API key required for low volume)
response = requests.get("http://ip-api.com/json/")
data = response.json()
if data['status'] == 'success':
lat = data['lat']
lon = data['lon']
city = data['city']
reg
Is there a standard image size to be used for a website
28 January 2026 @ 10:25 pm
Is there a standard image sizes for a website for varios aspect ratio ? I do not want to create a huge image which indirectly impact the page size. So are there a recommended size to use for aspect ratios like 16:9, 1:1 , 4:3.
I have browsed through multiple website and tried to understand their aspect ratio and the standard size they have used. Tools like this has helped me understand the aspect ratio of the image in a website but It doesn't recommend a ideal size i should use for a aspect ratio. Any help will really useful, thank you
https://tools.maverickapps.co.uk/aspect-ratio-calculator/
What do modern libraries like numpy or scipy specifically do in order to achieve partial pivoting during matrix inversion?
28 January 2026 @ 10:22 pm
As an exercise problem I am trying to write a program that will invert matrices using the method of LU decomposition with partial pivoting. I sort of understand LU decomposition but was struggling to achieve partial pivoting. So I asked Google Gemini and stack's AI this question - "what do modern libraries like numpy or scipy specifically do in order to achieve partial pivoting during matrix inversion?" The answer in both cases were more or less the same that they search for the highest magnitude number in a column and then swap rows in a manner such that the highest magnitude number is in the diagonal. I wasn't able to unearth any more specific about the process. But after several cycles of trial and error I came to realize that simply swapping rows such that the highest magnitude numbers are in the diagonal is not going to do, there are more ifs and buts involved. For example, what if multiple columns have their highest magnitude entries in the same row? What if fixing o
Most feasable way to achieve automated service update notifications using Bitbucket + K8s?
28 January 2026 @ 10:18 pm
I would like to send out a notification in teams to a specific channel using workflows whenever any deployment gets updated and re-deployed in k8s.
So for me its not enough to notify on push or merge, its important that the updated version is running.
Now I figured there are several approaches. If I use something like keel, i know that once bitbucket deploy step is done, within the next 15 minutes or so, the deployment in k8s will restart with the new version and it would be enough to notify once deploy is done. However not all deploys use keel yet.
Second: Use some kind of watcher or whatever in k8s directly. There however I do not know how to integrate teams notifications. Bitbucket has it natively.
You guys got any experience with that?
Need PHP code to Oauth2 authenticate and send email via Gmail API without using google-api-php-client
28 January 2026 @ 10:18 pm
I've learned that Digital Ocean doesn't allow outgoing SMTP requests on port 587 from their droplet servers so I am trying to find the most compact PHP code available to send email using the Gmail API. It's not practical for me to use Google's official PHP client for the api, google-api-php-client, which consists of a ludicrous 3,984,473 lines of PHP code in 32,365 files -- 180MB!.
I therefore need some PHP code which can
Obtain the access token to be used for sending mail. I don't think I'll have or need any redirect url -- I'm not trying to set up a page for users of my site to authorize stuff, I simply want to send email from my own gmail account.
Recognize if the access token is old and refresh the token, if necessary.
Use the access token to contact the Gmail API and send an email message using my gmail account.
I've enabled the Gmail A
MSS creating windows at different locations
28 January 2026 @ 10:17 pm
I have taken this snippet from the docs. However, there is an issue where the screen keeps sliding down. I am unsure of how to fix this. It fixes when I move it out of the captured region, but that is a problem because I need to capture the entire screen. I am on the newest version of all libraries and Python and on Windows 10. My windows scale is 100% at 1920x1080p.
import time
import cv2
import numpy as np
import mss
with mss.mss() as sct:
# Part of the screen to capture
monitor = {"top": 40, "left": 0, "width": 800, "height": 640}
while "Screen capturing":
last_time = time.time()
# Get raw pixels from the screen, save it to a Numpy array
img = np.array(sct.grab(monitor))
# Display the picture
cv2.imshow("OpenCV/Numpy normal", img)
# Display the pictur
import time
import cv2
import numpy as np
import mss
with mss.mss() as sct:
# Part of the screen to capture
monitor = {"top": 40, "left": 0, "width": 800, "height": 640}
while "Screen capturing":
last_time = time.time()
# Get raw pixels from the screen, save it to a Numpy array
img = np.array(sct.grab(monitor))
# Display the picture
cv2.imshow("OpenCV/Numpy normal", img)
# Display the picturHow to color a cylinder?
28 January 2026 @ 10:09 pm
I am just trying to render a red cylinder. But the cylinder comes out blue with a checker pattern on its side (I want it red and without the checkered pattern)
from manim import *
class RotateTable(ThreeDScene):
def construct(self):
cylinder = Cylinder(radius=2, height=3,
color=RED, fill_opacity=1,
stroke_opacity=0, stroke_width=0).shift(0.5*RIGHT+1*IN + 0.001*OUT)
self.add(cylinder)
self.set_camera_orientation(phi=70*DEGREES, theta=0)
self.wait(1)