Saturday, July 31, 2021

Posts from Recent Questions - Stack Overflow for 07/31/2021

View this email in your browser
Updates from https://stackoverflow.com/questions

Recent Questions - Stack Overflow



In the 07/31/2021 edition:

Donut Chart rendering center text dynamically on hover

By Ritika Neema on Jul 31, 2021 04:02 am

I am using angular 11. I am trying to render the center text dynamically on chart hover. I am using chartHovered function in component TS file and have set the same in HTML.(chartHover) = [chartHovered($event)]. In debugging, I can see text is getting rendered and it gets hidden as the plugins beforeDraw() method gets called. When I try the same logic in click event I can see the text over the default centertext. I am utilizing PluginServiceGlobalRegistrationAndOptions beforeDraw(){} to render the center text and referred to this link:- angular charts.js doughnut chart setting center text dynamically Detecting hover events over parts of a chart using Chart.js


Read in browser »
share on Twitter

the pestiside plugin not working on specific cases

By WBdevyL on Jul 31, 2021 04:02 am

the main problem is that the pestiside plugin is not working on the website page that i am trying to create, i have already tried to use different bowsers like chrome, opera, firefox. and i want to use the plugin cause it is very helpful for new devs like me. and here is the code of the page that i am trying to use the plugin on

<!doctype html>  <html lang="en">    <head>  <title> WebDev Deciple </title>  <link rel="stylesheet" href="Masterstyle.css">  </head>  <body>        <hr>    <div id="fpft">      <table class="fpft">          <tr>              <td class="pad">                  <h1> The Journey of Coding </h1>                  <h2> By </h2>                  <p>                      <a href="https://www.youtube.com/channel/UCUlVgrFGHm3d3AJt9h88xVA" target="_blank">                          <button id="C7Ghost">                              C7_Ghost                          </button>                      </a>                  </p>              </td>              <td class="pad">                  <img src="PP.jpg" alt="profile pic" id="fpfp">              </td>          </tr>      </table>  </div>      <hr>        <p> <i> This is an example of italics paragraph done by  tag < i>< /i>. </p>           <p> <em> This is an example of italics paragraph done with the use of < em> < /em> tag </em> </p>            <br> There are different type fo heading sizes,   <br>          <p> <i> This is an example of <strong>italics paragraph</strong> </i> </p>            <p><a href="Table.html" target="blank";> <button> Before we talk about any other thing first lets take a look at this link</button> </a> </p>       <div class="pre">           <pre>               This is a test for               code.           </pre>       </div>  <div>     <p><strong>Now we will talk about all the website refrences that we have used till now to build this page.</strong></p>      <div>          <ul>              <li>w3schools</li>              <li>mdn</li>          </ul>      </div>  </div>    <p><em>This here is the list of the things or you can say resources that are used <br> while making this webpage active</em></p>  <ol>      <li>udemy</li>      <li>opensource websites</li>  </ol>      <div id="aamb"; >          <button class="ldam";>  <a href="Personal Info.html" target="_blank"> <em> All About Me </em> </button>      </div>          </body>          </html>  

Read in browser »
share on Twitter

Stripe integrazione pagamento

By user8616565 on Jul 31, 2021 04:02 am

Sto cercando di utilizzare stripe per i pagamenti su sito web, utilizzando il seguente codice

il tutto messo all'interno di un form.

Non riesco a gestire l'esito della transazione, vorrei eseguire degli azioni in caso di successo o altre azioni in caso di fallimento. Come posso fare?


Read in browser »
share on Twitter

Admob ads not showing properly on .apk

By Diogo Dias on Jul 31, 2021 04:02 am

I've been using Google's AdMob in my Unity app and everything has been working fine on the app bundles I create for the play store, however, on the .apk build the ads don't show themselves.

I usually first build the app bundle and immediately after I build the .apk.

The type of ads that I'm displaying is banner ads.

Am I doing something wrong? Is this supposed to be happening? Any help and feedback would be greatly appreciated.


Read in browser »
share on Twitter

Struct Func and Struct Static Func. (Are Struct Static Fun still value type?)

By myjunk on Jul 31, 2021 04:02 am

Been searching SO and thru google for an hour. Haven't found an exact answer. Hence please verify my understanding.

Struct vs. Class

  1. Struct is by default preferred in swift.
  2. Struct is value type. Class is reference type

pic from : https://cocoacasts.com/value-types-and-reference-types-in-swift enter image description here

Okay. That's all fine and dandy. Now What's the difference between static func and func within a struct?

static just means that -> Static, but when it's within a struct and used to declare a func? What does it mean?

static keyword is same like final class. final keyword makes the variable or function final i.e. they can not be overridden by any inheriting class. (link)

class TestStruct {    var count = Int()        func popeye(name: String) -> String {      count = count + 1      return "TestStruct - func popeye - name:\(name) Count:\(count)"    }      static func brutus(name: String) -> String {      var count = Int() // when declared within the static func      count = count + 1 // this never gets incremented        return "TestStruct - static func brutus - name:\(name) count:\(count)"    }  }  

I tried this and found out that I can't do foo1.brutus as I can do foo1.popeye when it's assigned with a static func keyword.

But as just a func, I can have 2 variables referencing the same func and both will have it's own value (example below,count output is different). What's the benefit of using static then? When do I use static func

let foo1 = TestStruct()  let foo2 = TestStruct()  var bar1 = foo1.popeye(name: "popeye sailorman")  var bar2 = foo2.popeye(name: "popeye spinach  ")    print("foo1:\(bar1)")  print("foo2:\(bar2)")    bar1 = foo1.popeye(name: "popeye sailorman")  print("foo1:\(bar1)")  print("foo2:\(bar2)")    bar1 = foo1.popeye(name: "popeye sailorman")  print("foo1:\(bar1)")  print("foo2:\(bar2)")    bar1 = foo1.popeye(name: "popeye sailorman")  bar2 = foo2.popeye(name: "popeye spinach  ")  print("foo1:\(bar1)")  print("foo2:\(bar2)")      var oliveOil1 = TestStruct.brutus(name: "Brutus Big ")  var oliveOil2 = TestStruct.brutus(name: "Brutus Mean")  print("oliveOil1:\(oliveOil1)")  print("oliveOil2:\(oliveOil2)")    oliveOil1 = TestStruct.brutus(name: "Brutus Big ")  oliveOil2 = TestStruct.brutus(name: "Brutus Mean")  print("oliveOil1:\(oliveOil1)")  print("oliveOil2:\(oliveOil2)")  

which results in these printouts:

foo1:TestStruct - func popeye - name:popeye sailorman Count:1  foo2:TestStruct - func popeye - name:popeye spinach   Count:1  foo1:TestStruct - func popeye - name:popeye sailorman Count:2  foo2:TestStruct - func popeye - name:popeye spinach   Count:1  foo1:TestStruct - func popeye - name:popeye sailorman Count:3  foo2:TestStruct - func popeye - name:popeye spinach   Count:1  foo1:TestStruct - func popeye - name:popeye sailorman Count:4  foo2:TestStruct - func popeye - name:popeye spinach   Count:2  oliveOil1:TestStruct - static func brutus - name:Brutus Big  count:1  oliveOil2:TestStruct - static func brutus - name:Brutus Mean count:1  oliveOil1:TestStruct - static func brutus - name:Brutus Big  count:1  oliveOil2:TestStruct - static func brutus - name:Brutus Mean count:1  

Read in browser »
share on Twitter

How to add Firebase Timestamp when adding an object of a data class to the Firestore in Kotlin?

By Codist on Jul 31, 2021 04:01 am

Following is the sample of my data class to add product details to the Firestore, I wanted to add Firebase timestamp to know when the item was added. Even though I do not know how to do it, I tried like the following but I am getting an error.

Note: I know how to add Timestamp to Firestore and I have done that using "timestamp" to FieldValue.serverTimestamp() when adding a Hashmap. I am having trouble when it's part of an object of my data class.

    @Parcelize  data class Product @JvmOverloads constructor(      val user_id: String = "",      val mrp: String= "0.00",      val price: String = "0.00",      val description: String = "",      val stock_quantity: String = "",      val image: String = "",      val product_added_date: FieldValue? = null,  ) : Parcelable  

The object of the product to add to Firestore.

val product = Product(          FirestoreClass().getCurrentUserID(),          et_product_mrp.text.toString(),          et_product_price.text.toString(),          et_product_description.text.toString().trim { it <= ' ' },          et_product_quantity.text.toString().trim { it <= ' ' },          mProductImageURL!!,,          et_product_delivery_charge.text.toString().trim { it <= ' ' },          imageURL.size,          FieldValue.serverTimestamp(),      )  

Thanks


Read in browser »
share on Twitter

React Canvas detect bounding area at mouse click position

By Hiep Le on Jul 31, 2021 04:01 am

enter image description here

I have a canvas with this image

I want when I click into canvas I will the bounding area at position that I clicked

Example when I click into red dot, I will get area 1-2-3-4-5-6

// input: mousePosition: {x, y}  // output: listPoint: [  //  {x1, y1},  //  {x2, y2},  //  ...  //  {x6, y6}  // ]  

Does anyone have any ideas or any tools that could help me. Thank you


Read in browser »
share on Twitter

how to discover anomalies in dataset

By Jay Qadan on Jul 31, 2021 04:01 am

A common problem in ERP data quality, suppose most entries are correct, but there are few records as in this example, Antony Stark pay level=5, but anyone Pay Group=B-Standard shouldn't go beyond 2 in pay level. Similarly Eric Randy as Casual shouldn't have Leave Entitlement=4 weeks!

Is there a method to detect these anomalies considering columns selected influence other columns from left-to-right?

enter image description here


Read in browser »
share on Twitter

What JavaScript RegExp should I use for an HTML code example?

By GreyHope on Jul 31, 2021 03:59 am

I would like to make a JavaScript code snippet that colours all comments and strings. The code below shows what I managed to do.

const code = document.querySelector(".code")    code.innerHTML = code.innerHTML    // single line string  .replace(    /("|').+("|')/g,    a => "<span class=string>" + a + "</span>"  )    // single line comment  .replace(    /\/\/.+/g,    a => "<span class=comment>" + a + "</span>"  )    // multi line comment  .replace(    /\/\*.+/g,    a => "<span class=comment>" + a + "</span>"  )
.string {    color: #850;  }    .comment {    color: #080;  }    .code {    background-color: #eee;    padding: 0.5rem 0 0.5rem 1rem;    border-radius: 0.4rem;    border: 1px solid #ddd;  }
<div class = code>  <pre>  let variable = "string" // this is a comment  console.log('string')    // here are "some" notes    /* more notes */    /* multi  line  notes */  </pre>  </div>

As you can see, there are a few problems.

  1. Strings within comments are still coloured
  2. Multi line comments don't work

What alternative RegExp should I use for each situation?


Read in browser »
share on Twitter

How to remove quotation marks from innerHTML output

By KHIBAK on Jul 31, 2021 03:55 am

Good Day. I am facing a bit of a problem and I would appreciate your assistance

I am trying to create a JS code that will save information into localStorage then display the saved information into a new div...

It is working but the information returns in inverted commas and I would like to know if there is a way to remove them.

HTML

<div id = "dateHead" > Date : </div>    <div id ="incJobs></div>    *JAVASCRIPT*    var dateHead = document.getElementById("dateHead").innerHTML;      localStorage.setItem("jobInfo", JSON.stringify(dateLabel));    var storedInfo = localStorage.getItem("jobInfo    document.getElementById("incJobs").innerHTML = storedInfo;```    It returns : "Date :"        I plan on including input tags which is the reason I'm saving it to localStorage    Thank You.    

Read in browser »
share on Twitter

How to split column without delimiter pandas

By Maarten on Jul 31, 2021 03:41 am

I have this csv-file, where the first column is the date in this format: YYYYMMDD. I don't need the YYYY. I would like to delete the YYYY part and keep the MMDD part. But there is no delimiter between those. I've tried a couple of things, but nothing worked. Except for this method, which loops through each row and deletes the year, but this takes ages for my file with more than a million rows.

This is my loop, but I can't seem to find a way to do it for all rows in one go.

def drop_year(row):      print(row[0])      data.iloc[row] = str(row[0])[4:]  [drop_year(row) for row in data.iterrows()]  

Read in browser »
share on Twitter

How to go back in android app and take new input

By Harshit Singh on Jul 31, 2021 03:30 am

I have two Activities, Activity 1 has 2 EditText, it takes input and goes to next activity. Now if I go back to previous activity and enter different input in EditText then it doesn't get updated in next activity. It still takes the earlier input.


Read in browser »
share on Twitter

How can I minimize javascrpit logic of hamburger menu?

By Swapnil Kotkar on Jul 31, 2021 03:08 am

I made a hamburger menu using HTML, CSS, and JS and it works perfectly fine but I want to minimize my JS logic.
I did some research on YouTube, but everyone has almost the same logic.
Look at my JS logic, can I minimize my JS logic?

If you have better short and simple JS logic then answer me.

HTML :

    <div class="menu-btn">        <div class="hamburger"></div>      </div>      <div class="menu-list">        <ul class="menu-items">          <li><a href="#home">Home</a></li>          <li><a href="#about">About</a></li>          <li><a href="#skills">Skills</a></li>          <li><a href="#contact">Contact</a></li>        </ul>      </div>  

JS logic :

const hamburgerMenu = document.querySelector(".menu-btn");  const hamburger = document.querySelector(".hamburger");  const menuList = document.querySelector(".menu-list");  const homePage = document.getElementById("#home");    hamburgerMenu.onclick = () => {    hamburger.classList.toggle("active");    menuList.classList.toggle("active");    hamburgerMenu.classList.toggle("active");  };  menuList.onclick = function (e) {    if (e.target.classList !== "menu-btn") {      hamburger.classList.remove("active");      menuList.classList.remove("active");      hamburgerMenu.classList.remove("active");    }  };  

Read in browser »
share on Twitter

Retrieve data 60 days prior to their retest date

By Mansi Mandal on Jul 31, 2021 02:33 am

I have a requirement where I need to retrieve Row(s) 60 days prior to their "Retest Date" which is a column present in the table. I have also attached the screenshot and the field "Retest Date" is highlighted.

reagentlotid reagentlotdesc u_retest
RL-0000004 NULL 2021-09-30 17:00:00.00
RL-0000005 NULL 2021-09-29 04:21:00.00
RL-0000006 NULL 2021-09-29 04:22:00.00
RL-0000007 Y-T4 2021-08-28 05:56:00.00
RL-0000008 NULL 2021-09-30 05:56:00.00
RL-0000009 NULL 2021-09-28 04:23:00.00

This is what I was trying to do in SQL Server:

select r.reagentlotid, r.reagentlotdesc, r.u_retestdt  from reagentlot r  where u_retestdt = DATEADD(DD,60,GETDATE());  

But, it didn't work. The above query returning 0 rows. Could please someone help me with this query?


Read in browser »
share on Twitter

Volatile variables does not work as expected

By Tal Glik on Jul 31, 2021 01:22 am

I thought that if I have 2 volatile variables i, i1 then if I set for example:

i = 2;  i = 3;  i1 = 5;  

So another thread will never find that i1 == 5 but i == 2, but try the below code and see that sometimes it does not work as expected:

public class Main {  private static volatile int i=0;  private static volatile int i1=0;    public static void main(String args) throws InterruptedException {      Thread t = new Thread(Main::writerThread);      Thread t1 = new Thread(Main::readerThread);      t.start();      t1.start();      t.join();      t1.join();  }    public static void writerThread()  {      for (int j = 0; j < 100000; j++)      {          i = j;          i1 = j;      }  }    public static void readerThread() {      int myI, myI1;      for (int j = 0; j < 100000; j++) {          myI = i;          myI1 = i1;          if (myI1 > myI)          {              System.out.println(myI + " < " + myI1);          }      }  }  

}

myI should never be < myI1, but sometimes it is. For example i got: 711 < 712


Read in browser »
share on Twitter

How can I reshape a series so that I can use it the Scitkit-learn Standard Scaler function?

By jgg on Jul 31, 2021 12:55 am

For the below code, I get a ValueError: Expected 2D array, got 1D array error message.

So instead of the last line in the below, I also tried scaler.fit_transform(df[0]).reshape(-1,1) but got the same error. How can I transform a pandas series so I can scale it using the scikit learn StandardScaler?

In [1]: import numpy as np      ...: import pandas as pd      ...: from sklearn.preprocessing import StandardScaler      ...: from sklearn.model_selection import train_test_split      ...: X = np.random.uniform(size=15)      ...: index = pd.date_range(start = "2020-12-31", periods=15)      ...: df = pd.DataFrame(X, index=index)    In [2]: scaler.fit_transform(df[0])  

Read in browser »
share on Twitter

C# Class Property set is not being call nor set

By Bendy on Jul 30, 2021 09:42 pm

My class property set is not being call nor is my property being set.
I have a class called StudentDraw and there is a Property called Student that is that set is not being called. There is my code :

 public UserSettings Student      {          get => _student;          set          {              if (_student == value) return;              _student = value;              UserSettingsChanged?.Invoke(value);          }      }  

Here is how I update it :

Student.NumberOfPicture ++;  

here is my UserSettings class :

public class UserSettings  {        public string CurrentUser;      public int NumberOfPicture;          public UserSettings()      {          CurrentUser = string.Empty;         NumberOfPicture = 0;        }    }  

I used breakpoints and it called the Get but it never call the Set with I do :

Student.NumberOfPicture ++;  

Why is this ? and How do I fix it ?


Read in browser »
share on Twitter

Torch mv behavior not understandable

By SheppLogan on Jul 30, 2021 07:35 pm

The following screenshots show that torch.mv is unusable in a situation that obviously seem to be correct... how is this possible, any idea what can be the problem?

enter image description here

enter image description here

this first image shows the correct situation, where the vector has 10 rows for a matrix of 10 columns, but I showed the other also just in case. Also swapping w.mv(x) for x.mv(w) does not make a difference.

enter image description here

However, the @ operator works... the thing is that for my own reasons I want to use mv, so I would like to know what the problem is.


Read in browser »
share on Twitter

Arduino and pyserial and ble

By Sebastian vettel on Jul 30, 2021 02:48 pm

Actually i can send data from pyhton(pyserial) to arduino through cable,but i want to do that with hm-10, normally bluetooth module which is the hc-05 ,hc-06 u can find port, With wire or wirelles(hc-05) com7 port:

arduino = serial.Serial("COM7", baudrate=9600,timeout=.1)"  

But hm-10 is ble. what i need to write instead of com7? or how can i solve that problem? (windows 10)


Read in browser »
share on Twitter

`jekyll build` has error but gitlab ci still continues

By The Oddler on Jul 30, 2021 09:29 am

I have a Jekyll website running on Gitlab Pages, and one of my pages contained an error. This error is found and reported by Jekyll, but the website is still deployed, just without that page.

In Gitlab's job output I see the following:

$ jekyll build -d public  ...  Bundle complete! 5 Gemfile dependencies, 29 gems now installed.  Use `bundle info [gemname]` to see where a bundled gem is installed.  ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux-musl]  Configuration file: /builds/TheOddler/mjb/_config.yml              Source: /builds/TheOddler/mjb         Destination: /builds/TheOddler/mjb/public   Incremental build: disabled. Enable with --incremental        Generating...               Error: YAML Exception reading /builds/TheOddler/mjb/_work/immaculate.md: (<unknown>): did not find expected key while parsing a block mapping at line 2 column 1         Jekyll Feed: Generating feed for posts                      done in 1.104 seconds.   Auto-regeneration: disabled. Use --watch to enable.  Uploading artifacts for successful job 00:09  Uploading artifacts...  

So it shows Error: YAML Exception ... but then still continues as if everything is OK.

The job in my .gitlab-ci.yml file looks like this:

build-jekyll:    stage: build    image: jekyll/jekyll:4.2.0    script:    - jekyll build -d public    artifacts:      paths:      - public    only:    - master  

Why does this happen? And is there a way to make the process fail, or at least report this as a warning so I know something went wrong?

Thanks!


Read in browser »
share on Twitter




Recent Articles:

Is there any Terraform code or ARM Template code available for enabling diagnostic settings in data factory
How to store credentials for multiple Github accounts (not repos) using libsecret
Java conventions for calling non-static methods from the main() method [closed]
How to Retry 429 Errors On Scroll
SequelizeConnectionError in Node.js application
Twitter
Facebook
Website
Copyright © 2021 reader, All rights reserved.
You are receiving this email because you opted in via our website.

Our mailing address is:
reader
88 CELICA STREET
Davao 8000
Philippines

Add us to your address book


Want to change how you receive these emails?
You can update your preferences or unsubscribe from this list.

Email Marketing Powered by Mailchimp

No comments:

Post a Comment