r/programminghelp • • 21d ago

Project Related Raycasting Performance Help

1 Upvotes

I made a raycasting engine in python, and am using an HTML canvas as my method of display (passing the pixel colors through jinja in a <script> tag). It takes upwards of 10-15 seconds to render one angle of a scene with three spheres at a resolution of 800x400. Is the browser likely the bottleneck, or is this a sign of some other inefficiencies?

r/programminghelp • • Sep 21 '26

Project Related Beginner Coder: Stuck with an error

2 Upvotes

Hi,

Currently developing a basic web app following adonisjs docs.

I've ran into an error:

\[23:18:41.975\] ERROR (12316): Cannot transform undefined value. Use "this.whenLoaded(value)" to allow undefined values

My project is on github:

**https://github.com/Ajaz754/adonisjs-project-22-/tree/main\*\*

The error is pointing to '**app/transformers/post_transformer.ts**' Line 13

I've followed adonis docs completely step by step except for ?.depth(2) on line 13, which when I removed only introduced more errors along with this one.

Also VS Code isn't flagging the error. Only when I go to my browser and visit local host the error appears in powershell and my browser. Any help would be much appreciated

r/programminghelp • • Sep 25 '26

Project Related Beginner Coder: Stuck with an error

2 Upvotes

Hi,

I'm working on an adonisjs project. I've ran into an error:

My project is on github:

https://github.com/Ajaz754/adonisjs-project-22-

The error is in file 'app/transfromers/post_transformers' Line 22:

----------------------------------------------------
Object is possibly 'undefined'. ts (2532)
(method)
BaseTransformer<T>. transform‹ typeof CommentTransformer>
(this: typeof
CommentTransformer, data:
Maybe< Comment [] | undefined>):
Collection<CommentTransformer, 1, "toObject"> | undefined (+5 overloads)
static transform<Self extends { new (resource: any, ...rest: any\[\]): any i }> (this: Self, data:
Maybe ConstructorParameters<Self>[0][] | undefined>, ... rest:
ExtractTransformerRestTypes<Co nstructorParameters<Self>>):
Collection<InstanceType<Self>, 1,
'toObject'> | undefined;
----------------------------------------------------

Only thing I've done differently to the adonis docs is make 'post.author' into 'post.author?' to fix a type error as it was showing the error where it may possibly be undefined. That post is here:

https://www.reddit.com/r/adonisjs/s/V7eO8q3nfJ

Any help would be much appreciated

TIA

r/programminghelp • • Aug 15 '26

Project Related UML Diagrams for a flutter and BLOC mobile application?

0 Upvotes

hi everyone!

so i’m building a flutter mobile application using BLOC for state management, and it’s kind of combine with a layered architecture (repositories and services). ive never done this before so I’m super confused about the UML diagram aspect of it.

Should I draw every BLOC for each function? especially for the class and sequence diagrams? or would it be okay to just leave it as controllers? I’m somewhat okay with class diagrams but the sequence diagram is really confusing for me to draw for this application.

i would really appreciate any tips or advice! pls help! I’m on a short time constraints so I’m hoping to sit down and finish all the diagrams in one day

thanks a lot!

r/programminghelp • • Aug 20 '26

Project Related Trouble Preprocessing images from Flutter to feed into TFLite model

1 Upvotes

Hi everyone. So I built a CNN model using MobileNetv3 then converted it into TFLite. It performed well during training but once I integrated it into my application, it is making large errors. From flutter, the camera stream sends frames and those are processed before the model makes predictions, but it is still quite large. Is there any way I can solve this? This is my code to preprocess and resize the image (224 x 224 x RGB):

import 'package:camera/camera.dart';
import 'package:image/image.dart' as img;


class ImageProcessor {
  // converting to rgb
  img.Image convertYUVToRGB(CameraImage camImg) {
    final width = camImg.width;
    final height = camImg.height;


    final yPlane = camImg.planes[0];
    final uPlane = camImg.planes[1];
    final vPlane = camImg.planes[2];


    final yBytes = yPlane.bytes;
    final uBytes = uPlane.bytes;
    final vBytes = vPlane.bytes;


    final yRowStride = yPlane.bytesPerRow;
    final uRowStride = uPlane.bytesPerRow;
    final vRowStride = vPlane.bytesPerRow;


    final uPixelStride = uPlane.bytesPerPixel ?? 1;
    final vPixelStride = vPlane.bytesPerPixel ?? 1;


    final image = img.Image(
      width: width,
      height: height,
    );


    for (int y = 0; y < height; y++) {
      for (int x = 0; x < width; x++) {
        final yIndex = y * yRowStride + x;


        final uvX = x ~/ 2;
        final uvY = y ~/ 2;


        final uIndex =
            uvY * uRowStride +
            uvX * uPixelStride;


        final vIndex =
            uvY * vRowStride +
            uvX * vPixelStride;


        final yValue = yBytes[yIndex];
        final uValue = uBytes[uIndex];
        final vValue = vBytes[vIndex];


        // YUV -> RGB
        final r = (
          yValue + 1.402 * (vValue - 128)
        ).round().clamp(0, 255);


        final g = (
          yValue -
          0.344136 * (uValue - 128) -
          0.714136 * (vValue - 128)
        ).round().clamp(0, 255);


        final b = (
          yValue + 1.772 * (uValue - 128)
        ).round().clamp(0, 255);


        image.setPixelRgb(
          x,
          y,
          r,
          g,
          b,
        );
      }
    }


    return image;
  }


  /// resize images to 224 224
  img.Image resizeImage(img.Image image) {
    return img.copyResize(
      image,
      width: 224,
      height: 224,
      interpolation: img.Interpolation.linear,
    );
  }


  List<List<List<List<double>>>> imageToTensor(
    img.Image image,
  ) {
    return [
      List.generate(
        224,
        (y) => List.generate(
          224,
          (x) {
            final pixel = image.getPixel(x, y);


            return [
              pixel.r.toDouble(),
              pixel.g.toDouble(),
              pixel.b.toDouble(),
            ];
          },
        ),
      ),
    ];
  }


// do all processing
  List<List<List<List<double>>>> processFrame(
    CameraImage camImg,
  ) {
    final rgbImage = convertYUVToRGB(camImg);
    final resizedImage = resizeImage(rgbImage);
    final input = imageToTensor(resizedImage);


    return input;
  }
}import 'package:camera/camera.dart';
import 'package:image/image.dart' as img;


class ImageProcessor {
  // converting to rgb
  img.Image convertYUVToRGB(CameraImage camImg) {
    final width = camImg.width;
    final height = camImg.height;


    final yPlane = camImg.planes[0];
    final uPlane = camImg.planes[1];
    final vPlane = camImg.planes[2];


    final yBytes = yPlane.bytes;
    final uBytes = uPlane.bytes;
    final vBytes = vPlane.bytes;


    final yRowStride = yPlane.bytesPerRow;
    final uRowStride = uPlane.bytesPerRow;
    final vRowStride = vPlane.bytesPerRow;


    final uPixelStride = uPlane.bytesPerPixel ?? 1;
    final vPixelStride = vPlane.bytesPerPixel ?? 1;


    final image = img.Image(
      width: width,
      height: height,
    );


    for (int y = 0; y < height; y++) {
      for (int x = 0; x < width; x++) {
        final yIndex = y * yRowStride + x;


        final uvX = x ~/ 2;
        final uvY = y ~/ 2;


        final uIndex =
            uvY * uRowStride +
            uvX * uPixelStride;


        final vIndex =
            uvY * vRowStride +
            uvX * vPixelStride;


        final yValue = yBytes[yIndex];
        final uValue = uBytes[uIndex];
        final vValue = vBytes[vIndex];


        // YUV -> RGB
        final r = (
          yValue + 1.402 * (vValue - 128)
        ).round().clamp(0, 255);


        final g = (
          yValue -
          0.344136 * (uValue - 128) -
          0.714136 * (vValue - 128)
        ).round().clamp(0, 255);


        final b = (
          yValue + 1.772 * (uValue - 128)
        ).round().clamp(0, 255);


        image.setPixelRgb(
          x,
          y,
          r,
          g,
          b,
        );
      }
    }


    return image;
  }


  /// resize images to 224 224
  img.Image resizeImage(img.Image image) {
    return img.copyResize(
      image,
      width: 224,
      height: 224,
      interpolation: img.Interpolation.linear,
    );
  }


  List<List<List<List<double>>>> imageToTensor(
    img.Image image,
  ) {
    return [
      List.generate(
        224,
        (y) => List.generate(
          224,
          (x) {
            final pixel = image.getPixel(x, y);


            return [
              pixel.r.toDouble(),
              pixel.g.toDouble(),
              pixel.b.toDouble(),
            ];
          },
        ),
      ),
    ];
  }


// do all processing
  List<List<List<List<double>>>> processFrame(
    CameraImage camImg,
  ) {
    final rgbImage = convertYUVToRGB(camImg);
    final resizedImage = resizeImage(rgbImage);
    final input = imageToTensor(resizedImage);


    return input;
  }
}

Please advise! I need to finish this project within the next wee and I'm really struggling here! I tested the images from Flutter against TFLite and it worked well but something is clearly wrong with the preprocessing. Pls help and give me any advice.

Thank you so much!

r/programminghelp • • Aug 03 '26

Project Related Is bcrypt a good choice for hashing refresh tokens? I'm stuck with session lookup.

3 Upvotes

I'm building my own authentication system in Node.js, Express, MongoDB (Mongoose), JWT, and bcrypt. I'm trying to understand the architecture instead of just copying a tutorial.

My current flow is:

  • User registers/logs in.
  • Password is hashed with bcrypt.
  • I generate a refresh token (JWT).
  • I hash the refresh token with bcrypt before storing it in the sessions collection.
  • The actual refresh token is sent to the client as an HttpOnly cookie.

The problem appears during the refresh endpoint.

Since bcrypt generates a different hash every time, I can't do something like:

const refreshTokenHash = await bcrypt.hash(refreshToken, 10);

const session = await sessionModel.findOne({
    refreshTokenHash,
    revoked: false
});

because hashing the same refresh token again produces a different hash, so the session can't be found.

The tutorial I was following used SHA-256 for hashing refresh tokens, so searching by hash worked because SHA-256 is deterministic. I intentionally switched to bcrypt because I thought it would be more secure, but now I've run into this architectural problem.

I've thought about putting sessionId inside the refresh token so I can:

  1. Verify the JWT.
  2. Read the sessionId.
  3. Find the session by _id.
  4. Use bcrypt.compare(refreshToken, session.refreshTokenHash).

That seems reasonable, but creating the session first introduces another issue because my schema requires refreshTokenHash, while I need the sessionId before I can generate and hash the refresh token.

if anyone needs more info to tell me a solution just ask for it

r/programminghelp • • Aug 10 '26

Project Related I require assistance with Vivado Verilog Coding

3 Upvotes

Hi, I'm a newbie to this software and working on a Verilog FSM assignment which uses a basys3 board. I still cant seem to generate waveform

  • The user replays the game 4 times (3 rounds per replay)
  • The user has 11 seconds to memorize the LED sequence (You may set TIMER_VALUE = 110 for your simulation)
  • Achieve an accumulated score of at least 40 for each replay

I alr add all the parameters except

  • ca to cg and an3 to an0
  • COUNTER_VALUE and CLK DIVIDER COUNTER

cos i dont think its rlly needed. I have set FSM.v as the top module before running the simulation and TOP.v as the top module before generating bitstream. My clk, rst, all btn, random_val and sw are all blue

  1. IDLE (System Ready) Upon power-on or reset, the system enters the IDLE state. All 16 LEDs turn on simultaneously, displaying 16'hFFFF to signal that the game is ready, and the score counter resets to zero. The FSM remains in this state indefinitely, waiting for the user to press btn_start, which triggers the transition to the DISPLAY state.
  2. DISPLAY (Memorize the Pattern) Once the game starts, the FSM transitions to the DISPLAY state, where the LEDs display a random 16-bit pattern. The user is given a limited window of time to memorize which LEDs are lit, with the duration controlled by the TIMER_VALUE parameter. As soon as this timer expires, the FSM automatically advances to the GET_INPUT state.
  3. GET_INPUT (Enter Your Guess) In the GET_INPUT state, the system waits for the user to recreate the memorized pattern using the 16 physical switches (sw). To assist the user, the LEDs dynamically update to reflect the current switch positions in real-time. There is no time limit for this phase; the FSM remains here until the user is satisfied with their input and presses btn_submit to lock in their answer and transition to the CHECK state.
  4. CHECK (Scoring) During the CHECK state, the system evaluates the user's input by comparing the switch positions against the stored 16-bit pattern bit-by-bit. The user earns one point for every switch that correctly matches the corresponding LED state from the DISPLAY state. The system then updates the total score on the seven-segment display and increments the round counter. If the current round is less than the NUMBER_OF_ROUNDS parameter, the FSM loops back to the DISPLAY state for the next round; otherwise, it transitions to the FINISH state.
  5. FINISH (Game Over) The FSM enters the FINISH state after the user completes the maximum number of rounds defined by NUMBER_OF_ROUNDS. In this state, the seven-segment display locks to show the final score, and all 16 LEDs blink continuously to visually signal that the game is over. The hardware remains in this loop until the user presses btn_restart, which resets the internal game metrics and returns the FSM to the IDLE state for a new game.

Code:

`timescale 1ns / 100ps

module tb_memory_game();

// Parameters

parameter width = 16;

parameter NUMBER_OF_ROUNDS = 3;

parameter TIMER_VALUE = 110;

parameter BLINK_RATE = 32'd100;

reg clk;

reg rst;

reg btn_start;

reg btn_submit;

reg btn_restart;

reg [15:0] sw;

reg [15:0] random_val;

wire [15:0] led;

wire [31:0] score;

FSM#(

.width(width),

.NUMBER_OF_ROUNDS(NUMBER_OF_ROUNDS),

.TIMER_VALUE(TIMER_VALUE),

.BLINK_RATE(BLINK_RATE)

) FSM

(

.clk(clk),

.rst(rst),

.btn_start(btn_start),

.btn_submit(btn_submit),

.btn_restart(btn_restart),

.sw(sw),

.random_val(random_val),

.led(led),

.score(score));

initial clk = 1'b0;

always #5 clk = ~clk;

end

initial begin

rst = 0; btn_start = 0; btn_submit = 0; btn_restart = 0; sw = 16'h0000;

#20 rst = 1; #20 rst = 0; #20;

btn_start = 1; #10 btn_start = 0; // Start Game 1

#(110 * 10); sw = led; btn_submit = 1; #10 btn_submit = 0; #200; // Round 1

#(110 * 10); sw = led; btn_submit = 1; #10 btn_submit = 0; #200; // Round 2

#(110 * 10); sw = led; btn_submit = 1; #10 btn_submit = 0; #200; // Round 3

btn_restart = 1; #10 btn_restart = 0; #200; // Restart

btn_start = 1; #10 btn_start = 0; // Start Game 2

#(110 * 10); sw = led; btn_submit = 1; #10 btn_submit = 0; #200; // Round 1

#(110 * 10); sw = led; btn_submit = 1; #10 btn_submit = 0; #200; // Round 2

#(110 * 10); sw = led; btn_submit = 1; #10 btn_submit = 0; #200; // Round 3

btn_restart = 1; #10 btn_restart = 0; #200; // Restart

btn_start = 1; #10 btn_start = 0; // Start Game 3

#(110 * 10); sw = led; btn_submit = 1; #10 btn_submit = 0; #200; // Round 1

#(110 * 10); sw = led; btn_submit = 1; #10 btn_submit = 0; #200; // Round 2

#(110 * 10); sw = led; btn_submit = 1; #10 btn_submit = 0; #200; // Round 3

btn_restart = 1; #10 btn_restart = 0; #200; // Restart

btn_start = 1; #10 btn_start = 0; // Start Game 4

#(110 * 10); sw = led; btn_submit = 1; #10 btn_submit = 0; #200; // Round 1

#(110 * 10); sw = led; btn_submit = 1; #10 btn_submit = 0; #200; // Round 2

#(110 * 10); sw = led; btn_submit = 1; #10 btn_submit = 0; #200; // Round 3

// End Simulation

#1000;

end

endmodule

r/programminghelp • • Aug 10 '26

Project Related Debezium + NATS Jetstream or Redpanda

Thumbnail
1 Upvotes

r/programminghelp • • Jun 15 '26

Project Related How to understand code base?

1 Upvotes

I picked up my first open source project. But I have no idea how to understand the code base.

  1. how to do that ?
  2. Where do I start ? Any specific files to start ?

its my first time doing anything in the real world. so any suggestions are welcome!!!

r/programminghelp • • Apr 24 '26

Project Related Issue with my Thesis regarding LLMs

0 Upvotes

Hi everyone,

I’m currently working on my bachelor thesis in collaboration with a company, and I’ve run into a problem that I’m not sure how to resolve.

The general topic is about using LLMs for code reviews. The idea is to build a system that can analyze code changes (e.g., diffs), relate them to a ticket / user story / other relevant context, and then generate meaningful feedback (beyond simple static analysis).

Here’s the issue: The company I’m working with does not want to allow API usage (like OpenAI, Anthropic, etc.) due to cost concerns. Instead, they want me to use a fully local LLM setup (like Ollama).

My professor, however, is skeptical about this and says that local models are not strong enough for what the thesis is supposed to achieve. His concern is that local models won’t be able to handle larger context windows (e.g., combining ticket + diff + relevant parts of the codebase). They will likely fail at understanding whether a feature is actually implemented correctly according to requirements. As a result, the system would degrade into something closer to static code analysis with some NLP on top, which he considers "not enough" for a thesis. From his perspective, if the system cannot go beyond that level, the topic is basically “dead”.

I’m trying to figure out whether there is a viable direction here that stays within the company constraints and still satisfies academic requirements (non-trivial result).

Maybe there is some low-cost-way of achieving what I am trying to do?

Has anyone dealt with something similar? Or do you have any thoughts on whether this is fundamentally a dead end under these constraints? I’d really appreciate any input, especially from people who have worked with LLMs in constrained environments or in academic projects.

TL;DR: Company requires fully local LLM (no APIs) for my bachelor thesis on LLM-based code reviews, but my professor says local models aren’t strong enough and the topic risks becoming trivial. Not sure how to reconcile both sides.

r/programminghelp • • Jun 20 '26

Project Related Help on xor brute force in python

6 Upvotes

I want to write code that can check whether, given a key and an input, both the key and the input are real words/phrases. I have done lots of work in CyberChef and have mainly used dcode.fr for this problem, but neither has options to narrow down by the dictionary. I also want to implement code that first changes it to some format like A B C A⊕0x13 B C⊕0x1A and then searches through that. Before I started, I wanted to get advice on any potential problems, as I am not a 'perfect' coder and haven't done much like this.

r/programminghelp • • Dec 29 '25

Project Related GUI language

1 Upvotes

Hey everyone, I'm making a statistics/analysis tool and I'm not sure what GUI to use. All of my code so far (about the actual analysis) is in Python, so naturally I tried Tkinter but I'm not a huge fan - too limited, too basic etc etc. I'm open to learning other languages for this, but ideally something with a similarish syntax to Python. Any recommendations?

Also, since I'm doing a LOT of calculations, is there a better language than Python I can use (i.e. that's quicker)? I've heard F# is good but I'm not sure how much of an improvement it'll be...

r/programminghelp • • Jul 12 '26

Project Related Replit code import

Thumbnail
1 Upvotes

r/programminghelp • • Jul 02 '26

Project Related How do i build projects that i want to build without a guide/tutorial?

Thumbnail
1 Upvotes

r/programminghelp • • Apr 27 '26

Project Related How to test timed software?

2 Upvotes

Hello Everyone, Im working on a side project that involves having to track service calls that all the activity is timed. Theres a page for the admins and a page for the workers. Im trying todo e2e testing and it just seems not the most reasonable to be able to have to wait 20 minutes for the standard time or a day or two for something else to happen.

I have been working on a time control system that would be able to fake out when testing the UI what the time is and where we are in the schedule but something about it feels off like its not the way todo it. I have some automated testing already but this is more manual interaction testing that I am validating that when time moves the system reacts as expected.

I just want to hear some experienced software developers thoughts on how todo this kind of testing.

r/programminghelp • • May 25 '26

Project Related Advice about Flutter and BLOC state management

2 Upvotes

Hey everyone! SO i'm building my final project for uni using Flutter, Firebase, and BLOC for state management. I've only just built the login and sign-up page using phone authentication (took me three days lol). I'm a beginner, so I'd appreciate any advice for how I'm supposed to design the system most optimally.

I'm currently working on the user profile page. I obviously want the user profile data to be fetched and displayed on the first loading, and also want to allow users to update their name and location. This

I have a user profile service, a user profile repo, and the BLOC view models. THis is what I have so far:

- events:

class UserProfileDisplayedEvent extends UserProfileEvent{}


class UserProfileUpdatedEvent extends UserProfileEvent
{
  final Map<String,dynamic> values;


  const UserProfileUpdatedEvent({required this.values});
  
   UserProfileDisplayedEvent extends UserProfileEvent{}


class UserProfileUpdatedEvent extends UserProfileEvent
{
  final Map<String,dynamic> values;


  const UserProfileUpdatedEvent({required this.values});
  
  
  List<Object> get props => [values];
}
  List<Object> get props => [values];
}

- states

final class UserProfileInitialState extends UserProfileState {}


final class UserProfileLoadingState extends UserProfileState {
  final bool isLoading;
  const UserProfileLoadingState({required this.isLoading});   // whether loading or not
}


final class UserProfileSuccessState extends UserProfileState {
  final UserModel user;
  const UserProfileSuccessState(this.user);


  
  List<Object> get props => [user];   // if user func is successful, user will be used as a prop
}


final class UserProfileErrorState extends UserProfileState {
  final String errorMessage;
  const UserProfileErrorState({required this.errorMessage});


   class UserProfileInitialState extends UserProfileState {}


final class UserProfileLoadingState extends UserProfileState {
  final bool isLoading;
  const UserProfileLoadingState({required this.isLoading});   // whether loading or not
}


final class UserProfileSuccessState extends UserProfileState {
  final UserModel user;
  const UserProfileSuccessState(this.user);


  
  List<Object> get props => [user];   // if user func is successful, user will be used as a prop
}


final class UserProfileErrorState extends UserProfileState {
  final String errorMessage;
  const UserProfileErrorState({required this.errorMessage});


  
  List<Object> get props => [errorMessage];   // otherwise the error msg is a property
}



  List<Object> get props => [errorMessage];   // otherwise the error msg is a property
}

- the BLOC

class UserProfileBloc extends Bloc<UserProfileEvent, UserProfileState> {
  final UserProfileRepo userProfileRepo = UserProfileRepo();
  UserProfileBloc() : super(UserProfileInitialState()) {
    on<UserProfileEvent>((event, emit) {});


    on<UserProfileUpdatedEvent>((event, emit) async {
      log("USER PROFILE UPDATE EVENT RECIEVED");
      emit(UserProfileLoadingState(isLoading: true));
      try 
      {
        await userProfileRepo.updateUserName(event.values);
        final updatedUserProfile = await userProfileRepo.getUserProfile();
        if (updatedUserProfile != null) {
          emit(UserProfileSuccessState(updatedUserProfile));
        } else {
          emit(UserProfileErrorState(errorMessage: 'Something went wrong with updating the user profile.'));
        }
      }
      catch (e)
      {
        emit(UserProfileErrorState(errorMessage: e.toString()));
      }
    });


    // getting the user profile
    on<UserProfileEvent>((event, emit) async 
    {
      log("USER PROFILE EVENT RECIEVED");
      emit(UserProfileLoadingState(isLoading: true));
      try 
      {
        final userProfile = await userProfileRepo.getUserProfile();
        if (userProfile != null)
        {
          log("User profile is going to be displayed");
          emit(UserProfileInitialState());       
        }
        else 
        {
          log("User profile is not going to be displayed");
          emit(UserProfileErrorState(errorMessage: 'Something went wrong with displaying the user profile!'));
        }
      }
      catch (e)
      {
        emit(UserProfileErrorState(errorMessage: e.toString()));
      }
    });
  }
}

class UserProfileBloc extends Bloc<UserProfileEvent, UserProfileState> {
  final UserProfileRepo userProfileRepo = UserProfileRepo();
  UserProfileBloc() : super(UserProfileInitialState()) {
    on<UserProfileEvent>((event, emit) {});


    on<UserProfileUpdatedEvent>((event, emit) async {
      log("USER PROFILE UPDATE EVENT RECIEVED");
      emit(UserProfileLoadingState(isLoading: true));
      try 
      {
        await userProfileRepo.updateUserName(event.values);
        final updatedUserProfile = await userProfileRepo.getUserProfile();
        if (updatedUserProfile != null) {
          emit(UserProfileSuccessState(updatedUserProfile));
        } else {
          emit(UserProfileErrorState(errorMessage: 'Something went wrong with updating the user profile.'));
        }
      }
      catch (e)
      {
        emit(UserProfileErrorState(errorMessage: e.toString()));
      }
    });


    // getting the user profile
    on<UserProfileEvent>((event, emit) async 
    {
      log("USER PROFILE EVENT RECIEVED");
      emit(UserProfileLoadingState(isLoading: true));
      try 
      {
        final userProfile = await userProfileRepo.getUserProfile();
        if (userProfile != null)
        {
          log("User profile is going to be displayed");
          emit(UserProfileInitialState());       
        }
        else 
        {
          log("User profile is not going to be displayed");
          emit(UserProfileErrorState(errorMessage: 'Something went wrong with displaying the user profile!'));
        }
      }
      catch (e)
      {
        emit(UserProfileErrorState(errorMessage: e.toString()));
      }
    });
  }
}

I'm new so I'm taking help from AI tools to guide me because I feel so lost sometimes lol

I was initially planning on using the BLOC functions in my UI in the initState so prefetch and load the user profile data like this:

  
  void initState()
  {
    super.initState();
    context.read<UserProfileBloc>().add(UserProfileDisplayedEvent());
  }
  void initState()
  {
    super.initState();
    context.read<UserProfileBloc>().add(UserProfileDisplayedEvent());
  }

But is that correct? There seems to be so many diff ways on the internet and it's a little overwhelming. I'd appreciate any tips and advice, thanks!

r/programminghelp • • Jun 14 '26

Project Related Interactive method of conflicts resolution

1 Upvotes

So, I have several sources of data, and I wanna merge them in, e.g., a single JSON file. The sources often contain data that overlaps with the other. So, in order to use relevant data, I have to resolve these conflicts manually and write the result into this single JSON file.

And the sources are updating over time. So, I have to periodically pull the updates and redo the merge procedure again.

So, the question is, what tool may help me in facilitating my workflow?

Well, I could use git and use a separate branch for every source. And then just git-merge them in some sort of main branch when I wanna get that ultimate JSON. But all this stuff is already a part of a bigger git project, and I just don't wanna to complicate it with submodules.

To simply put the task, I have N JSON files/objects with the overlapping keys that are periodically overwritten. I want a tool/script for merging these N files into a single JSON file. And I want it to show me diff and the conflicts I have to resolve.

r/programminghelp • • May 29 '26

Project Related Flutter, BLOC and Suffix icon changes?

1 Upvotes

Hello, everyone! So this is basic but I'd still like to implement the best way so i was wondering what for an icon btn to appear only when its text field is clicked, is it better to declare BLOC logic (focus event, focus state, focus BLOC) to represent the state, along with a focus node in the UI widget? Or is it simpler to have a focus node only in the UI widget, without the BLOC impl?

Additionally, how do you do field validations (like for phone number, empty fields) in FLutter with BLOC management? There seems to be so many diff ways on the internet, and I want to follow the best practice.

I'd like to know, so if you have any suggestions/advice, please let me know!

r/programminghelp • • May 04 '26

Project Related AP CSP Create task - Is a switch statement considered selection?

2 Upvotes

I'm not sure if this is a good place to ask about the AP Computer Science test. My main procedure has both a switch statement and if statements. An example question I've got for review says to refer to the FIRST selection statement. The if statements are containedvwithin the switch statement, so technically the switch comes first. Which one should i refer to?

r/programminghelp • • Jan 27 '26

Project Related Running out of ideas

4 Upvotes

hello nice people. I’m a 3rd year CSE student. we have been asked to do a mini project which should have hardware + software (kind of like an IoT project). I had 2 ideas but both were rejected due to the difficulties in hardware implementation. so I want to know, do you guys have any ideas? we have to submit this project to conferences in March and it should be a unique idea (it can be existing but it should address the gaps - that’s the only way it’s allowed). please help me, I would forever be grateful.

r/programminghelp • • Dec 18 '25

Project Related What’s the correct way to input to database, high level? Opinions welcome

8 Upvotes

Hi all, I have a mildly complex backend that can’t just add data and be fine. The data needs to be processed and old data needs to be shut off.

Currently:

Cronjob gets data —> adds all feeds to database queue —> cronjob calls edge function A—> edge function A pops from queue and adds data to database after processing —> cronjob calls edge function B for each feed —> edge function B cycles through old data in database to deactivate it

I feel like I’m both overcomplicating this process and yet also making it cleaner. I also only have 1 cronjob at the moment cause I don’t want 2 of them missing each other while working on the same thing. Basically, I’m asking if it makes sense for a cronjob to: - get data - call edge function A For each feed: - call edge function B

When each step kind of depends on the last one? If there are no updates to the data, I have the cronjob still call edge function A and B

Sincerely, Woe is my database

r/programminghelp • • Feb 21 '26

Project Related Flight sim coding should be an easy fix

1 Upvotes

Hello, any help would be greatly appreciated.

I am using the xsaitekpanels plug-in with X-Plane. All the buttons work properly except for the NAV button. I'm trying to get it to toggle LNAV in my aircraft.

What is wrong in my code that isn't making this work?

; ********* NAV Button ******************************************

;Nav Button remapable = 0 default | = 1 remapable command | = 2 remapable datareference | = 3 remapable datareference toggle

Nav Button remapable = 1

;command for vorloc hold using the NAV button

nav_button_vorloc_remapable_cmd = laminar/B738/autopilot/lnav_press

;command for lnav using the NAV button

nav_button_lnav_remapable_cmd = laminar/B738/autopilot/lnav_press

;datareference for vorloc hold using the NAV button

nav_button_vorloc_remapable_data =

;datareference for lnav using the NAV button

nav_button_lnav_remapable_data =

; ********* NAV Light ******************************************

;datareference for vorloc NAV light solid value 0 = off | value 1 = on

nav_light_vorloc_remapable_data = laminar/B738/autopilot/lnav_status

;datareference for vorloc NAV light flashing = 0 off | = 1 flashing

nav_light_vorloc_flash_remapable_data = laminar/B738/autopilot/lnav_status

;datareference for lnav NAV light solid = 0 off | = 1 on

nav_light_lnav_remapable_data = laminar/B738/autopilot/lnav_status

;datareference for lnav NAV light flashing value 0 = off | value 1 = flashing

nav_light_lnav_flash_remapable_data = laminar/B738/autopilot/lnav_status

r/programminghelp • • Dec 06 '25

Project Related Real life stranger things lights

3 Upvotes

Hi so I've never really done programming that much and I'm not sure if this is the place for it but is it possible to make long distance Christmas lights that if you touch them they'll blink and you can communicate with someone else who has the same lights 😭 sorry if this is a stupid question but I just wanna know.

r/programminghelp • • Oct 27 '25

Project Related How do languages figure out where and which bracket ends a specific statement in a programming language?

0 Upvotes

I am trying to make my own toy language and I am trying to figure this out but I can't understand it. How do languages figure out where and which bracket ends a specific statement in a programming language?

Can someone help me out with this and give me an example in a simple language like python where the code reads a file and when ever a closed curly-bracket occurs, it prints the position of the opened curly-bracket that it just closed?

Helpful questions to help you answer this question: Do different statements (If, def, etc) make the logic different for figuring out their closing curly-bracket's position?

Additional Request: Please make the sample code work for common keywords like the def (define a function) and if keywords.

r/programminghelp • • Jun 01 '25

Project Related Project Ideas Needed for a College Student that solves a real world issue and can be completed in a span of 2-3 months

10 Upvotes

Hello fellow redditers I wish not for take up too much of your time so I'll get to the point.. I'm a college student doing an Associate Degree in ICT and I was given a special project to find an issue in Jamaica or the world and provide a solution as well as implement it whether it be creating an app/ web app/ website etc. Thing is I have no idea what to do nothing is really clicking so I'm hoping for some ideas if possible. I believe the time frame to complete it will be 2 months.

I've been researching problems and going through whether Quora, online sites, I've even resorted to ai for ideas but nothing is clicking.

I was working on a project management app for clients and business owners but the ideas I have for it I won't be able to implement in that timeframe.