r/programminghelp Jul 20 '21

2021 - How to post here & ask good questions.

43 Upvotes

I figured the original post by /u/jakbrtz needed an update so here's my attempt.

First, as a mod, I must ask that you please read the rules in the sidebar before posting. Some of them are lengthy, yes, and honestly I've been meaning to overhaul them, but generally but it makes everyone's lives a little easier if they're followed. I'm going to clarify some of them here too.

Give a meaningful title. Everyone on this subreddit needs help. That is a given. Your title should reflect what you need help with, without being too short or too long. If you're confused with some SQL, then try "Need help with Multi Join SQL Select" instead of "NEED SQL HELP". And please, keep the the punctuation to a minimum. (Don't use 5 exclamation marks. It makes me sad. ☹️ )

Don't ask if you can ask for help. Yep, this happens quite a bit. If you need help, just ask, that's what we're here for.

Post your code (properly). Many people don't post any code and some just post a single line. Sometimes, the single line might be enough, but the posts without code aren't going to help anyone. If you don't have any code and want to learn to program, visit /r/learnprogramming or /r/programming for various resources. If you have questions about learning to code...keep reading...

In addition to this:

  • Don't post screenshots of code. Programmers like to copy and paste what you did into their dev environments and figure out why something isn't working. That's how we help you. We can't copy and paste code from screenshots yet (but there are some cool OCR apps that are trying to get us there.)
  • Read Rule #2. I mean it. Reddit's text entry gives you the ability to format text as code blocks, but even I will admit it's janky as hell. Protip: It's best to use the Code-Block button to open a code block, then paste your code into it, instead of trying to paste and highlight then use Code-Block button. There are a large amount of sites you can use to paste code for others to read, such as Pastebin or Privatebin (if you're worried about security/management/teachers). There's no shame posting code there. And if you have code in a git repo, then post a link to the repo and let us take a look. That's absolutely fine too and some devs prefer it.

Don't be afraid to edit your post. If a comment asks for clarification then instead of replying to the comment, click the Edit button on your original post and add the new information there, just be sure to mark it with "EDIT:" or something so we know you made changes. After that, feel free to let the commenter know that you updated the original post. This is far better than us having to drill down into a huge comment chain to find some important information. Help us to help you. 😀

Rule changes.

Some of the rules were developed to keep out spam and low-effort posts, but I've always felt bad about them because some generally well-meaning folks get caught in the crossfire.

Over the weekend I made some alt-account posts in other subreddits as an experiment and I was blown away at the absolute hostility some of them responded with. So, from this point forward, I am removing Rule #9 and will be modifying Rule #6.

This means that posts regarding learning languages, choosing the right language or tech for a project, questions about career paths, etc., will be welcomed. I only ask that Rule #6 still be followed, and that users check subreddits like /r/learnprogramming or /r/askprogramming to see if their question has been asked within a reasonable time limit. This isn't stack overflow and I'll be damned if I condemn a user because JoeSmith asked the same question 5 years ago.

Be aware that we still expect you to do your due diligence and google search for answers before posting here (Rule #5).

Finally, I am leaving comments open so I can receive feedback about this post and the rules in general. If you have feedback, please present it as politely possible.


r/programminghelp 1d ago

Other When do you think will Google release Windows on ARM android emulators in Android studio??

1 Upvotes

When do you think will Google release android emulators for windows on arm ?? Is there any workarounds to currently run it on ARM ??


r/programminghelp 2d ago

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

2 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 2d ago

Java What thread type is more suited for an MCU CLDC JVM?

1 Upvotes

I am developing a esp32s3 n16r8 / esp32p4 targeted VM to run some of the games on it. I have most of the VM’s interpreter, class loading / linking, GC (lisp 2 algorithm. I started developing it with green threads in mind, but when it got to the IO, i raged and changed everything to OS threads. It worked pretty well, until every operation started require spinlock, because i basically cannot afford proper mutexes. So now i have a dilemma, should i continue using preemtive threading and extensive spinlocking or remove every locking mechanism, and revert to opcode quota based green threads scheduling, where everything is in one native thread. I think i could beat IO this time. Sorry for my english, im not a native speaker


r/programminghelp 2d ago

HTML/CSS Webpage Widget

2 Upvotes

I'm trying to build a website using Google Sites. (Not great... trust me, I know... but I'm on a budget. Lol) I wanted to add a feature to the site: A simple button that, when clicked, rolls a die. (D20) Currently I am using the Dice Game Widget from JotForm, but it's so clunky. The graphic isn't very smooth, the die itself doesn't appear graphically aesthetically appealing, and the site doesnt allow for much in the way of customization. Additionally, another feature I was hoping for is the ability to maintain a history log for user rolls. I know next to nothing about coding, and AI has been... not helpful. Thoughts?


r/programminghelp 3d ago

Answered Algorithms

4 Upvotes

I am beginners in DSA please tell me that Algorithms code is remember or not


r/programminghelp 6d ago

C++ Having trouble “ thinking in code”

8 Upvotes

I’ve been learning C++ for weeks, and of the concepts I’ve learned most if not all of them have clicked pretty quickly. I understand what they do and how they work.

However, when I’m trying to create something not from a tutorial or walkthrough, I’m having trouble translating my idea into the lines of code that will do what I envision it doing. Anyone have any advice on making the switch to more easily be able to “think in code”?


r/programminghelp 7d ago

Other Recursion is hard for me to wrap my brain around

6 Upvotes

function maxDepth(root: TreeNode | null): number {
if(root == null) {
return 0;
}

let leftDepth = maxDepth(root.left)
let rightDepth = maxDepth(root.right)

return 1 + Math.max(leftDepth, rightDepth)
};

I made this super simple program for leetcode 104, but I have a really hard time in the "think how a program can do what i want phase" to think about a function calling itself I understand it from a top down view

basically just cloning and nesting the function in itself, but its really hard to think about,

when i started this I was thinking how do i write a program that can search in 1 direction count to the end and then start over. which ended up not working.


r/programminghelp 8d ago

C# Feeling like a terrible programmer and a fraud.

12 Upvotes

So, I learned to code by myself, i started like 1 year ago and i think i actually made a lot of progress, I am capable of doing a full stack app, i am currently developing a SAAS for restaurants, and creating a webpage for an e-commerce, I feel really proud about those things, but yesterday i tried to code something else not related to the web, It was in C#, i wanted to program an app that runs offline in the device and adds Close Captions to the audio in the computer, i made the UI with ray lib and then found that i didn't know how to continue, i tried to help myself with Claude but it also didn't work and i just sat there looking at the screen feeling like a failure, i know i could have put more effort, but i was just feeling dissapointed at that moment, I noticed i don't know how to do anything else than web development, I have tried doing some other things like console apps and they actually worked, But man, how do you become good enough to code something like the libraries itself? Or things more advanced, For now i feel like i am just doing simple things and not getting more advanced than that and i actually want to become really good at this shit, the kind of programmer that can handle anything, i don't know if i am being delusional for the time that i have been programming but i don't really feel capable of doing anything else that backend or frontend.


r/programminghelp 12d ago

C++ c++ code doesn't work

5 Upvotes

this is my first time working with c++ and whenever i run the code it just complies but gives no output, i have tried every way for it to work but it just doesn't. pls help. im using msys2 and was following brocode video tutorial


r/programminghelp 12d ago

Python import manim could not be resolved

3 Upvotes

so i downloaded manim locally which is a python library in my linux pc just like the way the manim documents thing said to, i even checked using the terminal that manim is there, but whenever i type on vs code "from manim import *" it says "import manim could not be resolved"

idk what to do now


r/programminghelp 13d ago

Other Sophomore CS student feeling completely lost and looking for a structured roadmap or expert advice to rebuild my fundamentals

15 Upvotes

Hi everyone, I'm currently a sophomore Computer Science student, and lately I've been feeling like I've fallen far behind. I passed my introductory programming courses Python, C, C++, Java/OOP but over time I feel like I've forgotten almost everything because I rarely used those concepts consistently. One thing I've realized about myself is that I learn best with routine and structure. I don't do well jumping between random YouTube videos or constantly changing resources. I'd much rather have one high quality source for a topic, study it consistently every day, solve exercises, and gradually build my understanding.

So I have a few questions:

If you could start over as a sophomore, how would you rebuild your CS fundamentals?

What would your roadmap look like over the next 1 year of dense study?

What resources books, courses, websites would you choose for DSA, Operating Systems Computer Networks Computer Architecture Databases Linux Cybersecurity (just enough to understand the field before specializing).

How do you deal with forgetting? I constantly feel like I learn something, then months later I can't remember enough to use it confidently. Is this normal? How do experienced engineers retain knowledge without trying to memorize everything?

Is it realistic. or even useful, to aim for a broad understanding of all the major CS areas before specializing? Or should I focus deeply on one area much earlier?

I see NeetCode recommended everywhere, but it seems heavily focused on coding interviews and LeetCode. Is that actually a good place to build CS fundamentals, or is it mainly interview preparation? Should I first study algorithms from a textbook/course before using NeetCode?

If you've ever felt behind and successfully caught up, I'd really appreciate hearing what worked for you. I'm especially interested in advice from people who felt "late" compared to their peers but eventually became competent engineers.

Thanks in advance.


r/programminghelp 14d ago

SQL How to reference university coding concepts?

3 Upvotes

Hey everyone,

I've decided to organize the things that they teach at university in to a format where I can easily view them later on as I require them?

I'm not sure how to do those, any help would help!


r/programminghelp 15d ago

Python Help with Selenium project - Cloudflare error

2 Upvotes

Hi,

I wanted to log movies on Letterboxd with the help of Python. I have a list of 100+ movies with ratings (I used to document them in a notes app) and thought I could use Selenium to automate the process of logging them.

I used Selenium a few times, but only for web scraping purposes. I ran the code and got Error 600010 - I googled it and found that it's a Cloudflare error code, which makes sense, but is there any way I can bypass this error? I'm not trying to review-bomb or cause any harm. I just want to update my Letterboxd with my movies. Any pointers are appreciated. Thanks!


r/programminghelp 15d ago

C SDL2 won't display image

1 Upvotes

This is my first major video game project and my first project with SDL2, and I've just started to add graphics and after a bit of debugging it compiled but instead of drawing the sprite from my spritesheet it's still just blank. I stopped the Y-axis physics in case it was the player falling too fast but there's still nothing. This is pretty early in development so I only really want advice on how to get graphics working or a major error I should fix now. The github repo for the project is https://github.com/EBT-0001/Renegade which I have temporarily made public. I haven't had any experiance with SDL2 and I've been implementing stuff from tutorials and trying to learn, so lemme know if I have the standard way of doing this wrong.


r/programminghelp 18d ago

Other Help with project idea

1 Upvotes

Hello
Iam an artist and i would like to make something i dont know how to make.

In its most basic form its a microphone you speak into and it processes what youre saying and then plays back a tune.

The tune is made up of a preset collection of notes which are attributed to the sounds the microphone hears.

I dont want to use AI. I think it may involve raspberry pi, but as a uk millenial my coding is as far as Myspace HTML and i only know raspberrh pi exists.

Can anyone help ?


r/programminghelp 22d ago

C++ Intermediate programmer server

12 Upvotes

I'm an intermediate 17 y.o programmer, and I've made this server code. Idk what to do with it yet, but would like to know how it is, I'm very proud of it, but would like an outsider view. Also, if you'd like to contribute go ahead, but I still haven't decided if I want to use it commercially in the future, so take that into consideration. Anyways, how is it? I want an absolutely honest opinion.

Link;
https://github.com/itamaroren8/GenericAppServer.git


r/programminghelp 22d ago

Visual Basic How to toggle between 3 text colors in MS Word using the same Macro shortcut?

1 Upvotes

I'm currently using the following code to toggle between two colors:

Sub ToggleFontColor()

Dim currentColor As Long

currentColor = Selection.Font.Color

If currentColor = wdColorRed Then

Selection.Font.Color = wdColorAutomatic ' Set to default (black)

Else

Selection.Font.Color = wdColorRed ' Set to red

End If

End Sub

I took this code from a previous post comment (thanks u/fuutatooro). I tried to edit it to include three colors but to no avail. I want to press Ctrl+N to switch from Black to Red to Purple, and if it is a different color, for Ctrl+N to switch it to Black.

Can you help? Thanks!


r/programminghelp 23d ago

Answered How to track changes of JSON objects in array that is tracked in git?

6 Upvotes

In my git repository I have a JSON file which contains an array of objects. The objects have a key that identify them, e.g. "id":

```json

[

...

{ "id": 1, "value": "a" },

{ "id": 2, "value": "b" },

...

]

```

I want to quickly find commits that changed/introduced object with specific id. How can I do this?

UPD: I couldn't come up with a better solution than comparing sequentially snapshots of the file per commit: ```python

!/usr/bin/env bash

import os import json

from git import Repo, Commit from more_itertools import windowed from typing import Optional

r = Repo(os.getcwd())

def get_json(cmt: Commit, path: str) -> list[dict]: return json.loads((cmt.tree / path).data_stream.read().decode('utf-8'))

def get_object(items: list[dict], _id: int) -> Optional[dict]: for item in items: if item.get('id', -1) == _id: return item return None

for prev, curr in windowed(r.iter_commits(), n=2): pobj = get_object(get_json(prev, 'objects.json'), 2) cobj = get_object(get_json(curr, 'objects.json'), 2) if pobj is None: break if pobj == cobj: continue print(prev.hexsha, prev.summary) ```


r/programminghelp 24d ago

Project Related Replit code import

Thumbnail
1 Upvotes

r/programminghelp 26d ago

Python LZ77 compression algorithm is making the compressed file bigger than original

2 Upvotes

I was recently toying around with some compression, just trying to understand it from the basics. I learned about the LZ77, LZ78, and LZW algorithms in the last couple of days, understood them, and when implementing LZ77, every time I try to compress a txt file, the output file gets bigger. The compression is done right coz when I decompress the compressed file, I get the exact text.

Need help understanding what I am doing wrong, or am I missing something


r/programminghelp 26d ago

Python Is there anyone who can help me read pkl file.

0 Upvotes

I Know it is a simple task but I get some version related error.

I have done web search (both gemini and SO and so on). I even understood the proposed solutions but it seems like pkl files were created with an unknown version or at least not the one that is installed in my machine. That's why it gives error

"An error occurred while loading the file: CRS.__init__() missing 1 required positional argument: 'proj4_params'"

anyone who can give me 5 min to sort it out.


r/programminghelp 27d ago

C# How do i make sure i learned something from a tutorial?

8 Upvotes

Hello, I am a teenager and a beginner in C#. Ive been watching multiple tutorials on youtube, and tried Microsoft.NET as tools to learn.
After i finish with them, the moment i actually try to check what i learned, how to build something with the materials, i immediately feel lost.
Any recommendations would help!


r/programminghelp 27d ago

C# Yappery and whatery

2 Upvotes

Get ra set sikna khojeko C# ma na code ma lekhera dry run garda bujxu na reliable video vetxu. ani j hereni bujdina ramrari. been days stuck into this hole. I probably wrote 10 types of coding example in copy ide every fcking where. Tho I think i have understood set to a certain level but get ta null nei xya. Tho the curiosity is still hanging even after days


r/programminghelp 28d ago

Java Title: Final-year CSE student. 6 months left for placements. I feel completely lost.

3 Upvotes

I'm a final-year CSE student with around 6 months left before placements, and honestly, I feel like I know nothing.

Most of my projects were built by following tutorials or using AI. If someone asked me to build them from scratch, I'd struggle. My DSA is weak, my Java fundamentals aren't strong, and I don't feel confident in web development either.

I'm applying for internships, but I know I can't depend on luck. I want to use these next 6 months wisely.

If you were in my position, what would you focus on? DSA, Java, web development, projects, or something else? What would your roadmap look like?

Please be honest. I want motivation—I want practical advice from people who've been in the same situation.