StackOverflow.com

VN:F [1.9.22_1171]
Rating: 9.2/10 (11 votes cast)

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

getting timeout when adding second page.evaluate with puppeteer

9 November 2025 @ 2:30 am

I have this with node 25.0.0 and Windows and puppeteer. Basically the get_card_search_results is called and it loads a page that features lazy loading. It will "scroll" the page down to ensure that the entire page loads. This part works with no issues: const puppeteer = require('puppeteer'); var browser; var puppeteer_options = { headless: true, ignoreHTTPSErrors: true, args: ['--disable-dev-shm-usage', '--shm-size=4gb'], defaultViewport: {width: 1920, height: 1080}, protocolTimeout: 1500000, //https://www.puppeteersharp.com/api/PuppeteerSharp.LaunchOptions.html } try { browser = await puppeteer.launch(puppeteer_options); var page = await browser.newPage(); } catch (err) { console.log(err); } async function get_card_search_results(options) { await scroll_current_page({url:url, gp_args:gp_args}) } async function scroll_current_page(options) { await page.goto(url, {waitUntil: 'networkidle2'}); //, {waitUntil:

What options exist for ownership/references in Rust dependency injection?

9 November 2025 @ 2:19 am

I'm interested in the options for providing ownership or references to dependencies when doing dependency injection in Rust. I don't mean like a DI framework or anything like that, just the general pattern. For example let's say we have a trait for a storage layer that stores binary blobs. pub trait BlobStore { fn read_blob(&self, id: &str) -> Result<Vec<u8>, ()>; } Now we want to create a decorator blob store that wraps another, adding a caching layer. It needs to accept both a blob store and an in-memory cache. pub trait Cache { fn get(&self, key: &str) -> Option<Vec<u8>>; fn set(&self, key: &str, value: Vec<u8>); } The question is: what should the decorator look like in terms

Coarsening the resolution of a xarray dataset

9 November 2025 @ 2:18 am

Very new to python! I am trying to model bottom water temperatures over time and need to reduce the resolution of my model from 1/20º to 1º. My ultimate goal is to map this and select specific grid cells to calculate temperature for each year. I have tried re-grid but came up with errors when trying to import xesmf. Ive looked into using groupby_bins or the coarsen method but haven't been able to figure out how and if they would actually work. This is the error i get when trying to import xesmf: ModuleNotFoundError: No module named 'xarray.core.arithmetic' this is the work that I have done with coarsen so far: coarsen_factor = 20 v20x = v20x.rename({"nav_lon": "latitude", "nav_lat": "longitude"}) coarsened_ds = v20x.coarsen( latitude=coarsen_factor, longitude=coarsen_factor, boundary='exact' ).mean() But I am getting this error: ValueError:

How do I compute the space occupied (not the number of elements in it) by a TreeMap at Runtime (in MB)?

9 November 2025 @ 1:53 am

Background: I am working on an indexer and wish to set a threshold (in bytes) when the current index has to be flushed to disk and a new index must be created to accommodate more objects. Currently I am just flushing based on the number of documents processed by the indexer, but that seems to be very rudimentary and does not really take into account the fact that some documents may be massive (MB level) and others very small (KB level). I want to minimize the CPU and memory footprints, so using any instrumentation library is out of the question, since they do introduce heavy overhead while sampling the heap. What I have looked into: I looked into manually computing the size and although this would give a rough estimate, it seems kind of an ad-hoc fix and a last resort. Using the Runtime library, but it is unreliable due to varying periods of GC cycles. External libraries like JOL add measurab

BUN With SSR and Tailwind

9 November 2025 @ 1:43 am

I am trying to configure my project with SSR and Tailwind but I can not see tailwind in my SSR page. I mean, It is only working in html entry point in client routes, but I want to use it in my SSR routes. Is it possible? in dashboardHTML is working normally package json { "name": "bun-react-template", "version": "0.1.0", "private": true, "type": "module", "scripts": { "dev": "bun --hot src/index.ts", "start": "NODE_ENV=production bun src/index.ts", "build": "bun run build.ts" }, "dependencies": { "bun-plugin-tailwind": "^0.1.2", "react": "^19", "react-dom": "^19", "tailwindcss": "^4.1.11" }, "devDependencies": { "@types/react":

How do I scale and translate my Pentagons properly?

9 November 2025 @ 1:22 am

I am trying to finish a program that will take the world coordinates of polygons, in this case pentagons, and scale and translate them from a world size of 1280x720 so they are drawn based on the center of a 512x288 screen. I have a function for turning world coordinates into screen coordinates (define (world-to-screen x-coords y-coords) (let* ([worldWidth 1280]; define our total world width that we want to work with [worldHeight 720]; define world height [xScale (/ IMG-Width worldWidth)]; define the scale by wich we will scale polygons [yScale (/ IMG-Height worldHeight)] [xTrans (/ IMG-Width 2)]; define the amount we will translate the polygons by on the x [yTrans (/ IMG-Height 2)]); define the amount we will translate the polygons by on the y (vector (+ (* x-coords xScale) xTrans) (+ (* y-coords yScale) yTrans))); return a vector with the new x and y coordinates ) (world-to-screen 0 0) outputs -&

make a list according to max count

9 November 2025 @ 12:34 am

I have a list my_list = [3,8,11,8,3,2,1,2,3,3,2] # my list max(my_list,key=my_list.count) # most frequent number appeared on the list But i want to make a list according to the most frequent number appeared on the list. How can i do it? For example new list output will be: new_list = [3,2,8,2,1,11] # new list according to the most frequent number appeared. As 3 came 4 times, 2 came 3 times,8 and 2 came twice and 1,11 came once.

Why isn't font-face CSS working properly, did I mess up the file path?

8 November 2025 @ 10:40 pm

I've also tried to use the src: local("") for linking the font file but that also doesn't work. There was an issue with the font-family name not matching the actual file name which was odd but has since been resolved, now I really don't know what's wrong I'm using a Mac and running on Chrome, and coding on Phoenix Code Screenshot of CSS Code and File Tree: file tree Here's an image of what the html looks like when running on chrome html live preview on phoenix code HTML: <!DOCTYPE html> <html lang="en"> <head lang="en"> <title> Title </title> <

How to get value of cell in dataframe

8 November 2025 @ 9:34 pm

I'm new to Python, so please be lenient. I want to read the value of a single cell from a dataframe based on the selected row. I do this as below, but I get the value not when I click on a record (when the selection checkbox is checked), but only after I click on another one or uncheck the row. Why? I get some record from the database and draw a table using Streamlit and pandas: employees = get_all_employees() event = st.dataframe( employees, hide_index=True, selection_mode="single-row", on_select=on_employee_select, ) Then the on_select function goes like this: def on_employee_select(): global selected_emp_id, selected_emp_name row = event.selection.rows # type: ignore # List of selected row indices if row: selected_emp_id = int(employees.iat[row[0], 0]) # type: ignore selected_emp

The feasibility of creating a small-scope 3D multiplayer game using C and Vulkan

8 November 2025 @ 6:30 pm

I come seeking advice. I'm attempting to make a game with C and Vulkan (no engine). It will be low scope. It has a low-mid poly aesthetic, fairly involved mechanics, and will be multiplayer, supporting a handful of servers with lobbies with a max pop of ~16. I'm adequate with C, with a fairly robust knowledge of it's more advanced topics, although I know nothing of networking/multiplayer. Just from cursory research, I hear a lot of nightmare stories of how adding multiplayer could add years of dev time, compounded with using C, it is seen as potentially unfeasable unless you are some kind of savant, which I am not. Now, I did end up getting reasonably far from a first attempt, just implementing the foundations of Vulkan, having an interactable, 3D play area, and moderately advanced game state and mechanic stuffs. Then, my old computer shat the bed, so I am starting from scratch. So, I definitely can at least create the non-multiplayer aspects of the game, but mu