Categories
Mastering Development

Randomly generate pw as a default for new users and then let them change password later on using php

Hello everyone I am new to web dev and working on my personal project using php. I successfully generated 9 digit default pw for new users. I would like to let admin have visibility for the default 9 digit pw for new users. However, I don’t want admin to have visibility for newly changed user […]

Categories
Mastering Development

Trying to run function only if state changes

I want to run the set totals function only if the hours state has changed. if (this.state.hours > 0) { this.setState((prevState) => { if (prevState.hours !== this.state.hours) { console.log(prevState.hours); } return { total: this.state.total + this.state.hours * ratePerHour * Math.PI, }; }); console.log(this.state.total, ‘+’, this.state.hours, ‘*’, ratePerHour); } useEffect(() => { console.log(pCR.hours, ‘Final Quote Run’, […]

Categories
Database Development

MySQL right join with tables of rows in 100000s very slow

The following join is taking far too long in MySQL, almost half a day and it’s still not finished: INSERT INTO aaaaa SELECT * FROM chosenLang RIGHT JOIN chosenLOCC_P ON SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(chosenLang.call,’.’,1),’ ‘,1),’*’,1) LIKE concat(chosenLOCC_P.code,chosenLOCC_P.reference) chosenLang has 413826 rows, 42 columns (38 of them longtext, 3 of them varchar, 1 of them int(11)). call is varchar. […]

Categories
Mastering Development

Does the order of the comparison conditions matter when using OR operators in an IF function?

I’m trying to get a better understanding of the conditions within an IF statement. When I change the order of the conditions I receive a TypeError of undefined. I receive a TypeError: Cannot read property ‘length’ of undefined when the order is changed to: if (row < 0 || col < 0 || row === […]

Categories
Mastering Development

Does the order of the comparisons matter when using OR operators in IF statements?

I’m trying to get a better understanding of conditions within IF statements. When I change the order of the conditions I receive a TypeError of undefined. I receive a TypeError: Cannot read property ‘length’ of undefined when the order is changed to: if (col === maze[row].length || row < 0 || col < 0 || […]

Categories
Mastering Development

Octave least squares approximation

So i’ve got a task. That’s here: What values does the model F (t) = x(1) + x(2)*t^2 + x(3)sin(πt) best fit in the least squares sense of the following data take place at 1.0? t=[0.1 0.3 0.4 0.8 0.9] f=[2.06 2.91 3.19 3.16 2.89] t=[0.1 0.3 0.4 0.8 0.9]’; f=[2.06 2.91 3.19 3.16 2.89]’; […]

Categories
Database Development

How to remove wildcard character from field

I have fields that contain the character *. I’ve been trying to remove them but my commands fail with an error… Example: UPDATE name SET name = REGEXP_REPLACE (name, ‘*’, ”) WHERE category_id = 168; I’m also struggling to remove other characters like |

Categories
Mastering Development

replace special char in pyspark dataframe?

I have a column with value *NZ, i want to remove the *, df.groupBy(‘State1’).count().show() (5) Spark Jobs +———–+—–+ | State1|count| +———–+—–+ | NT| 1423| | ACT| 2868| | SA|12242| | TAS| 4603| | WA|35848| | *NZ| 806| | QLD|44410| | missing| 2612| | VIC|40607| | NSW|45195| +———–+—–+ I have tried these two df = df.select(“State1”, […]

Categories
Mastering Development

Sorting an array pulled from database using $obj->select

I have inherited a project from another developer that has a bunch of dropdown menus that pull information from the database. The way this is set up is as follows: $agent_list = $obj->select(TABLEPRIFIX.’agent’, ‘*’, [‘status’ =>1 ]); If I am reading this correctly it is basically saying “select table ‘the_agent’ and grab everything with a […]

Categories
Database Development

Replace a sequential set of numbers with special character

I have a varchar(200) column that contains entries such as, ABC123124_A12312 ABC123_A1212 ABC123124_B12312 AC123124_AD12312 A12312_123 etc.. I want to replace a sequence of numbers with a single * so that I can group the distinct non-numeric patterns in the table. The result for this set would be ABC*_A* ABC*_B* AC*_AD* A*_* I have written the […]