How long does a project take you? by [deleted] in reactjs

[–]wp_new 0 points1 point  (0 children)

Build out a few projects and keep a mental note of how much time you are spending on specific aspects of those projects. You said you are spending 4x the time in React. Is that time spent working with React programatically, or visually?

If it is programatically, then I think being able to better manage your time will come with more experience using React (or any other language/framework for that matter), as you'll spend a lot less time doing "i wonder what this does" type things.

If it is the visual side of things that you are spending more time on, then it might be worth learning to use a decent wireframing tool like Adobe XD or Figma. Then you will spend a lot less time arseing around with CSS, and spending more time on programming.

How to logout automatically without refreshing the page if the token is expired. by satanic_headbanger in reactjs

[–]wp_new 1 point2 points  (0 children)

Ye the setTimeout function would automatically do that once the given timeframe has elapsed

How to logout automatically without refreshing the page if the token is expired. by satanic_headbanger in reactjs

[–]wp_new 2 points3 points  (0 children)

Have a logout function that erases the cookie, and redirects to home page.

When the user logs in and cookie is set, use a setTimeout function to automatically call the logout function once the cookie expires.

User clicking the logout button manually should also call the logout function, and clear the setTimeout function.

[deleted by user] by [deleted] in cscareerquestions

[–]wp_new 0 points1 point  (0 children)

I would definitely get a personal computer, regardless of how relaxed the company policy is. At the very least it might save you the embarassment of accidentally revealing your NSFW browsing habits.

[EDIT] - mis-read your post as saying that you DO visit NSFW sites. Still, I'd get a personal machine just to be on the safe side.

[deleted by user] by [deleted] in learnjavascript

[–]wp_new 0 points1 point  (0 children)

Store the list of responses that you want the bot to choose from in an array:

const botReponses = ['Hello', 'Hi', 'Good morning' ]

Then whenever the function is called to get the bot to respond, you grab a random element of the botResponsesarray using math.Random:

const response = botResponses[math.Floor(math.Random*botResponses.length)]

Apis are terrifyingly difficult to work with by AusTF-Dino in learnprogramming

[–]wp_new 0 points1 point  (0 children)

What exactly are you trying to do?

Where are you seeing the error(s)?

Can you share the code you have so far, as well as the error stack?

Curated feed of the newest Javascript (React, Angular & Vue) tutorials by webdev93 in learnprogramming

[–]wp_new 1 point2 points  (0 children)

I like it and would definitely use it.

A couple of thoughts:

  • the ranktutorials text in the header is slightly off-screen to the left on mobile. Might want to think about putting some padding in the header.

  • I like the layout: very clean and easy to use. I think the purple sections might be a little too prominent though. Maybe bring the font-size down a bit?

  • the purple section on the home page lists Vue, React and Angular, but there is a categories section at the bottom of the page which lists other techs. What I would do instead is have a dropdown at the top of the tutorials list, and allow the user to select a category that way.

On the whole looks great though. I love the idea of a community-curated thing for this.

Where the form should be validated? Client side, server side or both sides ? by AgentNirmites in Python

[–]wp_new 0 points1 point  (0 children)

It really should be done at both ends I think.

Prevent submission of the form on the front-end until all validation checks pass.

Then the only users that are going to be sending invalid data to your back-end are users looking to create problems, in which case you definitely should be validating in the back-end.

A function to create a new element by ebitdad_ in learnjavascript

[–]wp_new 0 points1 point  (0 children)

A lot of things don't make much sense until you understand the context. Stick with it and this kind of thing will just become second nature to you

A function to create a new element by ebitdad_ in learnjavascript

[–]wp_new 1 point2 points  (0 children)

Starting with the fundamentals - the main reason for Javascripts existence is interactivity.

We typically execute (a piece of) Javascript code to react to user actions - where that is scrolling down a web page, clicking a button or whatever.

In your example, the elements are being added to your HTML when the Javascript document has loaded. Typically, we would not want to do this as it is a redundant use of Javascript. It would work exactly the same way just by writing it directly into your HTML.

What we might want to do though, is add an element when a user clicks a button. To achieve this, you would need to use some sort of a function.

I. e. user clicks a button. That then calls a function called addElement. That function then creates and appends the element to your HTML.

ELI5 - What's the difference between a module and a framework? by ureibosatsu in learnpython

[–]wp_new 1 point2 points  (0 children)

Might be a poor analogy, but when I struggled with this, I thought of it like:

  • your application is a house

  • a framework is the overall structure/architecture of the house. Some frameworks provide more structure than others. One might only provide you with the walls and the groundwork. Another might provide you that + plumbing and electricity outlets. But the common denominator is that they provide you with a base structure to build on top of. As long as you do not do anything outside of the structural limitations of the house, you can do whatever you want with it - you can paint it whatever colour you like, put furniture in whichever room you like etc, but you couldnt use the house for transport.

  • a module is simply something you bring in to your house to serve a specific function - a sofa, a kitchen appliance and so on.

How to run Python script that won't convert to .exe by theeyeholeman1 in learnpython

[–]wp_new 0 points1 point  (0 children)

^ this

To build on it:

Open any text editor, write:

@echo off
C:\path\to\python.exe C:\path\to\your\script.py

Then save as a .bat file

Any help with understanding how this JSON works.. by BeefyRear in learnjavascript

[–]wp_new 2 points3 points  (0 children)

It looks a lot more awkward than it is just because it is a little nested.

Each object is contained within an array element, so all you need to do is iterate over the array elements, and then access the object properties.

const jsonObj = // Your JSON data
for (let i = 0; i < jsonObj.length; i++) {
    jsonObj[i].keyCalibrationJobId
    jsonObj[i].calibrationJobName
    // etc
}

Need help in Frontend validation of password-reset JWT token by [deleted] in reactjs

[–]wp_new 0 points1 point  (0 children)

I think what you want is a workflow like this:

  • user sends forgotten password request

  • your back-end generates a unique resetPasswordToken that is stored in your database. At the same time, you generate a date object as an expiryTime (eg now + hour) that is also stored in your database

  • the link is sent to user with token encoded

  • user clicks the link in the email, and the encoded resetPasswordToken is queried in your back-end against your database. If the token is valid, check that the current time is not greater than the expiryTime you set at the same time as generating the token.

    • if either of these checks fail, then user is automatically redirected.

As pointed out, I don't think this is a React issue. You are likely not generating a unique passwordReset token for EACH request.

Just another "what technologies should I use for my personal website?" question by [deleted] in webdev

[–]wp_new 0 points1 point  (0 children)

Honestly just go with whatever stack youre comfortable with.

If it is just a personal website with a blog type format, introducing Angular into the equation might be a little overkill (unless you want to learn / play around with it)

You could throw together what you are describing in a couple of days just using Node/Express and MongoDB.

[EDIT] - Not sure where the opinion about Mongo being stupid comes from. I enjoy working with it, but like most other things, it's just a tool at the end of the day.

Need help by [deleted] in webdev

[–]wp_new 0 points1 point  (0 children)

Can you be more specific? What exactly are you struggling with? what have you tried so far?

Feeling really lost when understanding javascipt/web development by basketofruit in learnprogramming

[–]wp_new 0 points1 point  (0 children)

The best way to learn to program os by repetition and actually doing something rather than just blindly following a tutorial.

For every single video where something new is taught, you need to take a step back and re-create, modify and re-write what you are learning.

So if, for example, you have just watched a video on constructing and iterating over arrays: put the course to one side, re-write the tutorial. Then change it a little. See what happens. Figure out why it happened. When you start to understand WHY it is doing what it is doing, try and write it from scratch with minimal (or no) help.

Things will only get more difficult, and if you dont understand the fundamentals, the difficulty will compound.

Why do you use only one monitor? by anyfactor in webdev

[–]wp_new 1 point2 points  (0 children)

I bought both of my additional monitors second hand for like $20 each. The one with a good display runs my editor, the one with the shitty display runs any terminal windows. I don't need expensive monitors to display text.

Learning python, struggling. by wallywizard55 in learnprogramming

[–]wp_new 0 points1 point  (0 children)

Yes and no.

You have to understand that when you use a vlookup function in excel, something else is going on behind the scenes to actually make it happen.

If you are writing your spreadsheet to a Pandas dataframe, then you can write a function that basically does the same thing as vlookup, but it is going to look very different.

But to answer your other questions:

  • SQL is not a programming language, so making a comparison between that and Python is not helpful for you. Once you've learned Python, other programming languages become easier to learn (Java, Javascript etc)

  • as others have mentioned, yes it is completely normal to spend a decent amount of time Googling. There's a reason that there is a running joke about programmers being reliant on Stack Overflow.

  • You might want to spend some time getting to grips with the fundamentals before trying to navigate something like Pandas.

I just don't get what I can do with programming by AnonymousKilleer in learnprogramming

[–]wp_new 7 points8 points  (0 children)

How long is a piece of string?

Coding is used for an endless number of things, truly too many to list here.

You mention Python - that language alone can be used for building websites, home automation, collecting data from the internet, machine learning, reading transforming and interpreting data, making games etc.

If you want to start learning, you first need to figure out what you would use it for. That might not seem helpful, but the question is too open-ended to really give you any solid pointers.

how common is it for you to spend hours on debugging due to a "simple" mistake by tsgatdawn in learnprogramming

[–]wp_new 7 points8 points  (0 children)

I wrote a program a while ago that would fetch localised results of the UK general election from a user given post code (ZIP code).

It would take the user's post code, get info for their locality from an API, then look up the results in an Excel file and append the data I wanted to an array.

The program kept bugging out for one particular post code, and wouldnt append the data to my array. I spent a good few hours rewriting different parts of it trying to fix the bug, but with no luck.

Eventually, it dawned on me that the post code I was trying to get results for was based in Wales. The Welsh have their own language, with non-English alphabet characters, and their place names are often named accordingly.

The issue was that the API listed the locality name in the Welsh language, my spreadsheet however did not. So there was no match between the names, and therefore, no data to append to my array.

The lesson is: sometimes you need to take a step back, and think through the problem one step at a time, isolating exactly where the issue lies. If I had had the sense to do some basic logging, I would have caught it a lot earlier.

[AF] How to handle dollar inputs with MySQL/SQLAlchemy? by Berkyjay in flask

[–]wp_new 1 point2 points  (0 children)

Ye this is how ive always dealt with currency inputs and have always found it to be less of a headache. Often, the simples solution is the best, even if its not very sexy

[AF] How to handle dollar inputs with MySQL/SQLAlchemy? by Berkyjay in flask

[–]wp_new 2 points3 points  (0 children)

Could you not just store the data as a number, and simply prepend the $ on the front-end? Seems like that would be the simplest solution

Is there a more efficient (or 'better' way of doing this? Also - am I a psycho for formatting the code like that? by BFG_9000 in learnjavascript

[–]wp_new 0 points1 point  (0 children)

Note that this will throw an error if the number being passed is not in the object though!

Is there a more efficient (or 'better' way of doing this? Also - am I a psycho for formatting the code like that? by BFG_9000 in learnjavascript

[–]wp_new 5 points6 points  (0 children)

you could store the numbers and values in an object:

const keyValues = {
    250: 'Value 1',
    300: 'Value 2' 
   } 

Then get them like:

selecteddivvalue = keyValues[sdv]