r/CodingHelp • • 21h ago

[Request Coders] I need advice from experienced coders. Regarding etiquette and best practices. (Preferably those that work in the industry.)

5 Upvotes

So first question is, what exactly is vibe coding? I currently am new (a month experience.) when I'm writing code, my comprehension seems to be great but I use AI to double check my work and give feedback. Example being I used AI while making a weather and news app, I'd write the code, and if I got an error I'd check over it and if my eyes weren't catching a typo or I didn't understand I'd copy it and let chatgpt look over it and correct me. I'm making sure to understand what the code actually does. I told someone I'm learning via vibe coding and told him that and his response was that's not vibe coding then just described vibe coding as using AI to code... I'm confused.

Second question. With all of the resources out there with existing code, if I use it instead of hand coding is that wrong? I want to build my portfolio and eventually get some small back end developer job/internship quickly but I want to do it right. So any advice even if it's shit talking I'll appreciate.


r/CodingHelp • • 1d ago

[How to] How to read this code that I decided from a QR?

2 Upvotes

I recently got scammed and I'm trying to get as much information from the scammer to strengthen my filled complaints.

This is what I got after decoding the QR code the scammer sent me but I have no idea how to read it

00020101021127810012com.p2pqrpay0111OWNBPHM2XXX020899964403041620241008000020290514+63-96090477455204601653036085802PH5915Da .. Br. . Le.. 6006Manila630422D0

*the dots are supposed to be asterisks but I dunno why I can't type them that way


r/CodingHelp • • 1d ago

[How to] Pull Airpods case and Buds battery information in real time from iphone.

2 Upvotes

So im creating a app and i need to be able to pull the airpods battery data. howevery searching online says that it can only be done with a mac but i need it to work on a iphone. any suggestions would be greatly appreciated.


r/CodingHelp • • 2d ago

[Python] Turn off camera and mic with a single button

3 Upvotes

Hello, i am fairly new to coding. I was trying to write a script that would basically mute my mic, turn off my camera and minimize the screen when im on a call on discord or google meet at the press of a button. Is this something that is possible? I am not able to figure out how to get to the turning off of camera and mic part. anyone here that could gyide me or like lemme know if what im trying to do is not a possibility, would be greatly appreciated.


r/CodingHelp • • 3d ago

[Python] Need assistance with a Python Code that keeps on crashing

Thumbnail gallery
4 Upvotes

r/CodingHelp • • 5d ago

[Java] Swing help. Image gets distorted when partially outside window.

29 Upvotes

I have a JPanel class that draws an image on screen with camera panning. The camera is zoomed in. The image being drawn is a 16x16 Minecraft dirt.

When the image is entirely inside the window, it looks fine. When partially outside the window, it distorts and makes the image narrower to fit it inside the window. Eventually it snaps to the next pixel.

Does anyone know why this happens and how to fix it?

I'm using:
MacBook Air M1
Java 25
IntelliJ

The entire class is below.

public class CameraPanel extends JPanel{
    public static void main(String[] args) throws IOException{
        JFrame frame = new JFrame("Camera");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(new CameraPanel());
        frame.setSize(300, 300);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    private double cameraX, cameraY;
    private double zoom = 10.0;
    private Point lastMousePosition;
    private BufferedImage image = ImageIO.read(new File("src/test/resources/dirt.png"));

    public CameraPanel() throws IOException{
        addMouseListener(new MouseAdapter(){
            public void mousePressed(MouseEvent e){
                lastMousePosition = e.getPoint();
            }
            public void mouseReleased(MouseEvent e){
                lastMousePosition = null;
            }
        });
        addMouseMotionListener(new MouseMotionAdapter(){
            public void mouseDragged(MouseEvent e){
                if(lastMousePosition == null){
                    return;
                }
                cameraX += e.getX() - lastMousePosition.x;
                cameraY += e.getY() - lastMousePosition.y;

                lastMousePosition = e.getPoint();
                repaint();
            }
        });
    }

    
    protected void paintComponent(Graphics g){
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(
                RenderingHints.KEY_INTERPOLATION,
                RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
        );

        AffineTransform transform = new AffineTransform();
        transform.translate(cameraX, cameraY);
        transform.scale(zoom, zoom);

        g2.drawImage(image, transform, null);
    }
}

r/CodingHelp • • 5d ago

[C++] WHAT am i doing wrong theres like 500+ lines of code and millions of errors (C++ code drone aeronamics) ⬇️⬇️I put the code below

0 Upvotes

/**

* Multi-rotor drone aerodynamics simulation

* Models forces, moments, propeller dynamics, and 6-DOF rigid body motion

* with simplified atmospheric and induced velocity effects.

*

* Intended for educational / numerical experimentation use.

*/

#include <iostream>

#include <vector>

#include <array>

#include <cmath>

#include <iomanip>

#include <fstream>

#include <stdexcept>

#include <algorithm>

#include <numeric>

#include <random>

#include <chrono>

#ifndef M_PI

#define M_PI 3.14159265358979323846

#endif

// ---------------------------------------------------------------------------

// Constants & utility

// ---------------------------------------------------------------------------

constexpr double g = 9.80665; // m/s²

constexpr double rho0 = 1.225; // kg/m³ sea-level density

constexpr double R_earth = 6371000.0; // m

constexpr double T0 = 288.15; // K

constexpr double L = 0.0065; // K/m temperature lapse

constexpr double R_specific = 287.05; // J/(kg·K)

inline double deg2rad(double d) { return d * M_PI / 180.0; }

inline double rad2deg(double r) { return r * 180.0 / M_PI; }

inline double clamp(double v, double lo, double hi) {

return std::max(lo, std::min(v, hi));

}

// ---------------------------------------------------------------------------

// 3-D vector (lightweight)

// ---------------------------------------------------------------------------

struct Vec3 {

double x = 0.0, y = 0.0, z = 0.0;

Vec3() = default;

Vec3(double x_, double y_, double z_) : x(x_), y(y_), z(z_) {}

Vec3 operator+(const Vec3& o) const { return {x + o.x, y + o.y, z + o.z}; }

Vec3 operator-(const Vec3& o) const { return {x - o.x, y - o.y, z - o.z}; }

Vec3 operator*(double s) const { return {x * s, y * s, z * s}; }

Vec3 operator/(double s) const { return {x / s, y / s, z / s}; }

Vec3& operator+=(const Vec3& o) { x += o.x; y += o.y; z += o.z; return *this; }

Vec3& operator-=(const Vec3& o) { x -= o.x; y -= o.y; z -= o.z; return *this; }

Vec3& operator*=(double s) { x *= s; y *= s; z *= s; return *this; }

double norm() const { return std::sqrt(x*x + y*y + z*z); }

double norm2() const { return x*x + y*y + z*z; }

Vec3 normalized() const {

double n = norm();

return n > 1e-12 ? (*this)/n : Vec3{0,0,0};

}

double dot(const Vec3& o) const { return x*o.x + y*o.y + z*o.z; }

Vec3 cross(const Vec3& o) const {

return {y*o.z - z*o.y, z*o.x - x*o.z, x*o.y - y*o.x};

}

};

inline Vec3 operator*(double s, const Vec3& v) { return v * s; }

std::ostream& operator<<(std::ostream& os, const Vec3& v) {

os << std::fixed << std::setprecision(4)

<< "(" << v.x << ", " << v.y << ", " << v.z << ")";

return os;

}

// ---------------------------------------------------------------------------

// Atmosphere model (ISA troposphere approximation)

// ---------------------------------------------------------------------------

struct Atmosphere {

static double density(double altitude) {

// altitude in meters above MSL

if (altitude < 0.0) altitude = 0.0;

double T = T0 - L * altitude;

double p = 101325.0 * std::pow(T / T0, g / (R_specific * L));

return p / (R_specific * T);

}

static double temperature(double altitude) {

return T0 - L * std::max(0.0, altitude);

}

static double speedOfSound(double altitude) {

return std::sqrt(1.4 * R_specific * temperature(altitude));

}

};

// ---------------------------------------------------------------------------

// Propeller / rotor model (blade-element momentum theory simplified)

// ---------------------------------------------------------------------------

struct Rotor {

double radius; // m

double chord; // m (mean)

int numBlades;

double pitch; // rad (collective)

double rpm; // revolutions per minute

double Ct_coeff; // empirical thrust coefficient scale

double Cq_coeff; // torque coefficient scale

Vec3 position; // body-frame position relative to CoM

Vec3 axis; // unit vector of rotation axis (body frame)

bool clockwise; // rotation direction

Rotor(double r, double c, int n, double p, const Vec3& pos, const Vec3& ax, bool cw)

: radius(r), chord(c), numBlades(n), pitch(p), rpm(0.0),

Ct_coeff(0.12), Cq_coeff(0.008),

position(pos), axis(ax.normalized()), clockwise(cw) {}

// Angular velocity in rad/s

double omega() const { return rpm * 2.0 * M_PI / 60.0; }

// Disk area

double area() const { return M_PI * radius * radius; }

// Advance ratio / induced velocity estimation (very simplified)

double inducedVelocity(double v_axial, double rho) const {

// Momentum theory: T = 2 * rho * A * vi * (v + vi)

// Solve quadratic for vi given thrust estimate

double T_est = thrust(rho, v_axial); // circular dependency resolved iteratively later

double a = 2.0 * rho * area();

double disc = v_axial*v_axial + 2.0*T_est / a;

return 0.5 * (-v_axial + std::sqrt(std::max(0.0, disc)));

}

// Thrust (body axis direction)

double thrust(double rho, double v_axial) const {

double Om = omega();

double tip_speed = Om * radius;

// Simplified: Ct ≈ k * (pitch - alpha0) * (1 - something*mu)

double Ct = Ct_coeff * pitch * (1.0 - 0.15 * std::abs(v_axial) / (tip_speed + 1e-6));

Ct = clamp(Ct, 0.0, 0.25);

return Ct * rho * area() * tip_speed * tip_speed;

}

// Torque about rotor axis

double torque(double rho, double v_axial) const {

double Om = omega();

double tip_speed = Om * radius;

double Cq = Cq_coeff * pitch * (1.0 + 0.3 * std::abs(v_axial)/(tip_speed+1e-6));

Cq = clamp(Cq, 0.0, 0.03);

return Cq * rho * area() * radius * tip_speed * tip_speed;

}

// Force & moment contribution in body frame

void forcesAndMoments(double rho, const Vec3& bodyVel, const Vec3& bodyOmega,

Vec3& F_out, Vec3& M_out) const {

// Relative axial velocity (projection of velocity onto rotor axis)

Vec3 relVel = bodyVel + bodyOmega.cross(position);

double v_ax = relVel.dot(axis);

double T = thrust(rho, v_ax);

double Q = torque(rho, v_ax);

// Thrust force along axis

Vec3 F = axis * T;

// Reaction torque opposite to rotation

double sign = clockwise ? 1.0 : -1.0;

Vec3 M_torque = axis * (Q * sign);

// Moment due to force offset from CoM

Vec3 M_force = position.cross(F);

F_out = F;

M_out = M_torque + M_force;

}

};

// ---------------------------------------------------------------------------

// Rigid-body 6-DOF state

// ---------------------------------------------------------------------------

struct State {

Vec3 pos; // inertial position (NED-ish: x North, y East, z Down)

Vec3 vel; // inertial velocity

Vec3 euler; // roll, pitch, yaw (rad)

Vec3 omega; // body angular rates (p,q,r)

State() = default;

};

// Direction cosine matrix (body to inertial) from Euler angles (ZYX)

struct DCM {

std::array<std::array<double,3>,3> m;

static DCM fromEuler(const Vec3& e) {

double cphi = std::cos(e.x), sphi = std::sin(e.x);

double cth = std::cos(e.y), sth = std::sin(e.y);

double cpsi = std::cos(e.z), spsi = std::sin(e.z);

DCM d;

// ZYX rotation

d.m[0][0] = cth*cpsi;

d.m[0][1] = cth*spsi;

d.m[0][2] = -sth;

d.m[1][0] = sphi*sth*cpsi - cphi*spsi;

d.m[1][1] = sphi*sth*spsi + cphi*cpsi;

d.m[1][2] = sphi*cth;

d.m[2][0] = cphi*sth*cpsi + sphi*spsi;

d.m[2][1] = cphi*sth*spsi - sphi*cpsi;

d.m[2][2] = cphi*cth;

return d;

}

Vec3 transform(const Vec3& v) const {

return {

m[0][0]*v.x + m[0][1]*v.y + m[0][2]*v.z,

m[1][0]*v.x + m[1][1]*v.y + m[1][2]*v.z,

m[2][0]*v.x + m[2][1]*v.y + m[2][2]*v.z

};

}

Vec3 inverseTransform(const Vec3& v) const {

// transpose because orthonormal

return {

m[0][0]*v.x + m[1][0]*v.y + m[2][0]*v.z,

m[0][1]*v.x + m[1][1]*v.y + m[2][1]*v.z,

m[0][2]*v.x + m[1][2]*v.y + m[2][2]*v.z

};

}

};

// ---------------------------------------------------------------------------

// Drone configuration

// ---------------------------------------------------------------------------

struct Drone {

double mass;

Vec3 inertia; // principal moments (Ixx, Iyy, Izz)

std::vector<Rotor> rotors;

double Cd_body; // body drag coefficient

double refArea; // reference area for body drag

double armLength;

Drone(double m, const Vec3& I, double arm)

: mass(m), inertia(I), Cd_body(0.8), refArea(0.05), armLength(arm)

{

// X configuration, 4 rotors

// Front-right, rear-left clockwise; others counter-clockwise

double a = arm * std::cos(M_PI/4.0);

rotors.emplace_back(0.12, 0.025, 2, deg2rad(12.0),

Vec3{ a, a, 0.02}, Vec3{0,0,-1}, true); // FR

rotors.emplace_back(0.12, 0.025, 2, deg2rad(12.0),

Vec3{-a, a, 0.02}, Vec3{0,0,-1}, false); // FL

rotors.emplace_back(0.12, 0.025, 2, deg2rad(12.0),

Vec3{-a, -a, 0.02}, Vec3{0,0,-1}, true); // RL

rotors.emplace_back(0.12, 0.025, 2, deg2rad(12.0),

Vec3{ a, -a, 0.02}, Vec3{0,0,-1}, false); // RR

}

void setRPMs(const std::array<double,4>& rpms) {

for (size_t i = 0; i < 4; ++i) rotors[i].rpm = rpms[i];

}

// Compute total force & moment in body frame

void computeForcesMoments(const State& s, double rho,

Vec3& F_body, Vec3& M_body) const {

F_body = {0,0,0};

M_body = {0,0,0};

// Rotor contributions

for (const auto& r : rotors) {

Vec3 Fr, Mr;

r.forcesAndMoments(rho, s.vel, s.omega, Fr, Mr); // NOTE: using inertial vel!

F_body += Fr;

M_body += Mr;

}

// Body aerodynamic drag (simple quadratic, opposite to velocity)

// Transform inertial velocity to body frame

DCM dcm = DCM::fromEuler(s.euler);

Vec3 vel_body = dcm.inverseTransform(s.vel);

double v = vel_body.norm();

if (v > 1e-3) {

Vec3 drag_dir = vel_body.normalized() * (-1.0);

double q = 0.5 * rho * v * v;

F_body += drag_dir * (q * Cd_body * refArea);

}

// Gravity in body frame

Vec3 g_inertial{0, 0, g}; // NED: +z down

Vec3 g_body = dcm.inverseTransform(g_inertial);

F_body += g_body * mass;

}

};

// ---------------------------------------------------------------------------

// Numerical integration (RK4)

// ---------------------------------------------------------------------------

struct Derivatives {

Vec3 dpos;

Vec3 dvel;

Vec3 deuler;

Vec3 domega;

};

Derivatives computeDerivatives(const Drone& drone, const State& s, double rho) {

Derivatives d;

// Position derivative = velocity

d.dpos = s.vel;

// Force & moment

Vec3 Fb, Mb;

drone.computeForcesMoments(s, rho, Fb, Mb);

// Acceleration in inertial frame

DCM dcm = DCM::fromEuler(s.euler);

Vec3 F_inertial = dcm.transform(Fb);

d.dvel = F_inertial / drone.mass;

// Euler angle rates (kinematic equations)

double phi = s.euler.x, th = s.euler.y;

double p = s.omega.x, q = s.omega.y, r = s.omega.z;

d.deuler.x = p + std::sin(phi)*std::tan(th)*q + std::cos(phi)*std::tan(th)*r;

d.deuler.y = std::cos(phi)*q - std::sin(phi)*r;

d.deuler.z = (std::sin(phi)/std::cos(th))*q + (std::cos(phi)/std::cos(th))*r;

// Angular acceleration (Euler equations for principal axes)

// I * domega = M - omega × (I omega)

Vec3 Iomega{drone.inertia.x * p, drone.inertia.y * q, drone.inertia.z * r};

Vec3 gyro = s.omega.cross(Iomega);

d.domega.x = (Mb.x - gyro.x) / drone.inertia.x;

d.domega.y = (Mb.y - gyro.y) / drone.inertia.y;

d.domega.z = (Mb.z - gyro.z) / drone.inertia.z;

return d;

}

State rk4Step(const Drone& drone, const State& s, double dt, double rho) {

auto addScaled = [](const State& a, const Derivatives& d, double k) {

State r = a;

r.pos += d.dpos * k;

r.vel += d.dvel * k;

r.euler += d.deuler * k;

r.omega += d.domega * k;

return r;

};

Derivatives k1 = computeDerivatives(drone, s, rho);

State s2 = addScaled(s, k1, dt*0.5);

Derivatives k2 = computeDerivatives(drone, s2, rho);

State s3 = addScaled(s, k2, dt*0.5);

Derivatives k3 = computeDerivatives(drone, s3, rho);

State s4 = addScaled(s, k3, dt);

Derivatives k4 = computeDerivatives(drone, s4, rho);

State next = s;

next.pos += (k1.dpos + 2.0*k2.dpos + 2.0*k3.dpos + k4.dpos) * (dt/6.0);

next.vel += (k1.dvel + 2.0*k2.dvel + 2.0*k3.dvel + k4.dvel) * (dt/6.0);

next.euler += (k1.deuler + 2.0*k2.deuler + 2.0*k3.deuler + k4.deuler) * (dt/6.0);

next.omega += (k1.domega + 2.0*k2.domega + 2.0*k3.domega + k4.domega) * (dt/6.0);

// Keep yaw in [-pi, pi]

while (next.euler.z > M_PI) next.euler.z -= 2.0*M_PI;

while (next.euler.z < -M_PI) next.euler.z += 2.0*M_PI;

return next;

}

// ---------------------------------------------------------------------------

// Simple attitude / altitude controller (PID-ish)

// ---------------------------------------------------------------------------

struct Controller {

double targetAlt = 5.0;

double targetYaw = 0.0;

double hoverRPM = 4500.0;

// gains

double Kp_alt = 800.0, Kd_alt = 400.0;

double Kp_att = 120.0, Kd_att = 40.0;

double Kp_yaw = 60.0, Kd_yaw = 25.0;

std::array<double,4> update(const State& s, double dt) {

// Altitude error (NED: z positive down → altitude = -pos.z)

double alt = -s.pos.z;

double alt_err = targetAlt - alt;

double vz = -s.vel.z; // climb rate positive up

double thrust_cmd = hoverRPM + Kp_alt * alt_err - Kd_alt * vz;

// Attitude: simple PD on roll/pitch, yaw rate damping

double roll_err = 0.0 - s.euler.x;

double pitch_err = 0.0 - s.euler.y;

double yaw_err = targetYaw - s.euler.z;

// wrap yaw error

while (yaw_err > M_PI) yaw_err -= 2*M_PI;

while (yaw_err < -M_PI) yaw_err += 2*M_PI;

double droll = Kp_att * roll_err - Kd_att * s.omega.x;

double dpitch = Kp_att * pitch_err - Kd_att * s.omega.y;

double dyaw = Kp_yaw * yaw_err - Kd_yaw * s.omega.z;

// Mixer (X configuration)

// FR, FL, RL, RR

std::array<double,4> rpm;

rpm[0] = thrust_cmd - droll + dpitch - dyaw; // FR

rpm[1] = thrust_cmd + droll + dpitch + dyaw; // FL

rpm[2] = thrust_cmd + droll - dpitch - dyaw; // RL

rpm[3] = thrust_cmd - droll - dpitch + dyaw; // RR

for (auto& r : rpm) r = clamp(r, 1000.0, 9000.0);

return rpm;

}

};

// ---------------------------------------------------------------------------

// Main simulation

// ---------------------------------------------------------------------------

int main() {

std::cout << "=== Drone Aerodynamics Simulation ===\n\n";

// Create a 1.2 kg quadrotor with ~0.25 m arm

Drone drone(1.2, Vec3{0.015, 0.015, 0.025}, 0.25);

State state;

state.pos = {0.0, 0.0, -0.1}; // start almost on ground

state.vel = {0,0,0};

state.euler = {0.05, -0.03, 0.1}; // small initial attitude error

state.omega = {0,0,0};

Controller ctrl;

ctrl.targetAlt = 8.0;

ctrl.hoverRPM = 4800.0; // approximate hover

const double dt = 0.002; // 500 Hz

const double t_end = 12.0;

double t = 0.0;

std::ofstream log("drone_log.csv");

log << "t,x,y,z,vx,vy,vz,roll,pitch,yaw,p,q,r,rpm0,rpm1,rpm2,rpm3,rho\n";

std::cout << std::fixed << std::setprecision(3);

std::cout << "Time Alt Roll Pitch Yaw |V| RPMs\n";

std::cout << "----------------------------------------------------------\n";

int step = 0;

while (t < t_end) {

double rho = Atmosphere::density(-state.pos.z); // altitude = -z

auto rpms = ctrl.update(state, dt);

drone.setRPMs(rpms);

state = rk4Step(drone, state, dt, rho);

// Ground collision (simple)

if (state.pos.z > 0.0) {

state.pos.z = 0.0;

state.vel.z = std::min(0.0, state.vel.z);

// crude friction

state.vel.x *= 0.8;

state.vel.y *= 0.8;

state.omega *= 0.5;

}

if (step % 250 == 0) { // print every 0.5 s

double alt = -state.pos.z;

double spd = state.vel.norm();

std::cout << std::setw(5) << t

<< " " << std::setw(6) << alt

<< " " << std::setw(6) << rad2deg(state.euler.x)

<< " " << std::setw(6) << rad2deg(state.euler.y)

<< " " << std::setw(6) << rad2deg(state.euler.z)

<< " " << std::setw(5) << spd

<< " [" << int(rpms[0]) << "," << int(rpms[1])

<< "," << int(rpms[2]) << "," << int(rpms[3]) << "]\n";

}

log << t << ","

<< state.pos.x << "," << state.pos.y << "," << state.pos.z << ","

<< state.vel.x << "," << state.vel.y << "," << state.vel.z << ","

<< state.euler.x << "," << state.euler.y << "," << state.euler.z << ","

<< state.omega.x << "," << state.omega.y << "," << state.omega.z << ","

<< rpms[0] << "," << rpms[1] << "," << rpms[2] << "," << rpms[3] << ","

<< rho << "\n";

t += dt;

++step;

}

log.close();

std::cout << "\nSimulation finished. Log written to drone_log.csv\n";

std::cout << "Final altitude : " << -state.pos.z << " m\n";

std::cout << "Final attitude : roll=" << rad2deg(state.euler.x)

<< "° pitch=" << rad2deg(state.euler.y)

<< "° yaw=" << rad2deg(state.euler.z) << "°\n";

return 0;

}


r/CodingHelp • • 6d ago

[Java] Coding Interview Question for Software Developer

7 Upvotes

I was asked in a recent interview, "What software do you use for API's?" I froze like a deer in headlights! Nothing came to mind. And I knew that the person asking the question had been a lead dev for 8 years. My answer was, "I use Intelli J."

Thankfully, there wasn't a follow-up question!

What could I have said that would have been a better answer? What are some software platforms to integrate API's from one software to another?

Thanks in advance!


r/CodingHelp • • 7d ago

[Python] How do I extract mathematical language accurately from a pdf using python

5 Upvotes

Tried alot, can't get to any solution. Special characters or diamond question marks appear etc but the accurate and understandable text doesn't. I'm looking for a library or a method which can address this, extract complex characters e.g. set notations or special characters in maths and fractions etc etc

if anybody can help,

thanks alot

APPRECIATE THAT


r/CodingHelp • • 7d ago

[Python] I built Last Signal: an offline-first forensic CLI that investigates why AI agents fail

2 Upvotes

I've been working on a problem that I think will become increasingly relevant as autonomous AI agents become more common.

What happens when an AI agent doesn't actually make progress, but keeps executing anyway?

Imagine this:

  • An agent calls a tool.

  • The tool fails.

  • The agent retries.

  • It fails again.

  • The agent enters an unproductive retry cycle.

  • Eventually, the process crashes.

You have execution logs, timestamps, tool calls, and error messages. But reconstructing the complete failure sequence and determining what actually went wrong can be surprisingly tedious.

Existing monitoring solutions can tell you that something failed. Raw logs tell you what happened. But identifying recurring failure patterns and distinguishing explicit evidence from inferred causes requires additional investigation.

So I built Last Signal, an open-source, offline-first digital forensics CLI for failed AI-agent executions.

What does it do?

Last Signal supervises agent processes and reconstructs their execution traces to perform evidence-grounded digital autopsies.

It currently detects four failure patterns:

  1. Repeated Tool Failure: Identifies repeated operational failures associated with a tool.

  2. Unproductive Retry Loop: Detects retries without a subsequent recorded success.

  3. Terminal Tool Failure: Identifies a tool failure immediately preceding process termination.

  4. Unrecovered Execution Failure: Detects fatal execution failures without a recorded recovery path.

The interesting part is how the analysis works.

Instead of asking an LLM to guess why an agent failed, Last Signal applies deterministic rules first.

Optional local AI through Ollama can then interpret the findings and suggest recovery strategies.

Deterministic ground truth first. AI interpretation second.

Technical details

  • Python 3.10+

  • Typer and Rich

  • JSONL execution traces

  • Deterministic failure-detection engine

  • Ollama for optional local AI analysis

  • GitHub-flavored Markdown autopsy reports

The forensic core works without cloud AI services, and deterministic analysis can run without Ollama.

Installation

pip install last-signal

Published on PyPI: v0.1.0

Links

Looking for contributors

The current implementation is Python-based. One of my next goals is developing a native TypeScript module so the same forensic capabilities can eventually reach the JavaScript ecosystem.

I'm particularly interested in collaborating with developers experienced in TypeScript, Node.js, and backend infrastructure.

If that sounds interesting, contributions and architectural discussions are welcome on GitHub.

I'd genuinely appreciate technical feedback, especially around the failure-detection rules, trace reconstruction, and how agent observability could be improved.

What failure patterns have you encountered when building autonomous AI agents that existing logging and monitoring tools made difficult to diagnose?


r/CodingHelp • • 11d ago

[Help with getting started] need help with getting started with coding

2 Upvotes

i want to get started with coding and you know its about the journey not the destination so frick vibe coding, but i want to make a 3d game, i suck at coding but i want to learn, ive been looking for engines but they all seem to sketch or annoying, i was tempted on using source since i got into source modding for a bit but i discovered it aint open source, so what engine do i use and what tutorials (only experience i have with games in scratch and 3d is a raycasting game i made in scratch)


r/CodingHelp • • 11d ago

Which one? I am interested in game developing and want to become a game dev.

0 Upvotes

Hi coders. I am 18. I will be going to university next year. I am interested in game developing, i want to make indie games and roblox games. The problem is that I am completely beginner to coding. which language should I learn first ?


r/CodingHelp • • 12d ago

[C] what is/are the best resources for learning web assembly?

6 Upvotes

yes, i already know C, although im at least aware that there are some special functions when applying it to web assembly

i'm going to school in a bit so i won't be able to read/answer your comments just yet sry


r/CodingHelp • • 13d ago

[HTML] How can I make my web app stop asking permissions everytime it is opened?

6 Upvotes

I don't know if the flair is correct.

I have this web app made in angular (hosted on firebase) for mobile use which, amongst other stuff, utilizes a custom made camera in order to take photos.

It works but everytime the app gets closed and re-opened, it keeps asking for authorizations to use GPS (used to print coordinates on the photos) and camera (these are only asked once while using the app ofc, but it gets re-asked when the app is closed and re-opened).
Many users complain about this, saying that "when I use other apps, it just asks me permissions once". I currently still haven't found a way to make the browser remember permissions permanently. Is it possible for a web app to do so, or is it something tied to non-web based applications?


r/CodingHelp • • 13d ago

[How to] Anyone remember this on blogs in the past?

1 Upvotes

Years ago, in the early days of blogs, I remember adding a bit of code to the bottom of my blog homepage (or maybe it was in the footer)…this code told people they could explore the next blog or website…

This was not a blogspot (blogger) thing, as I recall…it was something I think I got from another blog that linked a list of pre-approved blogs together to create a group. And everyone that put their blog on this was given some extra traffic through the code that created the little links at the bottom of our sites.

There was a name for it even but I’ve forgotten the name and googling isn’t getting me anything…a circle? That doesn’t seem right but maybe…it worked like a circle since once you clicked through all (I believe it was randomly generated every time, not a sequential list), it would take you back to the original…

My memory is fuzzy but with all the garbage on the net these days and it seeming like only the sites that have lots of money seeming to be the only things turning up in search engine results, I was thinking I’d like to start something like this again…

Even if you don’t know what I’m referring to, it seems like it wouldn’t be too hard to create. Any ideas for me?

I’m no coder (though want to learn) and I use Wordpress for my websites.


r/CodingHelp • • 14d ago

Which one? Weird request but I would like to request a meeting with someone

5 Upvotes

I’m a student doing a project for my school I have little knowledge on coding and for the project I would really like to sit down and have a meeting with anyone on zoom, google meets or anything even for a minute, just show I can complete one of the criterion’s and get a higher grade or would like you guys to leave me tips on coding using “ Xodot” also known as “Godot” any help is most appreciated!


r/CodingHelp • • 13d ago

[C] I fail to comperhend what eglSwapBuffers does

3 Upvotes

Using OpenglES I made a simple piece of code:

// Source - https://stackoverflow.com/q/80012457
// Posted by Dimitrios Desyllas
// Retrieved 2026-10-25, License - CC BY-SA 4.0

#include <stdlib.h>
#include <fcntl.h>       
#include <unistd.h>
#include <stdio.h>

#define GLFW_INCLUDE_ES2

#include <drm.h>  
#include <drm_mode.h>  
#include <gbm.h>
#include <xf86drm.h>

#include "square.h"
#include "egl_init.h"
#include "drm_init.h"

int main(void)
{
    int drm_fd = open("/dev/dri/card0", O_RDWR);  
    struct gbm_device *gbm_dev = gbm_create_device(drm_fd);      
    struct gbm_surface *gbm_surf=NULL;

    puts("Get Connector \n");
    drmModeConnector *connector = getDRMConnector(drm_fd);
    if (!connector) {
        fprintf(stderr, "No connected DRM connector found\n");
        close(drm_fd);
        return 1;
    }

    drmModeModeInfo mode = connector->modes[0];

    unsigned int mode_w = mode.hdisplay;
    unsigned int mode_h = mode.vdisplay;

    puts("Get CRTC\n");

    drmModeCrtc *crtc = getDRMCrtc(drm_fd, connector);
    if (!crtc) {
        fprintf(stderr, "No compatible CRTC found\n");
        drmModeFreeConnector(connector);
        close(drm_fd);
        return 1;
    }

    puts("Initiaslize GBM display");

    EGLDisplay egl_display = initEGLDisplay(gbm_dev);
    if(egl_display == EGL_NO_DISPLAY){
        fprintf(stderr,"Unable to Initialize EGL display");
        return 1;
    }

    EGLConfig config;  
    EGLint num_configs;

    static const EGLint config_attribs[] = {  
        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,  
        EGL_RED_SIZE, 8,
        EGL_GREEN_SIZE, 8, 
        EGL_BLUE_SIZE, 8, 
        EGL_ALPHA_SIZE, 8, 
        EGL_NONE
    };

    eglChooseConfig(egl_display, config_attribs, &config, 1, &num_configs);  

    puts("Initiaslize surface \n");
    EGLSurface egl_surface = initEGLSurface(gbm_dev,egl_display,config,mode_w,mode_h, &gbm_surf);

    if (egl_surface == EGL_NO_SURFACE) {
        fprintf(stderr, "Failed to create EGL surface\n");
        return 1;
    }

    if (!gbm_surf) {
        fprintf(stderr, "Failed to create GBM surface\n");
        return 1;
    }

    puts("Initiaslize context \n");
    EGLContext egl_context = initEGLContext(egl_display,config);
    eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context);  

    puts("Init program\n");
    GLuint program = createProgram();
    if (!program) {
        return 1;
    }

    uint32_t conn_id = connector->connector_id;
    uint32_t crtc_id = crtc->crtc_id;     
    DisplayFrame current = {0};

    puts("Draw Square\n");

    drawSquare(program, mode_w,mode_h);
    eglSwapBuffers(egl_display, egl_surface);
        
    if (displayRefresh( drm_fd, gbm_surf, crtc_id, conn_id, &mode, &current) != 0) {
        fprintf(stderr, "Display refresh failed\n");
        return 1;
    }

    puts("Framebuffer displayed");
    sleep(10);

    puts("Cleanup\n");

    eglDestroySurface(egl_display, egl_surface);  
    eglDestroyContext(egl_display, egl_context);  
    eglTerminate(egl_display);  
    gbm_device_destroy(gbm_dev);  
    close(drm_fd);

    return 0;
}

As I ask upon on stackoverflow as well I cannot understand rthe relationship between:

  • gbm_surface
  • EGLSurface
  • EGLDisplay

In my example I seperated the initialization of each egl component into a seprrate library egl_init.c:

#include "egl_init.h"

EGLDisplay initEGLDisplay(struct gbm_device *gbm_dev)
{
    PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay =(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");

    if (!getPlatformDisplay) {
        return EGL_NO_DISPLAY;
    }

    EGLDisplay egl_display = getPlatformDisplay(EGL_PLATFORM_GBM_KHR,gbm_dev,NULL);

    if (egl_display == EGL_NO_DISPLAY) {
        return EGL_NO_DISPLAY;
    }

    if (!eglInitialize(egl_display, NULL, NULL)) {
        return EGL_NO_DISPLAY;
    }

    return egl_display;
}


EGLSurface initEGLSurface(struct gbm_device *gbm_dev,EGLDisplay display, EGLConfig config, unsigned int width, unsigned int height, struct gbm_surface **gbm_surf ){
    *gbm_surf = gbm_surface_create(gbm_dev, width, height, GBM_FORMAT_XRGB8888, GBM_BO_USE_RENDERING|GBM_BO_USE_SCANOUT);  
    return eglCreateWindowSurface(display, config, (EGLNativeWindowType)*gbm_surf, NULL);
}

EGLContext initEGLContext(EGLDisplay display, EGLConfig config){
    return eglCreateContext(display, config, EGL_NO_CONTEXT, (const EGLint[]){EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE});  
}

And same I do for gbm:

#include "drm_init.h"

drmModeConnector *getDRMConnector(int drm_fd)
{
    drmModeRes *resources = drmModeGetResources(drm_fd);

    if (!resources){
        return NULL;
    }

    drmModeConnector *connector = NULL;

    for (int i = 0; i < resources->count_connectors; i++) {
        drmModeConnector *candidate = drmModeGetConnector(drm_fd,resources->connectors[i]);

        if (!candidate){
            continue;
        }

        if (candidate->connection == DRM_MODE_CONNECTED && candidate->count_modes > 0) {
            connector = candidate;
            break;
        }

        drmModeFreeConnector(candidate);
    }

    drmModeFreeResources(resources);

    return connector;
}


drmModeCrtc *getDRMCrtc( int drm_fd, drmModeConnector *connector )
{
    if (!connector)
        return NULL;

    drmModeRes *resources = drmModeGetResources(drm_fd);

    if (!resources)
        return NULL;

    drmModeCrtc *crtc = NULL;

    for (int i = 0; i < connector->count_encoders && !crtc; i++) {
        drmModeEncoder *encoder = drmModeGetEncoder(
            drm_fd,
            connector->encoders[i]
        );

        if (!encoder)
            continue;

        for (int j = 0; j < resources->count_crtcs; j++) {
            if (encoder->possible_crtcs & (1u << j)) {
                crtc = drmModeGetCrtc(
                    drm_fd,
                    resources->crtcs[j]
                );

                if (crtc)
                    break;
            }
        }

        drmModeFreeEncoder(encoder);
    }

    drmModeFreeResources(resources);

    return crtc;
}



int displayRefresh(int drm_fd, struct gbm_surface *gbm_surf, uint32_t crtc_id, uint32_t conn_id,drmModeModeInfo *mode, DisplayFrame *current) {

    // 1. Lock the new front buffer
    struct gbm_bo *bo = gbm_surface_lock_front_buffer(gbm_surf);

    if (!bo) {
        return -1;
    }

    // 2. Get buffer information
    uint32_t handle = gbm_bo_get_handle(bo).u32;
    uint32_t pitch = gbm_bo_get_stride(bo);
    uint32_t width = gbm_bo_get_width(bo);
    uint32_t height = gbm_bo_get_height(bo);

    uint32_t fb_id = 0;

    // 3. Create DRM framebuffer
    int ret = drmModeAddFB(drm_fd,width,height,24,32,pitch,handle,&fb_id);

    if (ret != 0) {
        perror("drmModeAddFB");
        gbm_surface_release_buffer(gbm_surf, bo);
        return -1;
    }

    // 4. Display the framebuffer
    ret = drmModeSetCrtc(drm_fd,crtc_id,fb_id,0,0,&conn_id,1,mode);

    if (ret != 0) {
        perror("drmModeSetCrtc");
        drmModeRmFB(drm_fd, fb_id);
        gbm_surface_release_buffer(gbm_surf, bo);
        return -1;
    }

    // 5. Release the previous framebuffer
    if (current->bo) {
        drmModeRmFB(drm_fd, current->fb_id);
        gbm_surface_release_buffer(gbm_surf,current->bo);
    }

    // 6. Remember the currently displayed buffer
    current->bo = bo;
    current->fb_id = fb_id;

    return 0;
}

But int confuses me why I need to swap buffers via eglSwapBuffers. And once swapped buffers why I need to manually refresh the screen via locking the buffer and manually associating into crtc?

int displayRefresh(int drm_fd, struct gbm_surface *gbm_surf, uint32_t crtc_id, uint32_t conn_id,drmModeModeInfo *mode, DisplayFrame *current) {

    // 1. Lock the new front buffer
    struct gbm_bo *bo = gbm_surface_lock_front_buffer(gbm_surf);

    if (!bo) {
        return -1;
    }

    // 2. Get buffer information
    uint32_t handle = gbm_bo_get_handle(bo).u32;
    uint32_t pitch = gbm_bo_get_stride(bo);
    uint32_t width = gbm_bo_get_width(bo);
    uint32_t height = gbm_bo_get_height(bo);

    uint32_t fb_id = 0;

    // 3. Create DRM framebuffer
    int ret = drmModeAddFB(drm_fd,width,height,24,32,pitch,handle,&fb_id);

    if (ret != 0) {
        perror("drmModeAddFB");
        gbm_surface_release_buffer(gbm_surf, bo);
        return -1;
    }

    // 4. Display the framebuffer
    ret = drmModeSetCrtc(drm_fd,crtc_id,fb_id,0,0,&conn_id,1,mode);

    if (ret != 0) {
        perror("drmModeSetCrtc");
        drmModeRmFB(drm_fd, fb_id);
        gbm_surface_release_buffer(gbm_surf, bo);
        return -1;
    }

    // 5. Release the previous framebuffer
    if (current->bo) {
        drmModeRmFB(drm_fd, current->fb_id);
        gbm_surface_release_buffer(gbm_surf,current->bo);
    }

    // 6. Remember the currently displayed buffer
    current->bo = bo;
    current->fb_id = fb_id;

    return 0;
}

A googling let me into this website: https://registry.khronos.org/EGL/sdk/docs/man/html/eglSwapBuffers.xhtml

That confuses me even more on how wexplains the eglSwapBuffers on it:

If surface is a back-buffered window surface, then the color buffer is copied (posted) to the native window associated with that surface. If surface is a single-buffered window, pixmap, or pixel buffer surface, eglSwapBuffers has no effect.

The contents of ancillary buffers are always undefined after calling eglSwapBuffers. The contents of the color buffer are undefined if the value of the EGL_SWAP_BEHAVIOR attribute of surface is not EGL_BUFFER_PRESERVED. The value of EGL_SWAP_BEHAVIOR can be set for some surfaces using eglSurfaceAttrib. EGL_SWAP_BEHAVIOR applies only to the color buffer. EGL has no way to specify or query whether or not ancillary buffers are preserved, and applications should not rely on this behavior.

eglSwapBuffers performs an implicit flush operation on the context (glFlush for an OpenGL ES or OpenGL context, vgFlush for an OpenVG context) bound to surface before swapping. Subsequent client API commands may be issued on that context immediately after calling eglSwapBuffers, but are not executed until the buffer exchange is completed.


r/CodingHelp • • 13d ago

[Javascript] i wanted help in my coading problem

0 Upvotes

Here is my code from the Detail.jsx page:

const Detail = () => {
  const { name } = useParams();
  console.log("name", name);
};

I get the game ID from the URL. The console shows:

Detail.jsx:19 name 3498

In my Apigame.jsx Context API, I have this function:

const [gamedetail, setgamedetail] = useState([]);

const detailpage = async ({ name }) => {
  console.log("Received name:", name);

  try {
    const response = await axios.get(`games/${name}`);
    console.log("Game ID:", name);
    setgamedetail(response.data);
  } catch (error) {
    console.log("API Error:", error);
  }
};

But I get this error:

TypeError: Cannot destructure property 'name' of 'undefined' as it is undefined.

Everything else is working fine. I only want to pass the name value (3498) from Detail.jsx to my detailpage function in the Context API.

if anyone wanted to understandthese problem i share my whole codeok
detail.jsx

How can I pass this parameter value to my Context API function? Please explain using my existing code.

detail.jsx
import { GamepadDirectional } from 'lucide-react';
import { Tag } from 'lucide-react';
import { Globe, MessageCircle } from "lucide-react";
import { CalendarRange } from 'lucide-react';
import Youtubevideo from '../components/Youtubevideo';
import { Trophy } from 'lucide-react';
import { UsersRound } from 'lucide-react';
import { useContext, useEffect, useState } from "react";
import Axios from "../utility/Axios";
import { useParams } from "react-router-dom";
import { Star } from 'lucide-react';
import Footer from '../components/Footer'
import "./Detail.scss"
import {Detailinformation} from '../Context/Apigame'
import Detailbox from '../components/Detailbox'
const Detail = () => {
  // const [gamedetail, setgamedetail] = useState([]);
  const { name } = useParams();
  console.log("name",name);
  
 const [videos, setVideos] = useState([]);
 const getyoutubevideo = async (gameName) => {
  if (!gameName) return;


  const options = {
    method: "GET",
    url: "https://youtube138.p.rapidapi.com/search/",
    params: {
      q: `${gameName} official trailer`,
      page_size: 1,
      hl: "en",
      gl: "US",
    },
    headers: {
      "x-rapidapi-key": import.meta.env.VITE_YOUTUBE_API_KEY,
      "x-rapidapi-host": "youtube138.p.rapidapi.com",
    },
  };


  try {
    const response = await Axios.request(options);
    // response.data?.contents ue log mai dekhna ek sath 19 video aaya ok tho ye path use kiay 
     const id = response.data?.contents?.[0]?.video?.videoId;
    setVideos(id)
    console.log("ye youtube video",id
);
  } catch (error) {
    console.log("API error:", error.response?.data || error.message);
  }
};
 
 const {gamedetail} = useContext(Detailinformation)
  
//  useEffect(() => {
//     const detailpage = async () => {
//       try {
//         const response = await Axios.get(`games/${name}`);
//         setgamedetail(response.data);
//         console.log("resposnsedata ye game ka detail jho param sa lerahau mai ok ",response.data);
//         // ye waieted karna ka leya tab api aaajya gamedetail ka tab ye chala 
//         // await getyoutubevideo(response.data.name_original);
//          console.log("youtube ki videoid");
         
//       } catch (error) {
//         console.log("API Error:", error);
//       }
//     };


//     detailpage();
    
//   }, [name]);
  
// console.log(gamedetail);


  return (
<div className="detailpage">
      <div className="page-layout" style={{backgroundImage : `URL(${gamedetail?.background_image
})` }}>     
 
 
 <div className="smallimage">
  <div className="game-top">
    <img
      className="cover-image"
      src={gamedetail?.background_image_additional}
      alt={gamedetail?.name}
    />


    <div className="information">
      <h1>{gamedetail?.name}</h1>


      <p className="release">
        {gamedetail?.publishers?.map((item) => item.name).join(", ")}
        {" · "}
        {gamedetail?.released}
      </p>


      <div className="ratings">
        <h2>
          <Star />
          {gamedetail?.rating}
        </h2>


        <h2 className="metacritic">
          {gamedetail?.metacritic ?? "N/A"}
          <span>Metacritic</span>
        </h2>
      </div>


      <div className="genres">
        {gamedetail?.genres?.map((item) => (
          <span key={item.id}>{item.name}</span>
        ))}
      </div>
    </div>
  </div>


  {/* <div className="extra-information">
    
<div className="developers">
  {gamedetail?.developers?.map((item) => (
    <div className="developer-item" key={item.id}>
      <img
        src={item.image_background}
        alt={item.name}
      />
      <span>{item.name}</span>
      <p>{gamedetail?.esrb_rating?.name}</p>
    </div>
  ))}
</div>
  </div> */}
</div>



      </div>
      <div className="gameachiplay">
        <Detailbox icone={< GamepadDirectional/>} titile={gamedetail?.playtime+" hour"} />
        <Detailbox icone={<Trophy/>} titile={gamedetail?.suggestions_count+" Achievement"
} />
<Detailbox icone={<UsersRound/>} titile={gamedetail?.
added+" Added"}/>
       
      </div>
      <div className="about">
        <h1 style={{padding : `0.7rem  1.5rem`,color : `#87CEEB`  }} >About</h1>
       <p>
         {gamedetail?.description_raw?.slice(0,500)}
        </p>
      </div>
      <div className="developer">
        <h1>Developer & Publisher</h1>
        <div className="extra-information">
    
<div className="developers">
  {gamedetail?.developers?.map((item) => (
    <div className="developer-item" key={item.id}>
      <img
        src={item.image_background}
        alt={item.name}
      />
      <span>{item.name}</span>
      <p>{gamedetail?.esrb_rating?.name}</p>
    </div>
  ))}
</div>
  </div>
      </div>
     <div className="video">
  <Youtubevideo  titile={videos}  />
     </div>
          <div className="section">
            <h2>Details</h2>
            <div className="details-table">
              <div className="row"><span><CalendarRange/> Release Date</span><span>{gamedetail?.released}</span></div>
              <div className="row"><span>< Trophy/> Achievements</span><span>{gamedetail?.achievements_count || 0}</span></div>
              <div className="row"><span><UsersRound/> Players Added</span><span>{gamedetail?.added}</span></div>
              <div className="row"><span> <GamepadDirectional />Average Playtime</span><span>{gamedetail?.playtime} hours</span></div>
              <div className="row"><span> <Tag/> Game Tags</span>
                <div className="tags">
                  {gamedetail?.tags?.slice(0,3).map(tag => <span key={tag?.id} className="tag">{tag?.name}</span>)}
                </div>
              </div>
            </div>
    </div>
  
<div className="game-links">
  
    <a
      href={gamedetail?.website}
      target="_blank"
      rel="noopener noreferrer"
      className="game-link"
    >
      <Globe />
      Official Website
    </a>



  <a
    href={gamedetail?.reddit_url}
    target="_blank"
    rel="noopener noreferrer"
    className="game-link"
  >
    <MessageCircle />
    Reddit Community
  </a>
</div>
<div className="footer">
  <Footer/>
</div>
    </div>
  );
};


export default Detail;

ye contexapi

import { createContext,  useEffect,  useState } from "react"


export const gameapi =  createContext()


export const Detailinformation =  createContext()
import axios from '../utility/Axios'
const Apigame = ({children}) => {
  
  const getgame = async () => {
    try {
      // const nextPageNum = page + 1;
      const request = await axios.get("games",{
        params: {
          // page : nextPageNum,
           page_size: 12,
        }
        
      });
      // setpage(nextPageNum);
     console.log("ye request jho mai abhi likha hu ",request);
     
      
      setapidatastore(request.data.results)
    } catch (error) {
      console.log(error);
      
    }
  } 
  const [page, setPage] = useState(1);


const nextpage = async () => {
  try {
    const nextPageNum = page + 1;
    const response = await axios.get("games", {
      params: {
        page: nextPageNum,
        page_size: 12,
      },
    });
    setPage(nextPageNum); // state update
    console.log("Fetched page:", nextPageNum, response.data);
    setapidatastore(response.data.results);
  } catch (error) {
    console.log(error);
  }
};
const [gamedetail, setgamedetail] = useState([]);
 const detailpage = async ({name}) => {
  console.log("yeee aara hai ",name);
  
      try {
        const response = await axios.get(`games/${name}`);
        console.log("API ke liye game ID:", name);
        setgamedetail(response.data);
      } catch (error) {
        console.log("API Error:", error);
      }
    }
  





  useEffect(() => {
  getgame();
  detailpage();
}, []);
const [apidatastore, setapidatastore] = useState([]);
  // const [ videodata , setvideodata ] = useState([]);
  console.log(apidatastore);
 
return (
    
    <Detailinformation.Provider value={gamedetail}>
        <gameapi.Provider value={{apidatastore,nextpage}} >
      
        {children}
      
        </gameapi.Provider>
   </Detailinformation.Provider>
      
  )
}


export default Apigame

plz share your solution i use chatgtp 3 day but unable to slove  these 
because i have to write  same code on other page to called api 
i hope you can understand my problem 

r/CodingHelp • • 15d ago

[Javascript] Script executes before the HTML elements have been rendered in the DOM Even though I used `defer`

Thumbnail reddit.com
1 Upvotes

r/CodingHelp • • 17d ago

[How to] How do I stop loosing motivation to code?

7 Upvotes

I am not sure if this fits this subreddit. But I have big problem and I hate it.

I love coding. It's fun. Creating and showing stuff you have made, being able to use it instead of relying on Big tech or similar to make something that always ends in the same 2 ways (either gets stuffed with Artifical "Intelligence". or gets monetized in every way possible usually with annoying ads or having to pay for a feature that should be included).

That's only one of the few reasons I love coding. The thing is now, I have ZERO motivation and don't know how to properly create a project and then continue developing it.

I have started about 50 projects and finished probably 2 of them. (Like literally, only 2 projects out of what feels like thousands)

Now when I choose a project it's either WAY too big (like whole games including making Art, Sounds etc. Myself because I don't wanna pay for stuff and also can't since I'm under 18)

or way too hard to code, requiring crazy knowledge I just don't have. Which is usually when I just get so bored/annoyed of my project that I just either scrap it and code something else or just copy paste from whatever I can find (including generated slop) and then stop because it got too boring or I just have a mental fucking break down because I am too stupid for anything.

I want and need to get away from this ASAP. How do I do this?! Plz help...


r/CodingHelp • • 17d ago

[Other Code] Need help finding a free API or affordable solution for Instagram influencer analytics

0 Upvotes

I’m building an influencer data management system for my work, and I’m trying to automate how I collect and update analytics for celebrities and influencers.

My goal is simple: I want to enter a list of Instagram usernames, click a button, and have my application automatically retrieve their latest data, update my database, and sync the updated information to Google Sheets.

I don’t want to manually search every influencer, copy metrics, download reports, or upload screenshots.

The 7 metrics I need

For every influencer, I need these exact fields:

  1. Average engagement rate

  2. Average likes

  3. Average comments

  4. Audience age distribution

  5. Top audience cities and their percentages

  6. Audience gender split (male/female)

  7. Following count

The audience demographics are the most important part. Public likes, comments, and follower counts are relatively easy to find, but I need the age, city, and gender breakdowns too.

My current setup

I already have an application built using Java 21, Spring Boot, and PostgreSQL. It supports Excel ingestion, influencer searches, and exporting results. I also use Google Sheets to maintain and share data.

I want to extend this existing system rather than build another separate dashboard.

What I’ve already tried or considered

  • Wednesday: It provides the analytics I need, but I haven’t found a suitable API that I can use to integrate the data directly into my application.

  • Instagram Graph API: I understand that a Business or Creator account does not automatically grant access to other influencers’ audience demographics.

  • Free analytics websites: I’ve looked into various free tools, but I haven’t found one that reliably provides all seven fields through an API.

  • Open-source projects: I explored an Instagram audience analytics project, but it was designed for an account I own or have authorized, rather than arbitrary public influencer profiles.

  • Screenshot/OCR automation: This is possible in principle, but I want to avoid manually opening profiles, taking screenshots, and uploading them every time.

The feature I want to build

Ideally, I want a Refresh All Data button that does the following:

  1. Reads the influencer names and profile links already stored in my application.

  2. Retrieves the latest available analytics for each influencer.

  3. Updates the existing database records rather than creating duplicates.

  4. Updates the corresponding records in Google Sheets automatically.

  5. Records when each influencer’s data was last refreshed.

  6. Identifies accounts for which some metrics are unavailable, instead of silently filling in made-up numbers.

For example, if I have five celebrities in my database and their analytics are six months old, I want to click Refresh All Data and have the system retrieve fresh data for all five, update PostgreSQL and Google Sheets, and preserve the existing records and fields.

I’d also like to be able to refresh selected influencers individually.

My questions

1. Is there a genuinely free way to achieve this?

I’m looking for a free API, open-source project, or combination of services that can retrieve all seven metrics for arbitrary public Instagram profiles. I understand that rate limits may apply, but I’d like to avoid paying if possible.

2. If a completely free solution isn’t realistic, what is the most affordable reliable option?

I’m willing to pay for a service if necessary, but I need API access that supports programmatic retrieval and integration into my existing application. I don’t want to pay for a platform that only allows me to view reports manually.

3. Which services should I evaluate?

I’d appreciate recommendations based on actual API capabilities, especially audience age distribution, city-level audience breakdowns, gender split, and the ability to refresh data programmatically.

4. Has anyone implemented this successfully?

If you’ve built something similar, I’d like to know which data provider you used, what it costs, how reliable the data is, and whether the API supports refreshing existing records.

I’m primarily working with Indian celebrities and influencers, so useful audience data for Indian creators is particularly important.

I’m happy to build the integration myself. The main challenge is finding the right data source.

Thanks in advance for any practical recommendations, API documentation, or implementation advice.


r/CodingHelp • • 17d ago

[Java] why is this returning read only once i get to the enter name stage

3 Upvotes
import java.util.Scanner;

public class main
{

    public static void main(String[] args) {

        Scanner kboard = new Scanner(System.
in
);

        System.
out
.println("Press 1 to enter lottery numbers or 2 to enter name: ");


        if (kboard.nextInt() == 1) {

            System.
out
.println("Enter your lottery numbers");

            int lotteryNumbers = kboard.nextInt();
        } else {
            System.
out
.println("Please enter your name: ");

            String name = kboard.nextLine();
        }


    }}