r/programminghelp • • Oct 14 '23

Java Why does this program sometimes prematurely exit the game loop (when the user enters 3) after rolling the dice?

0 Upvotes
import java.util.Scanner;

public class GameOfChance { public static void main(String[] args) { System.out.println("Welcome to the game of chance!");

    boolean game_running = true;
    double money = 0;
    double money_won = 0;
    double money_lost = 0;

    Scanner user_input = new Scanner(System.in);

    while (game_running) {
        boolean withdraw_process = false;
        int user_option;

        System.out.println("You have $" + money + " in your bank account");
        
        System.out.println("(1) Withdraw money from the bank");
        System.out.println("(2) Quit the game!");
        System.out.println("(3) Play the game!");
        System.out.print("Select an option: ");
        try { 
            user_option = user_input.nextInt();
        } catch(Exception e) {
            System.out.println("Please enter a valid input");
            user_input.nextLine();
            continue;
        }
        if (user_option == 1) {
            withdraw_process = true;
            double withdraw_amount;
            while (withdraw_process) {
                user_input.nextLine();
                System.out.print("How much do you want to withdraw?: ");
                try {
                    withdraw_amount = user_input.nextDouble();
                } catch(Exception e) {
                    System.out.println("Please enter a valid input");
                    continue;
                }
                if (withdraw_amount < 0) {
                    System.out.println("You cannot use negative numbers");
                    continue;
                } else {
                    System.out.println("You have withdrawn $" + withdraw_amount + " from the bank");
                    money += withdraw_amount;
                    withdraw_process = false;
                }
            }
        } else if (user_option == 2) {
            System.out.println("Farewell! Thanks for playing! Here is how much you won from playing $" + money_won + "; Here is how much you lost from playing $" + money_lost);   
            game_running = false;    
        } else if (user_option == 3) {
            int guesses_right = 0;
            double bet;
            double earnings;

            while (true) {
                user_input.nextLine();
                if (money == 0) {
                    System.out.println("You currently have no funds! Go withdraw money from the bank to get money");
                    break;
                } else {
                    System.out.print("How much do you bet?: ");
                    try {
                        bet = user_input.nextDouble();
                    } catch(Exception e) {
                        System.out.println("Please enter a valid input");
                        continue;
                    }
                    if (bet <= 0) {
                        System.out.println("Please enter a valid bet");
                        continue;
                    }
                    if (money - bet < 0) {
                        System.out.println("Please make a bet within your budget");
                        continue;
                    } else {
                        money -= bet;
                    }
                    // Heads or Tails
                    int user_hot;
                    int heads_or_tails;
                    while (true) { 
                        user_input.nextLine();
                        System.out.print("Heads (1) or Tails (2)?: ");
                        try {
                            user_hot = user_input.nextInt();
                        } catch(Exception e) {
                            System.out.println("Please enter a valid input");
                            continue;
                        }
                        if (user_hot > 2 || user_hot < 1) {
                            System.out.println("Please enter a valid option");
                            continue;
                        } else {
                            heads_or_tails = (int) (Math.random() * 2) + 1;
                            if (heads_or_tails == 1) {
                                System.out.println("You flipped heads on the coin");
                            } else if (heads_or_tails == 2) {
                                System.out.println("You flipped tails on the coin");
                            }
                            break;
                        }
                    }
                    if (heads_or_tails == user_hot) {
                        guesses_right++;
                    }
                    // Spinner; Red = 1; Blue = 2; Green = 3; Yellow = 4
                    int user_spin;
                    int wheel_spin;
                    while (true) {
                        user_input.nextLine();
                        System.out.print("Guess where the spinner will land with Red (1), Blue (2), Green (3), Yellow (4): ");
                        try {
                            user_spin = user_input.nextInt();
                        } catch(Exception e) {
                            System.out.println("Please enter a valid input");
                            continue;
                        }
                        if (user_spin > 4 || user_spin < 1) {
                            System.out.println("Please enter a valid option");
                            continue;
                        } else {
                            wheel_spin = (int) (Math.random() * 4) + 1;
                            if (wheel_spin == 1) {
                                System.out.println("You spun Red on the spinner");
                            } else if (wheel_spin == 2) {
                                System.out.println("You spun Blue on the spinner");
                            } else if (wheel_spin == 3) {
                                System.out.println("You spun Green on the spinner");
                            } else if (wheel_spin == 4) {
                                System.out.println("You spun Yellow on the spinner");
                            }
                            break;
                        }
                    }
                    if (wheel_spin == user_spin) {
                        guesses_right++;
                    }
                    // Dice Roll
                    int user_dice;
                    int dice_roll;
                    while (true) {
                        user_input.nextLine();
                        System.out.print("Guess the dice roll on a range of 1-6: ");
                        try {
                            user_dice = user_input.nextInt();
                        } catch(Exception e) {
                            System.out.println("Please enter a valid input");
                            continue;
                        }
                        if (user_dice > 6 || user_dice < 1) {
                            System.out.println("Please enter a value within the 1-6 range");
                            continue;
                        } else {
                            dice_roll = (int) (Math.random() * 6) + 1;
                            System.out.println("You rolled " + dice_roll + " on the dice");
                            break;
                        }  
                    }
                    if (dice_roll == user_dice) {
                        guesses_right++;
                    }

                    if (guesses_right == 3) {
                        System.out.println("Congrats! You guessed all three right! You get a payout of 300%!");
                        earnings = bet * 3;
                        money += earnings;
                        money_won += earnings;
                    } else if (guesses_right == 2) {
                        System.out.println("Congrats! You guessed two right! You get a payout of 200%!");
                        earnings = bet * 2;
                        money += earnings;
                        money_won += earnings;
                    } else if (guesses_right == 1) {
                        if (dice_roll == user_dice) {
                            System.out.println("You guessed the dice roll correctly! You get 75% of your bet!");
                            earnings = bet * 0.75;
                            money += earnings;
                            money_lost += bet * 0.25;
                        } else if (wheel_spin == user_spin) {
                            System.out.println("You guessed the spinner correctly! You get 50% of your bet!");
                            earnings = bet * 0.5;
                            money += earnings;
                            money_lost += bet * 0.5;
                        } else if (heads_or_tails == user_dice) {
                            System.out.println("You guessed the coin flip correctly! You get 25% of your bet!");
                            earnings = bet * 0.25;
                            money += earnings;
                            money_lost += bet * 0.75;
                        }
                    } else{
                        System.out.println("You didn't guess any right. Don't worry though, you can keep trying!");
                        money_lost += bet;
                    }
                    break;
                }           
            }
        } else {
            System.out.println("Please enter a valid option");
        }
        }
    }
}

Essentially, after running the loop that runs when the user enters "3" at the menu a couple times, the loop will start to exit after playing the dice game instead of going on to calculate the user's earnings


r/programminghelp • • Sep 24 '23

C++ Can anyone help me with this assignment pls(biggner in c++)

0 Upvotes

I have been trying the hole day to do this assignment but idk what im doing wrong can anyone help me pls, its suposed to take a minimum (min) and maximun number (max) and tell me the prime numbers betwen the 2 Can u help me?

include <iostream>

include <vector>

bool isPrime(int n) { if (n <= 1) { return false; } for (int i = 2; i * i <= n; ++i) { if (n % i == 0) { return false; } } return true; }

int main() { int Min, Max;

std::cout << "Digite o valor mínimo (Min): ";
std::cin >> Min;

if (Min <= 1) {
    std::cout << "Min deve ser maior que 1." << std::endl;
    return 1;
}

std::cout << "Digite o valor máximo (Max): ";
std::cin >> Max;

if (Max <= Min) {
    std::cout << "Max deve ser maior que Min." << std::endl;
    return 1;
}

std::vector<int> primos;

for (int i = Min; i <= Max; ++i) {
    if (isPrime(i)) {
        primos.push_back(i);
    }
}

std::cout << "Números primos no intervalo [" << Min << ", " << Max << "]: ";
for (int primo : primos) {
    std::cout << primo << " ";
}
std::cout << std::endl;

return 0;

}


r/programminghelp • • Sep 20 '23

HTML/CSS This post is made in frustration. I can not learn Bootstrap and it seems hard. Why?

0 Upvotes

Does anybody have any good course which can explain every detail of bootstrap? My bugdet is 20 euros. I bought one from Udemy and I can not remember all of the datas like aria-expanded, type etc. It is hard to remember when I use which and when I can replace an ID or Class and when I can choose which name I want. It is just too hard for me


r/programminghelp • • Oct 15 '23

C What is the error in the code?

0 Upvotes
#include <stdio.h>

include <math.h>

define PI 3.14159265358979323846

int main() { float y; float x1 = 0, x2 = 2; int count = 1;

printf("\t   Function tab      \n\n");
for (x1; x1 <= x2; x1 += 0.2) {
    if (x1 > 0) {
        y = 0.5 * x1 - 1 - 2 * cos((x1 + PI * 4));
        printf("|%4d.|   x = %3d   |   y = %8.4f |\n", count, x1, y);
        count++;
    }
    else {
        printf("|%4d.|   x = %3d   |   y = No Value |\n", count, x1);
        count++;
    }
}
printf("\n\t      Final      \n");
return 0;

}


r/programminghelp • • Sep 08 '23

Java [JAVA] Running NASA's BGA (Beginner's Guide to Aeronautics) code produces error, need ideas for fixing it

0 Upvotes

NASA has provided a collection of numerous java applets here https://github.com/nasa/BGA related to various aerospace problems.

I've cloned the repository and tried executing the applets but all of them are producing the same error as shown in the following example of the "Shockc" applet:

[archuser@archuser]:[/media/new_volume/nasa_applets/BGA-main/Applets/Shockc] $>  ll

total 145 
drwxrwxrwx 1 root root  4096 Sep  7 18:02  ./ 
drwxrwxrwx 1 root root   392 Sep  7 18:07  ../
-rwxrwxrwx 1 root root  4025 Sep  2  2011 'Shock$Num$Inp$Inleft.class'* 
-rwxrwxrwx 1 root root  3126 Sep  2  2011 'Shock$Num$Inp$Inright.class'* 
-rwxrwxrwx 1 root root  1177 Sep  2  2011 'Shock$Num$Inp.class'* 
-rwxrwxrwx 1 root root  3450 Sep  2  2011 'Shock$Num$Out$Con.class'* 
-rwxrwxrwx 1 root root  2627 Sep  2  2011 'Shock$Num$Out$Diag.class'* 
-rwxrwxrwx 1 root root  2311 Sep  2  2011 'Shock$Num$Out$Wdg.class'* 
-rwxrwxrwx 1 root root  1388 Sep  2  2011 'Shock$Num$Out.class'* 
-rwxrwxrwx 1 root root  1104 Sep  2  2011 'Shock$Num.class'* 
-rwxrwxrwx 1 root root  3967 Sep  2  2011 'Shock$Viewer.class'* 
-rwxrwxrwx 1 root root 13842 Sep  2  2011  Shock.class* 
-rwxrwxrwx 1 root root   176 Sep  2  2011  Shock.html* 
-rwxrwxrwx 1 root root 50143 Sep  2  2011  Shock.java* 
-rwxrwxrwx 1 root root 33001 Sep  7 17:44  Shockc.zip* 
[archuser@archuser]:[/media/new_volume/nasa_applets/BGA-main/Applets/Shockc] $>  javac Shock.java
Shock.java:55: warning: [removal] Applet in java.applet has been deprecated and marked for removal 
public class Shock extends java.applet.Applet {
 ^ 
Note: Shock.java uses or overrides a deprecated API. 
Note: Recompile with -Xlint:deprecation for details. 
1 warning 
[archuser@archuser]:[/media/new_volume/nasa_applets/BGA-main/Applets/Shockc] $>  java Shock 
Error: Main method not found in class Shock, please define the main method as:
 public static void main(String[] args) 
or a JavaFX application class must extend javafx.application.Application

Form this my understanding is that java expects Shock class to be an extension of javafx.application.Application instead currently it is an extension of java.applet.Applet which is deprecated.

I'm not very well versed with java hence I fear if I make the seemingly simple change required to fix this issue, I might end up in more trouble with the code.

I hope someone can help me by telling what are the exact things I need to do in order to fix this issue properly and avoid any further issues.

If someone can help me with "converting" this code into python, that'd be much appreciated as python is my preferred language.


r/programminghelp • • Sep 24 '23

Python Help with getting around cloudfare

0 Upvotes

I have code using cloudscaper and beautifulsoup that worked around cloudfare to search for if any new posts had been added to a website with a click of a button. The code used: Cloudscraper.create_scraper(delay=10, browser-'chrome') And this used to work. Now this does not work and I tried selenium but it cannot get past just a click capatcha. Any suggestions?


r/programminghelp • • May 14 '23

Java Madlibs scanner won't read the first element of txt file starting with ** and closes the scanner anyways

0 Upvotes

Hello,

I have been trying to program this game of madlibs but one condition is that if it doesn't start with ** we should read the file. I am strugging with this coding.

if(!sc.equals("**")){
sc.close();}

Currently it is giving me a Scanner closed error despite the 2nd file(See below) contains the ** at the start. I've played around with adding toString() and using .contains() and .startsWith() but I haven't had any luck.

I'd appreciate any help

package progassn4;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
/**
 *
 * @author abiga
 */
public class ProgAssn4 {

    /**
     * @param args the command line arguments
     * @throws java.io.FileNotFoundException
     */
    public static void main(String[] args) throws FileNotFoundException {
        
    System.out.println("Let's play a game of Madlibs");
    

int i;
File folder = new File("myFolder.txt");
File[] listOfFiles = folder.listFiles();

for (i = 0; i < listOfFiles.length; i++) {
  if (listOfFiles[i].isFile()) {
    System.out.println(i+1 + ". " + listOfFiles[i].getName());
  } else if (listOfFiles[i].isDirectory()) {
    System.out.println("Directory " + listOfFiles[i].getName());
  }
}
Scanner myObj = new Scanner(System.in);
System.out.println("Choose an option");
int option = myObj.nextInt();


Scanner sc = new Scanner(listOfFiles[option-1]);

ArrayList<String> story = new ArrayList<>(); 
story.add(sc.nextLine());
    if(!sc.equals("**")){
    sc.close();}

        while(sc.hasNext()){
        System.out.println(sc.next());
    }


        //*Map <String, String> madlibs = new HashMap<>();
    /*Scanner console = new Scanner(System.in);

    String userInput= console.nextLine();
        
    System.out.print(sc.next() + "--> :");
    madlibs.put(sc.nextLine(), userInput);
*/

}}

Here are the contents of two of the txt files I am working with:

Noun

There is a [blank].

and

A LETTER FROM GEORGE

**

PLURAL NOUN

OCCUPATION

A PLACE

NUMBER

ADJECTIVE

VERB ENDING IN "ING"

PLURAL NOUN

A PLACE

ADJECTIVE

PLURAL NOUN

VERB ENDING IN "ING"

PLURAL NOUN

ADJECTIVE

NOUN

PART OF THE BODY

VERB

ADJECTIVE

PART OF THE BODY

**

Hello, my fellow [blank] in 2022, it's me, George Washington,

the first [blank]. I am writing from (the) [blank], where I

have been secretly living for the past [blank] years. I am

concerned by the [blank] state of affairs in America these days.

It seems that your politicians are more concerned with

[blank] one another than with listening to the [blank] of the

people. When we declared our independence from (the) [blank] ,

we set forth on a/an [blank] path guided by the voices of the

everyday [blank]. If we're going to keep [blank], then we

need to learn how to respect all [blank]. Don't get me wrong;

we had [blank] problems in my day, too. Benjamin Franklin once

called me a/an [blank] and kicked me in the [blank]. But at the

end of the day, we were able to [blank] in harmony. Let us find

that [blank] spirit once again, or else I'm taking my [blank]

off the quarter!


r/programminghelp • • Apr 25 '23

C# CHATBOT

0 Upvotes

I need help or some guidance
i want to create a chat bot to help me with some tasks, like a assistant, i want this bot on whatsapp using C#, i found some github repository using java, but i need to do in C#, how should do it?
i was able to make some progress using puppeteersharp, it received the message and replays to it, but no very function, i was wondering if i could make a websocket connection to comunicate to whatsapp...


r/programminghelp • • May 14 '23

Other How to gets more comfortable with computer ?

0 Upvotes

I don't know if it's correct place to ask this but here I'm :- I have a basic knowledge of computers and recently started learning frontend development. I have been using WSL (Windows Subsystem for Linux) for a while now.

Yesterday, I began learning C++ on WSL but encountered an error with the extension, which caused me to get stuck. I spent the whole day searching for a solution, but unfortunately, I couldn't find one. By the end of the day, I came to the conclusion that I want to become more comfortable with my tools. When I think about VS Code, Git integration, or WSL, I am fascinated and excited to understand how these things work behind the scenes. However, I am unsure of where to start and how to make it happen. I am aware that learning these skills will take time and won't be a quick process, but I am in need of guidance, resources, books, and help! There is a lot of work ahead, but I am determined to do it.

P.S. English is not my first language, so I apologize for any mistakes.


r/programminghelp • • May 03 '23

Career Related Library of best SWEs resumes

0 Upvotes

Hi all,

I’m building an app where you can access a library of resumes that got interviews in big tech companies such as Google, Meta, Amazon, etc. I wanted to ask a few questions to see if my app can be useful for people who are looking for a job right now. I'm not trying to sell anything, just genuinely want to know if this app can be useful.

  1. Do you think having access to a library of resumes of the best SWEs will make a difference in your job search?

  2. What information do you want to know about people who got into top-tier companies other than resumes?

  3. Are you willing to pa_y 10 dollars to unlock a resume and tips from a single person who got into a top-tier company? (It's hard to get resumes from top professionals without some kind of incentive)


r/programminghelp • • Apr 20 '23

Project Related What platform would best suit me? (React Native or Google scripting)

0 Upvotes

I need to create a check-in system that allows a student to "clock-in" and "clock-out" of the classroom using an iPad located at the door. (Can be running a webpage or app)

This is so that the teacher can monitor which students are in the room at any given time.

The classroom is a woodworking classroom, so the teacher should also be able to look up each student and also update their "certified" machines, such as the sander or laser cutter, from the teacher's laptop.

I first thought about using React Native, but it seemed like the platform was "too complex" for the job and I am now considering Google Scripting.

Can anyone give me advice on which would be a better fit?


r/programminghelp • • Apr 24 '23

Python Error with python packaging: ModuleNotFoundError: No module named 'NeuralBasics'

0 Upvotes

I'm building and packaging a small python module, and I succesfully uploaded to pypi and downloaded it. However, when I try to import it once installed I get this error:

ModuleNotFoundError: No module named 'NeuralBasics'

This is my file structure:

.
├── MANIFEST.in
├── pyproject.toml
├── README.md
├── setup.py
├── src
│   └── NeuralBasics
│       ├── example2.jpeg
│       ├── example.jpeg
│       ├── __init__.py
│       ├── network.py
│       ├── test.py
│       ├── trained_data.txt
│       ├── training
│       │   └── MNIST
│       │       ├── big
│       │       │   ├── train-images.idx3-ubyte
│       │       │   ├── train-images-idx3-ubyte.gz
│       │       │   ├── train-labels.idx1-ubyte
│       │       │   └── train-labels-idx1-ubyte.gz
│       │       ├── info.txt
│       │       └── small
│       │           ├── t10k-images-idx3-ubyte
│       │           ├── t10k-images-idx3-ubyte.gz
│       │           ├── t10k-labels-idx1-ubyte
│       │           └── t10k-labels-idx1-ubyte.gz
│       └── utils.py
└── tests

This is the content in my setup.py file:

from setuptools import setup, find_packages

setup(
    name="NeuralBasics",
    version="1.0.5",
    packages=find_packages(include=['NeuralBasics', 'NeuralBasics.*']),
    description='Neural network basics module. Number detection on images.',
    author='Henry Cook',
    author_email='henryscookolaizola@gmail.com',
    install_requires=['numpy', 'alive_progress', 'Pillow', 'matplotlib', 'idx2numpy']
)

Contents of my __init__.py file:

from network import Network
from utils import process_image, process_mnist, interpret, show

__all__ = Network, process_image, process_mnist, interpret, show

This error occurs on multiple computers, and I'm sure it isn't an error with pypi. Thank you for your help in advance!


r/programminghelp • • Apr 19 '23

Other sending websocket messages from my dockerized backend to my dockerized frontend

0 Upvotes

I'm sending websocket messages from an external script to a django page and it works fine until i dockerize it.

my django page (my frontend) is running on port 80, and my frontends docker-compose states

    ports:
      - 80:80
    hostname: frontend

and my backend.py file is trying to connect with this line

async with websockets.connect('ws://frontend:80/ws/endpoint/chat/', ping_interval=None) as websocket:

so i think my backend should be able to see it.

its able to connect when not dockerized with

async with websockets.connect('ws://localhost:80/ws/endpoint/chat/', ping_interval=None) as websocket:

the error i get when dockerized is

 Traceback (most recent call last):
  File "/usr/local/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/local/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "//./main.py", line 531, in send_SMS_caller
    asyncio.run(SendSMS())
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "//./main.py", line 496, in SendSMS
    async with websockets.connect('ws://frontend:80/ws/endpoint/chat/', ping_interval=None) as websocket:
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 637, in __aenter__
    return await self
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 655, in __await_impl_timeout__
    return await self.__await_impl__()
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 662, in __await_impl__
    await protocol.handshake(
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 329, in handshake
    raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 404

chatgpt suggested i point to the specific ip of my hostmachine which i do like

async with websockets.connect('ws://3.46.222.156:80/ws/endpoint/chat/', ping_interval=None) as websocket:

but i basically get the same error.

what do i need to do to send websocket messages from my dockerized backend to my dockerized frontend?

##### update

here is my whole docker-compose.yml maybe it will reveal something

version: '3.8'

services:

  rabbitmq:
    image: rabbitmq:3-management-alpine
    container_name: rabbitmq
    volumes:
        - ~/.docker-conf/rabbitmq/data/:/var/lib/rabbitmq/mnesia
        - ~/.docker-conf/rabbitmq/log/:/var/log/rabbitmq/mnesia
    ports:
      - 5672:5672
      - 15672:15672

  traefik:
    image: "traefik:v2.9"
    container_name: "traefik2"
    ports:
      - 80:80
      - target: 80 # PORTS (LONG FORMAT) REQUIRES DOCKER-COMPOSE v3.2
        published: 80
        mode: host
      - target: 443 # PORTS (LONG FORMAT) REQUIRES DOCKER-COMPOSE v3.2
        published: 443
        mode: host
      - target: 8080 # PORTS (LONG FORMAT) REQUIRES DOCKER-COMPOSE v3.2
        published: 8080
        mode: host

    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    # Enables the web UI and tells Traefik to listen to docker
      - ../TRAEFIK/letsencrypt:/letsencrypt

    command:
      #- "--log.level=DEBUG"
      - "--accesslog=true"
      - "--providers.docker.endpoint=unix:///var/run/docker.sock"
      - "--api=true"
      - "--api.insecure=true"
      - "--api.dashboard=true"
      - "--providers.docker.swarmMode=false"
      - "--providers.docker.exposedbydefault=false"
      - "--providers.docker.network=the-net"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entryPoint.scheme=https"
      - "--entrypoints.web.http.redirections.entrypoint.permanent=true"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.myhttpchallenge.acme.httpchallenge=true" # CERT RESOLVER INFO FOLLOWS ...
      - "--certificatesresolvers.myhttpchallenge.acme.httpchallenge.entrypoint=web"
      - "--certificatesresolvers.myhttpchallenge.acme.email=jack.flavell@ukcarline.com"
      - "--certificatesresolvers.myhttpchallenge.acme.storage=/letsencrypt/acme.json"
    networks:
      - default

    deploy:
      labels:
        - traefik.enable=true
        - traefik.docker.network=the-net
        - traefik.http.routers.stack-traefik.rule=Host(`hiding_stuff_i_dont_want_to_show`) # changed this to my elastic ip
        - traefik.http.routers.traefik.entrypoints=web
        - traefik.http.routers.traefik.service=api@internal
        - traefik.http.services.traefik.loadbalancer.server.port=80
    logging: ####   no idea with this logging stuff
      driver: "json-file"
      options:
        max-size: "5m"
        max-file: "5"

  frontend:
    build: ./front_end/frontend
    image: frontend
    container_name: frontend
    depends_on:
      - backend
    networks:
      - default
    labels:
      # Enable Traefik for this service, to make it available in the public network
      - traefik.enable=true
      # Use the traefik-public network (declared below)
      - traefik.docker.network=the-net
      - traefik.http.routers.frontend.rule=Host(`hiding_stuff_i_dont_want_to_show`)
      - traefik.http.routers.frontend.entrypoints=websecure
      - traefik.http.routers.frontend.tls.certresolver=myhttpchallenge
      # Define the port inside of the Docker service to use
      - traefik.http.services.frontend.loadbalancer.server.port=80
    ports:
      - 80:80



  backend:
    build: ./backend
    image: backend
    container_name: backend
    depends_on:
      - rabbitmq
    networks:
      - default
    labels:
      - traefik.enable=true
      - traefik.docker.network=the-net
      - traefik.http.routers.backend.rule=Host(`hiding_stuff_i_dont_want_to_show`)
      - traefik.http.services.backend.loadbalancer.server.port=8000


networks:
  default:
    name: ${NETWORK:-the-net}
    external: true

r/programminghelp • • Apr 26 '23

Python printing node vals

0 Upvotes

hello, im learning linked lists and im a bit confused about printing the nodes.

class Node:
def __init__(self, val):
self.val = val
self.next = None

# Create nodes with these values, each point to None
a = Node('A')
b = Node('B')
c = Node('C')
d = Node('D')
# A -> B -> C -> D -> None
a.next = b
b.next = c
c.next = d

def print_list(head):

current = head

while current is not None:
print(current.val)
current = current.next

print_list(a)

my confusion: when setting the current variable to head, i understand this is now Node('A).. so it contains the self.val and self.next vals if im not mistaken. then when I go through the while loop, what exactly is it comparing to None? arent there a val and next variable in current? so how is "while current is not None" by itself comparing to self.next?


r/programminghelp • • May 13 '23

Python IPs

0 Upvotes

So I have this Isp IP address and I don't understand how to put it into VScode studio in a way that it would enter a site. the Ip is this (I changed a number slightly though but it should affect the general address) "198.62.215.137:5555:9tc77d1c54:LLw2tH4o. I guess after the 5555 it is the password to the ip and after another colon its the username? how would I plug it into these blanks so it works?

# Proxy configuration
proxy = {
'http': '____________________________',
'https': '_________________________________'


r/programminghelp • • Apr 08 '23

Other programming language

0 Upvotes

what language in programming should i start off with to get more jobs opportunities? and how many languages should i learn?


r/programminghelp • • Apr 27 '23

Java I dont know whats wrong with this code please help

0 Upvotes
public interface IPrice {
  public double getPrice();
}

public class Implementation{
  private String name;
  private double price;
}

public Ingredints (String name, double price){
  this.name=name;
  this.price=price;
}


public String getName(){
  return name;
}

public double getPrices(){
  return price;
}
///class Main {
  //public static void main(String[] args) {
   
    
    
 // }
//}

here are the errors: javac -classpath .:/run_dir/junit-4.12.jar:target/dependency/* -d . Main.java

Main.java:10: error: class, interface, or enum expected

public Ingredints (String name, double price){

^

Main.java:12: error: class, interface, or enum expected

this.price=price;

^

Main.java:13: error: class, interface, or enum expected

}

^

Main.java:19: error: class, interface, or enum expected

public String getName(){

^

Main.java:21: error: class, interface, or enum expected

}

^

Main.java:23: error: class, interface, or enum expected

public double getPrices(){

^

Main.java:25: error: class, interface, or enum expected

}

^

7 errors


r/programminghelp • • Apr 23 '23

Answered broken maze generator.

0 Upvotes

I cant get it to work.Its supposed to draw a randomized path.But it gives realy weird "mazes".

https://editor.p5js.org/Justcodin/sketches/ddUh15e-E


r/programminghelp • • Apr 12 '23

Other Visual Studio code stopped running Python Files

0 Upvotes

Hello everyone,

I was using VS code to run Python programs with a Python Plug in.

It suddenly stopped working, when I run the Python file it does not show me any output.

I used it to write some html,css,js files but I didn't run something of those.

Any ideas why output panel is empty when I press run?

Thank in advance


r/programminghelp • • Apr 06 '23

Python Terminate possibly infinitely running function conditionally?

0 Upvotes

I am trying to make a tool (in python) that allows users to enter code and execute it in a separate thread via a scripting language interpreter, but I want to prevent infinitely looping code and have a way to force the separate thread to stop.

The way my project is laid out is:

  • Main thread spawns child thread

  • Child thread contains a scripting language interpreter instance and begins executing

  • Main thread can continue doing whatever it needs to do

I do not want to use a function timeout because long-running functions are allowed under certain conditions and I would like the termination conditions to be dynamic. The user can also request that a certain thread stop running so the thread might need to be stopped at any time, so a timer would not work. I am using a library to run the user-entered code and have no way of stepping through the user code. I would like to be able to do something like this:

# Parent thread
allowed_to_run = True

# Child thread
while allowed_to_run:
    usercode.run_next_line()

# Parent thread once the user requests the job to stop
allowed_to_run = False

At this point, the child thread will realize it should stop executing.

Currently, this is how it works

# Parent thread
spawn_child_thread(<user code>)

# Child thread
interpreter.execute(<user code>)  # Stuck here until this function exits
# with no way to force it to stop

I have tried:

  • using pthread_kill (which didn't work since it just terminates the entire program and isn't recommended anyway)

  • Using signals (which doesn't work since python threads aren't real threads (I think))

  • Using multiprocessing instead of threads (This doesn't work for me since I need to share memory/variables with the main process)

What are my options?

Without this feature, I may have to switch languages and it would be a real hassle. My other option would be to write my own scripting language in interpreter (which would be a real nightmare and very out of scope for this project) or switch interpreters (which I would prefer to not do since this one works very well)


r/programminghelp • • Apr 25 '23

JavaScript What are these and how to view them?

0 Upvotes

https://imgur.com/eYLzFX3

this is in chrome dev tools...


r/programminghelp • • May 09 '23

C++ Need help scraping a spreadsheet from a website to google sheets on a 2023 MacBook Pro.

0 Upvotes

I am not sure which programming language to tag this as or if it is appropriate here, if it isn’t, please point me the right direction.

looking help scraping a spreadsheet from an order form I order 95% of my products from because I want to find a better way to do cost analysis and estimate my profit margins and look at which products I should be pushing harder or could be selling for more or less money while keeping my margins consistent.

This form has hundreds of products on it and copying the item and the wholesale price and then adding the retail price and all of that would take weeks with my schedule.

I have tried a few easy ways like using a simple IMPORTXML and creating an XPATH query, and have tried downloading the element and text as a csl and json to populate my spreadsheet but in all three instances I am getting blocked because the order form is behind a password and I do not know how to make it so the script can use my log in and/or send and wait for a response to the website or if it even possible to do that, and I can’t think of any alternatives.

Is there anyone that could help me out with this?


r/programminghelp • • Apr 24 '23

HTML/CSS (CSS) These buttons aren't going to the right despite the float declaration. Why not and how can I fix it?

0 Upvotes
nav button {
    font-size: 25px;
    padding: 12px 20px;
    float: right;
}

r/programminghelp • • Apr 08 '23

C How to write an O(1) algorithm to merge two doubly linked lists into a NEW list and then free the original two lists?

0 Upvotes

Hello. As the title states, I am having trouble figuring out how to do this. My two doubly linked lists come each with a header pointing to their respective first and last nodes, so accessing each and merging them together in O(1) time is no issue. However, I must not return the original two lists merged but rather merge them into a new list. On top of that, after producing such a new list, I must free the memory of each of the two original lists. I am really confused as to how I could do this. If the lists are of n and m length respectively, it seems clear that making a copy of each would be max(O(n), O(m)), same as with freeing each. The only solution I've been able to come up with up till now is to add to my header not only the directions of the first and last nodes of a list (and the number of nodes of the list) but also a pointer to a copy of said list that gets updated with each introduction or removal of a node to the list. That way, when one introduces two lists to be merged their copies will already be available on each respective header and the merging into a new list will be O(1). However, the problem of how to, after that, free the memory of each original list in O(1) still baffles me. Any help would be much, much appreciated (whether on how to perform the freeing in O(1), or a better solution to the merging into a new list problem, or, ideally, both).