StackOverflow.com

VN:F [1.9.22_1171]
Rating: 8.5/10 (13 votes cast)

Random snippets of all sorts of code, mixed with a selection of help and advice.

Tweak to working Javascript to make it read from textfield

17 January 2026 @ 11:04 pm

I am using a Google Map API and simply want to display how many miles it is from one city to the next using one textfield. The following code works, but the origin and destination are hard coded into the function. I would like to be able to type "Nashville, TN to Atlanta, GA" into a textfield and have it display the milage between the two. The city names are always different. Perhaps you have a more simpler code that I can use. I just want the miles to display next to my textfield so I don't have to open up Google maps in a separate browser every time to see how many miles a place is from the origin to the destination. Thanks. <!DOCTYPE html> <html> <head> <title>Route Miles Only</title> <script src="https://maps.googleapis.com/maps/api/js?key=MY API GOES HERE"></script> <style> body { font-family: sans-serif; padding: 20px; } input { padding: 8px; width: 200px; font-we

Aging Page Replacement Algorithms: Searching for Pages to Replace in the Background vs. at the Moment of a Page Fault

17 January 2026 @ 11:04 pm

I read somewhere that an OS can calculate which page to upload to disk in the background with updating aging bits, and not at the time when a page fault happens. How does it actually work? Why would the approach I described not work, or why is it bad?

Are non-blocking Linux sockets thread-safe for multiple writers?

17 January 2026 @ 10:56 pm

Can multiple threads safely write to a shared TCP socket opened in non-blocking mode (if that changes anything compared to blocking sockets)? Will the Kernel serialize the data from each of these send() calls, i.e., prevent interleaving of data from two different buffers?

How do I stop this? [closed]

17 January 2026 @ 10:26 pm

I keep notifications alerting me that there is a security warning. I check my stuff and my phone is texting and clicking on items when I haven’t touched the screen, then I get alerts another person is using my account. I have a screenshot of a number that was never mine. And it’s showing my passkeys. The owner of the other phone number showed me. What is going on? How do I fix this?

Nodemon error causing app to crash when using npm start

17 January 2026 @ 10:26 pm

I'm trying to run my app that I just started but am running into an error when using npm start. Below is my index.js file: import express from 'express'; import bodyParser from 'body-parser'; import mongoose from 'mongoose'; import cors from 'cors'; const app = express(); app.use(bodyParser.json({ limit: "30mb", extended: true })); app.use(bodyParser.urlencoded({ limit: "30mb", extended: true })); app.use(cors()); const CONNECTION_URL = 'mongodb+srv://<username>:<password>@cluster0.igris4b.mongodb.net/?appName=Cluster0'; const PORT = process.env.PORT || 5000; mongoose.connect(CONNECTION_URL, { useNewUrlParser: true, useUnifiedTopology: true }) .then(() => app.listen(PORT, () => console.log(`Server running on port: ${PORT}`))) .catch((error) => console.log(error.message)); //mongoose.set('useFindAndModify', false); The last line is commented out because I recently found out useFindAndModify n

Gmail Add-on: close popup authentication window when AuthorizationAction completes

17 January 2026 @ 10:24 pm

In the Gmail add-on I build the authorization card: var authorizationUrl = getOAuthService().getAuthorizationUrl(); var card = CardService.newCardBuilder(); var section = CardService.newCardSection(); section.addWidget(CardService.newImage() .setImageUrl(imageUrl) .setAuthorizationAction(CardService.newAuthorizationAction().setAuthorizationUrl(authorizationUrl))) card.addSection(section); return card.build(); In the oauthCallback function I display a message depending on whether the authorization succeeded: function oauthCallback(request) { var service = getOAuthService(); var isAuthorized = service.handleCallback(request); if (isAuthorized) { return HtmlService.createHtmlOutput('Authorization Succeeded. You may close this window.'); } else { return HtmlService.createHtmlOutput('Authorization Denied.'); } } At this time I would like to automatically close the authorization

Delete Button Non-Functional

17 January 2026 @ 10:23 pm

I'm making a basic stat tracker with HTML, CSS, and JS for a fighting game. Most of it is functional, I can track which characters I used and whether I won or lost but now I'm trying to add a delete button to each match that was previously saved and is rendered on screen and running into issues. I was able to get the function to work when I clicked on the box a match result was in, but not the actual delete button. I tried adding line 55: if (e.target.closest(".delBtn")) { but now nothing is being deleted and no errors are being thrown. What am I doing wrong? <!DOCTYPE html> <html lang="en"> <head> <title>2KXO Tracker</title> <meta charset="UTF-8"> <link href="2KXO.css" rel="stylesheet"> </head> </html> <body> <h1>2KXO Trackertt</h1> <main> <form id="

Why does the interactive Python interpreter in PyPy have a slightly different command-line interface?

17 January 2026 @ 10:20 pm

I have identified that the interactive Python of PyPy is slightly different from the default Python interpreter specification, with PyPy lines starting with ">>>> " or ".... " instead of ">>> " or "... " prior to the command portions of each line. Why are there four right-angle symbols or dots at the beginning of each line in PyPy instead of the regular three?

How to read user 'roles' through a Discord bot?

17 January 2026 @ 10:17 pm

I am building a Discord Bot using Python + SQLite3, and am creating a function /add_active that adds all users in the guild with a role 'active'. However, my application can't seem to access member roles at all. Though there's no 'error' present, when I add debugging messages to see what roles are accessed it says that there are no 'active' in the server roles. I do have member intent enabled, and all other functions work, so I know it's not a problem with guild IDs and highly unlikely a permissions issue. @app_commands.command( name="add_active", description="add all active members to game!" ) async def add_active(interaction: discord.Interaction): # command can only be used in a server guild = interaction.guild if not guild: await interaction.response.send_message("This command can only be used in a server!", ephemeral=True) return players_added = 0 # add the user to the active pla

/usr/bin/arm-none-eabi-ld: error: crt0.o: conflicting use of R9

17 January 2026 @ 10:12 pm

I am working on an operating system for the RP 2040 chip (ARM Cortex-M0+). After returning to the project after a few years, it no longer compiles and I get the following linker error: /usr/bin/arm-none-eabi-ld: error: ./crt0.o: conflicting use of R9 /usr/bin/arm-none-eabi-ld: failed to merge target specific data of file ./crt0.o