r/programminghelp • • Feb 24 '22

PHP googles recaptcha being bypassed?

5 Upvotes

I have setup a simple contact form with a Google recaptcha but keep getting these generic spam emails about improving SEO and just advertising other products I have tested it with just a automated post request and it gets denied.

Edit: Forgot code bruh http://va1.snakecrafthosting.com:25570/arugatalic.php


r/programminghelp • • Feb 12 '22

Python Protecting my software.

5 Upvotes

I'd like to try something like this: Set a specific password for the software, secure it so that it can't be easily read, also secure the whole code.


r/programminghelp • • Jan 14 '22

Answered What's wrong with my simple java code?

5 Upvotes
import java.util.*;
public class test {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		System.out.print("Enter your name :");
		String st = s.nextLine();
		System.out.print("Enter your age :");
		int age = s.nextInt();
		System.out.print("Enter your year of birth :");
		String y = s.nextLine();
		System.out.print("Enter your father name :");
		String fn = s.nextLine();
		System.out.print("Name :" + st);
		System.out.print("Age :" + age);
		System.out.print("Year of birth :" + y);
		System.out.print("Your father is " + fn);
	}
}

Whenever it reaches "enter your year of birth", it jumps the instruction.

Please help. I'm gonna be crazy.


r/programminghelp • • Jan 02 '22

HTML/CSS Hello Everybody Happy New Year ! ! ! ! I am trying to embed google maps into my website and am running into issues. This is probably easy for you to solve but I haven't found anything helpful yet.

5 Upvotes

I want to embed a google maps section into my website. To do this I:

  1. went to google maps and typed in the location

  2. clicked "share"

  3. clicked "embed a map" and the "copy html"

  4. Then I pasted the html into my website code and let it run

When I did this, I got an error in the google chrome console saying " Indicate whether to send a cookie in a cross-site request by specifying its SameSite attribute"

What does this message mean and how do I resolve it?

Thanks in advance for you help.


r/programminghelp • • Dec 02 '21

Python How to solve order of operations math question using programming?

5 Upvotes

Hi all, I was wondering if anyone knew how to solve the attached problem using programming? I've tried to do it in Python, but answers in any other languages would also be helpful. Thanks!

"Place the missing parentheses so that:

60 - 18 / 2 + 4 + 15 /3 = 12"


r/programminghelp • • Nov 24 '21

Project Related How can I calculate a calendar date given a week, day of the week, and a month

5 Upvotes

For example, if I was given “The Second Monday in June” (for a given year) how could I calculate what the calendar date for that?

For 2021 the answer in this case should be 06/14/2021

I can’t even begin to wrap my head around the math that must be involved here


r/programminghelp • • Nov 17 '21

Python How can I update an the value of an instance variable to a new value after a method is performed on it (Object Oriented Programming).

5 Upvotes

Hi,

I'm fairly new to Python but especially new to Object Oriented programming. Currently, I am writing code to simulate gas molecules in a container. Essentially, one of the things I need my code to do is, create a ball object with a certain position and velocity, and then have it collide with the wall of the container. When it bounces back, it should have a new velocity. I have worked out all of the formulae necessary for this.

Firstly, I create a class Ball, which is initialised with mass = 1 and radius = 1 (these are not very important for my question).

class Ball():

    def __init__(self, pos = np.array([0,0]), vel = np.array([0,0]), mass = 1, radius = 1):
        self.mass = mass
        self.radius = radius
        self.pos = pos
        self.vel = vel
        self.patch = pl.Circle(self.pos, self.radius, fc = 'r')
            
    def pos(self, pos):
        self.pos = pos
        
    def vel(self, vel):
        self.vel = vel

I can then give this ball a position and velocity when I create the object, e.g. creating a ball which starts at (1,0) moving with velocity (3,0) is created like:

b1 = Ball([1,0], [3,0])

I have a daughter class of this ball object called Container, which is basically just a ball but with a radius of 10 instead, and the velocity and position are fixed at (0,0).

class Container(Ball):
    
    def __init__(self, radius = 10, vel = np.array([0,0]), pos = np.array([0,0])):
        self.radius = radius
        self.pos = pos
        self.vel = vel

Finally, I have a class Simulation, which takes a ball object, and the container object, and simulates the collision of the ball against the container wall.

class Simulation():
    def __init__(self, ball = Ball(), container = Container()):
        self._container = container
        self._ball = ball
        self._pos = ball.pos
        self._vel = ball.vel

    def next_collision(self):
        self._vel = self._container.collide(self._ball)

So, self._vel is the velocity of the ball, after it bounces off the wall. Now, I want to make this velocity the new velocity of the ball object, so that when I run the next_collision method again on this ball, it uses the new velocity, rather than the old velocity which I set at the start. So each time I run the next_collision method, it changes the velocity of the ball object to the new velocity calculated by next_collision.

As an example, if the ball is initialised with velocity (3,0), then running the next_collision method should update the ball's velocity to (-3,0). Then, if I run the next_collision method again, it should update the ball's value to (3,0) and so on and so on.

Currently, if I print self._vel, it does tell me the correct new velocity, though it doesn't update the velocity of the ball, so each time I run the next_collision method, it just prints the same velocity over and over again because it is using the same initial conditions.

Also, I didn't post the whole code for each of the classes here, to keep this as succinct as possible. However, i can provide them if nececessary.

Many thanks in advance,

Sid


r/programminghelp • • Nov 07 '21

Career Related How do u decide what you want to do in coding? I have been “learning to code for last 3 years” haven’t done anything

5 Upvotes

I can’t make a gui on my own and I don’t understand oop and all. My best program was using pyturtle to graph quadratic functions entered by user and a make shift bad mimic of ai that used file handling to learn things by asking the user. That’s all I have learnt I learnt 5 languages in last 3 years can remember any thing other than Java or python . And I don’t know what to do with my knowledge like should I learn more JavaScript and make web stuff or should I make android stuff or should I learn c and learn hacking or should I do machine learning. I realize that k owing languages won’t help but rather I need to learn concepts but I don’t know how I keep switching languages and can’t go beyond a beginner programmer . Help plz


r/programminghelp • • Oct 30 '21

C New To C, Need some Help

5 Upvotes

https://pastebin.com/B2fN5h58

Thats my code. I want to take an input and check if its a number, if its not a number i want the loop to run once and req an input again. If the input is a number this time i want y = 5 which wouldn't allow the loop to run and would move on with the rest of the program.

The problem im running into is that it creates an infinite loop, and i cant enter any input it just keeps running infinitely.


r/programminghelp • • Oct 19 '21

Other A should I learn assemby?

5 Upvotes

I want to know if I should learn Assembly Language. I know C++ but I don't know if I should learn assembly. On ine hand, Asm is good for optimization, but on the other hand how much will I use it?


r/programminghelp • • Sep 07 '21

ASM Incredibly basic Assembly assignment with minimal instruction

5 Upvotes

Instructor gave an assignment to have a program read in 3 ints and output their sum. The logic is incredibly simple and straightforward, but we've had extremely minimal instruction in how to actually write the language, so I'm not even sure what to call the syntax I need to look it up. I'm just writing in a text file and running the program with QtSPIM. The code I have below gives me an error for referring to main twice, then lets me just input numbers forever without outputting anything or ending. I have no idea what I'm doing.

.globl main

.data

.text
main:
li $v0, 5
syscall
move $t0, $v0
li $v0, 5
syscall
move $t1, $v0
li $v0, 5
syscall
move $t2, $v0
add $s0, $t0, $t1
add $s1, $s0, $t2
move $a0, $s1
li $v0, 1
syscall

#exit call
li $v0, 10
syscall

r/programminghelp • • Sep 01 '21

Career Related New programmer needing laptop information

5 Upvotes

Hello my little brother wants to start programming and I want to buy him a laptop. What are the features I should look for as I don't know much? Is a more expensive laptop better for a new programmer? Should I buy some high end laptops from the start?


r/programminghelp • • Aug 31 '21

C What is the logical output of this program and why does the output show "033" ?

5 Upvotes
#include <stdio.h>
int main()
{ 
    char* str[ ]={"11222", "44433", "99888", "00033"};            
    char **sp[ ]={str+1, str, str+ 3, str+2};

    char ***ps;

    ps=sp;
    ++ps;                                                                         
    printf("%s", **++ps+2);

    return -1;
}

r/programminghelp • • Aug 20 '21

C++ Please help me understand why my C++ program gives segmentation error

5 Upvotes
#include<iostream>
using namespace std;

const int SIZE = 3;

template <class T>

class Vector
{
    private:
        T* v;
    public:
        Vector()
        {
            v = new T[SIZE];
            for (int i =0; i<SIZE; i++)
            {
                v[i] = 0;
            }
        }

        Vector(T* a)
        {
            for(int i =0; i<SIZE; i++)
            {
                v[i] = a[i];
            }
        }
        
        T operator* (Vector &k)
        {
            T sum =0;
            for(int i =0; i<SIZE; i++)
            {
                sum += this -> v[i] * k.v[i];
            }

            return sum;
        }

        void display()
        {
            for(int i =0; i<SIZE; i++)
            {
                cout<<v[i]<<"\t";
            }
            cout<<endl;
        }
};

int main()
{
    int x[3] = {1, 2, 3};
    int y[3] = {4, 5, 6};
    Vector <int> v1;
    Vector <int> v2;

    v1 = x;
    v2 = y;

    cout<<"v1 = ";
    v1.display();

    cout<<"v2 = ";
    v2.display();
    
    cout<<"v1 * v2 ="<<v1 * v2;

    return 0;
}

r/programminghelp • • Aug 18 '21

C++ Undefined behavior in cpp

5 Upvotes

Hey everyone,

I just start to learn cpp at my school and there is one notion I don't understand that much. Some teachers gives an function to complete and they say the function can have an undefined behavior. I read some articles and I don't understand it really well soo if anyone can help me to understand it with some exemple it would be very kind, thx guys


r/programminghelp • • Aug 06 '21

Other What's the best programming language?

5 Upvotes

I'll try to be a bit more specific, since I'm pretty sure many feel there isn't a best programming language since they're all meant for different things. By best, I mean a programming language that is good for automating tedious tasks such as sorting google/computer files. A language that will perform monotonous, repetitive and boring tasks that usually take a long time instantly.

I'm pretty sure most languages can do these things, but which one is best for it in your experiences?


r/programminghelp • • Jul 30 '21

C# problems and confusion on C# classes and methods

5 Upvotes

here is what i need to do...

Write a C# application that implements a class ‘Employee’ with the following members. i. Six private data members ‘BasicSalary’, ‘HRA’, ’Deductions’, ‘Allowance’, ‘Insurance’ and ‘NetSalary’ of integer data type.

ii. A default constructor to display the message “Employee Pay Bill”.

iii. Four public methods, setMembers(), calcDed(), calcNet(), and disResult().

  1. setMembers() – set the values of BasicSalary as 2000, HRA as 200, Insurance as 100 and Allowance as 50.

  2. calcDed() – calculate and return the Deductions using the formulae “Deductions = Insurance + Allowance”.

  3. calcNet() – calculate and return the NetSalary using the formulae “NetSalary = BasicSalary + HRA – Deductions”.

  4. disResult() – display BasicSalary, HRA, Deductions and NetSalary

the output should look like

Employee Pay Bill
Basic Salary = 2000
HRA = 200
Deductions = 150
Net Salary = 2050

it says i have 6 errors

and this is the class Employee

using System;
using System.Collections.Generic;
using System.Text;

namespace Final_THE_M109
{
    class Employee
    {
        private int BasicSalary;
        private int HRA;
        private int Deductions;
        private int Allowance;
        private int Insurance;
        private int NetSalary;
        public void setMembers(int B, int H, int A, int I)
        {
            BasicSalary = B;
            HRA = H;
            Allowance = A;
            Insurance = I;
        }
        public int calDed()
        {
            int Deductions = Insurance + Allowance;
            return Deductions;
        }
        public int calcNet()
        {
          int  NetSalary = BasicSalary + HRA – Deductions; // i get a red line under the (-) and (deductions)
            return NetSalary
        }
        public void disResult()
        {
            Console.WriteLine("Basic Salary = ", setMembers(B)); // i also get a red line under (B)
            Console.WriteLine("HRA = ", setMembers(H));// a line under (H) too
            Console.WriteLine("Deductions = ", calDed());
            Console.WriteLine("Net Salary = ", calcNet());
        }
    }
}

now the code for the main method

using System;

namespace QuestionTwo
{
    class Program
    {
        public static void Main(string[] args)
        {
            Employee e = new Employee();
            Console.WriteLine("Employee Pay Bill");
// it gives me a red line under every setMembers
            int B = 2000;
            e.setMembers(B);
            int H = 200;
            e.setMembers(H);
            int A = 50;
            e.setMembers(A);
            int I = 100;
            e.setMembers(I);
            e.disResult();
        }
    }
}

r/programminghelp • • Jul 09 '21

Answered Find the ? in "? ×2 = 4"

5 Upvotes

I have a variable called question which has the content "? ×2 = 4", how would I go about finding the value of the "?". Thanks for any help :)


r/programminghelp • • Jul 07 '21

C# which would be easier for processing? Store a series of numbers as an INTEGER and then just convert them into FLOATS when needed, or store them as FLOATS and then convert them to INTEGERS when needed?

5 Upvotes

[RESOLVED] I need to reference these numbers often and they're long numbers (mostly 3 or so digits long); in most cases I need them to be floats, and in others as integers.
The need for one or the other is fairly equal, too.

These numbers are also stored in a 2-dimensional array that's 250x250 in size, soo... Which is wiser?

[ RESOLUTION: Storing as floats.]


r/programminghelp • • Jul 06 '21

C Who knows a good compiler for C?

5 Upvotes

For a very long time, I could not find a sufficiently convenient compiler for C and had to use an online compiler. And this is not convenient enough. Could you advise me on good compilers for C?


r/programminghelp • • Jun 04 '21

Python How do I pass an index value from one list to another in Python?

5 Upvotes

I've been working on a word guessing game exercise. I'm pretty new when it comes to this so ELI5.

There is a function get_word that returns a random word (not really random at this point. I'll work on that later.) which is used in the play_game function below. The program should check the user input (letter) against a list (computer_word). If letter is in computer_word then the if statement should run. If letter is not in computer_word then the else statement should run. So if the word is HAPPY the user would see -----. If they input a 'Y' then dashed_word should change to ----Y.

I guess I really don't get how to take the index of computer_word and pass it dashed_word. I've tried a few things and I always get an error or it runs but doesn't do what I want. It's the if/else statement at the bottom that's the problem.

TLDR: I need to take an index value from computer_word and do something at that same index value in dashed_word. I want to change a '-' to a letter which the user inputs. Computer_word and dashed_word are the same length.

Here's the code:

def play_game(secret_word):
    computer_word = get_word()  #Takes the function get_word and sets it as a variable in this function.
        
    guesses = INITIAL_GUESSES

    dashed_word = '-' * len(computer_word)  #Takes in computer_word and replaces characters with dashes.
    
    while guesses > 0:          #So that it gives you only INITIAL_GUESSES (8 tries.)
        print("The word now looks like this: " + dashed_word)
        print("You have " + str(guesses) + " guesses left")
        letter = str(input("Type a single letter here, then press enter: "))
        
        guesses -= 1
        
        comp_word_list = list(computer_word)
        g = comp_word_list.index(letter)

        for i in range(len(computer_word)):
            if letter in comp_word_list:
                print("That guess is correct.")
                print("TEST: " + str(g) +" " +letter + " " + str(list(computer_word)) + " " + dashed_word) #Just testing.  Delete later
                dashed_word[g] = letter
            else:
                print("There are no " +letter + "'s in the word")

Here's what happens when I run it:

(I input a Y when prompted.)

The word now looks like this: -----
You have 8 guesses left
Type a single letter here, then press enter: Y
That guess is correct.
TEST: 4 Y ['H', 'A', 'P', 'P', 'Y'] -----
Traceback (most recent call last):
  File "/home/word_game.py", line 72, in <module>
    main()
  File "/home/word_game.py", line 66, in main
    play_game(secret_word)
  File "/home/word_game.py", line 36, in play_game
    dashed_word[g] = letter
TypeError: 'str' object does not support item assignment

r/programminghelp • • May 28 '21

Python How can I decode an encrypted RLE compressed .dat file?

5 Upvotes

How would I go about decoding a RLE compressed .dat file that has been encrypted?

This is not a homework question, I'm trying to decode an old save file. Here is the save file if anyone wants to take a look themselves. Here is the only information I can find on how the file was created.

I fully understand how RLE compression works HHHHEYY --> 4H1E2Y

I'm just not sure how do go about decrypting it, I do know how it was encrypted, it was done by adding 39393939 and then rotating each DWord right 5 bits.

Any tips/tools that would help, that would be awesome!


r/programminghelp • • May 23 '21

C++ how can I get a less-like output in C++?

5 Upvotes

I'm building an application and one of its outputs are very long and you can't always scroll up/down in a terminal, how can I get a less/man like output in C++ where you can scroll up and down the output with the up and down arrow?


r/programminghelp • • May 19 '21

Answered [Python] bytearray() returning "001@" for input of 108. This doesn't make sense to me?

5 Upvotes

Edit 3: ive realised the problem. Print is just printing the byte array as ASCII characters. Makes sense now.

python 3.9, I suspect this is functioning as intended I just dont understand the meaning of an "@" in a byte array.

Input:

print(bytearray([1, 17, 0, 0, 0, 0, 108, 64, 0]))           

Result:

bytearray(b'\x01\x11\x00\x00\x00\x00l@\x00')

Edit: now I look, this doesn't seem right at all. where did all my zeros go?

Edit 2: Wait, thats not a 1, its a lower case L! Now im more confused.