/r/AskProgramming

Photograph via snooOG

Ask questions about programming.

AskProgramming

All questions related to programming welcome. Wonder how things work? Have a bug you can't figure out? Just read about something on the news and need more insights? We got you covered! (probably)

Do

  1. Ask questions and start discussions
  2. Keep things civil and support each other
  3. Give your threads descriptive titles
  4. Include relevant information when asking for help
  5. Stay on topic in your posts and replies

Don't

  1. Post off-topic material
  2. Troll or flamebait, insult others, or act in bad faith
  3. Self-promote
  4. Ask others to do your work for you
  5. Ask for help in illegal or unethical activities
  6. Repost the same question within 24 hours
  7. Post AI-generated answers

You can find out more about our (preliminary) rules in this wiki article. If you have any suggestions please feel free to contact the mod team.

Have a nice time, and remember to always be excellent to each other :)

/r/AskProgramming

147,890 Subscribers

0

How to go about building a web app that can search through multiple pdf files as well as add and delete them

I need to build a web app that can search multiple pdf files by file name. Or ,if it's possible, by it's content, like in Adobe Acrobat. And also add/upload and delete pdf files through the web app itself. Can I use MERN Stack? or is there an alternative where I do not have to use database and just grant direct access to the files on my pc.

I also need this to work on a local server where multiple PC's can have access to it.

Please any suggestion can greatly help..

0 Comments
2024/10/11
09:59 UTC

4

Which online tool is used to format JSON and XML blazingly fast?

I use this https://json-formatter.cc to format JSON and I love it, and I'm looking for a similar one for XML.

3 Comments
2024/10/11
07:42 UTC

1

Help with Homeserver

I have bought a Orange Pi 5 to play a little with mini computers, and after playing with it a little, I decided to turn it on a home server

I've been using it a couple of months now, eveyrhing running ok so far, but lately I've been trying to go to the next step, using it outside my house

To be able to use it without risking on opening ports I wanted to install a vpn, my option was hamachi, but after downloading the ARM version it still gave me problems to install, and after searching a lot I couldn't find a solution

Are there other good alternatives for free vpn like hamachi that could work with it?

Or any other options? maybe something that is not a VPN or even forwarding ports, but making it safer?

Thanks!

1 Comment
2024/10/11
06:26 UTC

0

Best DB for school project

Hello All I am currently making a web app for my swe class and the idea is to allow user to sign up and upload music in .wav files. I plan on using react for the front end. What is the best cloud DB to use for storing this type of data?

17 Comments
2024/10/10
23:00 UTC

3

Code Structure? - Files & Functions

I know design patterns but what about file to file? Sometimes my code can gets way too messy cause of the amount I add to a file.

More in terms of when to use a new function, when to much code is added to a function, best way to separate

Any suggestions on how to improve this? Any steps, tricks, tactics?

Iv'e seen exclusive getters and setters in some cases (in files with the functions), what else?

In short, how small / large should functions be, how precise and how many to a file?

Hope that makes sence.

Thanks

5 Comments
2024/10/10
22:44 UTC

2

Advice on language(s) for a specific project, from an older non-programmer looking to learn

I'm looking for advice on what programming language(s) to learn to fulfill a vision I have for a project I'm hoping to develop myself.

My project: a historical (not current/google maps) overhead/plat map that I can host as a web page, which has the following features:

  • hover over the plat/building, it will be highlighted and then somehow present some data on that location. Maybe a pop-up at the cursor, maybe in a dedicated "corner" of the map.
  • the data in the pop-up would include an image, and would allow the user to click and launch a new page/tab that will present more details about the building.
  • eventually, I'd like to filter the full map by date, where the data that pops-up is germane to that date.

This might be simple for many of you, but will be an interesting learning experience for me.

What language(s) should I consider learning in order to bring this project to life? Or, is there a course online that I should just take that would help me develop the skills for this kind of project?

I have very little experience in programming (BASIC in the early 80's, Pascal in the early 90's, M/Cache in the late 90's), but I'm eager to take the next 1-3 years to learn what I need.

Sorry if this question is not well-formed -- I'm an old looking to keep my brain young with this project, but clearly I'm just starting out. Please let me know what other information would be helpful if your answer is "it depends."

Thank you

3 Comments
2024/10/10
21:20 UTC

0

Is using AI cheating

Is using AI really cheating if it’s helping me understand basic concepts? I had a professor even encourage the use of AI so I was just curious. I use it as a last resort if I’m really stuck on a problem but still feel guilty for some reason. Thoughts ?

24 Comments
2024/10/10
20:39 UTC

0

How does my code and note-taking skills look? Also need help with the modulo portion.

I'm making a program that takes inputs direction, street number, and street type and basically outputs the location relevant to other streets in the town. How does it look overall, including the notes?

I also need help on lines 67 & 91. I created ordinalSuffixes to go with 1's, 2's, and 3's on lines 37-47, but it doesn't change with the stNum on 66 & 90. I'm pretty sure it's from placement within the program, but to make it readable can I add lines 37-47 under lines 66 & 90?

Thanks.

import java.util.Scanner;
public class MainProgram {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scnr = new Scanner(System.in);

String direction;                                //declare variables
int stNum;
String stType;
String ordinalSuffix;

System.out.println("direction: ");              //getting inputs
direction = scnr.nextLine();
while (!(direction.equalsIgnoreCase("north") 
|| direction.equalsIgnoreCase("south"))) {
System.out.println("invalid direction. Please try again: ");
direction = scnr.nextLine();
}

System.out.println("Street number: ");
stNum = scnr.nextInt();
while (stNum <= 0) {
System.out.println("Invalid street number. Please try again: ");
stNum = scnr.nextInt();
}

System.out.println("Street type: ");
stType = scnr.nextLine();
while (!(stType.equalsIgnoreCase("Avenue") || stType.equalsIgnoreCase("drive")
|| stType.equalsIgnoreCase("lane") || stType.equalsIgnoreCase("street")
|| stType.equalsIgnoreCase("place") || stType.equalsIgnoreCase("way"))) {
System.out.println("Invalid street type. Please try again: ");
stType = scnr.nextLine();
}

if (stNum % 10 == 1) {                         // cycling through street number suffixes
ordinalSuffix = "st";                          //using modulo

} else if (stNum % 10 == 2) { 
ordinalSuffix = "nd";

} else if (stNum % 10 == 3) {
ordinalSuffix = "rd";

} else {
ordinalSuffix = "th";
}

if (stType.equalsIgnoreCase("Avenue")             //print first part of 1st line
|| stType.equalsIgnoreCase("Drive")               //based on street type
|| stType.equalsIgnoreCase("Lane")) {
System.out.print(direction + " " + stNum + ordinalSuffix + " " + stType);
System.out.print(" is " + stNum + " blocks west of Central Avenue and is ");

if (direction.equalsIgnoreCase("north")) {          //nested if-else that tells direction
System.out.println("north of Washington Street.");  //from washington st
System.out.print("The preceding street is ");

} else if (direction.equalsIgnoreCase("south")) {
System.out.println("south of Washington Street.");
System.out.print("The preceding street is ");
}

if (stType.equalsIgnoreCase("avenue")) {            //print 2nd part of 2nd line
stNum -= 1;
System.out.println(direction + " " + stNum + ordinalSuffix + " lane.");
} else if (stType.equalsIgnoreCase("drive")) {
System.out.println(direction + " " + stNum + ordinalSuffix + " avenue.");
} else {//don't have to specify lane-already specified on line 50
System.out.println(direction + " " + stNum + ordinalSuffix + " drive.");//it's the last available option.
}

} else if (stType.equalsIgnoreCase("Street")                //print second part of 1st line
|| stType.equalsIgnoreCase("Place")//based on street type
|| stType.equalsIgnoreCase("Way")) {
System.out.print(direction + " " + stNum + ordinalSuffix + " " + stType);
System.out.print(" is " + stNum + " blocks east of Central Avenue and is ");

if (direction.equalsIgnoreCase("north")) {                  //nested if-else that tells direction
System.out.println("north of Washington Street.");          //from washington st
System.out.print("The preceding street is ");

} else if (direction.equalsIgnoreCase("south")) {
System.out.println("south of Washington Street.");
System.out.print("The preceding street is ");
}

if (stType.equalsIgnoreCase("street")) {                    //print 2nd part of 2nd line
stNum -= 1;
System.out.println(direction + " " + stNum + ordinalSuffix + " way.");
} else if (stType.equalsIgnoreCase("place")) {
System.out.println(direction + " " + stNum + ordinalSuffix + " street.");
} else {                                    //don't have to specify way-already specified on line 74
System.out.println(direction + " " + stNum + ordinalSuffix + " place.");//it's the last available option.
}
}
}

}
0 Comments
2024/10/10
19:26 UTC

2

How do I do this?

I was doing some research and came across a new set of variable length prefix codes that are on average half a short as Huffman codes and I wanted to modify the DEFLATE algorithm to use my codes instead to better the compression ratio of the DEFLATE algorithm which uses Huffman codes and is a gold standard in computer science. How would I be able to modify the DEFLATE algorithm to use my codes instead?

1 Comment
2024/10/10
19:22 UTC

6

If you could add one feature to your favorite programming language that currently doesn't exist, what would it be and why?

46 Comments
2024/10/10
18:42 UTC

1

Docker Learning Resources for Beginners [AT]

Hi everyone,

I have a job interview at Docker as a Senior Enterprise Customer Success Manager (CSM).

I have 5 years of professional experience as a Senior Enterprise CSM which I gained at another, non-technical SaaS company.

However, I'm a beginner with technical SaaS such as Docker.

Can you please share some free-of-charge online learning resources focusing on Docker for non-technical beginners?

I prefer video tutorials and bullet-pointed texts that are easily readible and understandeable.

I already conducted some research on YouTube. But since I have no Docker experience I find it challenging to identify which resources are accurate, up-to-date and suited for beginners. Also, the amount of options is overwhelming.

Thank you in advance.

0 Comments
2024/10/10
18:14 UTC

3

New to java

Hello beautiful people, I want to learn java and I don't know where to start (I'm not new to programming I have an idea about oo languages I've already worked with c++) so any advice(maybe a course or somthings I should focus on)

3 Comments
2024/10/10
17:29 UTC

6

Need AI Integration Ideas for Development Processes – CEO is Pushing Hard, and I’m Stuck

I'm a developer at a software company that offers B2B solutions using 2-3 core products. Recently, the CEO has jumped on the AI bandwagon and is eager to integrate AI into our workflows. They’ve even purchased company-wide subscriptions to GPT-4 and GitHub Copilot.

Now, they’re pushing us developers to come up with ideas on how to use AI in our development processes. One idea that’s been floated is using Cursor AI because it can analyze the entire codebase. The CEO has made it clear that our suggestions will factor into our performance evaluations.

Honestly, I’m frustrated with this approach and am already looking for other job opportunities. But in the meantime, I need to pitch something by next week. So, I’m turning to the community for any ideas. For context, our codebase is fully integrated into Azure DevOps, which we use for bug reports, PRs, user stories, sprints, etc. Any suggestions?

36 Comments
2024/10/10
16:57 UTC

0

Ai tools to explain a code base

Hey I’m jumping into a new framework. The documentation is sparse and it’s a large code base so I’m spending lots of time reading code trying to figure out what does what and which classes are useful for my project.

Does anyone have recommendations on Ai tools that could analyze the repo and give me summaries of how the various pieces fit together?

1 Comment
2024/10/10
16:51 UTC

1

Question for DSS Plug Ins

Hello guys,

I am currently working on a Decision Support System for a Wordpress Website. Do you got any recommendations for Plug ins for Wordpress to fullfill this purpose?

It should just answer questions with yes/no.

Kind regards

0 Comments
2024/10/10
16:39 UTC

1

best way to learn language, framework and tool

I'd appreicate it if someone could show me the best way they have heard or know of or done on how to learn a language, framework and tool. All 3 of them , thank you

7 Comments
2024/10/10
14:27 UTC

5

Hello guys, need advice.

I wanted to become a developer but due to some circumstances, I couldn't pursue that path. I know some of the basics of programming. And still I want to become a programmer. Is it really possible to become a self taught programmer? If yes, then which field should be good: front-end, backend, data analysis, data science, or something else. I know that I am dreaming big but still I wanna try.

6 Comments
2024/10/10
11:11 UTC

5

How to learn programming with books and is it actually better?

Hi all,

I hear people say that great programmers learn from books and I as wondering if it was true and maybe try it my self. But I have some questions

  1. How do you structure your learning from a book—cover-to-cover or selective?

  2. How do you practice? Do you follow examples or work on side projects?

  3. Any must-read book recommendations for beginners/intermediate learners?

  4. How do you keep up with new tech when books can get outdated?

Would love any tips or advice. Thanks!

37 Comments
2024/10/10
09:39 UTC

1

Wrist pain from coding.

Odd question I know and may not be for this sub, but I've started getting pain in my right wrist which I think is from consistently moving from typing, to using the arrow keys, to using the mouse.

I've been coding for just over a year and in the last 2 months been coding almost every day, so maybe it's something il get used to overtime, but wondered if I am doing something wrong? I.e. should I not be using the arrow keys as much? Or maybe it's the type of keyboard.

I already use a vertical ergonomic mouse and my setup feels pretty comfortable with wrist supports etc.

From a search on keyboards I can't really see anything different to my current one. But maybe there is?

Am i alone on this issue or has others experienced this in the past? If so, how have you overcome it?

19 Comments
2024/10/10
09:12 UTC

2

Roadmap suggestion !

I wanna start coding but DK the path to follow like which language would be the best to start with nd whom shall I follow nd other imp factors. I am a beginner in coding and need to start from scratch.

Would appreciate if someone could share all this!

3 Comments
2024/10/10
08:30 UTC

1

Request for Feedback on My UML Diagram for Low-Level Design Preparation!

Hi, Reddit community!

I’m preparing for a low-level design interview and would appreciate your expertise in reviewing a UML diagram I created for my project. 

Project Overview:

  • Context: A parking lot is an area where cars can be parked for a certain amount of time. A parking lot can have multiple floors with each floor having a different number of slots and each slot being suitable for different types of vehicles.
  • Key Elements: 
    1. Entities:
      • Vehicle
      • Gate
      • Bill
      • Parkinglot
      • Floor
      • Slot
    2. Enumerations:
      • VehicleType
      • GateStatus
      • BillStatus
      • ParkingLotStatus
      • FloorStatus
      • SlotStatus
    3. Services:
      • FeeCalculationStrategy
      • SlotAllocationStrategy
      • TransactionStrategy
      • VehicleTypeCalculationStrategy
      • VehicleTypeSlotAllocationStrategy
      • CashTransactionStrategy
      • OnlineTransactionStrategy
    4. Controller:
      • ParkingLotController

UML Diagram: here

Requirements:

I’ve attached a PDF that outlines the requirements I’ve gathered.

What I’m Looking For:

  • Could you please check whether I have implemented all the requirements mentioned in the PDF?
  • Are the relationships (composition, aggregation, etc.) accurately represented?
  • Is the diagram clear and easy to understand?
  • Any suggestions for improvement or elements that I might have overlooked?

I appreciate any insights you can share! Thank you for taking the time to help me improve my work.

0 Comments
2024/10/10
08:04 UTC

1

Tools or methods for comparing boilerplates and libraries in new tech stacks?

When diving into a new language or framework, do you use any specific tools or methods to compare different boilerplates and libraries?

If not, what's your process for selecting these? What are the key factors you consider that might not be immediately obvious?

I'm particularly interested in hearing about approaches that work across different domains

0 Comments
2024/10/10
07:49 UTC

6

What do you call this kind of API page?

Hello, I'm aware of swagger, which is useful for dev teams to communicate work to other teams. Then there are pages like this:
https://docs.fiserv.dev/public/reference/createpaymenturl
That have curl, request, response, language variations etc. How are these provided? This setup looks 90% identical to two other pages I had to implement, so I assume this is some kind of framework? What do you call it.

6 Comments
2024/10/10
05:13 UTC

1

Please help me pick my NICHE

Hi everyone!

As the title says, I can't decide on my niche in programming and it gives me pain.

I am a CS graduate with some experience in DSA, Python, PHP and Databases, but I want to deep dive a language/niche and I can't find one.

I want something interesting, that will have a future in this industry.

To me, cybersecurity sounds interesting... but from what I heard, it's kind of hard to get into...

I know that I don't really like web/mobile development and Machine Learning/AI.

If you have more questions, feel free to ask!

And please help me, I need to make a decision.

Thank you guys!

8 Comments
2024/10/10
05:06 UTC

0

What’s your take on AI code reviews?

I’d love to hear from people who have actually used AI for programming assistance or code reviews.
In teams of all sizes, code reviews can be time-consuming and disruptive to workflow. When mandated as a strict process, like in many large companies, it can slow down iteration speed. But skipping reviews altogether feels risky, as it’s easy to miss your own mistakes or overlook issues.

So, what’s been your experience? Is AI a viable solution for making this process more efficient without compromising quality? If used any,what's your recommended product?

13 Comments
2024/10/10
05:05 UTC

3

which language

I am wanting to write a program to show text or symbols on the screen to show information stored at a position in three dimensions. Such as the name of a planet at a certain point in time in it's orbit.

With quick basic I wrote a two dimensional pacman-like game, but I did not know how to program in the third dimension.

I have read books on C, and Python but have not found what I was looking for.

7 Comments
2024/10/10
03:36 UTC

2

Looking for Tools to Generate Documents Like These

I'm trying to automatically generate using AI documents similar to the ones linked below and was wondering if anyone could recommend a tool that might support this (if any). DeepWriter for instance can generate long narrative documents. Any suggestions are welcome!

  1. FDsys Architecture
  2. Complex Project Plan
  3. eDistrict To Be & FRS Haryana

Thanks in advance for your help!

4 Comments
2024/10/10
01:55 UTC

2

Programming study partner

Hello everyone! I'm a freshman Computer Science student from Brazil. I'm currently studying Angular and Java. If anyone is interested, I'd love to have a programming study partner. I think sharing ideas and progress is a very engaging way to learn, and we can also do some projects together. If you're interested, please contact me, it'll be a pleasure to meet you.

0 Comments
2024/10/10
01:37 UTC

0

Coding a video playback experience dedicated to human language learning

To put it clearly, watching undubbed american movies while reading the provided english subtitles did't quite help me to succeed in my attempt to improve my English listening skills. This got me an idea for some alternative way to use those subtitles for the aimed goal:

  1. The subs should only appear when the video is paused.

  2. Going backward/forward in playback after hitting pause should work in terms of subtitle blocks, not in terms of seconds.

Is this already possible or do I have to code some shit to get it done? Does it have to be a whole new video player to be coded or just some mod/script on any exising software?

2 Comments
2024/10/10
01:05 UTC

2

401 Error When Fetching a Large CSV File Streamed with Fetch API in Angular + Spring Boot

Hi everyone, I want to fetch a large CSV file streamed from the backend using the Fetch API on the frontend. I'm using Angular and Spring Boot technologies in the project. Below you can see an example of the request and response. When I send the request this way, I get a 401 error. How can I fix it? (checked security config and cors config) Please help.

Back end:

@GetMapping( "/getRowsForExport")
public ResponseEntity<StreamingResponseBody> getExportData() {
    StreamingResponseBody responseBody = outputStream -> {
        StringBuilder csvBuilder = new StringBuilder();
        byte[] data = new byte[0];
        for (int i = 0; i < 10000000; i++) {
            csvBuilder.append(i).append("\n");
            data = csvBuilder.toString().getBytes(StandardCharsets.UTF_8);
            if (i % 1000 == 0) {
                outputStream.write(data);
                outputStream.flush();
                csvBuilder.setLength(0);
            }
        }
        outputStream.write(data);
        outputStream.flush();
        csvBuilder.setLength(0);
    };
    HttpHeaders headers = formHeaders();
    return ResponseEntity.ok().headers(headers).body(responseBody);
}
private HttpHeaders formHeaders() {
    HttpHeaders headers = new HttpHeaders();
    headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM_VALUE);
    headers.add(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, CONTENT_DISPOSITION);
    headers.add(CONTENT_DISPOSITION, String.format("attachment; filename=segment.csv"));
    return headers;
}

Front end:

const response = await fetch(ENV_CONFIG.backendUrl + 'xdr/getRowsForExport', {
  method: 'GET',
  allowHTTP1ForStreamingUpload: true,
  headers: {
    'Content-Type': 'application/json',
    Accept: 'application/json',
    responseType: 'blob',
    Authorization: `Bearer ${token}`,
  },
} as any);
2 Comments
2024/10/09
21:52 UTC

Back To Top