Random snippets of all sorts of code, mixed with a selection of help and advice.
Pixel-accurate SERP truncation and OG image validation without a browser?
19 April 2026 @ 4:12 am
Problem
I'm building a CMS publishing pipeline where I need to validate SEO metadata before content goes live. I need to:
Detect if a SERP title will be truncated in Google search results
Validate Open Graph image dimensions before publishing
Validate Twitter/X Card images per card type (summary vs summary_large_image)
What I'm doing now
// ❌ Inaccurate — character count ≠ pixel width
if (title.length > 60) {
console.warn('Title might be too long');
}
// ❌ Incomplete OG validation
if (width < 1200 || height < 630) {
console.warn('OG image too small');
}
Why this fails
Google truncates SERP titles based on pixel width (~580px), not character count. Wide characters like W or M get cut much earlier than narrow ones like i o
Arrow key causes delta jump in spritekit
19 April 2026 @ 4:11 am
I have a problem where my macOS (Sequoia) Spritekit game spikes delta during the first press of an arrow key. I've test this with a small program, code below:
//
// GameScene.swift
import SpriteKit
import GameplayKit
class GameScene: SKScene {
var lastTime: TimeInterval = 0
override func keyDown(with event: NSEvent) {
print("---------------> delta keyDown: \(event.characters!) keyCode: \(event.keyCode)")
}
override func update(_ currentTime: TimeInterval) {
// Called before each frame is rendered
print("update begins")
let dt: CGFloat
if lastTime > 0 {
dt = (CGFloat(currentTime - lastTime))
} else {
dt = 1.0 / 60.0
}
if dt > (1/30) {
print("************************************ delta spike ", dt)
}
lastTime = currentTime
print("dt: ", dt)
print("up
Permissions with google drive
19 April 2026 @ 3:08 am
To avoid installing each time I start a session, I tried to put the miniconda inside the google drive. Here is the error I got:
The Permission denied error means Google Drive is still preventing the execution of binaries (like Conda's Python). Modifying the mount options requires root access, so we need to add sudo back to the mount command. I'll update the cell to properly apply the execution permissions.
Unfortunately, Google Colab mounts Google Drive using a special FUSE filesystem that strictly enforces the noexec (no execution) flag for security reasons. Attempting to remount it with exec using mount or sudo mount will not work, which is why we keep getting the Permission denied error when trying to run Conda binaries directly from Drive.
the raspberry pi pico extension in vscode cannot create a C++ project
19 April 2026 @ 3:01 am
I've tried to create a C++ project for several times, but it showed me a blank every time. Instead, I am able to create a micropython project.
The empty "new pico project" tab
I've tried the pre-release version and the extension I am using now is the one I've downloaded from GitHub. Both of them didn't work, so I think it has nothing to do with the extension itself.
The project is at /home/hdkghc/picoproj/calculator.
extension version: 0.19.0
I've tried the pre-release version and the extension I am using now is the one I've downloaded from GitHub. Both of them didn't work, so I think it has nothing to do with the extension itself.
The project is at /home/hdkghc/picoproj/calculator.
extension version: 0.19.0Immigration management system
19 April 2026 @ 2:56 am
Add personal information associated with immigration operation , update , delete , search and display all information."Create a Linked List code project for me, completing every part, and make it look like it was written by a person rather than an AI."
Scoring items if the text appears in another list
19 April 2026 @ 2:28 am
I am trying to use excel to check if a typed answer can be found in another list. If the word can be found in one of the other lists, I want to score that a 1, if not I want it to be scored a 0.
I am having difficulties figuring out how to have excel check one item against a whole list, then provide either a 1 or 0 depending on if it does match.
UnicodeDecodeError (character maps to <undefined>) when reading a text file [duplicate]
19 April 2026 @ 1:30 am
I have a Python file and a text file in the same folder in VS Code, and I have the following code:
intro_doc = open("0_intro.txt","r")
intro_text = intro_doc.readlines()
print(intro_text)
intro_text.close
I thought it would just print out the text file, but instead I get
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 730: character maps to <undefined>
I have no idea what this means.
line count returns 2 less than expected
18 April 2026 @ 8:46 pm
// Last task removal
if(!strcmp(argv[2], "last")) {
int line = 0; // Which line is last in the file
FILE *fileptr = fopen(FileAddress, "r"); // Create file pointer and open it in read and write
char* filebuffer = calloc(10000, sizeof(uint8_t)); // Create memory on the heap
while(fgetc(fileptr) != EOF) { // Loop through the file until end of file
if (fgetc(fileptr) == 10) { // Check if its a new line
line++; // Increment line count
}
}
printf("%d", line);
}
This code is supposed to return how many lines are in a simple txt file but for some reason it returns 2 less than expected every single time. I have tried to fix this myself but for the life of me can't figure it out
Also, yes I know the code is probably bad but this is my second ever C project after a number guessing game. There is definit
Practical tips for coding
18 April 2026 @ 8:19 pm
I’m pretty much just getting started with coding and web development. To be honest, I’m not too bad at HTML and CSS, but I’m really struggling with dynamic web projects—I’m having a hard time using PHP and SQL. Besides working on active projects, what else should I do?
Where in the C standard does it specify the corresponding argument for %n in fscanf shall be a pointer to int
18 April 2026 @ 7:47 pm
The C23 standard draft n3220 says the following about the conversion specifier n for fscanf in statement 7.23.6.2p12 (emphasis mine)
n No input is consumed. The corresponding argument shall be a pointer of a signed integer type. The number of characters read from the input stream so far by this call to the fscanf function is stored into the integer object pointed to by the argument. Execution of a %n directive does not increment the assignment count returned at the completion of execution of the fscanf function. No argument is converted, but one is consumed. If the conversion specification includes an assignment-suppressing character or a field width, the behavior is undefined.
I don't see any mention that the corresponding argument for the conversion specification %n (n