Tuesday, March 15, 2022

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Need insight on how to replicate design in CSS

Posted: 15 Mar 2022 04:22 AM PDT

I need some advice/pointers on how to approach this design in CSS : https://imgur.com/a/eFzyAPC

I'm trying to learn CSS, but I am a bit overwhelmed by the complexity of this design. Any pointers would be appreciated.

This is what I've tried: https://jsfiddle.net/4fs91j8t/23/ , however as you can see I can't seem to get the spacing right for each tile, as it overflows into the next.

HTML:

<div class="card-labels">    <div class="label-title">    Product details    </div>    <div class="label-title">    Category    </div >    <div class="label-title">    Quantity    </div>    <div class="label-title">    Price    </div>    <div class="label-title">    Delivery    </div>    <div class="label-title">    Actions    </div>  </div>    <div class="card-product">    <div class="product-details">       <img src="https://images.pexels.com/photos/10164553/pexels-photo-10164553.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" class="product-image">       <div class="product-description">         <div class="product-title">         Sample product         </div>         <div class="product-seller">         Seller         </div>            </div>      </div>  </div>  

CSS:

body{    background-color: #F3F6FA;  }  .card-labels {    width: 80%;    margin: auto;    display: flex;    flex-direction: row;    justify-content: space-between;  }  .card-product {    width: 80%;    height: 160px;    margin: auto;    background-color: #FFFFFF;    border-radius: 35px;   }  .product-details {    width: 400px;    display: flex;    flex-direction: row;    justify-content: start;    align-items: center;  }  .product-image{    width: 120px;    height: 120px;    margin: 20px;  }   

Javascript Choices are not printing

Posted: 15 Mar 2022 04:22 AM PDT

I did console.log(questionEl) and it is printing well as I coded (currentQuiozData.question) but the choices are not working. They don't bring currentQuizData.a so printing only Question.

const quiz = document.getElementById("quiz");  const answerEls = document.querySelectorAll(".answer");  const questionEl = document.getElementById("question");  const a_text = document.getElementById("a_text");  const b_text = document.getElementById("b_text");  const c_text = document.getElementById("c_text");  const d_text = document.getElementById("d_text");  const submitBtn = document.getElementById("submit");    let currentQuiz = 0;  let answer = undefined;    loadQuiz();    function loadQuiz() {      deselectAnswers();      const currentQuizData = quizData [currentQuiz];        questionEl.innerText = currentQuizData.question;        a_text.ineerText = currentQuizData.a;      b_text.ineerText = currentQuizData.b;      c_text.ineerText = currentQuizData.c;      d_text.ineerText = currentQuizData.d;  };

<div class="quiz-header">              <h2 id="question">Question text</h2>              <ul>                  <li>                      <input type="radio" id="a" name="answer" class="answer" />                      <label id="a_text" for="a">Question</label>                  </li>                  <li>                      <input type="radio" id="b" name="answer" class="answer" />                      <label id="b_text" for="b">Question</label>                  </li>                  <li>                      <input type="radio" id="c" name="answer" class="answer" />                      <label id="c_text" for="c">Question</label>                  </li>                  <li>                      <input type="radio" id="d" name="answer" class="answer" />                      <label id="d_text" for="d">Question</label>                  </li>              </ul>          </div>

Regex to capture portion of filename

Posted: 15 Mar 2022 04:22 AM PDT

I have the below regex statement within my python script that I use to help build a SQL BULK INSERT statement to populate several tables in a SQL DB via CSVs.

for filename in gl.glob("(Compressed)_*.csv"):      filekey = re.match(r"^\(Compressed\)_([A-Z0-9-]+_[0-9A-z]+)_[0-9]{8}_[0-9]{6}.csv$", filename).group(1)  

The filenames do vary although they follow a similar pattern where they begin with the string "(Compressed)_" followed by an alphanumeric "identifier", and then a date "15032022" and time "100028" string. Examples of the filenames are:

  • (Compressed)_A123_10_15032022_100028.csv
  • (Compressed)_T985_4160_15032022_100028.csv
  • (Compressed)_GDAF_Fault_MSG_15032022_100028.csv
  • (Compressed)_T600_INC_Header_15032022_100028.csv

The sections highlighted in bold are the strings that I'd extract. So far this works for all the examples shown above. However I've come across a different filename structure that isn't captured.

New Filename:

  • (Compressed)_GXXY_20_TIC008416_FTR_01_02_20_to_19_02_20_11032022_153430.csv

Again, I only want to extract the bold part of the above CSV as this would be my identifier. How can I amend my regex statement to capture this new format while retaining the capture of the original filenames too?

how to render html template in javascript from flask

Posted: 15 Mar 2022 04:22 AM PDT

and my script is : const starting = 3; let time = starting;

countdownEl = document.getElementById('countdown');

setInterval(updateCountdown,1000);

function updateCountdown(){ let seconds = time; countdownEl.innerHTML = ${seconds}; if (time > 0) { time--; }

if (time == 0) {      window.location="{{ url_for('disinfect') }}";  }  

}

Getting System.ArgumentOutOfRangeException: Length cannot be less than zero

Posted: 15 Mar 2022 04:22 AM PDT

 System.ArgumentOutOfRangeException: Length cannot be less than zero.  Parameter name: length     at System.String.Substring(Int32 startIndex, Int32 length)  

Getting above exception from below code. I am already checking for -1.

    int tableMasterIndex = tableMaster.IndexOf(':');          if (tableMasterIndex == -1) {              continue;          }            int tableMasterId = int.Parse(tableMaster.Substring(0, tableMasterIndex));          string[] codeValues = tableMaster.Substring(tableMasterIndex + 1).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);  

clang-format file not working in Visual Studio code

Posted: 15 Mar 2022 04:21 AM PDT

I have put a .clang-format file in my workspace. But that formating is not applied on my code. I have checked the settings and they are set to None for fallback-style and file for clang_format_style.

The good news is that the fallback Style doesn't work anymore. Which means when I try to Format the Document or Selection nothing happens. Please help. Thanks

Hibernate query hangs on one machine only

Posted: 15 Mar 2022 04:21 AM PDT

I have a Java application deployed on Glassfish server. During the move from one Windows 7 to another PC with Windows 10 I have encountered a very strange problem. As I launch local dev environment, connecting to the same database, with the same versions of war artifacts, on the new machine, everything seems to be working fine, but when I try to access one function, it just freezes. No error messages, the http request is never answered.

I connected to the debug port on Glassfish and tracked down exactly the line that never executes. It's the hibernate Query object .list() method. It's supposed to execute a SELECT.

I tried deploying artefacts, tried different versions, confirmed that they ARE being deployed, added logging to make sure that the code stops where I think it does, no change in the behavior.

The same artifact, copied to my old machine works without a problem. The difference between environments, aside from OS, is the fact that new machine is connecting via VPN, while the old one is on the local network, however I don't think this could matter, as obviously the connection to DB is established.

Environment:

  • Glassfish 2.1.1
  • Java 1.8
  • Hibernate version: 5.4.21
  • DB: JNDI Oracle
  • JDBC version: 19.3.0.0

Making a program to visualize sensor data

Posted: 15 Mar 2022 04:21 AM PDT

I have a task to make a program capable of visualizing data coming from a variety of sensors through the serial port in a real-time fashion. The measurements can last up to a month, the horizontal and vertical axes should be scalable mid-run and there should also be a possibility of writing information to a csv-file mid-run. I tried using Streamlit for this but it doesn't really support some of the features that i've specified here. Any ideas as to what could get the job done in this case? Tkinter sounds like a possibility. Thank you.

How To Play Music From Any Music Platform like Spotify, amazon music, etc. Using Python

Posted: 15 Mar 2022 04:21 AM PDT

I am new to python programming so forgive me if this question is too basic. I am trying to play music from a music platform like Spotify using python. I was able to play songs using python, but I had to download the mp3 of that song and then play it. There are a lot of songs I like & I can't keep downloading all of them, so I thought that I can play music from any other music platform like Spotify, amazon music, etc. I tried with the 'spotipy' module but it didn't work.

Any help would be appreciated.

Creating tabs with html and javascript

Posted: 15 Mar 2022 04:22 AM PDT

I'm new in these things so this might be an easy one. I want to create tabs with the following code from w3schools. The original one is here: https://www.w3schools.com/howto/howto_js_tabs.asp

I don't want images to be in the tabcontent section. So I made a new class named tabimage and added it to the javascript. Also I've added new events with the image's ids at the html. But it keeps showing other tabs when clicked. Can anyone help?

function openCity(evt, cityName) {    var i, tabcontent, tablinks;    tabcontent = document.getElementsByClassName("tabcontent tabimage");    for (i = 0; i < tabcontent.length; i++) {      tabcontent[i].style.display = "none";    }    tablinks = document.getElementsByClassName("tablinks");    for (i = 0; i < tablinks.length; i++) {      tablinks[i].className = tablinks[i].className.replace("active", "");    }    document.getElementById(cityName).style.display = "block";    evt.currentTarget.className += "active";  }
body {font-family: Open Sans;}  .order {    display: grid;    /* grid-template-columns: 1fr 1fr;*/      }  /* Style the tab */  .tab {    overflow: hidden;    border: 1px solid #ccc;    background-color: #f1f1f1;  }    /* Style the buttons inside the tab */  .tab button {    background-color: inherit;    float: left;    border: none;    outline: none;    cursor: pointer;    padding: 14px 16px;    transition: 0.3s;    font-size: 17px;  }    /* Change background color of buttons on hover */  .tab button:hover {    background-color: #ddd;  }    /* Create an active/current tablink class */  .tab button.active {    background-color: #ccc;  }    /* Style the tab content */  .tabcontent {    display: none;    padding: 6px 12px;    border: 1px solid #ccc;    border-top: none;  }  .tabimage {    display: none;    padding: 6px 12px;    border: 1px solid #ccc;    border-top: none;  }
<div class="order">  <div class="tab">    <button class="tablinks" onclick="openCity(event, 'London'); openCity(event, 'London1')">London</button>    <button class="tablinks" onclick="openCity(event, 'Paris'); openCity(event, 'Paris1')">Paris</button>    <button class="tablinks" onclick="openCity(event, 'Tokyo')">Tokyo</button>  </div>    <div id="London" class="tabcontent">    <h3>London</h3>    <p>London is the capital city of England.</p>      </div>    <div id="Paris" class="tabcontent">    <h3>Paris</h3>    <p>Paris is the capital of France.</p>   </div>    <div id="Tokyo" class="tabcontent">    <h3>Tokyo</h3>    <p>Tokyo is the capital of Japan.</p>  </div>        <img src="https://cdn.shopify.com/s/files/1/0044/8718/4457/files/800x600_Wallpaper_Blue_Sky.png?v=1646897329" class="tabimage" id="London1">     <img src="https://cdn.shopify.com/s/files/1/0044/8718/4457/files/Auckland_Skyline_800x600_80c6b2c0-28bc-4885-8440-a6da7de39c82.jpg?v=1646897329" class="tabimage" id="Paris1">          </div>

Show api data in JSX, React

Posted: 15 Mar 2022 04:22 AM PDT

trying to load the props data into the jsx, when I try to iterate it inside the return, getting an error of .map not defined.

const SavedListTable = (props) => {      console.log(props);      const {listData, setListData} = props;           if(setListData.length > 0) {          return(              setListData.map((setListData, index) => {                  console.log(setListData)                  return(                      <div>                          <tr>                          <td >{setListData.name}</td>                          <td >Project</td>                          <td>00 May 2022</td>                          </tr>                      </div>                    )                })                                                )        }    

this is the response from for console.log(props)

{notes: Array(8)}  notes: (8) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]  [[Prototype]]: Object  

Simulator overload in Xcode 13.3 (13E113)

Posted: 15 Mar 2022 04:21 AM PDT

When launching Xcode today, I was prompted that additional components needed to be installed. Had no other choice but to accept and man did I get more than I bargained for! The list goes on an on, next is the iPad Air (5th generation) with just as many and so on.

So far I have relaunched Xcode and the simulator, but to no avail.

Any one else experiencing this?

Confusion matrix for FASTER R-CNN

Posted: 15 Mar 2022 04:21 AM PDT

I have trained my faster r-cnn model but i need precision, recall value. I have searched on google and I have found something about it.

I have found this link(https://github.com/svpino/tf_object_detection_cm ) and I have implemented it like enter image description here Step1 :

python infer_detections.py --input_tfrecord_paths=C:/tensorflow1msff/models/research/object_detection/test.record --output_tfrecord_path=C:/tensorflow1msff/models/research/object_detection/inference_graph/detection_tfrecord --inference_graph=C:/tensorflow1msff/models/research/object_detection/inference_graph/frozen_inference_graph.pb

but Step 2 : I have failed enter image description here

python confusion_matrix.py--detections_record=C:/tensorflow1msff/models/research/object_detection/inference_graph/detection_tfrecord.record--label_map=C:/tensorflow1msff/models/research/object_detection/training/labelmap.pbtxt-- output_path=C:/tensorflow1msff/models/research/object_detection/confusion_matrix.csv

https://github.com/svpino/tf_object_detection_cm/issues/12

As you can see Picture 2 : There is a syntax error. And Can you help me how can I fix that ? File "confusion_matrix.py", line 159 for record in tf.python_io.tf_record_iterator(<tfrecord_file>): ^ SyntaxError: invalid syntax

How to understand sched_period in the cfs schedule class?

Posted: 15 Mar 2022 04:22 AM PDT

As far as I understand, __sched_period is the time incurred in making the task runnable again. When the processes are less than sched_nr_latency, the CFS scheduler splits time into periods in which each process is anticipated to run once.

u64 __sched_period(unsigned long nr_running)  {      if (unlikely(nr_running > sched_nr_latency))          return nr_running * sysctl_sched_min_granularity;      else          return sysctl_sched_latency;  }  
  1. Does each process have a maximum of 'sysctl_sched_latency/2' time to run or do we have to perform 'sysctl_sched_latency/2' for each process if we have two processes with the same weight?

  2. What about context switching time, scheduler cost calculation, and other factors? What does the sched_period consist of?

Makefile only recompile changed files

Posted: 15 Mar 2022 04:21 AM PDT

I am trying to write a makefile but it does not do exactly what I want. I have the following files:

a.h, b.h, c.h, d.h, main.h

a_functions.c, b_functions.c, c_functions.c, d_functions.c, main.c

main.c includes main.h

And every x_functions.c includes x.h

I want make to recompile only the files that have been edited.

This is how my code looks like now:

CC = gcc  CFLAG = -Wall -Werror  OBJ = program1  CPPFLAGS += -MD -MP  SRC = $(wildcard *.c)     all: $(SRC:%.c=%.o)      $(CC) $(SRC) -o $(OBJ)    -include $(SRC:%.c=%.d)  

What do I need to change to make it work? I have tried to find an answer on google but I can't find something that works (or something that I understand how to use)

Need guidance in using ORDER BY when using LISTAGG

Posted: 15 Mar 2022 04:22 AM PDT

SELECT B.ID,  LTRIM(LISTAGG(ITEM_ID,';')WITHIN GROUP(ORDER BY B.PG_NO), '0') as PROCESS_ID  FROM table1 A  JOIN table2 B  ON A.CAS_ID=B.CAS_ID  WHERE B.DATE = '2022-03-03'  AND B.ID IS NOT NULL  AND P_CD NOT IN ('1','2','5','7')  AND A.ID IN(12690222,24515955)  GROUP BY B.ID  

When I run the above query, I'm getting results as mentioned below:

ID           PROCESS_ID    12690222     5544973696;5544973696;5544973696;5544973696  24515955     777239598;777239598;777239598  

I want to display only the distinct values in PROCESS_ID column and the results should be ordered by PG_NO column. Kindly guide me how to achieve this.

How would you do that opening effect with React Native?

Posted: 15 Mar 2022 04:21 AM PDT

Imagine a feed of items and then you click on one item and it opens in this way. We need to create a news app that has this identical animation (check sec 00:13 of video linked). enter link description here

Use return data from one function in another and pass it to Smarty template

Posted: 15 Mar 2022 04:21 AM PDT

What I'm trying to do is to have one datatable probably as a template and passing different datas on different pages.

Example functions.php

function force() {      global $DBconn;      $q =  "SELECT * FROM table";      $res = $DBconn->query($q);                                          return $this->result;  }    function force_1() {      global $DBconn;      $q =  "SELECT * FROM table_1";      $res = $DBconn->query($q);                                    return $this->result;  }    function table() {          echo '           <table class="sortable">              <thead>              <tr>                  <th>                      Title                  </th>              </tr>              </thead>              <tbody>';                  foreach ($this->result as $key) {                 echo ' <tr>                      <td>                          $key->name                      </td>                  </tr>';                  }              echo '</tbody>          </table>';      }    return true;  }  

Then in the page.php

$table = table();  $smarty->assign("table", $table);  

and page.tpl

<div> {$table} </div>  

Currently nothing showed on page, not even an error or something. So:

  1. Is this the way that should be done? With using the returned result in either function and then pass it to the smarty template?

Maven -- Why are dependencies versions not overwritten?

Posted: 15 Mar 2022 04:22 AM PDT

My project depends on spring-boot-starter-data-mongodb and I just want to upgrade mongodb driver's version. Here is my pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">      <modelVersion>4.0.0</modelVersion>      <groupId>com.demo</groupId>      <artifactId>demo</artifactId>      <version>0.0.1-SNAPSHOT</version>      <packaging>jar</packaging>        <parent>          <groupId>org.springframework.boot</groupId>          <artifactId>spring-boot-starter-parent</artifactId>          <version>2.5.9</version>          <relativePath /> <!-- lookup parent from repository -->      </parent>        <properties>          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>          <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>          <java.version>11</java.version>      </properties>        <dependencies>          <dependency>              <groupId>org.mongodb</groupId>              <artifactId>mongodb-driver-sync</artifactId>              <version>4.5.0</version>          </dependency>                    <dependency>              <groupId>org.springframework.boot</groupId>              <artifactId>spring-boot-starter-data-mongodb</artifactId>          </dependency>      </dependencies>  </project>  

Here is final dependency tree:

[INFO] --- maven-dependency-plugin:3.1.2:tree (default-cli) @ demo ---  [INFO] com.demo:demo:jar:0.0.1-SNAPSHOT  [INFO] +- org.mongodb:mongodb-driver-sync:jar:4.5.0:compile  [INFO] |  +- org.mongodb:bson:jar:4.2.3:compile  [INFO] |  \- org.mongodb:mongodb-driver-core:jar:4.2.3:compile  [INFO] \- org.springframework.boot:spring-boot-starter-data-mongodb:jar:2.5.9:compile  [INFO]    +- org.springframework.boot:spring-boot-starter:jar:2.5.9:compile  [INFO]    |  +- org.springframework.boot:spring-boot:jar:2.5.9:compile  [INFO]    |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.5.9:compile  [INFO]    |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.5.9:compile  [INFO]    |  |  +- ch.qos.logback:logback-classic:jar:1.2.10:compile  [INFO]    |  |  |  \- ch.qos.logback:logback-core:jar:1.2.10:compile  [INFO]    |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.17.1:compile  [INFO]    |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.17.1:compile  [INFO]    |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.33:compile  [INFO]    |  +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile  [INFO]    |  +- org.springframework:spring-core:jar:5.3.15:compile  [INFO]    |  |  \- org.springframework:spring-jcl:jar:5.3.15:compile  [INFO]    |  \- org.yaml:snakeyaml:jar:1.28:compile  [INFO]    \- org.springframework.data:spring-data-mongodb:jar:3.2.8:compile  [INFO]       +- org.springframework:spring-tx:jar:5.3.15:compile  [INFO]       +- org.springframework:spring-context:jar:5.3.15:compile  [INFO]       |  \- org.springframework:spring-aop:jar:5.3.15:compile  [INFO]       +- org.springframework:spring-beans:jar:5.3.15:compile  [INFO]       +- org.springframework:spring-expression:jar:5.3.15:compile  [INFO]       +- org.springframework.data:spring-data-commons:jar:2.5.8:compile  [INFO]       \- org.slf4j:slf4j-api:jar:1.7.33:compile  [INFO] ------------------------------------------------------------------------  

My question is why bson and mongodb-driver-core's version are still 4.2.3 instead of 4.5.0. mongodb-driver-sync will depends on bson and mongodb-driver-core, and the versions are 4.5.0. Here is the pom of mongodb-driver-sync.

<project>    <groupId>org.mongodb</groupId>    <artifactId>mongodb-driver-sync</artifactId>    <version>4.5.0</version>    <dependencies>      <dependency>        <groupId>org.mongodb</groupId>        <artifactId>bson</artifactId>        <version>4.5.0</version>        <scope>compile</scope>      </dependency>      <dependency>        <groupId>org.mongodb</groupId>        <artifactId>mongodb-driver-core</artifactId>        <version>4.5.0</version>        <scope>compile</scope>      </dependency>    </dependencies>  </project>  

Copyng and renaming multiple files in a .bat file with FOR ... DO xcopy

Posted: 15 Mar 2022 04:21 AM PDT

I want to move several thousand files (.jpg and .pdf) from one location to another and then rename each file.

My 'copy_rename_docs.csv' input file contains two columns:

  • the first column containing the original path AND file names for each file that I want to move and rename
  • and the second column containing the new paths AND file names that I want to move and rename each file to

like this:

\\myapp\data\e3\9b\e39bf5e8d745833418d3edcd97c6c7589716970b,\\myapp\test_migration\e3\9b\Test File-xxx - SS1.pdf  \\myapp\data\09\f5\09f58d1a1345f67a36154e99ffedb27308fa4292,\\myapp\test_migration\09\f5\nxf7.pdf  

so "e39bf5e8d745833418d3edcd97c6c7589716970b" is a SHA1 hash of "Test File-xxx - SS1.pdf"

To copy and rename the files I tried this batch file:

@echo off  FOR /F "tokens=1,2 delims=," %%a IN (copy_rename_docs.csv) DO (xcopy /e /i "%%a" "%%b\*")  pause  exit  

But instead of copying and renaming the files to this:

\\myapp\test_migration\e3\9b\Test File-xxx - SS1.pdf  \\myapp\test_migration\09\f5\nxf7.pdf  

It is creating a FOLDER for each file with the FILE names as the FOLDER names and copying the files with their original file names into each FOLDER, like this:

\\myapp\test_migration\e3\9b\Test File-xxx - SS1.pdf\e39bf5e8d745833418d3edcd97c6c7589716970b  \\myapp\test_migration\09\f5\nxf7.pdf\09f58d1a1345f67a36154e99ffedb27308fa4292  

What I want is:

\\myapp\test_migration\e3\9b\Test File-xxx - SS1.pdf  \\myapp\test_migration\09\f5\nxf7.pdf  

What's wrong with my batch file?

And is xcopy the best tool for this?

Method with multiprocessing tool in python works worse than methoud without that

Posted: 15 Mar 2022 04:21 AM PDT

I am trying to use multiprocessing to speed up dealing with lots of files instead of reading them one by one. I did a test to learn before that. Below is my code:

from multiprocessing.pool import Pool  from time import sleep, time    def print_cube(num):      aa1 = num * num      aa2 = num * num * num      return aa1, aa2      def main1():      start = time()      x = []      y = []      p = Pool(16)      for j in range(1, 5):          results = p.apply_async(print_cube, args = (j, ))          x.append(results.get()[0])          y.append(results.get()[1])      end = time()      return end - start, x, y         def main2():      start = time()      x = []      y = []      for j in range(1, 5):          results = print_cube(j)          x.append(results[0])          y.append(results[1])      end = time()      return end - start, x, y    if __name__ == "__main__":      print("Method1{0}time : {1}{2}x : {3}{4}y : {5}".format('\n' ,main1()[0], '\n', main1()[1], '\n', main1()[2]))      print("Method2{0}time : {1:.6f}{2}x : {3}{4}y : {5}".format('\n' ,main2()[0], '\n', main2()[1], '\n', main2()[2]))  

And the result is:

Method1  time : 0.1549079418182373  x : [1, 4, 9, 16]  y : [1, 8, 27, 64]  Method2  time : 0.000000  x : [1, 4, 9, 16]  y : [1, 8, 27, 64]  

Method1 uses multiprocessing and consumes more CPU, but costs more time than method2.

Even if the number of cycles j goes to 5000 or greater, method2 works better than method1. Can anybody tell me what's wrong with my code?

How to send text within username input field on a https://discord.com/register webpage with Selenium and Python3

Posted: 15 Mar 2022 04:21 AM PDT

I'm trying to select the username text box in the https://discord.com/register website I tried:

driver.find_element ( by=By.CSS_SELECTOR ...)  driver.find_element ( by=By.CLASS_NAME ...)  driver.find_element ( by=By.CSS_XPATH ...)  

They all didn't work . Can anyone help me out with this?

I want to implement login and register functionality using Auth0

Posted: 15 Mar 2022 04:22 AM PDT

I want to provide the login and registration functionality to my user. But, I don't know how to implement this. I read these links but I can't find the proper solutions.

https://github.com/auth0/laravel-auth0#backend-api-applications https://auth0.com/docs/quickstart/backend/laravel/01-authorization https://github.com/auth0/laravel-auth0 https://auth0.com/docs/quickstart/backend/laravel-beta/

Please give me the solution as soon as possible.

Thanks

Error: FIREBASE FATAL ERROR: Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com

Posted: 15 Mar 2022 04:22 AM PDT

I'm making an app that writes a waiting list in the firebase realtime databse, but when I try to run this simple bit of code, I get this error (Note- I'm running this on web):

class FirebaseMethods {    FirebaseDatabase database = FirebaseDatabase.instance;      void createPartyWaiting(String partyCode, String partyHostName) async {      partyCode = partyCode.trim();      DataSnapshot data = await database.ref("e").get();      print(data.value);    }  }  

and i'm calling it as-

await FirebaseMethods().createPartyWaiting("PartyCode123", "Adam");  

But when I call it, I get this error-

Error: FIREBASE FATAL ERROR: Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com      at Re (https://www.gstatic.com/firebasejs/8.10.0/firebase-database.js:1:22344)      at Ws (https://www.gstatic.com/firebasejs/8.10.0/firebase-database.js:1:148180)      at au (https://www.gstatic.com/firebasejs/8.10.0/firebase-database.js:1:166314)      at K.xu.INTERNAL.registerComponent.Y.setServiceProps.Reference [as instanceFactory] (https://www.gstatic.com/firebasejs/8.10.0/firebase-database.js:1:187315)  

I'm initializing the web like this (I've censored the actual values)-

void main() async {    WidgetsFlutterBinding.ensureInitialized();    if (kIsWeb) {      Firebase.initializeApp(          options: const FirebaseOptions(              apiKey: "apikey",              authDomain: "authDomain",              projectId: "projectId",              storageBucket: "storageBucket",              messagingSenderId: "messagingSenderId",              appId: "appId"));    }    runApp(const MyApp());  }  

I've also found out that there's this optional arguement to the initilaziation method-

enter image description here

But after adding my databaseUrl here, I got this error-

Error: [core/duplicate-app] A Firebase App named "[DEFAULT]" already exists      at Object.throw_ [as throw] (http://localhost:53659/dart_sdk.js:5063:11)  at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:53659/packages/firebase_core_web/firebase_core_web.dart.lib.js:248:27)  

What am I doing wrong, and how do I fix this? Thanks!

Is it possible to scrape amazon reviews by brand?

Posted: 15 Mar 2022 04:22 AM PDT

In order to do some scalable web scraping on amazon product reviews, I want to find out, if there is a possibility to scrape all product reviews for a particular brand, without knowing all the ASIN and product description information.

Currently I am using a self-made R-scraper. In order to scrape the reviews, I need to collect ASIN and product description from the product page. As I am scraping a lot of products with just 5 to 30 review texts, this takes some time and includes a lot of manual work.

Here is my R-Code (Note, that Primavera is the brand name):

library(pacman)  pacman::p_load(RCurl, XML, dplyr, rvest, purrr)      #### SCRAPE    scrape_amazon <- function(page_num) {    url_reviews <- paste0("https://www.amazon.de/Primavera-Bio-Geschenkset-Zitrusdüfte-17ml/product-reviews/B00F43W2I6/ref=cm_cr_getr_d_paging_btm_next_3?ie=UTF8&reviewerType=all_reviews&pageNumber=", page_num)    doc <- read_html(url_reviews)        map_dfr(doc %>% html_elements("[id^='customer_review']"), ~ data.frame(      review_title = .x %>% html_element(".review-title") %>% html_text2(),      review_text = .x %>% html_element(".review-text-content") %>% html_text2(),      review_star = .x %>% html_element(".review-rating") %>% html_text2(),      date = .x %>% html_element(".review-date") %>% html_text2() %>% gsub(".*vom ", "", .),      author = .x %>% html_element(".a-profile-name") %>% html_text2(),      helpful_votes = .x %>% html_element(".a-size-base.a-color-tertiary.cr-vote-text") %>% html_text2(),      verified = .x %>% html_element(".a-size-mini.a-color-state.a-text-bold") %>% html_text2(),      page = page_num    )) %>%      as_tibble %>%      return()  }    # loop extract  datalist = list()  i = 1  for (i in 1:20) {    df_in <- scrape_amazon(page_num = i)     datalist[[i]] <- df_in   }  output = do.call(rbind, datalist)  

React native bottom tab bar pushing itself up when opening keyboard

Posted: 15 Mar 2022 04:22 AM PDT

We are using createBottomTabNavigator. In one of the tab contains search bar at the top. While clicking on that search bar, we are opening the keyboard. But the keyboard pushing up the bottom tab bar also. We need the bottom tab bar remains at the bottom when opening keyboard.

  1. One of the solution I have tried is, in android manifest, I have changed android:windowSoftInputMode="adjustPan" or "adjustNothing". It is working fine as expected. But we are using chat layout in another tab which needs "adjustResize". So I have to keep "adjustResize" for windowSoftInputMode.
  2. As another solution, I tried to change windowSoftInputMode inside component itself. SO I have tried with this - https://www.npmjs.com/package/react-native-android-keyboard-adjust. But no use.
  3. As another one, I tried to create a TabBarComponent like mentioned here https://github.com/react-navigation/react-navigation/issues/618. But not working as expected.
const SignedIn = createBottomTabNavigator(    {      Followers: {        screen: FollowerStack,        ...      },      Search: {        screen: SearchStack,      },      Home: {        screen: HomeStack,      },      Bookmarks: {        screen: BookmarkStack,      },      Profile: {        screen: ProfileStack,      }    },    {      initialRouteName: "Home",      tabBarPosition: 'bottom',      swipeEnabled: false,      animationEnabled: false,      tabBarOptions: {        keyboardHidesTabBar: true,        showIcon: true,        showLabel: false,        activeTintColor: "red",        inactiveTintColor: "gray",        adaptive: true,        safeAreaInset: {          bottom: "always"        },        style: {          position: 'relative',          backgroundColor: "#F9F8FB",          height: TAB_NAVIGATOR_DYNAMIC_HEIGHT,          paddingTop: DeviceInfo.hasNotch() ? "5%" : "0%",          minHeight: TAB_NAVIGATOR_DYNAMIC_HEIGHT,          width: '100%',          bottom: 0        }      }    }  );  
  1. Is there any other properties existed for making the bottom tab bar sticky at the bottom? or
  2. Is it possible to change the android manifest windowSoftInputMode from inside component? Please comment below if you required any other code part for reference. Thanks for any help.

How to fix HttpException: Connection closed before full header was received

Posted: 15 Mar 2022 04:22 AM PDT

I have recently upgraded my flutter version in my app. But when I want to debug the application, it shows me the following error.

Error connecting to the service protocol: HttpException: Connection closed before full header was received, URI = http://127.0.0.1:50795/ws

Is there anyone facing the same issue after upgrading the flutter version? If is there any workaround, please share.

Sorting an array of objects based on a property value (int) [duplicate]

Posted: 15 Mar 2022 04:21 AM PDT

This question deals with my algorithm and why it isn't working. More specifically, I would like to know how it can be improved to do what I want it to do. That is why it is different from the suggested duplicate question.

I am trying to create a function that sorts an array of objects based on a property value (int) that they all share in common, "indexFound". As you may suspect, I am trying to place elements with a lower indexFound at the beginning of the array.

function organizeTokens(list) {      for (i = 0; i < list.length - 1; i++) {          if (list[i].indexFound < list[i + 1].indexFound) {            // do nothing          } else if (list[i].indexFound > list[i + 1].indexFound) {            var tempVal = list[i];            list[i] = list[i + 1];            list[i + 1] = tempVal;          } else {          // should not happen unless we are comparing the same token          }      }  };  

As it stands, this code is not making any difference when I feed it an array of objects. The elements are still not in the order that they should be. Am I approaching this in the right way? Am I missing something obvious?

EDIT: -------------------------------------------------------------------

Example input: organizeTokens([{value: "if", indexFound: 7}, {value: "a", indexFound: 0}])

Expected output: [{value: "a", indexFound: 0}, {value: "if", indexFound: 7}]

Actual output: [{value: "if", indexFound: 7}, {value: "a", indexFound: 0}]

Intuitive Understanding of GCD algorithm

Posted: 15 Mar 2022 04:22 AM PDT

What's an intuitive way to understand how this algorithm finds the GCD?

function gcd(a, b) {      while (a != b)          if (a, b)              a -= b;          else              b -= a;      return a;  }  

How does sum of squared difference algorithm work?

Posted: 15 Mar 2022 04:21 AM PDT

I have a two images a and b, where b is a block of image a. I want to find b using block matching. How do I go about it?

No comments:

Post a Comment