/r/CodingHelp
Join our discord server: https://discord.gg/r-codinghelp-359760149683896320
1. FLAIR YOUR POSTS! Don't put tags in post titles!
2. Do not ask us to do all the coding for you unless you have money to spend. (If you have got money to spend, make that clear and the amount in question).
3. Do not post spam and/or misleading titles.
4. Do not be abusive to other coders.
5. Please format code properly, or use a site such as Gist or Pastebin. If possible please provide a live example of your issue.
6. Do not downvote people because you think they asked a dumb question. Just because you think that someone has a dumb question, doesn't mean that it is dumb to them.
7. Do not have a misleading user flair. Keep them sensible, describing your level of coding ability and/or languages you know and/or your profession.
8. Please do not ask unethical questions, such as asking for homework to be written by someone else, or asking someone to copy another project directly.
9. Make sure to follow the Reddit Rules.
Check our website https://codinghelp.site we have all the information you need there!
If you have any suggestions for flairs (programming languages or generic coding topics) that we should add, please use the button below to message the mods with your suggestion.
If approved as a sensible flair for the community to use, it will be added to our bot for automated suggestions and to the flair list for everyone to use!
Anyone who abuses this by spamming mods will be banned.
Green
Web Related Languages (Eg HTML, CSS)
Blue
App Related Languages (Eg Python, C#)
Red
Generic Coding Topics (Eg Open Source)
Yellow
Other Flairs (Eg Random, Meta)
/r/CodingHelp
Hi!
So, i got an interview about email marketing and in the assessment they are asking about some coding (although they say I won't do it on my job... HR right?) anyways, can you help me to know what is it that they want me to fix?
thanks:
In the below block of HTML, we need to update the images and URLs to feature the bedding category. Can you please highlight the elements that you would update to do this? Any other changes that you would recommend making besides the URL and image changes to ensure best practices are met?
align="center" style="padding-bottom: 0px; font-size: 0px; line-height: 0px;"><a href="https://havenly.com/shop"><img alt="Havenly" class="w100pct" src="https://d2axdqolvqmdvx.cloudfront.net/d2bc1078-b978-4772-aded-ee37b75e3fd0/EditorialBanner2.gif" style="display: block; border: 0px; width: 660px; font-size: 12px;" width="660"></a><a href="https://havenly.com/blog/contemporary-outdoor-patio-furniture"><img alt="Outdoor Trends" class="w100pct" src="https://d2axdqolvqmdvx.cloudfront.net/a158cf82-88e8-4e38-8248-2a7b80bb6961/4\_6\_OutdoorTrends\_FINAL.gif" style="display: block; border: 0px; width: 660px; font-size: 12px;" width="660"></a><</td>
Now, what if this block of HTML was too wide within a design - highlight what you would change:
align="center" style="padding-bottom: 0px; font-size: 0px; line-height: 0px;"><a href="https://havenly.com/shop"><img alt="Havenly" class="w100pct" src="https://d2axdqolvqmdvx.cloudfront.net/d2bc1078-b978-4772-aded-ee37b75e3fd0/EditorialBanner2.gif" style="display: block; border: 0px; width: 660px; font-size: 12px;" width="660"></a><a href="https://havenly.com/blog/contemporary-outdoor-patio-furniture"><img alt="Outdoor Trends" class="w100pct" src="https://d2axdqolvqmdvx.cloudfront.net/a158cf82-88e8-4e38-8248-2a7b80bb6961/4\_6\_OutdoorTrends\_FINAL.gif" style="display: block; border: 0px; width: 660px; font-size: 12px;" width="660"></a><</td>
I'm having some issues with my cubemap. It looks like the images are being flipped and/or reflected in some way such that when the rendering loop occurs, the faces of the cubemap split at the seams and you can see the reflection of the other side of the cube. I can attach any necessary code if needed, but I'm trying to practice WebGL and can't figure this out.
A screen recording of what's happening here: https://imgur.com/qiPdEuw
Hi, i downloaded Kali linux on virtualbox. Whenever I try to download vscode inside of Kali linux my host computer gives me a blue screen and then it restarts my computer, i have no idea what could cause this.
So I wrote a code to live plot BTC prices and used CCXT too provide history data points and used websocket to provide live data and connected them. but the problem I am running into is the live updated price isnyt retaining the timeframe of the past data
I can get the components to work and do their stuff and I know that they have already been thoroughly tested by the creators of this library, but I want to make sure the componenets display the right things and fire the right events that I passed in as custom props.
Here is a basic example.
import { render, screen } from "@testing-library/react";
import { describe, it, expect } from "vitest";
import { Button } from "react-aria-components";
describe("Button Component", () => {
it("renders a regular button", () => {
render(<button>Click Me</button>);
const buttonElement = screen.getByRole("button");
expect(buttonElement).toBeInTheDocument();
});
it("renders a react-aria-button", () => {
render(<Button>Click Me</Button>);
const buttonElement = screen.getByRole("button");
expect(buttonElement).toBeInTheDocument();
});
});
I set up the testing environment and import the stuff I need, including the Button component from the library.
I then run 2 tests, both of which render a simple button. The first test renders a regular/manually created button, and the second one uses the <Button> component from the library.
The results:
TypeError: Cannot read properties of null (reading 'useContext')
❯ Button Component (2)
✓ renders a regular button (passed)
× renders a react-aria-button (failed)
...
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
I then looked at the source code of the Button component, and realized I don't want to rebuild the entire thing using only react-aria (not react-aria-components).
I also looked at the react docs on "Rules of Hooks". I understand what the rule means, but I have no idea what I have to do in this situation.
Lets say I want to use my button in a little more complex manner:
import { Button } from "react-aria-components";
export function Btn_profilePreviewIcons({
icons,
onClick = () => alert("No function provided"),
visibleIcon_COUNT = 1,
IS_open,
activeDigit,
aria_LABEL,
}) {
const [dance, setDance] = useState(false);
const handleDance = () => {
if (dance) return;
setDance(true);
setTimeout(() => {
setDance(false);
}, 1000);
};
const displayedIcons = icons ? icons.slice(0, visibleIcon_COUNT) : [];
const remainingTagsCount =
displayedIcons.length > 0 ? Math.max(0, icons.length - visibleIcon_COUNT) : 0;
return (
<Button
className={css["btn-show-icons"]}
data-open={IS_open}
onClick={() => {
onClick();
handleDance();
}}
data-dance={dance}
data-testid="btn-profile-preview-icons"
aria-label={aria_LABEL}
>
{activeDigit}
{icons &&
displayedIcons.map((icon) => (
<img
key={icon}
src={icon}
alt=""
className={css.icon}
data-testid="tag-preview-btn-icon"
/>
))}
{!icons && <p data-testid="no-tags">No tags</p>}
{remainingTagsCount > 0 && visibleIcon_COUNT && (
<>
{remainingTagsCount === 1 ? (
icons && (
<img
src={icons[visibleIcon_COUNT]}
alt=""
className={css.icon}
data-testid="tag-preview-btn-icon"
/>
)
) : (
<p data-testid="hidden-icon-count">+{remainingTagsCount}</p>
)}
</>
)}
</Button>
);
}
And I am only talking about unit testing. How in the world should I do integration tests with more complex components like a Date picker if I can't implement them in my tests?
Does this mean I need to complelety separate my logic and my other props from the component and test them separately? That would be such a hassle.
I'm a rookie. Would appreciate any help I could get.
I'm trying to create a voice-to-voice web app using an AI platform API wherein users can talk to the AI using their voice.
The app has a WebSocket endpoint which sends back AI voice response when it receives user's voice command. In their docs, they specify that the audio input is to be sent in the form of a audioIn message. The audio must be mono (single channel) µ-law (mu-law) encoded at 16000Hz and sent as base64 encoded string.
As for the output, it is specified that the Audio output from the server will be received in an audioStream message. The data field contains base64 encoded audio binary in the selected outputFormat.
I'm having trouble initializing the browser mic and then managing, converting and sending the audio in right format. Also need help with processing the audio data received.
If someone can help me implement the API, I'd be happy to pay
10010001110111100000000 can someone tell me how to calculate Hamming code for this numbers ive been trying 2 hours and chat gpt dont even explain it to me ive tried everyting please save me from summer semester
APPRECIATED))
hello, i am trying to make a ray recursion function but for some reason i am gettingn black splotches as a result? I thought maybe it was the normals and some pixel by pixel error but im just not sure how to go about fixing this? I wish i could show a picture but i have 2 spheres and theyre suppsoed to have reflections. Now they do have reflections but a bunch of black spots are showing on them and it looks wrong.
void shade_ray_recursive(int level, double weight, Ray* ray, Intersection* inter, Vect color)
{
Vect direction;
Vect position;
double e = 1.0e-15;
Surface\* surf = inter->surf;
Ray\* reflect;
// Initialize color to Phong reflectance model
shade\_ray\_local(ray, inter, color);
Vect final\_color = { 0,0,0 };
// Store final color separately for shading
printf("max level:%d\\n", maxlevel);
maxlevel = 2;
// If not too deep, recurse
if (level + 1 < maxlevel) {
// Add reflection component to color
if (surf->reflectivity \* weight > minweight) {
printf("In function\n");
// Calculate reflected ray direction using reflection formula
double dot = VectDotProd(inter->N,ray->dir);
direction[X] = ray->dir[X] - 2 * dot * inter->N[X];
direction[Y] = ray->dir[Y] - 2 * dot * inter->N[Y];
direction[Z] = ray->dir[Z] - 2 * dot * inter->N[Z];
VectUnit(direction);
// Offset the position slightly to avoid self-intersection
position[X] = inter->P[X] + e * direction[X];
position[Y] = inter->P[Y] + e * direction[Y];
position[Z] = inter->P[Z] + e * direction[Z];
// Create a reflected ray
reflect = make_ray(position, direction);
// Trace the reflected ray recursively
trace_ray(level + 1, weight * surf->reflectivity, reflect, color);
// Free memory allocated for the reflected ray
free(reflect);
}// Add refraction component to color
if (surf->transparency * weight > minweight) {
// Handle refraction here if needed
}
}
public class Main {
public static void main(String[] args) {
int[] x = {6, 8, 3, 9, 4};
int n = x.length;
for (int j = 0; j < n-1; j++)
x[ j ] = x[ j+1 ];
for (int j = n-1; j > 1; j--)
System.out.print(x[ j ]);
}
} \\can someone explain to me how this works i have no idea (java btw)
I have little experience with JavaFX and I'm not too knowledgeable in regard to what return statements to input for the UML class diagram. I'm also not sure what to import to the main class so I can actually perform this. I would greatly appreciate the help.
I have this project in c when I test it it gives me "segmentation fault (core dumped) can any one help me fix it BY TOMMOROW I am willing to pay.
I need to create some kind of software or app that reads through an excel file I have with a bunch of home addresses. I want this program to search each address on Zillow and see what year the home was built. Is that an easy thing for someone with very little programming knowledge to do? I just have a very large database of addresses I need to look up and I wanted to see if I could automate it easily. Where would I even build something like this?
Forgive me if I'm in the wrong sub for this, if you know of a better sub where I can ask this let me know.
how can i do these in real time without paying for an actual server
I just learned the basics of AI development and I can't really find any simple product example to implement the stuff that I've learned, any suggestions?
private State getState() {
// returns the state of Mario
//if velocity is greater than 0, Mario is jumping or if he was jumping in the previous state while falling
if (body.getLinearVelocity().y > 0 || ((body.getLinearVelocity().y < 0 && previousState == State.JUMPING))) {
return State.JUMPING;
} else if (body.getLinearVelocity().y < 0) {
return State.FALLING;
} else if (body.getLinearVelocity().x != 0) {
return State.RUNNING;
} else {
return State.STANDING;
}
}
I got this code from Brent Aureli, however, I'd like to know what's causing a problem:
first i know that:
when mario jumps and falls from that jump, he will be continuously in that jump state.
when mario falls off a cliff, instead of going into a jump state, he will go into a falling state.
however, when mario hits his head on a ceiling, his jump state is cut short abruptly?
I've tried setting conditions for whenever y velocity hits 0 which i assume is what happens when his head hits the ceiling, however doesnt velocity hit 0 at the top of a jump as well?
I'm trying to find out if there's a way to keep the jumping state after hitting a ceiling from the jump
Hi,
I’m looking for some help/ guidance on how difficult it would be to create a software program that would use plaid or another alternative to connect to a business bank account and look for specific withdraws and deposits within that account?
Then it would do some basic calculations/ math and that would be used for push notifications. Etc..
I know plaid is pretty popular, but curious if there’s anything better and how expensive this would be to build out.
So ive been trying to add a macro that will flip the sign of a formula or value in excel. It does this by multiplying to cell by -1. However this does work by flipping the sign, it does not remove the parentheses its added surrounding the cell if i run it again to flip the sign again and they just continue to build up if I keep running the macro.
If it keep running the code the formula ends up looking sometihng like this =((((20*2))))
Heres the code
"Sub FlipSign()
Dim rng As Range
Dim cell As Range
' Check if any cells are selected
If Not Selection Is Nothing Then
Set rng = Selection
For Each cell In rng
' Check if the cell contains a numeric value
If IsNumeric(cell.Value) And Not cell.HasFormula Then
cell.Value = cell.Value * -1
' Check if the cell contains a formula
ElseIf cell.HasFormula Then
' If the formula is already multiplied by -1, remove this multiplication
If Left(cell.formula, 4) = "=(-1" And Right(cell.formula, 1) = ")" Then
cell.formula = "=" & Mid(cell.formula, 6, Len(cell.formula) - 6)
Else
' Multiply the entire formula by -1
cell.formula = "=(-1*(" & Mid(cell.formula, 2) & "))"
End If
End If
Next cell
End If
End Sub"
I created another macro that can remove these parentheses
"Sub RemoveParenthesisAndNegativeSign()
Dim cell As Range
Dim formula As String
' Loop through each selected cell
For Each cell In Selection
' Check if the cell contains a formula
If cell.HasFormula Then
' Get the formula in the cell
formula = cell.formula
' Check if the formula starts with "=" and contains a negative sign and parentheses
If Left(formula, 1) = "=" And InStr(formula, "-(") > 0 Then
' Remove negative sign and parentheses
cell.formula = "=" & Mid(formula, 4, Len(formula) - 4)
End If
End If
Next cell
End Sub"
however I would like to combine it into the first macro so it does this
Ex: When macro is run the cell will look like this =(-1*(20*2)). When I run it again I want it to look like this =20*2
Any help? Thanks!
Also anyone feel free to use this code if you would like a FlipSign Macro!
Hey guys so I’m working with XQuery and need a function to remove white space and specialised characters (E.g £@!-?) from the value of a specific XML node such as:
(/… [1]/…. [1]/….[1]/Example) [1]
I need this to be done using SQL Server compatible XQuery functions(I previously tried XPath “replace” but that was not compatible with SQL Server), these include:
Any help would be greatly appreciated,
Thanks guys
‹!DOCTYPE html>
<html > <head> <title> JavaUser1</title> <script lang="JavaScript"> function reveal(){ var magic =document.ITLoginform.elements[0].value; document.write("firstname"+magic+"lastname"+ kagic+"password" + jagic+"Email"+ dagic); var kagic = document.Iname.elements|0].value; var jagic = document.Email.elements[0].value; var dagic = document.Pword.elements[0].value; } </script> </head> ‹body> <h2> Login Form</h2> <form name = "ITLoginform"> <label for="fname" >First name:</label><br> <input type="text" id="fname" name="fname"> <br> <label for="Iname"> Last name:</label><br> < input type="text" id="Iname" name="Iname" ><br> < label for="pass"> Password:</label ><br> <input type="text" id="Pword" name="Pword"> <br> <label for="email"> Email Address:</label > <br> <input type="text" id="email" name="email"> <br><br> <input type="button" value="Submit" onClick="reveal()"> </form> </body> </html>I have a monorepo, with private packages. There is MAIN, and a package-mini.
Main package is widely using package-mini across the components this with no error as:
import { foo } from "@workspace/package-mini";
But, when I do the same within gatsby-config.ts I get build errors like: ReferenceError: Cannot access 'A' before initialization.
The ugly workaround is just to use a relative path since my packages are private are in the same repo:
import { foo } from "../package-mini";
I'm reading in Gatsby Docs that workspaces are not supported. Is that referring to the config so there is basically no other choices? I tried setting alias but no difference.
Hi, I have an up coming BCS exam for Principles in Coding Level 3.
Just wondering if there's anyone out there that has done this exam and can provide me with any past papers or answer sheets?
Thanks
Hi, I would like to have a code that allows me, just by entering the name of an Instagram account, to obtain its 50 most liked photos, to be able to download them all at once as well as their descriptions. THANKS !
Hello dear community.
So me and a few friends are doing a project in physics class in which we created a quadratic function of a jet stream of a hole made in a plastic bottle.
As the code is created by Chatgpt on Python, due to me having not competence in coding, I can't post it on here. Additional Information, im able to edit the parameters as im understanding some basics. I'd share the Github with anyone who is interested.
But as right now, I have the function displayed as a rocket wich lands on the y axis on the moon. I think the theme is kind of off from the original topic. So im looking for cool ideas to display our function.
Maybe some of you have some cool ideas which are more related to our ''problem''.
My friend gave me a cpp project running perfectly fine in visual studio with run button both in release and debug mode (not using cmake), however i want to run in vscode. There i am facing "undefined reference to " errors, he is using tinycbor, the problem is coming from functions of tinycbor. I think it is a linker problem but it sucks i want to get rid of it as soon as possible i dont know what should i do. I think
Is there any way to check or have the same configuration as visual studio for vscode
I tried using cmake but i am not understanding which files to link.
Hey 👋, I have my own agency which helps in all kinds of coding assignments or projects for students like you. If you are facing any challenges with your assignments or projects, do reach out to me, my developer can help for sure.
We have developers for almost all coding languages and all tech stacks. But it is mandatory to add one flair so I am adding Java for now.
Thanks!
Hello, first here is my code
install.packages("fastDummies")
library(class)
library(caret)
library(fastDummies)
# Read data
business_data <- read.csv("C:/Comp sci
stuff/yelp_academic_dataset_business_converted.csv")
review_data <- read.csv("C:/Comp sci stuff/541
Proj/yelp_academic_dataset_reviews_modified_true1.csv")
# Sample reviews
num_rows <- nrow(review_data)
num_rows_to_keep <- floor(num_rows / 10)
sampled_reviews <- review_data[sample(num_rows,
num_rows_to_keep), ]
# Merge data
combined_data <- merge(business_data, sampled_reviews, by
= "business_id")
selected_data <- combined_data[, c("user_id", "business_id",
"user_rating", "rest_overall_rating", "categories")]
# Check unique values and data types
print(unique(selected_data$rest_overall_rating))
print(class(selected_data$categories))
head(selected_data)
View(selected_data)
class(selected_data$categories)
remove_u <- function(category_string) {
# Replace 'u' with an empty string
cleaned_category <- gsub("u'", "", category_string)
return(cleaned_category)
}
# Remove 'u' character from categories
selected_data$cleaned_categories <-
sapply(selected_data$categories, remove_u)
selected_data$categories <- NULL
clean_category <- function(category_string) {
# Check if the category string is in dictionary-like format
if (grepl("^'?[a-zA-Z]+': ?[a-zA-Z]+$", category_string)) {
# Extract the category name from the string (remove single
quotes and ': True')
category_name <- gsub("^'([a-zA-Z]+)':.*", "\\1",
category_string)
# Capitalize the first letter of the category name
category_name <- paste0(toupper(substr(category_name,
1,
1)), substr(category_name, 2, nchar(category_name)))
} else {
# If not in dictionary-like format, use the original category
name
category_name <- category_string
}
return(category_name)
}
# Clean category names in the cleaned_categories column
selected_data$cleaned_categories_2 <-
sapply(selected_data$cleaned_categories, clean_category)
View(selected_data)
# View the updated dataframe
print(selected_data)
View(selected_data)
is.na(selected_data)
dummy_cols(selected_data, select_columns =
c("cleaned_categories_2"))
# Create train-test split
set.seed(255)
trainIndex <-
createDataPartition(selected_data$rest_overall_rating,
times = 1,
p = 0.8,
list = FALSE)
train <- selected_data[trainIndex, ]
test <- selected_data[-trainIndex, ]
print("-----------------")
nrow(train)
ncol(train)
dim(train)
length(train)
nrow(test)
ncol(test)
dim(test)
length(test)
View(train)
View(test)
# Train the model
model <- knn(train = train[, c("rest_overall_rating",
"categories")],
test = test[, c("rest_overall_rating", "categories")],
cl = train$user_rating,
k = 5)
# Make predictions
predictions <- model
# Evaluate the model
accuracy <- sum(predictions == test$user_rating) /
length(test$user_rating)
cat("Accuracy of K-NN model:", accuracy, "\n")
The problem occurs on this line
dummy_cols(selected_data, select_columns =
c("cleaned_categories_2"))
where I get this error
Error in if (m < n * p && (m == 0L || (n * p)%%m)) stop(sprintf(ngettext(m, : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In n * p : NAs produced by integer overflow 2: In n * p : NAs produced by integer overflow
The column I am trying to convert is a character column according to the class(selected_data$categories) line
Here is a look at the df if it helps: https://imgur.com/a/594u602 I don't have much other info to give as I am lost even after searching online so any help would be appreciated.
am creating a small little website that allows you to add pictures and stuff to it, a lil gallery basically. I want to make it so once an image is added to an image slot, it is saved there even if you refresh or exit the page, please help!
so im currently doing a college work and generative ai just gave me a code where it uses CLOB instead of Varchar, is it going to put my college's connection in any danger? (I really need to write paragraphs inside serveral lines so...)
EDIT: I didnt have a perfect answer yet but apparently its better to use VARCHAR2 cause it can store up to 4000 characters and my text is 1000 wide, so yeah, almost sure varchar2 is better then clob.
I am in dire need of help to do what’s honestly a simple assignment but I don’t know where to even start.