Random snippets of all sorts of code, mixed with a selection of help and advice.
Kotlin: How to Initialize Array of MutableList
13 June 2026 @ 12:18 am
I understand that initializing an array in kotlin is pretty straight-forward if you know the items to put in the array. In my situation, I know how many elements at run time, not during compile time.
What I want is an array of MutableLists. The size is given in the parameter numLists. The lists will be constantly changing.
I have tried the following, but I keep getting various syntax errors. Any ideas?
fun foo(numLists: Int) {
val daLists = arrayOf<MutableList<Float>>(numLists) {
mutableListOf<Float>()
}
// use the info
daLists[0].add(newData)
daLists[1].add(anotherData)
...
}
How to stop previous flow when new trigger arrives
12 June 2026 @ 11:40 pm
I'm trying to create a workflow in Outlook. Currently is working partially is shown below and works like this:
Check email received
If an email body contains the text "Start Process" --> (this is the Trigger)
The workflow waits 5 minutes
When 5 minutes have elapsed, sends 3 emails (1 email every 1 minutes)
After sending the 3 emails, the process ends and restarts if it receives the Trigger again.
My final goal is make that if it receives the Trigger before it finishes sending the 3 emails, stops the previous flow and begins again waiting the 5 min. In other words, if 5 minutes have passed and the workflow has sent the first email and receives the trigger before sending the second or third email, I want the previous workflow to stop and restart the 5 minute countdown to send the 3 email again.
I have a Excel online file with the following columns
Key
CurrentRunId
LastTriggerTime
Should trailing slash URLs redirect to non-trailing slash URLs?
12 June 2026 @ 10:22 pm
I have a Laravel website running behind nginx, and I am trying to understand the correct way to handle URLs with a trailing slash.
For example, there can be two possible versions of the same page:
/en/
and:
/en
At the moment, the version with the trailing slash redirects to the version without the trailing slash.
So:
/en/
redirects to:
/en
The root URL stays unchanged:
/
I am not sure if this is the correct setup, or if both versions should return the same page.
My concern is that allowing both versions may create duplicate URLs for the same content, but redirecting one version means that tools such as Google Search Console may report the redirected URL as “Page with redirect”.
As far as I could check, my internal links use URLs without the trailing slash.
Should trailing-slash URLs redi
Why is variable not expanding in jq?
12 June 2026 @ 10:17 pm
Why does this work (variable expanded by bash)
jq -r "include \"i3\";stack(.id==$ID)|
.[]|select(.type==\"workspace\")|.name" <<< "$TREE"
When this does not work (variable expanded by jq)
jq -r --arg ID "$ID" 'include "i3";stack(.id==$ID)|
.[]|select(.type=="workspace")|.name' <<< "$TREE"
Function stack in i3.jq (thanks)
def stack(condition):
if condition then
[.], [.] + ((.nodes + .floating_nodes)[]
| stack(condition))
elif . then
[.] + ((.nodes + .floating_nodes)[]
| stack(condition))
else
empty
end;
How to display names instead of IDs, using Django with React?
12 June 2026 @ 10:15 pm
I'm using Django with React.
I'm creating a CRUD application for products. My Product table is related to the Category, Brand, Model, Quality, and Supplier tables.
I can save the data, but when I try to view it, it shows the IDs (category, brand, model, quality, supplier) instead of the names.
Here's the code.
Serializer.py
class ProductoSerializer(serializers.ModelSerializer):
categoria = serializers.PrimaryKeyRelatedField(queryset=Categoria.objects.all())
marca = serializers.PrimaryKeyRelatedField(queryset=Marca.objects.all())
modelo = serializers.PrimaryKeyRelatedField(queryset=Modelo.objects.all())
calidad = serializers.PrimaryKeyRelatedField(queryset=Calidad.objects.all())
proveedor = serializers.PrimaryKeyRelatedField(queryset=Proveedor.objects.all())
class Meta:
model = Producto
fields = [
'id',
'nombre',
'precio',
'stock',
'categoria',
'marca',
Simple p5.js sound player, sound is forever 'undefined'
12 June 2026 @ 8:45 pm
I started this project two days ago with the intent to slowly learn about audio features while building up a simple audio player, but I can't even get past step one: getting the audio to play. It just keeps throwing the error in browser; "Uncaught (in promise) TypeError: can't access property (insert property the program first encounters here), sound is undefined". I checked pathings, checked my source tags, spelling, put the loadSound command in the setup function instead of the preload. I'm at the point where I'm starting to chase down rabbit holes because I've lost all sense of what the problem could be. The code is basically a barebones minimalist template from a website with a button added:
let sound;
let ply;
functio
Specific dependencies in Pom.xml not overriding transitive dependencies
12 June 2026 @ 8:32 pm
I am using the awssdk dependency
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
<version>2.46.9</version>
</dependency>
which brings in via
software.amazon.awssdk:netty-nio-client:jar:2.46.9:runtime
the io.netty dependency 4.1.132.
Our Twistlock scan complains about vulnerabilities in that IO-Netty version (codec, handler, transport) and I need to upgrade those modules to 4.1.133.
Following the Google AI advice of
To force the upgrade past 4.1.132, you must explicitly declare the specific Netty artifacts in your own <dependencyManagement> section, or use Maven properties if your AWS SDK version supports it.
I copied the exact Google-provided specs as follows:
Babylon.js + Vite: Failed to load module script and blank index.html in dist
12 June 2026 @ 8:26 pm
I'm trying to deploy a Babylon.js game using Vite onto Github Pages and I'm running into a couple issues.
- index.html in the built folder is blank.
- Navigating to the deployed Github Page displays the following error:
Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "video/mp2t". Strict MIME type checking is enforced for module scripts per HTML spec.
Vite Config: https://github.com/JungDefiant/defiance-engine/blob/main/vite.config.js
TS Config: https://github.com/JungDefiant/defiance-engine/blob/main/tsconfig.json
package.json:
Python Selenium - how to download via execute_script
12 June 2026 @ 8:17 pm
I made a small app in Python, using Selenium and Firefox, where I want that in response to a click in an anchor element, the file is downloaded instead of opened in a new tab (PDF file).
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
URL="https://no.net.com/INFO/details.xhtml"
options = webdriver.FirefoxOptions()
service=webdriver.FirefoxService(executable_path='/.../geckodriver')
driver = webdriver.Firefox(options=options,service=service)
driver.get(URL)
objects = driver.find_elements(By.CSS_SELECTOR, "a > span.documents-text")
print(f"Array[{len(objects)}]") # gives 3
for o in objects:
print(o.text)
parent = o.find_element(By.XPATH, "./..") # this element is a anchor element
try:
# A strange div is hiding th
How to fix json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 9035) without modifying a file? [duplicate]
12 June 2026 @ 9:43 am
I am working on a polymarket bot and downloaded historical bitcoin data from bybit. Whenever I try to iterate it I get this error:
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 9035)
What am I doing wrong?
import json
import pytz
import pandas as pd
from datetime import datetime, timezone
import requests
orderbook = "C:/Users/Owner/PycharmProjects/polymarket strategy/.venv/historical orderbook data"
import os
data = []
file_number = 0
class File:
def __init__(self,file_number):
self.file_number = file_number
file_number += 1
def get_timestamp(self):
with open(filepath, 'r') as file:
json.load(file)
timestamps = []
for row in file:
timestamps.append(row.get("ts"))
print(timestamps)
lowest_timestamp = timestamps[0]
highest_timestamp = timestamps[-1]
for filename in os.listdir(order