r/programminghelp • • Jul 20 '21

2021 - How to post here & ask good questions.

42 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 • • 23m ago

Project Related Can someone humanise this for me pleeeeeas e

1 Upvotes
$title
 Level 4 process and cost model for DME production
$ontext
Level 4 mass balances and economic potential for the DME process
(question 3), followed by a search over the design variables
(question 4). Stream numbers follow the flowsheet in question 2.
Flows are in kmol per h and money in millions of EUR per year.
$offtext
set 
s streams on the flowsheet /1*12/;
set 
i components /DME, MeOH, H2O/;
* the design variables are t, r1 and r2 (3 degrees of freedom)
parameters
    
t residence time in the reactor [s] /1.5/
    r1 recovery of the keys in T-1 /0.998/
    r2 recovery of the keys in T-2 /0.99/
    alpha intercept of the conversion fit from question 1 /0.3416/
    beta slope of the conversion fit from question 1 /0.6119/
    HPY operating hours in a year /8150/
    pDME value of DME [EUR per kg] /1.15/
    pfeed cost of the feed [EUR per kg] /0.4/
    feed(i) fresh feed for d = 1 [kmol per h]
    / DME 0
      MeOH 455.4
      H2O 4.6 /
    mw(i) molar mass [kg per kmol]
    / DME 46.069
      MeOH 32.042
      H2O 18.015 /;
* Antoine coefficients from the NIST webbook, log10(P/bar) = A - B/(T/K + C)
* the DME set is valid for 194.9-248.2 K so it is extrapolated here
* MeOHlow 288-357 K, MeOHhigh 354-513 K, H2Olow 334-363 K, H2Ohigh 344-373 K
set 
ant Antoine data sets /DME, MeOHlow, MeOHhigh, H2Olow, H2Ohigh/;
set 
coeff /A, B, C/;
set 
pos top and bottom of each column /T1top, T1bot, T2top, T2bot/;
Table 
antoine(ant, coeff) Antoine coefficients
                A          B           C
DME         
 4.11475     894.669     -30.604
MeOHlow     
 5.20409    1581.341     -33.50
MeOHhigh    
 5.15853    1569.613     -34.846
H2Olow      
 5.0768     1659.793     -45.854
H2Ohigh     
 5.08354    1663.125     -45.622 ;
* column temperatures from question 2 (bubble points at column pressure)
parameter 
Tcol(pos) temperature [K]
    / T1top 314
      T1bot 420
      T2top 342
      T2bot 378 /;
parameters
    
pstar(ant, pos) vapour pressure [bar]
    a1 relative volatility of DME to methanol in T-1
    a2 relative volatility of methanol to water in T-2 ;
* evaluate p* for each data set at each column temperature
pstar(ant, pos) = 10**(antoine(ant,'A') - antoine(ant,'B')/(Tcol(pos) + antoine(ant,'C')));
* geometric mean of the volatility at the top and bottom of each column
a1 = 
sqrt
( pstar('DME','T1top')/pstar('MeOHlow','T1top')
         * pstar('DME','T1bot')/pstar('MeOHhigh','T1bot') );
a2 = 
sqrt
( pstar('MeOHlow','T2top')/pstar('H2Olow','T2top')
         * pstar('MeOHhigh','T2bot')/pstar('H2Ohigh','T2bot') );
variable 
EP economic potential [M EUR per y];
positive variables
    
F(s,i) flow of each component in each stream [kmol per h]
    x single pass conversion of methanol
    xi extent of reaction [kmol per h]
    purity mole fraction of DME in the product
    revenue value of the DME sold [M EUR per y]
    feedcost cost of the fresh feed [M EUR per y]
    tacR total annualised cost of the reactor [M EUR per y]
    tacT1 total annualised cost of T-1 [M EUR per y]
    tacT2 total annualised cost of T-2 [M EUR per y] ;
equations
    
mixerbalance(i), pumpbalance(i), vaporiserbalance(i), superheaterbalance(i),
    conversion, extentdefinition, reactormethanol, reactorDME, reactorwater,
    condenserbalance(i), T1topDME, T1topmethanol, T1topwater, T1bottoms(i),
    valvebalance(i), T2topDME, T2topmethanol, T2topwater, T2bottoms(i),
    puritydefinition, revenuedefinition, feedcostdefinition,
    reactorcost, T1cost, T2cost, economicpotential ;
* mass balances, all of the form:
*     input + generation = output + consumption
* M-1: fresh feed mixed with the methanol recycle
mixerbalance(i) .. F('3',i) =e= F('1',i) + F('2',i);
* the pump and the two heaters do not change the flows
pumpbalance(i) .. F('4',i) =e= F('3',i);
vaporiserbalance(i) .. F('5',i) =e= F('4',i);
superheaterbalance(i) .. F('6',i) =e= F('5',i);
* conversion from the fit in question 1 (log is the natural log)
conversion .. x =e= alpha + 
beta
*
log
(t);
* 2 MeOH -> DME + H2O
* methanol consumed is twice the extent of reaction
extentdefinition .. 2*xi =e= x*F('6','MeOH');
reactormethanol .. F('7','MeOH') =e= F('6','MeOH') - 2*xi;
* DME and water generated in the reaction
reactorDME .. F('7','DME') =e= F('6','DME') + xi;
reactorwater .. F('7','H2O') =e= F('6','H2O') + xi;
* total condenser, no change in the flows
condenserbalance(i) .. F('8',i) =e= F('7',i);
* T-1, semi-sharp: DME is the light key and methanol the heavy key
* water is heavier than the heavy key so it all goes to the bottom
T1topDME .. F('9','DME') =e= r1*F('8','DME');
T1topmethanol .. F('9','MeOH') =e= (1-r1)*F('8','MeOH');
T1topwater .. F('9','H2O') =e= 0;
T1bottoms(i) .. F('10',i) =e= F('8',i) - F('9',i);
* the valve drops the pressure from 9 to 1.2 bar, flows unchanged
valvebalance(i) .. F('11',i) =e= F('10',i);
* T-2, semi-sharp: methanol is the light key and water the heavy key
* DME is lighter than the light key so it all goes to the top
* and the top product is the methanol recycle (stream 2)
T2topDME .. F('2','DME') =e= F('11','DME');
T2topmethanol .. F('2','MeOH') =e= r2*F('11','MeOH');
T2topwater .. F('2','H2O') =e= (1-r2)*F('11','H2O');
T2bottoms(i) .. F('12',i) =e= F('11',i) - F('2',i);
* purity of the DME product, needs to be at least 0.99
puritydefinition .. purity*
sum
(i, F('9',i)) =e= F('9','DME');
* costs
* only the DME in the product is sold
revenuedefinition .. revenue =e= HPY/1e6*F('9','DME')*mw('DME')*pDME;
* all of the fresh feed is bought
feedcostdefinition .. feedcost =e= HPY/1e6*
sum
(i, feed(i)*mw(i))*pfeed;
* reactor cost from table 2, using the reactor feed (stream 6)
reactorcost .. tacR =e= 0.001*t*
sum
(i, F('6',i));
* column costs from table 2, using the feed to each column
T1cost .. tacT1 =e= 1/(100*(1-r1))*1/(a1-1)*
sqrt
(
sum
(i, F('8',i)));
T2cost .. tacT2 =e= 1/(100*(1-r2))*1/(a2-1)*
sqrt
(
sum
(i, F('11',i)));
* level 4 economic potential (heat exchangers and utilities are level 5)
economicpotential .. EP =e= revenue - feedcost - tacR - tacT1 - tacT2;
model 
dme /all/;
* initialise the flows to help GAMS start, then fix the fresh feed
F.l(s,i) = 100;
purity.l = 0.99;
F.fx('1',i) = feed(i);
* base case for question 3
solve
 dme 
using
 
cns
;
* check the methanol balance closes (should be zero)
parameter 
mbal methanol in minus methanol out and reacted [kmol per h];
mbal = feed('MeOH') - F.l('9','MeOH') - F.l('12','MeOH') - 2*xi.l;
display
 a1, a2, x.l, purity.l, mbal, F.l, revenue.l, feedcost.l,
        tacR.l, tacT1.l, tacT2.l, EP.l;
$ontext
Question 4: solve the model over the design variables and write the
results to dme.data for plotting. t covers the valid range of the
conversion fit, r1 and r2 the range of the cost model in table 2.
Designs with a purity below 0.99 are written out but not accepted.
$offtext
* keep the listing short inside the loop, otherwise it is very long
option
 
solprint
 = silent, 
limrow
 = 0, 
limcol
 = 0, 
solvelink
 = 5;
parameters
    
bestEP best feasible economic potential [M EUR per y] /-1000/
    bestt t at the best design [s]
    bestr1 r1 at the best design
    bestr2 r2 at the best design ;
file 
results /dme.data/;
results.nd = 4;
results.pw = 200;
put
 results;
put
 '# t r1 r2 x purity EP revenue feedcost tacR tacT1 tacT2 status' /;
for
 (t = 0.80 to 2.051 by 0.05,
   
for
 (r1 = 0.900 to 0.9985 by 0.002,
      
for
 (r2 = 0.900 to 0.9985 by 0.007,
         
solve
 dme 
using
 
cns
;
         
put
 t, r1, r2, x.l, purity.l, EP.l, revenue.l, feedcost.l,
             tacR.l, tacT1.l, tacT2.l, dme.modelstat /;
* keep the best design that meets the purity specification
         
if
 (purity.l >= 0.99 
and
 EP.l > bestEP,
            bestEP = EP.l;
            bestt = t;
            bestr1 = r1;
            bestr2 = r2;
         );
      );
   );
);
putclose
 results;
* solve again at the best design and report it (used in question 5)
t = bestt;
r1 = bestr1;
r2 = bestr2;
option
 
solprint
 = on;
solve
 dme 
using
 
cns
;
display
 bestEP, bestt, bestr1, bestr2, x.l, purity.l, F.l,
        revenue.l, feedcost.l, tacR.l, tacT1.l, tacT2.l, EP.l;

r/programminghelp • • 12d ago

Other Help us with our research pleasee!!

2 Upvotes

r/programminghelp • • 12d ago

Other Help us with our research pleaseeee

0 Upvotes

We need respondents for our research pleaseeee!!!

https://forms.gle/tks5tpqecDNPDVTc8


r/programminghelp • • 16d ago

Career Related How should i start making more complex and low-level projects?

12 Upvotes

I've been in game development for the past 6 years. I like it for creative freedom and a few other aspects.

I chose programming as my career path and planning to pursue a degree in computer science and engineering.

But i never made any applications or games outside of simple game engines.

So where should i start developing my programming skills and creating more complex projects?

Edit: Thank you all for great ideas, i appreciate it. Gonna dive into this and maybe post my results soon.


r/programminghelp • • 17d ago

C++ does anyone have any tips for c++?

15 Upvotes

(i’m new to most of this, so advice would be helpful!)


r/programminghelp • • 17d ago

JavaScript BEGINNER CODER: Stuck with a migrations error

0 Upvotes

Hi,

I'm working on an adonisjs project and I'm having issues with migrations. I don't think I'm using the wrong command. I'm doing:

node ace make:migration (migration name here)

Then:

node ace migration:run

My project is on github. Apologies the migrations folder is a little cluttered. The ones with issues are the "item" and "item_comments" ones:

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

The error is:

C:\Windows\System32\adonis22>node ace migration:run
❯ error database/migrations/1794008714673_alter_item_comments_table
[ error ] INSERT INTO "_knex_temp_alter555" SELECT * FROM "item_comments"; - no such table: main.item

Please correct me if I'm wrong but I thinks its saying my "item" table doesnt exist which doesnt make sense since its clearly my 'schema.ts'. It said the same error before for the "user" table aswell.

Any help would be much appreciated

TIA


r/programminghelp • • 18d ago

C Why every time I execute a code, like in C, it runs in a different time?

3 Upvotes

If I execute the same code no matter how many times, it always will show me a different execution time. Why:?


r/programminghelp • • 22d ago

HTML/CSS need a solution to an impossible problem

8 Upvotes

essentially, im tryna publish a public css website on a HEAVILY restricted school network

I'm developing a website which is essentially a student focused grade calculator that I've built using Python, Gradio, HTML, CSS, and JavaScript. ik there are other grade calcs out there, but this one is more specific to my district and solves the need of people constantly asking me to calculate their grades manually. The application itself is practically built, but I'm having a really difficult time figuring out how to actually publish it so other students can use it.

My requirements and limitations:

  • Students need to access it through one normal URL in their browser
  • No downloads, installations, or student accounts
  • AI website generators or a template builders are blocked
  • Student grade data needs to stay entirely in their browsers and not be sent to a server
  • It needs to be accessible on school computers, which have a VERYYYYY restrictive network filter
  • No paid hosting, adult involvement, administrator permissions, or requests to school IT
  • Ideally, I'd like a professional-looking URL that doesn't advertise that the site was made through an educational coding platform (ex. i know code .org is available and practically my only option but the name itself ruins the credibility. im ok with using if i HAVE to but i would rlly prefer not to)

I've already looked into A LOTTT of other options, including Google Sites, Google Apps Script, Firebase, Blogger, GitHub, and several other hosting platforms. either ALLLLL are blocked on school computers, or they don't actually support what I need. Google Colab works for development but im unable to publish past that

Does anyone have ideas for unconventional hosting or publishing methods that I might be overloking?


r/programminghelp • • 29d ago

JavaScript Beginner Coder: Stuck with an error

2 Upvotes

Hi,

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

My project is on github:

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

The error is in file 'database/seeders/ product_seeder.ts' Line 10

The error is:

Object literal may only specify known properties, and 'userld' does not exist in type
'OneOrMany<Partial<ModelAttributes<Product>>>.

Any help would be much appreciated

TIA


r/programminghelp • • Oct 12 '26

Java What the hell is going on?

Thumbnail reddit.com
0 Upvotes

r/programminghelp • • Oct 12 '26

C++ Book recommendations for C++ beginner

Thumbnail reddit.com
1 Upvotes

r/programminghelp • • Oct 12 '26

Processing STUCK FOR A LONG TIME NOW ITS IRRITATING..Can anyone please help!

3 Upvotes

I am making an attendance dashboard and i there are already APIs made for different purpose

one is the punch in data API where we have to give the

from- to date

and the area_code 

so with respect to that it will fetch the

	emp_id, emp name, punch_in/punch_out location, date-in/out location, time-in/out location, hours and minutes between pucnhes

now with respect to all the detail i am calculating the total punches, single punch, avg hours and etc

but it will work perfectly for 10 areas but i want to make it for 112 areas and for this it will take a lot of time to load

and then again there is a roaster API which will tell how many members will be present per area and that will also be fetched and calculated

now if all this data is loaded on the client side it will take a lot of time

what is the optimal way to do this

i have already searched for one option where i will

preload the data and calculation and sync that same data in the database and whenever we fetch the data the result with the particular date range will be feteched

But i want to know any more optimal way to do that

CAN ANYONE SUGGEST!!


r/programminghelp • • Oct 10 '26

Python Duplicate static while serving static files with Vite to Django backend

Thumbnail reddit.com
1 Upvotes

r/programminghelp • • Oct 09 '26

Java identifying what topic/subject

2 Upvotes

i was tired from working and i still go to my class and i just zoned out and didn't know what topic my professor was teaching, it would be so nice if it help identify what topic from this for me to catch up

1st cycle x = 0, n = 5, temp = ?

2nd cycle x = 1, n = 5, temp = 7

3rd cycle x = 2, n = 5, temp = 5

all i know is there is also a 4th cycle :D


r/programminghelp • • Oct 08 '26

C# What is the proper way to make a unified interface ?

Thumbnail reddit.com
1 Upvotes

r/programminghelp • • Oct 07 '26

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 • • Oct 07 '26

JavaScript Need Guidance

Thumbnail reddit.com
1 Upvotes

r/programminghelp • • Oct 06 '26

C 300 lines of code just to receive one packet

Thumbnail reddit.com
1 Upvotes

r/programminghelp • • Oct 05 '26

Java Java 21 static-analysis engine for dependency and call graphs what edge cases am I missing?

Thumbnail reddit.com
1 Upvotes

Hi everyone,

I’ve been building a Java 21 code-analysis engine and would love some feedback on the dependency resolution.

It uses JavaParser and resolves imports, same-package classes, inheritance, method calls, etc. I’m mainly trying to avoid false dependency edges in complex Java codebases.

GitHub: https://github.com/abhishek94443/CodeContext-Java

Would appreciate any feedback on edge cases or things I may be missing.


r/programminghelp • • Oct 04 '26

C Codeblocks

3 Upvotes

Can i download Codeblocks on Macbook neo?


r/programminghelp • • Oct 04 '26

Python How do I find valid points within 7-dim parameter space? Global NuFIT

2 Upvotes

I don't know where I should ask this, it's related to physical and coding, so I am posting here. I am struggling with this particular problem for a month and still couldn't get to a satisfactory results.

So, I was working on a physics problem, many of you might be familiar or maybe not. I have to find a valid region within a 7-dim parameter space. I have some matrices in hand (Neutrino mass matrices) and 7 free parameters that goes into it i.e. g1,g2,g3,M1,M2, imaginary tau, real tau. I need to build a code that scans the space and finds the values of these free parameters which being inserted into the matrices and upon diagonalization spits out 3 eigenvalues and 3 eigenvalues vectors. From those we then calculate 6 neutrino observables that should be within acceptable range known as Global NuFIT. Any values that comes within the range gets sorted out.

I tried to build the code in python but it seems impossible to search for the whole parameter space! I tried gemini and chat gpt, even they are struggling to satisfy the tight NuFIT bounds. If anyone knows any efficient and fast way for parameter scanning that would atleast give 200 valid points (for scatter plots), please help me.


r/programminghelp • • Oct 03 '26

C Help me understand NUL please!

Thumbnail reddit.com
1 Upvotes

r/programminghelp • • Oct 03 '26

C why does fgets allocates a 4096 characters long buffer for a 22 bytes long file ?

0 Upvotes

I'm learning C and playing around trying to rely on the bare minimum down to system calls to learn the most I can. Had to read a file line by line in the process, so i dived into stdio's code to try to understand how fgets do it nice and quick.

if I got it right a chunck of file is loaded into a buffer delimited by _IO_buf_base and _IO_buf_end if it isn't yet loaded or the precedent buffer ended without finishing the line, fgets starts copying the line in the buffer we gave it until he finds a new line.

did I got it right ? I couldn't find a plain explanation of how stdio file management works, I had to search my way into source code...

I thought I was done but I noticed _IO_buf_base and _IO_buf_end were 4096 bytes apart when I loaded a 22 bytes long file.

is there any reason for this ? wouldn't having a pointer for the beginning of the buffer and a pointer for the end allow us to allocate precisely the size of the file using fstat ? why do we use 2 pointers and not a pointer and the size of the buffer ? (I got a theory for this one but I'm not sure, is it for easier looping in the array by incrementing a pointer instead of using an incremented index who would make us calculate pointer + i every time we need to get a character ?)

thank you for reading this far and have a nice day !