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.

Is there anyway to extract live data from listed products (ei 1oz gold bar) for apps script?

18 April 2026 @ 3:12 am

The goal of this is to query Walmart, filter by product “metadata”, grab top 5 results, average price) is doable in principle. I created the trigger to execute every 8 hours., but the key issue is this. Walmart does not expose “metadata tags” in a clean, reliable way via simple XML/IMPORTXML scraping. So the approach slightly toward either: structured search result scraping (HTML), or a product API (preferred), or a hybrid (search → parse → filter keywords in title) Any advice would be appreciated. This is what I have so far after asking ChatGPT: function getWalmartAverage(searchTerm) { const query = encodeURIComponent(searchTerm); const url = `https://www.walmart.com/search?q=${query}`; const response = UrlFetchApp.fetch(url, { muteHttpExceptions: true, headers: { "User-Agent": "Mozilla/5.0" } }); const html = r

Parsing Problems in HTTP Web Proxy Server

18 April 2026 @ 3:02 am

In a Python exercise, I need to develop a small web proxy server that is able to cache web pages. This proxy server only needs to understand simple GET-requests but is able to handle all kinds of objects, not just HTML but also images. Below are my codes: # Proxy Server from socket import * import sys # Create a server socket, bind it to a port and start listening tcpSerSock = socket(AF_INET, SOCK_STREAM) serverName = '0.0.0.0' serverPort = 8000 tcpSerSock.bind((serverName, serverPort)) tcpSerSock.listen(1) while 1: # Start receiving data from the client print('Ready to server...') tcpCliSock, addr = tcpSerSock.accept() print('Received a connection from:', addr) message = tcpCliSock.recv(1024).decode() print(message) # Extract the filename from the given message filename = message.split()[1].partition("/")[2] print(f"filename: {filename}") fileExists = "False" try: # Check wh

Automating importing live price of gold & silver, setting a trigger every 8hrs, and appending

18 April 2026 @ 2:10 am

I want to run a script to automate the process of copying live values into a new row every 8 hours as static data and append new data points to your sheet automatically to build a historical record into google sheets, Using apps script and GOOGLEFINANCE for spot Gold and Silver Prices. I only return the date and not the price of both Gold and Silver. Here's how the output should be structured: Date Collected Gold Price Silver Price 2026-04-17 00:00:00 5301.10 80.41 2026-04-17 08:00:00 5401.91 75.51 Sheet name where data should be stored "precious metal tracker" function logMetalsData() { const ss = SpreadsheetApp.getActiveSpreadsheet(); const sourceSheet = ss.getSheetByName("

How can a class that implements an interface return another interface in a method?

18 April 2026 @ 1:36 am

I am sorry for asking this, but I am very confused. I am creating a project where I compare various sorting methods (such as Selection Sort, Bubble Sort, and Merge Sort). It asks me to create two interfaces, one called ISorter and one calle ISortStats. ISorter has a method that returns the interface ISortStats, how does that work? And, is it possible for an object that implements ISorter can return ISortStats in a method? (The interfaces were already given to me in the assignment). I am supposed to implement ISorter on each of my sorter classes. I ask that you please don't give me the answers and try to explain. Thanks! public interface ISorter { public SortStats sort(int[] a); } public interface ISortStats { String getAlgorithm(); int getNumItems(); int getNumComparisons(); int getNumMoves(); long getNumNanoseconds(); }

Structure of a union with a struct inside of it? [duplicate]

18 April 2026 @ 1:30 am

I'm working on an emulator for a z80 based system and have decided to structure my registers like this: union Reg { uint16 reg_; struct { uint8 hi_; uint8 lo_; }; }; The only problem I'm experiencing with this is that when I access those lower level fields, they seem to have the opposite data than what I expect. I never considered the endianness of the host system playing a part here, but is that the case? For example, in case I'm not very clear, when I create data like so Reg BC; BC.reg_ = 0x0123; I expect to be able to access the hi byte with BC.hi_ and receive 0x01, but instead I get 0x23. Is this just how data is structured on a low level on modern systems? Or is this something I should check for different systems?

Problem with the function remove in a class function

17 April 2026 @ 11:56 pm

this is my first question in this website. the problem is, i tried to adapt a function of python 2 to python 3.14, the function is eliminaCarta, that take a class named carta and delete this carta for a list in another class called mazo, the problem is that the function delete the first element of the list, not the correct element, i dont know where is the problem. The code contain another function, but the principal with problem is the last in the class mazo import random class Carta: listaDePalos = ["Tréboles", "Diamantes", "Corazones", "Picas"] listaDeValores = ["nada", "As", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Sota", "Reina", "Rey"] def __init__(self, palo=0, valor=0): self.palo = palo self.valor = valor def __str__(self):

BCB32 ver.6 bug [closed]

17 April 2026 @ 10:31 pm

Could someone please verify this bug in BCC32.EXE 6.16.0.33 (CodeGear™ RAD Studio 2009 Version 12.0.3170.16989): typedef struct{ __int64 i; } S; void foo(){ S s={0I64}, *p=&s; p->i <<= 2; //AV /*workaround: p->i = p->i<<2; or p->i = Int64ShllMod32(p->i, 2); */ }

Which services are typically required to scale a LAMP stack for high-traffic production environments?

17 April 2026 @ 8:42 pm

I am designing a LAMP-based application expected to handle high concurrent traffic (e.g., thousands of requests per minute). The core stack includes Linux, Apache, MySQL, and PHP. Based on documented architectures or widely adopted production patterns, which additional services are generally required to ensure scalability and performance? For example: Is an in-memory cache like Redis or Memcached considered essential in such scenarios? Under what conditions is a reverse proxy (e.g., Nginx) introduced in front of Apache? Are message queues (e.g., RabbitMQ) typically used for background processing in LAMP environments? Please provide answers based on real-world architectures, documentation, or measurable constraints (e.g., performance bottlenecks), rather than personal preference. https://github.com/wnunezc/wsdd-rust

How to assert the number of SQL queries EF Core executes in integration tests?

17 April 2026 @ 6:17 pm

I want to write integration tests that verify my ASP.NET Core endpoints don't produce N+1 queries. Specifically, I want a test to fail if an endpoint that should execute 1 query suddenly starts executing 10. I know I can log EF Core queries, but I don't want to parse log output in tests. Is there a clean way to assert the exact number of SQL queries executed during an HTTP request in an integration test?

How to smooth out a geom_ribbon plot?

17 April 2026 @ 3:57 pm

I wanted to reach out as I have been struggling with making a graph look correct and was wondering if you had some insights into the R-code. So the issue I am working on is smoothing out an insect abundance graph. My current R-code looks like this: Y2_insect_time%>% ggplot(aes(x = Date.num, y =total, colour = Treatment))+ geom_line(aes(alpha= 1)) + geom_ribbon(aes(ymax = total + seY2t, ymin = total - seY2t,alpha = 0.01 , fill = Treatment)) + guides(alpha="none") + theme_bw() + xlab(NULL) + ylab("macroinvertebrates collected") + ggtitle("Number of Macroinvertebrates Over Time in Year Two") And gives me this result: enter image description here I was looking to smooth out the graph since there are so many sharp turns. So I attempted to run the system through geom_smooth with code that looked like this: