Random snippets of all sorts of code, mixed with a selection of help and advice.
having trouble getting d3 graph to show bars when using array of data
6 April 2026 @ 5:54 pm
I have an array of data showing years and percents and I'm trying to draw a bar graph using d3. I can get a single bar drawn if I feed in numbers that I know will work, but when I'm using the x and y axes and an array of data, nothing is showing. I get no error messages.
I am super new to d3 and struggling with the learning curve, so if someone could explain the issues here, I would greatly appreciate it.
<!DOCTYPE html>
<div id="container"></div>
<script src="https://cdn.jsdelivr.net/npm/d3@7"></script>
<script type="module">
// Declare the chart dimensions and margins.
const width = 1140;
const height = 500;
const marginTop = 20;
const marginRight = 20;
const marginBottom = 50;
const marginLeft = 70;
// Declare the x (horizontal position) scale.
const x = d3.scaleUtc()
.domain([new Date("2017-01-01"), new Date("2024-01-01")])
.range([marginLeft, wi
Is calling `omp_pause_resource` allowed after forking (v.s. before forking)?
6 April 2026 @ 5:49 pm
I have a question on what is technically allowed by the omp standard when it comes to relinquish resources (using omp_pause_resource) with forking.
I understand that in section 12.12, pause_resource.1.c of the omp examples pdf, it explicitly allows calling omp_pause_resource before forking, and it's safe to use omp after forking inside the child (and the parent).
I'd like to know that if the omp standard also allows the same example, but calling omp_pause_resource after forking? I.e. is the following allowed and is the behaviour after forking equivalent to the pause_resource.1.c example in section 12.12?
//initializes omp (for eg, a #pragma omp parallel call)
pid_t pid = fork(); //suppose fork() doesn't fail
if (pid == 0){
//child process
omp_pause_resource(omp_pause_
Canva Button SDK returns 403 Forbidden on embed?action=createDesign in Vite + React app — why?
6 April 2026 @ 5:33 pm
I'm integrating the Canva Button into a Vite + React app. The SDK loads and my React button calls createDesign, but the SDK's embed request returns HTTP 403 and the Canva editor shows a "Forbidden (403)" modal. I followed the docs (SDK script in index.html, initialize then createDesign) and tried the usual suggestions (referrer meta, adding origin to Canva allowlist, using VITE_ env var), but it still returns 403.
I want to know what exact conditions cause Canva to return 403 for the embed request and how to fix it — in particular, what headers/values Canva expects and what I should check in my network trace.
Environment
Vite dev server (default)
React 18
Tailwind (styling only)
Browser: Chrome (latest)
Dev origin used: http://localhost:5173 (also tried 3000)
Canva SDK added via <script src=&q
How can I create a vector in R where each number in the output is double the last number?
6 April 2026 @ 5:33 pm
For example, I am trying to create a vector where the output would be 1, 2, 4, 8, 16... and so on.
I was attempting to use the "rep" function, but now I am not even sure if that's the right place to start. I am new to R so bear with me!
Sorting with MongoDB Java driver during aggregation pipeline by a Mutated(?) value
6 April 2026 @ 5:26 pm
I am executing the following query on my MongoDB using the Java driver
private static AggregateIterable<Document> averageVendorTotalSent(MongoCollection<Document> collection) {
return collection.aggregate(Arrays.asList(
Aggregates.group("$transaction vendor", Accumulators.avg("Average Vendor Transaction Sent", "$amount sent"))
));
}
On a collection with Documents formatted like
_id: "69cb3d75c6146e2646e66330"
date: "2026-02-17"
transaction vendor: "TIM HORTONS #47 _F"
amount sent: 11.21
amount received: 0
remainingBalance: 3269.39
here is part of the output
{"_id": "SQ *THE TASTE O _F", "Average Vendor Transaction Sent": 25.82}
{"_id": "HECTOR'S YOUR I", "Average Vendor Transaction Sent": 27.72}
{"_id": "TIM HORTONS #47 _F&quo
What is Power Pivot in Excel and when should a beginner use it?
6 April 2026 @ 5:24 pm
I am a beginner learning Microsoft Excel, and recently discovered the Power Pivot feature.
I understand basic Excel features like formulas and PivotTables, but I am confused about when Power Pivot is actually needed.
I would like to know:
What problem does Power Pivot solve that regular PivotTables cannot?
When should I start using Power Pivot as a beginner?
Can someone explain with a simple real-life example (like sales data, reports, etc.)?
For example, if I have multiple Excel sheets with related data, is that a case where Power Pivot is useful?
I am looking for a simple explanation with practical use cases.
How to properly sort in a lazy loading way in Python?
6 April 2026 @ 5:22 pm
Is there a way to reuse some loop to sort the final result?
I used the sorted but its not lazy loading, i wanted to find a way to rewrite my code in a way where everything is done lazyly. Its is possible? What solutions do you recommend me to do?
from dataclasses import dataclass
from datetime import date
import csv
@dataclass
class Product():
Id: int
Code: str
Quantity: int
Price: float
Date: str
Country: str
def read_rows(filename):
with open(filename, "r") as f:
reader = csv.DictReader(f)
for row in reader:
#print(row)
yield row
def parse_rows(rows):
for row in rows:
try:
yield Product(
Id=int(row["Id"]),
Code=row["Code"],
Quantity=int(row["Quantity"]),
Price=float(row["Price"]),
Date=row["Date"],
Country=row[&
Java ConnectException: Connection refused [closed]
6 April 2026 @ 5:22 pm
Recently, I've started a project about making a game of Otello on the command line. The game needs 1 server and 2 clients to play. I've finished development of the game part, and moved on to the networking part (which I'm new to).
At first, I tried running both a client and the server on my own computer, and everything went perfectly. But, when I deployed the programs to their respective VMs, I got this error message when running the client (the server was running):
Exeption in thread "main" java.net.ConnectException: Connection refused
[...]
at contactServ.startConnection(contactServ.java:10)
at Main.main(Main.java:9)
The VMs are all connected through an NAT network with DHCP to attribute the IP adresses. The server is running on a Debian 12 machine and th client is running on a Mint one.
Here's the Main class:
import java.io.IO
How would you describe the Java programming language to a beginner?
6 April 2026 @ 3:14 pm
I've noticed in my Information Systems course that many people still lack the specific knowledge to program, and don't even understand a new and complex language like Java. We're in our third semester, and even so, we're having a lot of difficulty really understanding what the professors are actually trying to teach. Therefore, I'd like to know, "If you were teaching someone Java from scratch, what would your explanation be for understanding the basics?"
Why does my HashSet allow duplicate objects in Java even when values are same? [duplicate]
6 April 2026 @ 1:51 pm
I am trying to store unique objects in a HashSet, but it still allows duplicates even though the values are the same.
Here is my code:
import java.util.HashSet;
import java.util.Set;
class Student {
int id;
Student(int id) {
this.id = id;
}
}
public class Test {
public static void main(String[] args) {
Set<Student> students = new HashSet<>();
students.add(new Student(1));
students.add(new Student(1));
System.out.println(students.size());
}
}
Expected output:
1
Actual output:
2
Why is HashSet allowing duplicate objects even when the id is the same?
Do I need to override something in the Student class to make it work correctly?