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.

Loading template is very slow due to same interal clean ups

24 March 2026 @ 2:24 pm

I have a docx document which has about 85 pages and is 1.6 MB in size. Loading it with $TBS->LoadTemplate() takes more than 80 sec. and the reason for it is calling the internal method MsWord_Clean(). According to the documentation this is done 'to cleanup or prepare somes sub-files' and the proposed work around is to call $TBS->Plugin(OPENTBS_MAKE_OPTIMIZED_TEMPLATE, $template, $new_template); and afterwards use $new_template I wonder what this optimization is about? Why is it required? When I turn it off by setting $TBS->OtbsClearMsWord to false the resulting document still looks fine and the template loads much faster.

Hoppscotch API Import Issue

24 March 2026 @ 2:11 pm

I recently downloaded Hoppscotch 26.2.1. I added some APIs and created a collection. But when I do an export to JSON and share it with a colleague. All the APIs show up as "Untitled". The only difference being I am on version 26.2.1 and he is on 25.5. At the end of the day its a JSON file, so I am not sure the version mismatch would cause an issue. Any pointers would be helpful. enter image description here

Adding or having an mathematical operational function using arrays?

24 March 2026 @ 2:11 pm

Hello! I'm sorry if it may sound dumb but I'm still learning java as it's the first thing that we are currently learning in university. We are now discussing arrays and I'm a bit confused how to do addition using arrays, I do have a sample code and I just want to know what are like the methods that are used to add them. I'd appreciate the help deeply! Here is the code currently I'm trying to figure out how to code (also the instructions are there teehee): public class arrays { public static void main (String []args){ //two-dimensional arrays int [][] arr = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12, 13}}; // Display the sum of each row [0], [1], [2]. // Display the sum of each column. // Display the sum of all the elements. for (int i = 0; i < arr.length; i++){ for (int j = 0; j < arr[i].length; j++){ Syste

Retrieving data such as impressions for each share for each day

24 March 2026 @ 1:55 pm

I am stuck on this for quite some time, and the API guide lines are not helping. I am trying to retrieve impressions, viralImpressions, clicks etc from shares. I have all rights neccessary. I have tried multiple API's, and think the organizationalEntityShareStatistics API is my best bet. I get different data for each post, which I expected. However, every post has the same result for each day (i.e. days 1 through 7 have the same data for each post, but I expect different data for each day for each post). I am using the following API call, and I am using the python requestslibrary.  "https://api.linkedin.com/rest/organizationalEntityShareStatistics?q=organizationalEntity&pivot=CREATIVE&organizationalEntity=urn%3Ali%3Aorganization%3A"+org_id+"&shares=List("+share+")&timeIntervals=(timeRange:(start:"+str(start)+",end:"+str(eind)+"),timeGranularityType:DAY)"

RStudio is telling me that the compressed files I'm trying to use contain more than 1 unsupported file

24 March 2026 @ 1:53 pm

I am a student who is learning R for the first time and I am having to use it for an assignment. I downloaded a dataset in RStudio and I am trying to work on it, but I am getting this error "Compressed files containing more than 1 file are currently not supported". I'm not sure what to do: I don't know if there is a problem with the code I am using (maybe the name I've given the data to tell R the path of the files from my computer) or if I've downloaded the dataset wrong. For specificity, the dataset I'm using is: Replication Data for: Playing to the Gallery: Emotive Rhetoric in Parliaments. If anyone has any idea how to fix this, I'd be so grateful! :)

Linking Google Form and Google Sheets

24 March 2026 @ 1:26 pm

I have a Google Form which is linked to a Google Sheet When a new form is submitted, I want some other columns calculated for the new row which has been created. I've done most of them using ARRAYFORMULA, but some of the other columns are using SUMPRODUCT, so I'm getting confused about the syntax For example, I have this formula: =SUMPRODUCT((($F$1:$F9=F10)*1)*(($R$1:$R9="Approved")*1)*(($S$1:$S9>AllocationFreeBooking)*1)) Can I wrap ARRAYFORMULA around this (or vice versa) If not, then presumably a Google Script might be the answer, but I've never written one 😢 Any help appreciated Bob

C# - How to parse and filter microplate measurement data from a text file into a 2D array? Bad Dragon

24 March 2026 @ 1:04 pm

using System; using System.IO; using System.Globalization; namespace MicroplateApp { internal class Microplate { // 8x12 Grid for the microplate wells public Messwert[,] Grid = new Messwert[8, 12]; public void LoadFromFile(string path) { if (!File.Exists(path)) return; string[] lines = File.ReadAllLines(path); foreach (string line in lines) { // Split by space to get individual entries like "A1:0.5" string[] parts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string part in parts) { string[] split = part.Split(':'); if (split.Length < 2) continue; string well = split[0]; ''' Here comes an error! why tho?''' // Handling decimal separators for different cultures if (double.TryParse

Low Transposition Table Usage Rate

24 March 2026 @ 12:23 pm

I'm currently learning to make a Gomoku ai script that uses minimax algorithm along with alpha beta pruning and other methods to improve performance. In this current state, I've implemented a transposition table into the project. The problem is, the hit rate of the table is only around 1~4%, which is quite low I suppose. So I start by making a Zobrist hash table, import random BOARD_SIZE = 19 zobrist_table = [[[random.getrandbits(64) for _ in range(3)] for _ in range(BOARD_SIZE)] for _ in range(BOARD_SIZE)] def get_initial_hash(grid): h = 0 for r in range(BOARD_SIZE): for c in range(BOARD_SIZE): piece = grid[r][c] if piece != ' ': h = update_hash(piece, r, c) return h def update_hash(player, row, col, current_hash): p_idx = 1 if player == 'X' else 2 current_hash ^= zobrist_table[row][col][p_idx] return current_hash then I integrate i

Looking for a term of art ("pseudo-phantom type"?) in typeful programming

24 March 2026 @ 5:57 am

Typically typeful programming uses Proxy to signal to the reader this is used for its type, not its value. Indeed there might not be any usable value/it's typically undefined. Here's a previous q with an example usage. data Proxy t = Proxy deriving ( Bounded -- ^ @since base-4.7.0.0 , Read -- ^ @since base-4.7.0.0 ) The type param t there is called a 'phantom type', because it doesn't appear on RHS of the =. But As far as Haskell/the compiler is concerned, that's just any old (phantom) type. There's nothing to stop also declaring unProxy :: Proxy t -> t; unProxy _ = undefined . (That res

How Can My App React to Power Connecting/Disconnecting Even When Closed?

24 March 2026 @ 4:50 am

I have tried creating a context-registered receiver following the docs and other examples on StackOverflow, but for some reason none of these logs ever fire. Not when the app is open, not when it's closed - never. Using ACTION_POWER_CONNECTED and BroadcastReceiver did not work for me. Forgive me if I'm making a basic mistake as it's been quite awhile since I've done Android development. AndroidManifest.xml: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <application android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules" android:fullBackupContent="@xml/backup_rules" android:icon="@mipmap/ic_launcher"