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.

How can I convert a cubemap stripe to a 'little planet' projection

14 October 2025 @ 1:48 am

I have some images in cubemap format which I'm using with photo-sphere-viewer (see my repo). I've made a simple Apple Shortcut that converts six separate cubemap angles to one stripe. For example: example cubemap I want to convert the cubemap to a 'little planet' style image such as the one below as a download option for my image. I don't want to have to download any software, I only want to use JS, but I'm not familiar with THREE.JS. example little planet image Thanks!

How do I make a frame update and a time update?

14 October 2025 @ 1:36 am

I am making a game (HTML/JS/CSS) where you have things that update every second, but also other things (e.g. keypresses) that need to be updated every frame. So far I have a setTimeout() in a requestAnimationFrame() loop for the former, but I need to know how to add a frame update alongside it.

Data aggregated from ad level metrics doesn't equate to account level metrics

14 October 2025 @ 1:23 am

I'm trying to fetch data for each ad for a given account and aggregate it at the adset/campaign/account level internally so we don't have to make multiple calls to the Meta API. However, while doing this we discovered that some aggregated metrics, notably those corresponding to the actions field don't seem to equate to the account level responses. Here's a simple script to recreate the query we're passing: def fetch_meta_insights( access_token: str, entity_id: str, level: str, fields: str, date_preset: str = "last_30d", ) -> Dict[str, Any]: url = f"https://graph.facebook.com/v23.0/{entity_id}/insights" params = { "access_token": access_token, "level": level, "fields": fields, "date_preset": date_preset, } all_data = [] while url: response = requests.get(url, params=params) response.raise_for_stat

What is the difference between underscore-prefixed functions and #[allow(dead_code)] before a function?

14 October 2025 @ 1:11 am

Underscore-prefixed functions (fn _foo()) disable the compiler warning about unused functions. The same can be achieved using #[allow(dead_code)] before the function. Is there a difference between the two similar to how #[allow(unused)] also disables, for example, unused variables inside the function? When do I use which?

Compilation error for 'terra' in Rstudio v 4.1.1

14 October 2025 @ 12:33 am

I am hoping to install the R-INLA package (https://www.r-inla.org/what-is-inla) which requires the package terra. I need to install the source version of terra to use the INLA package (the binary version is not compatible). When attempting to install the source version I get the following error, that gdal_priv.h does not exist: installing the source package ‘terra’ trying URL 'https://cran.rstudio.com/src/contrib/terra_1.8-70.tar.gz' Content type 'application/x-gzip' length 1049207 bytes (1.0 MB) downloaded 1.0 MB * installing *source* package 'terra' ... ** package 'terra' successfully unpacked and MD5 sums checked ** using staged installation ********************************************** WARNING: this package has a configure script It probably needs manual configuration ********************************************** ** libs

Autoplay embeded video and/or slideshow

14 October 2025 @ 12:22 am

I am trying to auto play and loop a slideshow on a website from a file hosted on OneDrive. I have tried to embed the slideshow using: <iframe src="source.pptx?wdAr=1.7770833333333333" width="476px" height="288px" frameborder="0"> </iframe> When that didn't work, I tried to export as a video and embed the mp4 using both <iframe> and <video> both with and without the ?autoplay=1 `<div style="text-align:center"> <iframe src="source.mp4?loop=1&autoplay=1" width="800px" height="550px" frameborder="0" allow="autoplay; loop"> </iframe> </div>` <div style="text-align:center"> <video><source src="source.mp4?loop=1&autoplay=1" allow="autoplay; loop" type="video/mp4"> </video

Post request body empty - XMLHttpRequest to PHP

13 October 2025 @ 7:17 pm

Always getting empty post data null in php end var data = new FormData(); data.append('ip', 'val'); data.append('ua', 'val2'); data.append('country', 'val3'); var xhr = new XMLHttpRequest(); xhr.open('POST', 'visitor.php?type=visitorControl', true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(data); PHP END if ($_GET['type'] == 'visitorControl') { $file = 'visitors.json'; $visitors = json_decode(file_get_contents($file), true); $userid = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0,6);; $newEntry = [ 'userip' => $_POST['ip'], 'useragent' => $_POST['ua'], 'country' => $_POST['country'], 'status' => 'Pending', 'timestamp' => 'NA' ]; $visitors[$userid][] = $newEntry; file_put_contents($

Can I clean the phrase of the C++ n4928 working draft (regarding mandatory copy-elision during initialization with identical types) like this?

13 October 2025 @ 11:05 am

So there is a phrase from the C++ Standard working draft (n4928): [dcl.init.general] 9.4.1 \ 16.6.1 If the initializer expression is a prvalue and the cv-unqualified version of the source type is the same as the destination type, the initializer expression is used to initialize the destination object [Example 2: T x = T(T(T())); value-initializes x. — end example] For me, the words "is used to initialize" sounds like an infinite recursion... And if not, then why is the reader of the Standard supposed to think that neither copy- nor move-constructors of T are called? It looks like the authors intended this meaning: If the initializer expression is a prvalue and the cv-unqualified version of the source type is the same as the destination type, no constructors are cal

Simpy not showing other process name

12 October 2025 @ 5:46 pm

I am trying to work my self into simpy. Which uses python generators to create sim steps. From the documentation for simpy state access. import simpy def subfunc(env): print(env.active_process.name) # will print "my_proc" def my_proc(env): while True: print(env.active_process.name) # will print "my_proc" yield env.process(subfunc(env)) yield env.timeout(1) return 42 env = simpy.Environment() p1_result = env.process(my_proc(env)) print(type(env.active_process)) # None env.step() print(type(env.active_process)) # None Is there an explenation why subfunc is printed out as my_proc ?

Generating Key & Nonce Pairs from Web Crypto API vs from Word List. Is entropy the same?

12 October 2025 @ 4:06 am

I want to find out if the 2 methods shown below achieve the same level of entropy. For this first secure method, a 32 byte / 256 bit key and a 12 byte / 96 bit nonce are generated using the JavaScript Web Crypto API which is guaranteed to generate cryptographically strong random values. Therefore we can affirm that the key & nonce contain maximum entropy for their respective sizes. function generateSecureKeyNoncePair() { const keyBytes = new Uint8Array(32); // Buffer for random values crypto.getRandomValues(keyBytes); const nonceBytes = new Uint8Array(12); // Buffer for random values crypto.getRandomValues(nonceBytes); return { keyBytes, nonceBytes }; } const { keyBytes, nonceBytes } = genera