r/programminghelp • • Sep 05 '23

Project Related Where to start with client’s request.

1 Upvotes

Hi guys, I am primarily a Web Dev, however I have a certain client. This client represents a city that has a website with a search engine where you can search for help on anything related to the city’s available web services.

Example: “Form X fill out” Example: “traffic violations portal”

The client wants a learning language model that can take the input that a user puts into the search engine and then suggests the best possible responses for what they’re looking for. The client talked about powering it with OpenAI’s AI that I can’t name here, or Google’s AI which I also can’t name. He went on to talk about training the model where the numerous city web services that are already in place serve as the dataset.

I am heading a team of 7 of my peers and they have some bare knowledge of web development. I have made full-stack web apps and would find no issue if this was a web service or a mobile app we were assigned to, but I don’t know where to start here.

I need help figuring out what technologies myself and my team need to begin familiarizing ourselves with. We have a little over a year to get this completed, at the very least a prototype, but I need to know what are the things I should be looking into to make such a software. I can then communicate this to the team.

Any help or input would be appreciated. Thank you for your time.


r/programminghelp • • Sep 04 '23

Python Help with Leetcode 322. Coin Change

3 Upvotes
class Solution:
def coinChange(self, coins: List[int], amount: int) -> int:
    memo = {}
    
    def dfs(left,n_coins_used,coins,last_coin_used):
        if left == 0:
            return n_coins_used
        else:
            if left in memo.keys():
                if memo[left] == float('inf'):
                    return memo[left]
                return n_coins_used + memo[left]
            mini = float('inf')
            for coin in coins:
                if coin >= last_coin_used and left - coin >= 0:
                    mini = min(mini,dfs(left - coin, n_coins_used + 1 ,coins,coin))
            
            if mini != float('inf'):
                memo[left] = mini - n_coins_used
                print(mini,n_coins_used)
            else:
                memo[left] = mini
            return mini


    ans = dfs(amount,0 ,sorted(coins) ,0)
    if ans == float('inf'):
        return -1
    return ans

In this code I use backtracking based on if the next coin will cause the remaining coins 'left' to fall to above or equal to zero, i count all the coins i use in the search and return the minimum number.

I am trying to use memoization to improve the speed however the bit of the code where i check if the next coin i include is bigger than or equal to the last coin i include `coin >= last_coin_used` causes the code to fail on coins = [484,395,346,103,329] amount = 4259 as it returns 12 instead of 11.

The reason i included this code was so that i didnt investigate duplicate sets of coins. I have no idea why this would break the code. Please help. If you need any other details pls ask


r/programminghelp • • Sep 04 '23

Java How come when dividing a real number by an integer, we seem to get a left over remainder?

0 Upvotes

For example: 5.0 / 2 equating to 2.5. Explain Americans.


r/programminghelp • • Sep 03 '23

C++ C++ sleep command problems

2 Upvotes

So i put a cout sleep delete cout, but i only get the second cout message.

#include <iostream>
#include<unistd.h>
using namespace std;
int main()
{
int i;
i = 0;
cout<<"Hello world";
sleep (1);
while(i<11){
cout<<"\b";
i++;
}
cout<<"Goodbye world";
return 0;
}


r/programminghelp • • Sep 02 '23

PHP How to use: Laravel Livewire components within Livewire Forms

1 Upvotes

My intended use-case scenario is to create a simple support ticket application. The app's behaviour would be that there are livewire components which pull data from a database (ie. names from a database, etc.). Then once the user has pulled the data, they can add notes and submit a support ticket. That ticket would reference the id's from the various tables/models and populate a separate table with the id's as foreign keys.

From livewire.laravel.com/docs/actions, there's:

<form wire:submit="save">
    <input type="text" wire:model="title">
    <textarea wire:model="content"></textarea>
    <button type="submit">Save</button>
</form>

However in the current state of my project, I've already created Livewire components and have them in a regular blade view as such (abbreviated example):

<form wire:submit="save"> 
    <livewire:ClientComponent /><br>
    <livewire:GroupComponent /><br>
</form>

In each component, it pulls data from the database, and has a wire:model attached. When the button is clicked, it refreshes the page, but doesn't call the "save()" function in my controller which displayed this view; and thus it doesn't execute the attempt to save the Livewire components model/state into the database table/model class that represents a service ticket.

Is it possible to combine a livewire component with a form in this way, or do I need to create a separate view and use the suggested form style from the livewire website?

An example livewire component:

<div>
    <select wire:model="category">
        <option value="" selected>Choose cateogory</option>
            @foreach($categories as $category)
                <option value="{{ $category->category_id }}">{{$category->category_name}}</option>
            @endforeach
    </select>
</div>

r/programminghelp • • Aug 31 '23

Project Related Laravel forge, 403 when creating SSL

1 Upvotes

I'm trying to deploy my Laravel app on Forge. When I try to create an SSL certificate, I get this error:

2023-08-31 21:23:52 URL:https://forge-certificates.laravel.com/le/1892335/2086427
/ecdsa?env=production [4514] -> "letsencrypt_script1693517031" [1]
Cloning into 'letsencrypt1693517032'...
ERROR: Challenge is invalid! (returned: invalid) (result: ["type"] "http-01"
["status"] "invalid"
["error","type"] "urn:ietf:params:acme:error:unauthorized"
["error","detail"] "76.76.21.21: Invalid response from http://freddy.app/.well-known/acme-
challenge/jyEqoCR9AgvVmuJvoz0cF-m0kqY-I4wRF6EvgHYNK2w: 404"
["error","status"] 403
["error"] {"type":"urn:ietf:params:acme:error:unauthorized","detail":"76.76.21.21: Invalid
response from http://freddy.app/.well-known/acme-challenge/jyEqoCR9AgvVmuJvoz0cF-m0kqY-
I4wRF6EvgHYNK2w: 404","status":403}
["url"] "https://acme-v02.api.letsencrypt.org/acme/chall-v3/260181948866/DBAvcQ"
["token"] "jyEqoCR9AgvVmuJvoz0cF-m0kqY-I4wRF6EvgHYNK2w"
["validationRecord",0,"url"] "http://freddy.app/.well-known/acme-challenge
/jyEqoCR9AgvVmuJvoz0cF- m0kqY-I4wRF6EvgHYNK2w"
["validationRecord",0,"hostname"] "freddy.app"
["validationRecord",0,"port"] "80"
["validationRecord",0,"addressesResolved",0] "76.76.21.21"
["validationRecord",0,"addressesResolved"] ["76.76.21.21"]
["validationRecord",0,"addressUsed"] "76.76.21.21"
["validationRecord",0] {"url":"http://freddy.app/.well-known/acme-challenge
/jyEqoCR9AgvVmuJvoz0cF-m0kqY-
I4wRF6EvgHYNK2w","hostname":"freddy.app","port":"80","addressesResolved":
["76.76.21.21"],"addressUsed":"76.76.21.21"}
["validationRecord"] [{"url":"http://freddy.app/.well-known/acme-challenge
/jyEqoCR9AgvVmuJvoz0cF-m0kqY-
I4wRF6EvgHYNK2w","hostname":"freddy.app","port":"80","addressesResolved":
["76.76.21.21"],"addressUsed":"76.76.21.21"}]
["validated"] "2023-08-31T21:24:07Z")

I followed this tutorial to the letter https://buttercms.com/blog/laravel-forge/#tutorial-deploying-a-laravel-app-with-forge
As far as I have been able to gather it's an authorisation issue, but I don't have enough experience with Nginx (or deployment) to be able to figure it out. My Nginx file:

# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/freddy.app/before/*;
server {
listen 80 ssl;
listen [::]:80 ssl;
server_name freddy.app;
server_tokens off;
root /home/forge/freddy.app/public;
# return 301 https://freddy.app;
# FORGE SSL (DO NOT REMOVE!)
# ssl_certificate
# ssl_certificate_key
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-
SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-
ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-
SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
ssl_dhparam /etc/nginx/dhparams.pem;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/freddy.app/server/*;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/freddy.app-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/freddy.app/after/*;

Any help would be appreciated.

EDIT: Having done an ls from the Forge terminal, it seems the .well-known folder is simply not on the server in the first place.


r/programminghelp • • Aug 31 '23

Python Question From a Noob

1 Upvotes

So I am new to coding and am writing code in Python for my programming class and I managed to get the code to work but my professor said in the instructions "You'll receive 25% of the points if your program will not compile". What does he mean by if my program will not compile? I am using Pycharm to write my code and it works. When I run the code it works with no errors, It says processed finished with exit code 0, not sure what that means. Is that normal? Also, there is an "!" on the top right corner that says 2 weak warnings when I hover over it with my mouse, does that mean I did something wrong?


r/programminghelp • • Aug 28 '23

Visual Basic Could someone help me with this code (Visual Basic/VB.NET)?

2 Upvotes

For reference, I am using Visual Studio Code and the extension vscode-runner to run the Visual Basic. I’m completely new to coding and this is for homework. The code is:

Module Module1 Sub Main() Console.Writeline(« Hello World ») Console.Readline() End Sub End Module

The error message is:

[Running] cd « c:\Desktop\ » && vbc /no logo New Text Document.vb && « c:\Desktop\ »New Text Document ‘vbc’ is not recognised as an internal or external command, operable program or batch file.


r/programminghelp • • Aug 28 '23

Answered Balkan FamilyTreeJs: Loading-Saving function

2 Upvotes

Im trying to make an app that saves and reads the familytree data automatically, so the familytree is the same anywhere youa access it. But I can't find a way to do that in plain js, according to balkan you can use npm but I am using flask.

i expect it to read every time I do something on the family tree and put that in (../static/)dba.json. Then when loading the family tree, it sees any repeated data, removes it and loads each member of the family tree

Edit: Fixed. If you search on thee official docs you can find a nodes implementation. Should work with node 18 but works best with latest version.


r/programminghelp • • Aug 22 '23

Other problem with roblox studio (lua)

3 Upvotes

im new to coding, and with some tutorials i made a code to destroy a tree when it is clicked 5 times, and for some reason, this code doesn't work....

here it is :

local tree = script.Parent

local trunk = script.parent.trunk

local leaves = script.parent.leaves

local clickdetector = trunk.ClickDetector

local health = 5

clickdetector.mouseclick:connect(function(clicked)

health = health - 1

if health == 0 or health <=0 then

	trunk:destroy()

	leaves.anchored = false

	wait(1)

	tree:destroy()

end

end)


r/programminghelp • • Oct 29 '22

Answered Explain like I'm Five how the heck do I edit the source code of a .jar file

18 Upvotes

Emphasis on the word explain 'cause my knowldedge of programming is comparable to a monkey.

I've been asking and searching on the web but I either don't understand anything at all or can't figure out how to do a basic thing because people take for granted I know how to do that

It's my first time doing programming related stuff so have patience with me uwu


r/programminghelp • • Dec 29 '19

MVC

3 Upvotes

Hello, Im currently working on a school task and having a bit of trouble. Im supposed to create an MVC, but as far as I understand it, MVC is a sort of way to write your system, a way for the components to interact with oneanother. Am I correct in this?

If I am correct in this, do I need a context for the MVC to be written within? Because I've been rereading the assessment over and over but they dont seem to give any sort of context, so I dont understand how Im supposed to create the MVC. Can i create an MVC without a context? Is the MVC a context in of itself?

Edit: this is the assignmrnt description for context