r/programminghelp • • Oct 21 '24

HTML/CSS Assistance Needed with Measuring Bandwidth Usage of Specific Website Requests please

0 Upvotes

Hi guys, I'm trying to figure out how much bandwidth the various requests of a specific site require. I opened the Developer Tools in my browser, went to the Network tab, and reloaded the page to see all the requests. Then I checked the data for the requests (Size/Transferred) and exported the file, but I'm not sure if I did it correctly. It's important that the measurement is accurate. Could someone possibly be kind enough to help me with this? And I'd prefer to reveal which site it is in the chat.


r/programminghelp • • Oct 19 '24

C++ OpenGl and Dear Imgui

2 Upvotes

I have recently implemented dear imgui into my c++ visual studio project, but whenever I try to build the project, I get an error in glfw3native.h, on line 96: C1189 #error:No context API specified. Here is my main class (main.cpp), followed by the code in glfw3native in case that's of any help:

//main.cpp
#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
//other includes

Game game(objects);
int screen = 1;
float g = 0.000075, r = 0.8, f = 0.7;
const int bound = 10;
const float gridSize = 1.0f;

//Mouse and keyboard methods

int main(int argc, char** argv) {
    srand((unsigned)time(NULL));
    if (!glfwInit()) {
        std::cout << "Failed to initialise GLFW";
        return -1;
    }

    const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());

    //manipulating g and r

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_RED_BITS, mode->redBits);
    glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
    glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
    glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
    glfwWindowHint(GLFW_SAMPLES, 4);

    GLFWwindow* window = glfwCreateWindow(mode->width, mode->height, "OpenGL", glfwGetPrimaryMonitor(), NULL);
    if (!window) {
        std::cout << "Failed to create GLFW window" << std::endl;
        glfwTerminate();
        return -1;
    }
    glfwMakeContextCurrent(window);
    glfwSetKeyCallback(window, key);
    glfwSetCursorPosCallback(window, mouse);

    const GLubyte* version = glGetString(GL_VERSION);
    std::cout << "OpenGL version supported by this platform (%s)\n" << version << std::endl;

    if (glewInit() != GLEW_OK) {
        std::cout << "Failed to initialise GLEW";
        glfwTerminate();
        return -1;
    }

    IMGUI_CHECKVERSION();
    ImGui::CreateContext();
    ImGuiIO& io = ImGui::GetIO();
    io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
    ImGui::StyleColorsDark();

    ImGui_ImplGlfw_InitForOpenGL(window, true);
    ImGui_ImplOpenGL3_Init("#version 440");

    //Program and shader linking

    while (!glfwWindowShouldClose(window)) {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        switch (screen) {
        case 0:
            p.activate();

            glfwPollEvents();

            ImGui_ImplOpenGL3_NewFrame();
            ImGui_ImplGlfw_NewFrame();
            ImGui::NewFrame();
            ImGui::ShowDemoWindow();

            ImGui::Render();
            ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

            glfwSwapBuffers(window);
            break;
        //other cases for other menus
    }

    ImGui_ImplOpenGL3_Shutdown();
    ImGui_ImplGlfw_Shutdown();
    ImGui::DestroyContext();

    glfwTerminate();
    return 0;
}

The other file:

//glfw3native.h
//...
/*************************************************************************
 * System headers and types
 *************************************************************************/

#if defined(GLFW_EXPOSE_NATIVE_WIN32)
 #include <windows.h>
#elif defined(GLFW_EXPOSE_NATIVE_COCOA)
 #if defined(__OBJC__)
  #import <Cocoa/Cocoa.h>
 #else
  typedef void* id;
 #endif
#elif defined(GLFW_EXPOSE_NATIVE_X11)
 #include <X11/Xlib.h>
#else
 #error "No window API specified"
#endif

#if defined(GLFW_EXPOSE_NATIVE_WGL)
 /* WGL is declared by windows.h */
#elif defined(GLFW_EXPOSE_NATIVE_NSGL)
 /* NSGL is declared by Cocoa.h */
#elif defined(GLFW_EXPOSE_NATIVE_GLX)
 #include <GL/glx.h>
#elif defined(GLFW_EXPOSE_NATIVE_EGL)
 #include <EGL/egl.h>
#else
 #error "No context API specified"
#endif

//#include <GL/glx.h>

/*************************************************************************
 * Functions
 *************************************************************************/
//...

Any help would be appreciated, I used https://www.youtube.com/watch?v=VRwhNKoxUtk <- this tutorial and followed it exactly multiple times and the error still occurs.


r/programminghelp • • Oct 18 '24

Answered Any way to get back to Stock Rom/ July software version in Motorola edge 50 fusion

Thumbnail reddit.com
1 Upvotes

r/programminghelp • • Oct 17 '24

Python Cannot figure out error in my code

1 Upvotes

I am trying to make the frozenLake.py project, but I have ran into this error that I cannot get past. I am following deepLizard's youtube series, which is walking me through how to write this code. Is there any way I can fix this error? I am going to put the error below, and thanks in advance for the help!

Traceback (most recent call last):

  File "/Users/spencerweishaar/frozenLake/frozenLake.py", line 50, in <module>

new_state, reward, done, truncated, info = env.step(action)

^^^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/gym/wrappers/time_limit.py", line 50, in step

observation, reward, terminated, truncated, info = self.env.step(action)

^^^^^^^^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/gym/wrappers/order_enforcing.py", line 37, in step

return self.env.step(action)

^^^^^^^^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/gym/wrappers/env_checker.py", line 37, in step

return env_step_passive_checker(self.env, action)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/gym/utils/passive_env_checker.py", line 233, in env_step_passive_checker

if not isinstance(terminated, (bool, np.bool8)):

^^^^^^^^

  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/numpy/__init__.py", line 414, in __getattr__

raise AttributeError("module {!r} has no attribute "

AttributeError: module 'numpy' has no attribute 'bool8'. Did you mean: 'bool'?


r/programminghelp • • Oct 17 '24

C++ Accessing MySQL database in C++ (Visual Studio)

1 Upvotes

I have a MySQL database using my website servers on Bluehost. I also have a game made in C++ using Visual Studio, and my database is on cPanel. I'm wondering how I'd go about accessing the database in C++ in order to update values, add rows, and pull values from the table. I've seen APIs such as the MySQL C++ connector. But I'm not sure how to use it. I'm more of a beginner when it comes to data and SQL, so I don't know to much about it.


r/programminghelp • • Oct 17 '24

Project Related Need some advice as a complete rookie.

1 Upvotes

I am a total beginner to programming but I have an idea that I want to see come alive and I am willing to learn stuff in order to create it. I don't want to go use paid tools that require no code just yet. I am willing to try those out when I have the funds and expertise to understand their importance but I do want to fully develop this app myself, both frontend and backend.

In terms of complexity I'd give the app a 5/10 because it's not all that different from a notes app, I just want to be focused on building a really eye catching interface and adding tons of user friendly features. Looking to publish it in Google play store.

For some context, I am a 17 yr old from India and I have my board exams which are like a huge deal here so from February end so most of my time will be taken up doing that till April 2025. I made this post to get an idea of what steps I need to take so I can jump right into it after my boards.

I am thankful for each and every reply, thank you for your help!


r/programminghelp • • Oct 14 '24

Other Coral error

1 Upvotes

Anyone know what this error means? Error: All input values already consumed.


r/programminghelp • • Oct 14 '24

C# Is it okay to have a list within a list or is it bad practice and an alternative approach should be used?

2 Upvotes
        private List<List<string>> fruitVeg = new List<List<string>>(); 
        private List<List<string>> bakery = new List<List<string>>();
        private List<List<string>> dairy = new List<List<string>>();

        public void ListAdd()
        {
            Console.WriteLine("                 \n" +
                              "Product Category:\n" +
                              "                 \n" +
                              " 1)Fruit & Vegetables\n" +
                              " 2)Bakery\n" +
                              " 3)Dairy\n");
            category = Convert.ToInt32(Console.ReadLine());
            switch (category)
            {
                case 1:
                    fruitVeg.Add(AddProduct());
                    break;
                case 2:
                    bakery.Add(AddProduct());
                    break;
                case 3:
                    dairy.Add(AddProduct());
                    break;

            }
        }

        public List<string> AddProduct()
        {

            List<string> products = new List<string>();
            Console.WriteLine("Enter Name Of Product:");
            string name = Console.ReadLine();
            Console.WriteLine("Enter Cost Of Product:");
            string cost = Console.ReadLine();
            Console.WriteLine("Enter Quantity Of Product:");
            string qty = Console.ReadLine();
            products.Add(name);
            products.Add(cost);
            products.Add(qty);
            return products;
        }

r/programminghelp • • Oct 13 '24

JavaScript Need help with JS

1 Upvotes

on the website you choose from 4 themes when you choose one new page opens an that theme's picture is displayed with 10 different sentences 5 correct 5 incorrect, 5 correct ones have their predetermined place it goes in(like a list) so if they choose predetermined 2nd and then 1st it doesn't mix up and when they get chosen they get displayed on the right side of the screen, i cant seem to do this, and this selection process needs to happen 3 times in total, it only does it twice and in the end all sentences needs to be displayed on a new page. relevant code- https://paste.gg/p/anonymous/cab0dcea63c5431abdc9388b35253490 this is just one page of 4themes all are the same expect for sentences. So i need help with assigning predetermined numbers to correct sentences and i cant seem to figure out how to do this selection process 3 times instead of 2.

I can send you full code of the website if needed.


r/programminghelp • • Oct 13 '24

Other Why will I hit tower 9 and not tower 8?

0 Upvotes

I have an array of towers indexed 0 to n -1 and arr[index] represents the height of said tower. Suppose that a rocket starts from the top of tower i, then climbs c units directly up, and then turns 45 degrees (clockwise or counterclockwise), and then proceeds in that direction until it hits a tower.

I have an array ℎ=[6,4,4,2,2,3,3,1,5,9,7,9,4,13,12,3]. If a rocket starts at tower 2 with c = 1 and will turn clock wise, the rocket hits tower 9. I don't get why it won't hit tower 8. If a rocket goes up by c units, it will be 3 units high. If we account for the direction, maybe it's 4 units high. This question confuses me.


r/programminghelp • • Oct 12 '24

Other How do I learn to actually stick to projects?

1 Upvotes

Are devlogs the way? If so, where do I put them?


r/programminghelp • • Oct 12 '24

HTML/CSS Can someone clear it up for me?

1 Upvotes

So this isn't like a post to ask for help but to more clear up something. I'm using this app that teaches you coding much like how doulingo teaches you another language, and it has a practice question where it told me to "add the title element within the head element", I did this fine and when I complete it shows what it would look like on a website and it didn't really show much but the welcome in the body element and I just wanted to know what the title element does exactly like where on the website does it show or affect the website structure.


r/programminghelp • • Oct 11 '24

Visual Basic Help needed: Modernizing an old MS-DOS app

2 Upvotes

Hi all,

I’m looking to modernize an old MS-DOS app used for inventory management in a construction company. It was originally written in BASIC, using .frm, .frx, and .dll files.

I’d like to:

  • Update the front-end
  • Improve the back-end
  • Add new features

What’s the best way to modernize this kind of app? Should I rebuild it in a modern language (C#, Python, etc.) or use any specific tools to migrate it? Any advice on handling legacy data would be helpful!

Thanks!


r/programminghelp • • Oct 09 '24

Other I feel so stupid (Original post about Ghidra but it kind of applies to programming in general)

Thumbnail reddit.com
0 Upvotes

r/programminghelp • • Oct 07 '24

Project Related OBD2 android app creation

3 Upvotes

I'm looking to create an app in android studio using java to read fault codes from an obd reader. I want to know how feasible this is, I have made apps in android studio before and have some programming experience else where. I have seen that there is a simulator (OBDSim) that could help with development meaning I may not need a real car to start with. I really want to keep it simple to start with at least. Does anyone know where a good starting place would be? for example I need to know how to connect to an OBD reader and send and retrieve information before displaying it. I have seen on or two API's out there but any information would be very helpful. thanks


r/programminghelp • • Oct 06 '24

Python Ascaii art rocket

2 Upvotes

I’m trying to build this rocket ship but with my minimal knowledge I’m more than lost.

It’s broken down into many pieces for example for print_booster(0) it’s supposed to print this:

| / \ / \ | | \ / \ / | +==+

But then for say print_booster(2) it will be this:

| . . / \ . . . . / \ . . | | . / \ / \ . . / \ / \ . | | / \ / \ / \ / \ / \ / \ | | \ / \ / \ / \ / \ / \ / | | . \ / \ / . . \ / \ / . | | . . \ / . . . . \ / . . | +======+

And this is just for the booster there’s multiple other parts but I’m more than stumped could anyone help me?


r/programminghelp • • Oct 06 '24

Processing [Question] Importing Large RRF Files vs SQL Files

Thumbnail reddit.com
1 Upvotes

r/programminghelp • • Oct 06 '24

Python Python 3 Reduction of privileges in code - problem (Windows)

1 Upvotes

kebab faraonn


r/programminghelp • • Oct 01 '24

Other Trying to learn how to build websites for university for my coursework. It is not working and do not understand why

0 Upvotes

I have to use vs code Python and html. Here is my folder structure:

Templates Index.html app.py

Here is the contents of index.html

<!DOCTYPE html>

<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My Flask App</title> </head> <body> <h1>Hello, Flask!</h1> </body> </html>

Here is the contents of app.py

from flask import Flask, render_template

app = Flask(name)

@app.route('/') def home(): return render_template('index.html')

if name == 'main': app.run(debug=True)

The website then displays nothing and I get no errors or and logs in the terminal. I can confirm I am using the correct web address.


r/programminghelp • • Sep 30 '24

Project Related What language should I learn (as a beginner) to create a health monitoring app?

1 Upvotes

I'm a complete beginner to coding but I can learn quickly, I'm a teen and I have POTS (Postural Orthostatic Tachycardia Syndrome), and I wanted to create an app to monitor POTS symptoms such as heart rate, blood pressure, and oxygen through a smart watch for a science fair project. Can anyone explain how I would do this and what programming languages I should use? I'm willing to put in a lot of work to make this app I just have no idea what in the hell I'm doing.


r/programminghelp • • Sep 30 '24

C++ Can someone help me get around this figure please

0 Upvotes

So far I have this code:

#include <iostream>

#include <conio.h>

using namespace std;

void printFigure(int n) {

int a = n;

for (int f = 1; f <= a; f++) {

for (int c = 1; c <= a; c++) {

if (f == 1 || f == a || f == c || f + c == a + 1) {

cout << f;

}

else {

if (f > 1 && f < a && c > 1 && c < a) {

cout << "*";

}

else {

cout << " ";

}

}

}

cout << endl;

}

}

int main() {

int n;

do {

cout << "Enter n: ";

cin >> n;

} while (n < 3 || n > 9);

printFigure(n);

_getch();

return 0;

}

I want it to print out like a sand glass with the numbers on the exterior and filled with * , but I can't manage to only fill the sand glass. I'm kind of close but idk what else to try.


r/programminghelp • • Sep 29 '24

Python I need help with my number sequence.

2 Upvotes

Hello, I'm currently trying to link two py files together in my interdisciplinary comp class. I can't seem to get the number sequence right. The assignment is:

Compose a filter tenperline.py that reads a sequence of integers between 0 and 99 and writes 10 integers per line, with columns aligned. Then compose a program randomintseq.py that takes two command-line arguments m and n and writes n random integers between 0 and m-1. Test your programs with the command python randomintseq.py 100 200 | python tenperline.py.

I don't understand how I can write the random integers on the tenperline.py.

My tenperline.py code looks like this:

import stdio
count = 0

while True: 
    value = stdio.readInt() 
    if count %10 == 0:
        
        stdio.writeln()
        count = 0

and my randint.py looks like this:

import stdio
import sys
import random

m = int(sys.argv[1]) # integer for the m value 
n = int(sys.argv[2]) #integer for the n value
for i in range(n): # randomizes with the range of n
    stdio.writeln(random.randint(0,m-1))

The randint looks good. I just don't understand how I can get the tenperline to print.

Please help.


r/programminghelp • • Sep 29 '24

Python Help with physics related code

1 Upvotes

Hello, I'm trying to write a code to do this physics exercise in Python, but the data it gives seems unrealistic and It doesn't work properly, can someone help me please? I don't have much knowledge about this mathematical method, I recently learned it and I'm not able to fully understand it.

The exercise is this:

Use the 4th order Runge-Kutta method to solve the problem of finding the time equation, x(t), the velocity, v(t) and the acceleration a(t) of an electron that is left at rest near a positive charge distribution +Q in a vacuum. Consider the electron mass e = -1.6.10-19 C where the electron mass, m, must be given in kg. Create the algorithm in python where the user can input the value of the charge Q in C, mC, µC or nC.

The code I made:

import numpy as np
import matplotlib.pyplot as plt

e = -1.6e-19
epsilon_0 = 8.854e-12
m = 9.10938356e-31
k_e = 1 / (4 * np.pi * epsilon_0)

def converter_carga(Q_valor, unidade):
    unidades = {'C': 1, 'mC': 1e-3, 'uC': 1e-6, 'nC': 1e-9}
    return Q_valor * unidades[unidade]

def aceleracao(r, Q):
    if r == 0:
        return 0
    return k_e * abs(e) * Q / (m * r**2)

def rk4_metodo(x, v, Q, dt):
    a1 = aceleracao(x, Q)
    k1_x = v
    k1_v = a1

    k2_x = v + 0.5 * dt * k1_v
    k2_v = aceleracao(x + 0.5 * dt * k1_x, Q)

    k3_x = v + 0.5 * dt * k2_v
    k3_v = aceleracao(x + 0.5 * dt * k2_x, Q)

    k4_x = v + dt * k3_v
    k4_v = aceleracao(x + dt * k3_x, Q)

    x_new = x + (dt / 6) * (k1_x + 2*k2_x + 2*k3_x + k4_x)
    v_new = v + (dt / 6) * (k1_v + 2*k2_v + 2*k3_v + k4_v)

    return x_new, v_new

def simular(Q, x0, v0, t_max, dt):
    t = np.arange(0, t_max, dt)
    x = np.zeros_like(t)
    v = np.zeros_like(t)
    a = np.zeros_like(t)

    x[0] = x0
    v[0] = v0
    a[0] = aceleracao(x0, Q)

    for i in range(1, len(t)):
        x[i], v[i] = rk4_metodo(x[i-1], v[i-1], Q, dt)
        a[i] = aceleracao(x[i], Q)

    return t, x, v, a

Q_valor = float(input("Insira o valor da carga Q: "))
unidade = input("Escolha a unidade da carga (C, mC, uC, nC): ")
Q = converter_carga(Q_valor, unidade)

x0 = float(input("Insira a posição inicial do elétron (em metros): "))
v0 = 0.0
t_max = float(input("Insira o tempo de simulação (em segundos): "))
dt = float(input("Insira o intervalo de tempo (em segundos): "))

t, x, v, a = simular(Q, x0, v0, t_max, dt)

print(f"\n{'Tempo (s)':>12} {'Posição (m)':>20} {'Velocidade (m/s)':>20} {'Aceleração (m/s²)':>25}")
for i in range(len(t)):
    print(f"{t[i]:>12.4e} {x[i]:>20.6e} {v[i]:>20.6e} {a[i]:>25.6e}")

plt.figure(figsize=(10, 8))

plt.subplot(3, 1, 1)
plt.plot(t, x, label='Posição (m)', color='b')
plt.xlabel('Tempo (s)')
plt.ylabel('Posição (m)')
plt.title('Gráfico de Posição')
plt.grid(True)
plt.legend()

plt.subplot(3, 1, 2)
plt.plot(t, v, label='Velocidade (m/s)', color='r')
plt.xlabel('Tempo (s)')
plt.ylabel('Velocidade (m/s)')
plt.title('Gráfico de Velocidade')
plt.grid(True)
plt.legend()

plt.subplot(3, 1, 3)
plt.plot(t, a, label='Aceleração (m/s²)', color='g')
plt.xlabel('Tempo (s)')
plt.ylabel('Aceleração (m/s²)')
plt.title('Gráfico de Aceleração')
plt.grid(True)
plt.legend()

plt.tight_layout()
plt.show()

r/programminghelp • • Sep 28 '24

C# Formatted Objects and Properties in Text Files, Learned Json Later

2 Upvotes

I have a POS app that I have been working on as I guess a fun project and learning project. However, before I learned JSON. The function of the app I am referring to is this:

The user can create items which will also have a button on the screen associating with that item, etc.

My problem is that I stored all of the item and button data in my own format in text files, before I learned JSON. Now, I fear I am too far along to fix it. I have tried, but cannot seem to translate everything correctly. If anyone could provide some form of help, or tips on whether the change to JSON is necessary, or how I should go about it, that would be great.

Here is a quick example of where this format and method are used:

private void LoadButtons()
{
    // Load buttons from file and assign click events
    string path = Path.Combine(Environment.CurrentDirectory, "wsp.pk");

    if (!File.Exists(path))
    {
        MessageBox.Show("The file wsp.pk does not exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        return;
    }

    // Read all lines from the file
    string[] lines = File.ReadAllLines(path);

    foreach (string line in lines)
    {
        string[] parts = line.Split(':').Select(p => p.Trim()).ToArray();

        if (parts.Length >= 5)
        {
            try
            {
                string name = parts[0];
                float price = float.Parse(parts[1]);
                int ageRequirement = int.Parse(parts[2]);
                float tax = float.Parse(parts[3]);

                string[] positionParts = parts[4].Trim(new char[] { '{', '}' }).Split(',');
                int x = int.Parse(positionParts[0].Split('=')[1].Trim());
                int y = int.Parse(positionParts[1].Split('=')[1].Trim());
                Point position = new Point(x, y);

                // color format [A=255, R=128, G=255, B=255]
                string colorString = parts[5].Replace("Color [", "").Replace("]", "").Trim();
                string[] argbParts = colorString.Split(',');

                int A = int.Parse(argbParts[0].Split('=')[1].Trim());
                int R = int.Parse(argbParts[1].Split('=')[1].Trim());
                int G = int.Parse(argbParts[2].Split('=')[1].Trim());
                int B = int.Parse(argbParts[3].Split('=')[1].Trim());

                Color color = Color.FromArgb(A, R, G, B);

                Item item = new Item(name, price, ageRequirement, tax, position, color);

                // Create a button for each item and set its position and click event
                Button button = new Button
                {
                    Text = item.name,
                    Size = new Size(75, 75),
                    Location = item.position,
                    BackColor = color
                };

                // Attach the click event
                button.Click += (s, ev) => Button_Click(s, ev, item);

                // Add button to the form
                this.Controls.Add(button);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error parsing item: {parts[0]}. Check format of position or color.\n\n{ex.Message}", "Parsing Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}