Random snippets of all sorts of code, mixed with a selection of help and advice.
Two arrays, map or filter and return indexes in a new array
6 January 2026 @ 10:30 pm
I am currently using the following code to return a new array with the
map_of_indexes = [];
pupils =[1000,1001,1002,1005,1003,1004,1020,1006,1007,1008,1009,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020];
subjects = [1000,1001,1002,1015,1004,1005,1011,1014,1005,1003,1008,1020];
for(n=0; n<subjects.length; n++){
new_indexes.push(pupils.indexOf(subjects[n]));
};
// Should return 0,1,2,16,5,3,12,15,3,4,9,6;
console.log(new_indexes);
I am happy this works on a small amount of data but not sure how to best go about it, should I use map or filter?
Here is a link to a fiddle of above code
python requests XHR - get response 405
6 January 2026 @ 10:27 pm
Code written in Python on Mac.
Url retrived from inspect in google chrome.
Trying to fetch information from an XHR but does not succeed. The print at the end gives the response <Response [405]>. I have not added any params now since I am not sure which to add.
Need support with understanding how I know which params to include? Can this be read in the inspect+header tab in the browser, and which part is it then I shall look at? Or how can I else find this?
Need to understand what I need to do in order to make the code work?
import requests
url = 'https://web.jmapi.io/residence/search_object'
sess = requests.Session()
sess.headers.update({'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36',
"Accept": "application/json, text/plain, /",
"Referer": "https://www.jm.se/",
'X-Requested-With': 'XMLHttpRequest',
})
res
Vuejs & ts, app-wide settings: as const with satisfies VS abstract class with static readonly properties
6 January 2026 @ 10:18 pm
While I found quite a lot on the topic "enum VS as const", I could not find a satisfying clue to my current design decision:
I need a solution for a typed app settings object/class in a Vuejs & ts app, basically to be able to have my IDE auto-complete the available settings options and to avoid literal strings hardcoded in dozens of places. I also want to be able to use env vars from import.meta.env in there. I gathered as much as: ts enums seem to have fallen out of favour because of runtime bloat. So, leaving them aside, which one of the following two solutions would you prefer, considering ease of use / IDE sugar, resilience and process resources (which I don't know a lot about, tbh):
export default abstract class AppSetting {
static readonly UI_API_HOST: string = import.meta.env.VITE_UI_API_HOST
}
OR
BFS Method Error when Parsing Through a Flattened Hierarchal Structure in Python
6 January 2026 @ 10:15 pm
So i posted this question earlier but did not match my code to my sample dataset.
Below is a sample data structure, but the current data structure is about 18k ids and I will have to send the Ids to a REST API using a POST Command
{
"1": {
"name": "Item 1",
"ownedElement": [{"@id": "2"}, {"@id": "3"}]
},
"2": {
"name": "Item 2",
"ownedElement": []
},
"3": {
"name": "Item 3",
"ownedElement": [{"@id": "4"}, {"@id": "5"}, {"@id": "6"}]
},
Godot 4.5: Godotx-Firebase fails to detect google-services.json
6 January 2026 @ 10:15 pm
I'm developing a game in Godot4.5, and need to implement Firebase push notifications using the Godotx-Firebase plugin. However, I'm running into an issue where the plugin fails to read my google-services.json file. I've already configured the file path in Project > Export to both res:// and res://android/build/, but it still won't work. Does anyone know how to properly link this file or fix this initialization error? I am following this steps: https://github.com/godot-x/firebase
#FirebaseService.gd
extends Node
var firebase_core
var messaging
func _ready() -> void:
print("Init firebase service...")
# Get all singletons
if Engine.has_singleton("GodotxFirebaseCore"):
print("Found GodotxFirebaseCore")
firebase_core = Engine.get_singleton("GodotxFirebaseCore")
firebase_core.core_initialized.connect(_on_core_initi
How do I get a unique ID for a W5500 Pi Pico using Arduino IDE?
6 January 2026 @ 10:09 pm
I have many picos controlling sensors on my network. I want to generate unique MAC addresses for them (using the unique ID) so I can keep them organized in my Postgres database which is controlled by django. Right now everything is built through Arduino IDE. I am trying to generate a HTTP POST with the MAC address and firmware version, but I can't figure out how to properly generate a MAC address without switching up my entire toolchain. I am using Ubuntu 24.04 LTS
What is the chance of losing a redis pub/sub message?
6 January 2026 @ 10:07 pm
I understand that message loss in Redis Pub/Sub is possible and is considered normal behavior. The probability is low, but not zero.
What I’m trying to understand is how often this can realistically happen in practice.
For example, I have two servers:
server A publishes a message instructing server B to refresh data from the database.
Under typical production conditions, what is the practical likelihood that such a Pub/Sub message will be lost?
Which factors most strongly influence this probability (network issues, client disconnects, Redis restart, slow subscribers, etc.)?
Thank You!
Is there a way to have a global variable in elixir
6 January 2026 @ 10:02 pm
I have this way to compare user accounts, to help prevent duplicates.
When I do the compare I pass in the two accounts, and the function returns 0 -> 1.0 where 1.0 is a perfect match. There is however an edge case where even if the data isn't a perfect match, a "global_id" exists on both new and old account, that is identical. This subverts the compare, and just tells me the data is identical.
What I would do in c/c++ is create a const, and have the compare return that. GLOBAL_ID_MATCH, in ruby I'd have a class value. @GLOBAL_ID_MATCH, and then test against that in the consuming code..
I know you can create a module global, but how do you access the value outside that module?
@global_id_match 10000
But there doesn't seem to be a way to use that variable/const outside the module.
How to get approver email addresses for Power Automate approval reminders?
6 January 2026 @ 9:59 pm
I am building a Power Automate flow creates an approval when a SharePoint form is submitted. I would like to implement a reminder email that gets sent out to any approvers who have yet to respond after an interval.
Flow
I added an action to create an approval, then created a parallel branch which:
1.) Waits for a set interval (Delay action)
2.) Gets the row from the Approvals table with the Approval ID from the previously-made approval.
Approvals
3.) A Condition checks the Approvals table to see if the approval's Stage is not equal to 'Completed'.
Condition
4.) If the approval is not completed, then another action gets rows from the Approval Requests table that have the Approval ID of the previously-made ap
Cannot find Syn3tasks when running hello world in Syn3
6 January 2026 @ 9:57 pm
my code:
import Syn3tasks as s
s.PRINT("Hello, World!")
Error:
Syn3Runner:out:
(V): Syn3Runner™ All Rights Reserved.
(V): Running...
ERR "Cannot find "Syn3tasks, Is it not imported or not defined?"