Wednesday, November 10, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Find 4 X 4 pixels of a point in a raster in R?

Posted: 10 Nov 2021 08:29 AM PST

If I have a raster like this:

 library(raster)   r1 <- raster(ncol=10, nrow=10)   r1[] <- runif(ncell(r1))   r1[] = 1:ncell(r1)   x=c(-6)               y=c(-67)  

I can extract values that correspond to this point as:

values = extract(r1, SpatialPoints(cbind(y,x),CRS("+init=EPSG:4326")))  

However, this extracts the closest pixel to the coordinates of this point. I need to extract the 4 closest pixels to this point. Any idea?

Woocommerce show product title on hover image overlay

Posted: 10 Nov 2021 08:29 AM PST

I am working on a woocommerce webshop. Now, i am looking for a solution to display the product title and price inside an overlay when a customer hovers the product image/thumbnail.

I'm almost there. At this moment the product price (price), title (product_category_title) are shown under the thumbnail image. This code however 'takes' the product category title and price and 'places' it inside the image overlay. The problem is that i want to display the title and price in both positions. So inside the image overlay and in it's original position; under the image.

How can i adapt the code to get this to work?

<script>  jQuery(document).ready(function( $ ) { // When jQuery is ready          var shop_module = $( '.divi-engine-custom-overlay' ),               shop_item = shop_module.find( 'li.product' );          shop_item.each( function() { // Runs through each loop item in the shop              var product_title = $( this ).find( '.product_category_title' ), // Finds the Product Title                  product_price = $( this ).find( 'span.price' ), // Finds the Product Price                  product_overlay = $( this ).find( '.et_overlay' ); // Finds the Divi Overlay              product_title.detach(); // Detaches the Product Title              product_price.detach(); // Detaches the Product Title              product_overlay.prepend(product_title, product_price); // Adds Product Title and Price to the Overlay          } )    } );  </script>  

I want #tabulator to show loader when data is loading and throw error when no data is available

Posted: 10 Nov 2021 08:28 AM PST

I am using the latest version 5.0 so i am using the dataloaders instaed of ajax but still not working, i am fetching data from a database using meteor.call()

height: "100%",          dataLoader: true,          dataLoaderLoading:"<div style='display:inline-block; border:4px solid #333; border-radius:10px; background:#fff; font-weight:bold; font-size:16px; color:#000; padding:10px 20px;'>Loading Data</div>",          dataLoaderError: "<div style='display:inline-block; border:4px solid #D00; border-radius:10px; background:#fff; font-weight:bold; font-size:16px; color:#590000; padding:10px 20px;'>Loading Error</div>",          data: this.selector.get(),          layout: "fitColumns",           placeholder: "No Data Available",  

Convert TSTAMP to human date and time

Posted: 10 Nov 2021 08:28 AM PST

I'm trying to read a device using Modbus RTU. The type of these fields is TSTAMP. When I read these fields, it returns an integer for each field. In the manual there is a table, with the addresses and types.

Each date consists of reading 2 addresses. For example: I want to read the "Volts" field so I need to read the address 8400-8402. Reading these fields returns the values 4622 and 9483.

How do I convert these 2 integers to date and time format?

MANUAL:

enter image description here

READING:

enter image description here

cant run Anaconda-Navigator

Posted: 10 Nov 2021 08:28 AM PST

after reinstallation it on win10, at startup I get

Traceback (most recent call last):    File "C:\Users\Tanya\anaconda3\lib\site-packages\qtpy\__init__.py", line 209, in <module>      from PySide import __version__ as PYSIDE_VERSION  # analysis:ignore  ModuleNotFoundError: No module named 'PySide'    During handling of the above exception, another exception occurred:    Traceback (most recent call last):    File "C:\Users\Tanya\anaconda3\Scripts\anaconda-navigator-script.py", line 10, in <module>      sys.exit(main())    File "C:\Users\Tanya\anaconda3\lib\site-packages\anaconda_navigator\app\main.py", line 119, in main      from anaconda_navigator.app.start import start_app    File "C:\Users\Tanya\anaconda3\lib\site-packages\anaconda_navigator\app\start.py", line 19, in <module>      from qtpy import PYQT5    File "C:\Users\Tanya\anaconda3\lib\site-packages\qtpy\__init__.py", line 215, in <module>      raise PythonQtError('No Qt bindings could be found')  qtpy.PythonQtError: No Qt bindings could be found  

due to conflicts I can not install PySide, Qt, PYQT5. And why full reinstall doesnt help whith this?

What's the correct Microsoft Graph API endpoint for promoting a subdomain to root in Azure AD? It exists in Azure AD Graph API, but that's deprecated

Posted: 10 Nov 2021 08:28 AM PST

Background:
I want to add a subdomain to Azure AD so that users can have it as a UPN suffix. The parent domain is federated, but I don't want the child domain to be federated. The child domain inherits the authentication type of the parent, unless you use this one Azure Active Directory Graph API method to promote the subdomain to root. Then it can have it's own authentication type and settings applied.

Problem:
What's the correct Microsoft Graph API endpoint for promoting a subdomain to root? It exists in Azure AD Graph API, but that's deprecated: https://docs.microsoft.com/en-us/azure/active-directory/enterprise-users/domains-verify-custom-subdomain

Use Microsoft Graph API to make this a root domain
Use the following command to promote the subdomain:
POST https://graph.windows.net/{tenant_id}/domains/child.mydomain.com/promote?api-version=1.6

If I fill in {tenant_id} and fill in the subdomain I want to promote into Microsoft Graph Explorer, it fails with this:

"Your access token has expired. Please renew it before submitting the request."

I think that's because it's a Azure Active Directory Graph API call (graph.windows.net) instead of a Microsoft Graph API call. So the tokens have different audiences.

It sounds like the conversion process is this:

https://graph.windows.net/{tenant_id}/{resource}?{version}
https://graph.microsoft.com/{version}/{resource}

So I tried to run it like this:
https://graph.microsoft.com/v1.0/domains/child.mydomain.com/promote

But that fails with:
BadRequest
Resource not found for the segment 'promote'.

I did try to create an Application Registration in Azure and give it permission to Azure Active Directory Graph, but it's locked. It sounds like Microsoft is locking out new registrations to avoid people creating new Application that target it. It displays this warning message:
Azure Active Directory Graph will be deprecated in June 2022. We recommend using Microsoft Graph APIs for your application. If you are currently using Azure Active Directory Graph, please migrate to Microsoft Graph.

Disable Serial Console on an Android Emulator

Posted: 10 Nov 2021 08:29 AM PST

I've been learning and working with Flutter for a few weeks now. I used some of the Android Emulators that Android Studio provides and it was doing fine. But recently, I opened an emulator to run a Flutter project while a memory card was connected with my laptop, and suddenly a notification was shown in the emulator of detecting a SD card and with that another notification was shown saying:

Serial console enabled   Performance is impacted. To disable, check bootl..  

The notification is not clickable, and neither it removes even after I deleted all the emulators that I installed using the AVD manager. And as the notification says, it really is impacting the performance of the emulators. Before it showed up, I could see the changes in the app immediately after making changes to the code and saving it, but now, it takes so much time to show the changes even if I use hot reload or hot restart.

Is there any way to get rid of this? How can I disable the Serial console?

Group by "years"

Posted: 10 Nov 2021 08:28 AM PST

i am a begginer in the oracle´s world. I have a question for you How can i group by years and create a new columnu with the sum of all quantity*unite_price for year?enter image description here

How to get values in dataframe for process new data set?

Posted: 10 Nov 2021 08:28 AM PST

I run the regression with IQR and MinMax Scale before fit the model via sklearn. I need to save all values that might use for further dataset (import from somewhere).

I made the pandas dataframe as below. In this case, I would like to use both lower_bound and upper_bound to detect outlier values from new dataset.

Paramerters lower_bound upper_bound
0 X1 22.02 44.01
1 X2 122.02 144.01
3 X3 2.02 4.01

First Question

How can I call/get the values in each parameters to transform outlier for new any dataset with lower_bound and upper_bound?

Pandas to Dict?

Second Question

When we have new dataset, we actually define own function and call to get the outout.

If we have the Df or Dict or something else? How can we call those thing into script?

Thanks,

React TS: wait for props before calling function with props as arguments

Posted: 10 Nov 2021 08:28 AM PST

I'm using React through functional components. One of my components has props that are passed by its parent components. These props are used in a function to manipulate the prop data before rendering it, such as:

const Skills: FC<SkillsProps> = ({ skills, columns }): JSX.Element => {    const skillsTable = sliceArray(skills, columns);    return (      <div className="skillsContainer">        skillsTable.map(...)      </div>    );  };  

Within the Skills component, the props contain data when I console.log the data with an useEffect hook, nevertheless sliceArray() complains that its arguments are undefined.

What I already tried:

const Skills: FC<SkillsProps> = ({ skills_, columns_ }): JSX.Element => {    const [skills, setSkills] = useState([]);    const [columns, setColumns] = useState(1);      useEffect(() => {      setSkills(skills_);      setColumns(columns_);    }, []);      const skillsTable = sliceArray(skills, columns);  

What am I missing here?

Email Cleaning using Regex in python

Posted: 10 Nov 2021 08:28 AM PST

I am facing the annoying problem of cleaning Emails so that I can use them with my NLP solution. I got pretty messy mails with a lot of attached older mails, signatures etc. However, I try to take care of my attached mails like this:

texts =['Everything is alright --Sent from my iphone-- How are you doing?', 'Nuthin to say From: XY Tuesday 2nd']      signal_pattern = [r'\--Sent from my iphone--.*',r'\From:.*']      clean_mails = []    for t in texts:      for c in signal_pattern:          if re.search(c,t):              c_1 = re.sub(c,'',t)              clean_mails.append(c_1)      OUTPUT:    ['Everything is alright', 'Nuthin to say  XY Tuesday 2nd']  

So it results in the wanted output. The problem occurs when I add a sentence to the texts which doesn't contain one of those patterns. It obviously doesn't add the one to my cleaned texts. I could do a list comprehension to add the missing ones but maybe someone has a more elegant idea.

Thank you

Cannot Set Dynamic TableView Row Height

Posted: 10 Nov 2021 08:28 AM PST

I'm trying to set dynamic row height in TableView. But unfortunately is not working.

The only thing is working is to set the heightForRowAt indexPath to a constant number.

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {      return 470 //or any other number  }  

If I delete this function, or try to set it to automatic the cell will not show at all. Something like this:

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {      return UITableView.automaticDimension  }  

I also tried to use:

self.tableView.estimatedRowHeight = UITableView.automaticDimension //Tried even with a number  self.tableView.rowHeight = UITableView.automaticDimension  

But seems nothing to work besides using a constant height in heightForRowAt indexPath function. Which is not what I want, I want cell to be expanded based on content inside the cell.

Error al intentar actualizar mi base de datos con PHP / PDO

Posted: 10 Nov 2021 08:28 AM PST

Estoy intentando actualizar una base de datos a partir de un formulario ingresado por el usuario.

Mi HTML:

<!-- Formulario -->      <form action="" method="POST">          <div class="contenedorBP">              <div class="elemento" style="width: 30%">                  <h4>Alfanumérico: </h4>                  <input type="text" name="alfanum" value="<?php echo $alfanum;?>" onClick="this.select();">              </div>              <div class="elemento" style="width: 30%">                  <h4>Estrato: <?php echo $estrato;?></h4>                  <input type="text" name="estrato" value="<?php echo $estrato;?>" onClick="this.select();">              </div>              <div class="elemento" style="width: 30%">                  <h4>Familia: <?php echo $familia;?></h4>                  <input type="text" name="familia" value="<?php echo $familia;?>" onClick="this.select();">              </div>              <div class="elemento" style="width: 30%">                  <h4>Largo: <?php echo $largo;?></h4>                  <input type="text" name="largo" value="<?php echo $largo;?>" onClick="this.select();">              </div>              <div class="elemento" style="width: 30%">                  <h4>Ancho: <?php echo $ancho;?></h4>                  <input type="text" name="ancho" value="<?php echo $ancho;?>" onClick="this.select();">              </div>              <div class="elemento" style="width: 30%">                  <h4>Alto: <?php echo $alto;?></h4>                  <input type="text" name="alto" value="<?php echo $alto;?>" onClick="this.select();">              </div>          </div>            <div class="boton">              <input type="submit" name="update" value="Actualizar">          </div>      </form>  

Mi PHP:

<?php    include 'conexion.php';  if(isset($_POST['update'])){      $alfanum = $_POST['alfanum'];      $estrato = $_POST['estrato'];      $familia = $_POST['familia'];      $largo = $_POST['largo'];      $ancho = $_POST['ancho'];      $alto = $_POST['alto'];        $actualizaQuery = "UPDATE productos                         SET SGOcodigo=:alfanum,                             SGOestrato=:estrato,                             SGOfamilia=:familia,                             SGOdimLargo=:largo,                             SGOdimAncho=:ancho,                             SGOdimAlto=:alto                         WHERE IdProducto = ".$_GET['producto'].")";        $actualizaQuery_run = $conn->prepare($actualizaQuery);      try{          $actualizaQuery_exec = $actualizaQuery_run->execute(                                                          array(                                                              ':alfanum' => $alfanum,                                                              ':estrato' => $estrato,                                                              ':familia' => $familia,                                                              ':largo' => $largo,                                                              ':ancho' => $ancho,                                                              ':alto' => $alto                                                              )                                                          );            if($actualizaQuery_exec){              echo '<script> alert("Data actualizada") </script>';          } else {              echo '<script> alert("Data NO actualizada") </script>';           }      } catch(Exception $e){          echo($e->getMessage());      }    }  ?>  

Sin embargo, al enviar la petición, me arroja el siguiente error:

SQLSTATE[42000]: Syntax Error Or Access Violation: 102 [Microsoft][ODBC Driver 17 For SQL Server][SQL Server]Incorrect Syntax Near ')'. (SQLExecute[102] At Ext\Pdo_odbc\Odbc_stmt.C:257)  

Luego de depurar un poco, me percaté de que este error se genera en la siguiente línea:

$actualizaQuery_run->execute(                                                      array(                                                          ':alfanum' => $alfanum,                                                          ':estrato' => $estrato,                                                          ':familia' => $familia,                                                          ':largo' => $largo,                                                          ':ancho' => $ancho,                                                          ':alto' => $alto                                                          )                                                      );  

No sé como resolverlo, alguna idea o sugerencia de que pudiera estar ocurriendo?

Game Development, Collision

Posted: 10 Nov 2021 08:28 AM PST

I'm new to the game development and I'm trying to code 2D RPG game. im using png images to create objcts and move around. So it is pretty easy to detect collision between rectngles and other simple shapes like this.

if(object1.collides(object2)){  }  

what is best way to detect collision of image objects like player, or npc?

Please help me for the correct My Code looping (C Language)

Posted: 10 Nov 2021 08:28 AM PST

#include <stdio.h>  #include <stdlib.h>    int main()  {       int i;        for(i=1; i<5; i++)      {          printf(" %d Perulangan %d \n ", i);      }        return 0;  }  

Please help me for the correct My Code looping (C Language) , i want print this output :

    1 perulangan 1      2 perulangan 2      3 perulangan 3      4 perulangan 4   

Is Es5/Es6/Typescript just an extension of C# with extra steps? [closed]

Posted: 10 Nov 2021 08:29 AM PST

enter image description here

I am just curious if the almighty mod let this pass.

Unable to update new column values in rows which were derived from existing column having multiple values separeted by ','?

Posted: 10 Nov 2021 08:29 AM PST

Original dataframe

DF1 - original dataframe

Converted Dataframe using stack and split:

Converted Dataframe using stack and split

Adding new column to a converted dataframe:

Adding new column to a converted dataframe

What i am trying to is add a new column using np.select(condition, values) but it not updating the two addition rows derived from H1 its returning with 0 or NAN. Can someone please help me here ?

Please note i have already done the reset index but still its not helping.

How to connect flask rest API output to react and display result

Posted: 10 Nov 2021 08:28 AM PST

I am doing inference using flask rest API and I got the result

{  result: {  predictions: -3.4333341121673584  } }  

bypassing multiple args in the get as the URL I got the above result http://127.0.0.1:3000/predict?solute=CC(C)(C)Br&solvent=CC(C)(C)O Now I want to use this result to use in a react app.

I have written the code below

import { useState, useEffect } from "react";    function App() {    const [state, setState] = useState({});      useEffect(() => {      fetch("api/")        .then((response) => {          if (response.status == 200) {            return response.json();          }        })        .then((data) => console.log(data))        .then((error) => console.log(error));    });  

I have written the following using a tutorial on the internet. I am new to using fetch API or Axios. Need help to get this result in react app

Easy way to extract common measures such as accuracy, precision, recall from 3x3 confusion matrix with numpy or pansas?

Posted: 10 Nov 2021 08:28 AM PST

enter image description here

Hi there, do anyone knows how to speed up this process. Just a easy way to extract common measures such as accuracy, precision, recall, f-score from 3x3 confusion matrix only with numpy or pandas? Any suggestions? I am attaching you a image with the my outcome.

cm =confusion_matrix.to_numpy()  acuracy_0 = np.round_(cm[0][0]/cm[3][3], 2)  acuracy_1 = np.round_(cm[1][1]/cm[3][3], 2)  acuracy_2 = np.round_(cm[2][2]/cm[3][3], 2)  acuracy = (acuracy_0, acuracy_1, acuracy_2)  col1 = np.array(acuracy)    precision_0 = np.round_(cm[0][0]/cm[3][0], 2)  precision_1 = np.round_(cm[1][1]/cm[3][1], 2)  precision_2 = np.round_(cm[2][2]/cm[3][2], 2)  precision = (precision_0, precision_1, precision_2)  col2 = np.array(precision)    recall_0 = np.round_(cm[0][0]/cm[0][3], 2)  recall_1 = np.round_(cm[1][1]/cm[1][3], 2)  recall_2 = np.round_(cm[2][2]/cm[2][3], 2)  recall = (recall_0, recall_1, recall_2)  col3 = np.array(recall)    f_score_0 = np.round_((2*precision_0*recall_0)/(precision_0 + recall_0), 2)  f_score_1 = np.round_((2*precision_1*recall_1)/(precision_1 + recall_1), 2)  f_score_2 = np.round_((2*precision_2*recall_2)/(precision_2 + recall_2), 2)  f_score = (f_score_0, f_score_1, f_score_2)  col4 = np.array(f_score)    d = {'Acuracy': col1, 'Precision':col2, 'Recall':col3, 'F1_score':col4}  measurs = pd.DataFrame(data=d)  measurs.index.name = 'Class_Label'  measurs  

Installation Process of Flutter

Posted: 10 Nov 2021 08:29 AM PST

C:\Users\aakas>flutter doctor

'Information' is not recognized as an internal or external command, operable program or batch file. 'Information' is not recognized as an internal or external command, operable program or batch file. Error: Unable to find git in your PATH.

[1]How to fix it, I already set the environment variable and dart is working but flutter is not working

How do I counter value in a for loop as part of my dictionary key

Posted: 10 Nov 2021 08:29 AM PST

I am trying to create a for loop that adds keys and values to a dictionary every time it loops. The counter value of this for loop is part of the key name that gets added to the dictionary every time. How can I code this without defining a separate set for key values and assigning them to key values? or better said, how can I remove this line? "y.insert(i, "This is key number " + str(i+1))"

Here is my current code:

Dic = {}  y = []  for i in range(0,4):      y.insert(i, "This is key number " + str(i+1))      Dic[y[i]] = "This is a constant value for all keys"  

NextJS rewrites with wildcard query string params

Posted: 10 Nov 2021 08:28 AM PST

I am having a bit of an issue: I am trying to setup a rewrite in NextJS that will automatically send on the query string to the destination. However, the only examples I can find are with named params. In this case there could be any number of params, so I need a way of making a wildcard (I assume this will be possible?)

What I am looking to do is the following:

/results?param1=a&param2=b... => https://www.somedomain.com/results?param1=a&param2=b...  or  /results?house=red&car=blue&money=none => https://www.somedomain.com/results??house=red&car=blue&money=none    
rewrites() {      return [         {          source:'/results?:params*',          destination:'https://www.somedomain.com/results?:params*'        },  

Of course this doesn't work, so I looked into has but I cannot workout how to make it work without names params

       {            source: '/some-page',            destination: '/somewhere-else',            has: [{ type: 'query', key: 'overrideMe' }],          },  

Calling a function from JavaScript

Posted: 10 Nov 2021 08:28 AM PST

Trying to understand wasm in go, so I wrote the below that:

  1. Manipulate DOM
  2. Call JS function
  3. Define a function that can called by JS

first 2 steps are fine, but the last one is not working as expected, as I got the JavaScript error function undefined, my code is below, the issue I have is in the function sub

package main    import (      "syscall/js"  )    // func sub(a, b float64) float64    func sub(this js.Value, inputs []js.Value) interface{} {      return inputs[0].Float() - inputs[1].Float()  }    func main() {      c := make(chan int) // channel to keep the wasm running, it is not a library as in rust/c/c++, so we need to keep the binary running      js.Global().Set("sub", js.FuncOf(sub))      alert := js.Global().Get("alert")      alert.Invoke("Hi")      println("Hello wasm")        num := js.Global().Call("add", 3, 4)      println(num.Int())        document := js.Global().Get("document")      h1 := document.Call("createElement", "h1")      h1.Set("innerText", "This is H1")      document.Get("body").Call("appendChild", h1)        <-c // pause the execution so that the resources we create for JS keep available  }  

compiled it to wasm as:

GOOS=js GOARCH=wasm go build -o main.wasm wasm.go  

Copied the wasm_exec.js file to the same working folder as:

cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" .  

My HTML file is:

<!DOCTYPE html>  <html lang="en">  <head>      <title>WASM</title>      <script src="http://localhost:8080/www/lib.js"></script>      <!-- WASM -->      <script src="http://localhost:8080/www/wasm_exec.js"></script>      <script src="http://localhost:8080/www/loadWasm.js"></script>  </head>  <body>  </body>  <script>     console.log(sub(5,3));  </script>  </html>  

The lib.js is:

function add(a, b){      return a + b;  }  

The loadWasm.js is:

async function init(){      const go = new Go();      const result = await WebAssembly.instantiateStreaming(          fetch("http://localhost:8080/www/main.wasm"),          go.importObject      );      go.run(result.instance);  }  init();  

The server code is:

package main    import (      "fmt"      "html/template"      "net/http"  )    func wasmHandler() http.Handler {      return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {          tmpl := template.Must(template.ParseFiles("www/home.html"))            w.Header().Set("Content-Type", "text/html; charset=utf-8")          w.Header().Set("Access-Control-Allow-Origin", "*")          err := tmpl.Execute(w, nil)          if err != nil {              fmt.Println(err)          }      })  }    func main() {      fs := http.StripPrefix("/www/", http.FileServer(http.Dir("./www")))      http.Handle("/www/", fs)        http.Handle("/home", wasmHandler())      http.ListenAndServe(":8080", nil)    }  

The output i got is:

enter image description here

UPDATE

I tried using the TinyGO example as below, but got almost the same issue:

//wasm.go    package main    // This calls a JS function from Go.  func main() {      println("adding two numbers:", add(2, 3)) // expecting 5  }    // module from JavaScript.  func add(x, y int) int    //export multiply  func multiply(x, y int) int {      return x * y  }  

Compliled it as:

tinygo build -o main2.wasm -target wasm -no-debug  cp "$(tinygo env TINYGOROOT)/targets/wasm_exec.js" .  

And server.go as:

package main    import (      "log"      "net/http"      "strings"  )    const dir = "./www"    func main() {      fs := http.FileServer(http.Dir(dir))      log.Print("Serving " + dir + " on http://localhost:8080")      http.ListenAndServe(":8080", http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {          resp.Header().Add("Cache-Control", "no-cache")          if strings.HasSuffix(req.URL.Path, ".wasm") {              resp.Header().Set("content-type", "application/wasm")          }          fs.ServeHTTP(resp, req)      }))  }  

And the JS code as:

const go = new Go(); // Defined in wasm_exec.js    go.importObject.env = {      'main.add': function(x, y) {          return x + y      }      // ... other functions  }      const WASM_URL = 'main.wasm';    var wasm;    if ('instantiateStreaming' in WebAssembly) {      WebAssembly.instantiateStreaming(fetch(WASM_URL), go.importObject).then(function (obj) {          wasm = obj.instance;          go.run(wasm);      })  } else {      fetch(WASM_URL).then(resp =>          resp.arrayBuffer()      ).then(bytes =>          WebAssembly.instantiate(bytes, go.importObject).then(function (obj) {              wasm = obj.instance;              go.run(wasm);          })      )  }    // Calling the multiply function:  console.log('multiplied two numbers:', exports.multiply(5, 3));  

And the output i got is: enter image description here

Performance and memory difference between re-mounting vs setting display = "none"

Posted: 10 Nov 2021 08:28 AM PST

I have a single page application written in React. The app has multiple pages which can be displayed when the user clicks the tabs on the Nav Bar. So there are 2 possible designs:

  1. Mount the pages 1 at a time; unmount and remount whenever the user switches between pages via clicking the tab.

  2. Mount all of the pages simultaneously and only display the page selected while setting the rest to display = "none".

Questions:

  1. Which is better in terms of speed performance.
  2. Which is better in terms of memory performance.
  3. Which is standard practice?

Javascript - Move forward overlapping intervals

Posted: 10 Nov 2021 08:28 AM PST

Having this input:

[   {key: 'a', start: 0, end: 100}, // 100ms of duration   {key: 'b', start: 10, end: 30}, // 20ms of duration   {key: 'c', start: 110, end: 200}, // 90ms of duration,   {key: 'd', start: 300, end: 400},  ]  

I'd like this output:

 {key: 'a', start: 0, end: 100}, // 100ms of duration   {key: 'b', start: 100, end: 120}, // still 20ms of duration   {key: 'c', start: 120, end: 210}, // still 90ms of duration   {key: 'd', start: 300, end: 400}, // no modifications    

I need to fix only the overlapping intervals

How can reordering the linked libraries fix multiple definitions error?

Posted: 10 Nov 2021 08:28 AM PST

I faced a situation where different order of linking librdkafka and the Pulsar C++ client does matter, because both of them include their version of LZ4 compression. The linking fails because of multiple definitions of LZ4 functions (both librdkafka and Pulsar have the same names for those functions). I checked the static libraries, but I couldn't find anything suspicious, why it works in one order and doesn't in the another. Because it is hard to provide a minimal working example with those big libraries, I tried to reproduce the same situation, and I was able to do so. I created a small project where the linking order matters.

libA.hpp:

#pragma once    void NotClashingFunctionA();  void ClashingFunction();  

libA.cpp:

#include "libB.hpp"    #include <iostream>    void NotClashingFunctionA() {      std::cout << "Not clashing function A\n";  }    void ClashingFunction() {      std::cout << "Clashing function A\n";  }  

libB.hpp:

#pragma once    void NotClashingFunctionB();  

libB.cpp:

#include "libB.hpp"    #include <iostream>    void NotClashingFunctionB() {      std::cout << "Not clashing function B\n";  }  

libBSub.hpp:

#pragma once    void ClashingFunction();  

libBSub.cpp:

#include "libBSub.hpp"    #include <iostream>    void ClashingFunction() {      std::cout << "Clashing function B\n";  }  

main.cpp:

#include "libA.hpp"  #include "libB.hpp"  #include "libBSub.hpp"    int main() {      NotClashingFunctionA();      NotClashingFunctionB();      ClashingFunction();      return 0;  }  

CMakeLists.txt:

project(clashing)    add_library(A STATIC libA.cpp)    add_library(B STATIC libB.cpp libBSub.cpp)    add_executable(working main.cpp)  target_link_libraries(working A B)    add_executable(failing main.cpp)  target_link_libraries(failing B A)  

From the logs I can clearly see that working just links fine:

clang++ -g -rdynamic CMakeFiles/working.dir/main.cpp.o -o working  libA.a libB.a   make[3]: Leaving directory 'build'  [100%] Built target working  

But failing fails to link:

clang++ -g -rdynamic CMakeFiles/failing.dir/main.cpp.o -o failing  libB.a libA.a   ld: libA.a(libA.cpp.o): in function `ClashingFunction()':  libA.cpp:9: multiple definition of `ClashingFunction()'; libB.a(libBSub.cpp.o):libBSub.cpp:5: first defined here  clang-12: error: linker command failed with exit code 1 (use -v to see invocation)  

I removed the common prefixes to make the logs more readable.

As you can see the only difference between the two is the linking order A and B. I don't know why it works in A B order, and not B A order.

If you cannot explain it in details, helping keywords are also very appreciated, because I have absolutely no idea why it is happening.

BI Publisher - Display Image using the URL in RTF

Posted: 10 Nov 2021 08:28 AM PST

I am using Word 2019 to create RTF Templates for BI Publisher

I have a table ITEM_IMAGE that has a column IMAGE_URL that contains the URL of the image on the internet

I need to display the Image using the URL that is there on the field

How can I do that on MS Word 2019?

standard_init_linux.go:207: exec user process caused "exec format error" - Raspberry Pi 4

Posted: 10 Nov 2021 08:28 AM PST

I have a cluster of 4 raspberry pi 4 model b, on which Docker and Kubernetes are installed. The versions of these programs are the same and are as follows:

Docker:

Client:   Version:           18.09.1   API version:       1.39   Go version:        go1.11.6   Git commit:        4c52b90   Built:             Fri, 13 Sep 2019 10:45:43 +0100   OS/Arch:           linux/arm   Experimental:      false    Server:   Engine:    Version:          18.09.1    API version:      1.39 (minimum version 1.12)    Go version:       go1.11.6    Git commit:       4c52b90    Built:            Fri Sep 13 09:45:43 2019    OS/Arch:          linux/arm    Experimental:     false  

Kubernetes:

Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.3", GitCommit:"c92036820499fedefec0f847e2054d824aea6cd1", GitTreeState:"clean", BuildDate:"2021-10-27T18:41:28Z", GoVersion:"go1.16.9", Compiler:"gc", Platform:"linux/arm"}  Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.3", GitCommit:"c92036820499fedefec0f847e2054d824aea6cd1", GitTreeState:"clean", BuildDate:"2021-10-27T18:35:25Z", GoVersion:"go1.16.9", Compiler:"gc", Platform:"linux/arm"}  

My problem occurs when a kubernetes pod is deployed on machine "02". Only on that machine the pod never goes into a running state and the logs say

standard_init_linux.go:207: exec user process caused "exec format error"  

On the other hand, when the same pod is deployed on any of the other 3 raspberry pi, it goes correctly in a running state and does what it has to do. I have tried to see similar topics to mine, but there seems to be no match with my problem. I put below my Dockerfile and my .yaml file.

Dockerfile

FROM ubuntu@sha256:f3113ef2fa3d3c9ee5510737083d6c39f74520a2da6eab72081d896d8592c078  CMD ["bash"]  

yaml file

apiVersion: v1  kind: Pod  metadata:    labels:      name: mongodb    name: mongodb  spec:    nodeName: diamond02.xxx.xx    containers:      - name : mongodb        image: ohserk/mongodb:latest        imagePullPolicy: "IfNotPresent"        name: mongodb        ports:        - containerPort: 27017          protocol: TCP        command:         - "sleep"         - "infinity"  

In closing, this is what happens when I run "kubectl apply -f file.yaml" specifying to go to machine 02, while on any other machine the output is this

kubectl get pod -w -o wide

I could solve this problem by specifying precisely on which raspberry to deploy the pod, but it doesn't seem like a decent solution to me. Would you know what to do in this case?

EDIT 1

Here the journelctl output just after the deploy on machine 02

Nov 05 08:33:39 diamond02.xxx.xx kubelet[1563]: I1105 08:33:39.744957    1563 topology_manager.go:200] "Topology Admit Handler"  Nov 05 08:33:39 diamond02.xxx.xx systemd[1]: Created slice libcontainer container kubepods-besteffort-pod6a0d621a_55ab_449a_91cb_a88ac10df0cf.slice.  Nov 05 08:33:39 diamond02.xxx.xx kubelet[1563]: I1105 08:33:39.906608    1563 reconciler.go:224] "operationExecutor.VerifyControllerAttachedVolume started for volume \"kube-api-access-trqs4\" (UniqueName: \"kubernetes.io/projected/6a0d621a-55ab-449a-91cb-a88ac10df0cf-kube-api-access-trqs4\") pod \"mongodb\" (UID: \"6a0d621a-55ab-449a-91cb-a88ac10df0cf\") "  Nov 05 08:33:40 diamond02.xxx.xx systemd[9494]: var-lib-docker-overlay2-03b99c20a2e9dd9b6f06a99625272c899d6e7a36e2071e268b326dfee54476c8\x2dinit-merged.mount: Succeeded.  Nov 05 08:33:40 diamond02.xxx.xx dockerd[578]: time="2021-11-05T08:33:40.702427163Z" level=info msg="shim docker-containerd-shim started" address=/containerd-shim/moby/a62195de2c6319ff8624561322d9f60e4a68bc14d56248e8d2badd7cdeda7dc4/shim.sock debug=false pid=15599  Nov 05 08:33:40 diamond02.xxx.xx systemd[1]: libcontainer-15607-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:40 diamond02.xxx.xx systemd[1]: libcontainer-15607-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:40 diamond02.xxx.xx systemd[1]: Created slice libcontainer_15607_systemd_test_default.slice.  Nov 05 08:33:40 diamond02.xxx.xx systemd[1]: Removed slice libcontainer_15607_systemd_test_default.slice.  Nov 05 08:33:40 diamond02.xxx.xx systemd[1]: Started libcontainer container a62195de2c6319ff8624561322d9f60e4a68bc14d56248e8d2badd7cdeda7dc4.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: libcontainer-15648-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: libcontainer-15648-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: Created slice libcontainer_15648_systemd_test_default.slice.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: Removed slice libcontainer_15648_systemd_test_default.slice.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: libcontainer-15654-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: libcontainer-15654-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: Created slice libcontainer_15654_systemd_test_default.slice.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: Removed slice libcontainer_15654_systemd_test_default.slice.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: libcontainer-15661-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: libcontainer-15661-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: Created slice libcontainer_15661_systemd_test_default.slice.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: Removed slice libcontainer_15661_systemd_test_default.slice.  Nov 05 08:33:41 diamond02.xxx.xx kubelet[1563]: I1105 08:33:41.673178    1563 pod_container_deletor.go:79] "Container not found in pod's containers" containerID="a62195de2c6319ff8624561322d9f60e4a68bc14d56248e8d2badd7cdeda7dc4"  Nov 05 08:33:41 diamond02.xxx.xx kernel: IPv6: ADDRCONF(NETDEV_CHANGE): veth27f79edb: link becomes ready  Nov 05 08:33:41 diamond02.xxx.xx kernel: cni0: port 1(veth27f79edb) entered blocking state  Nov 05 08:33:41 diamond02.xxx.xx kernel: cni0: port 1(veth27f79edb) entered disabled state  Nov 05 08:33:41 diamond02.xxx.xx kernel: device veth27f79edb entered promiscuous mode  Nov 05 08:33:41 diamond02.xxx.xx kernel: cni0: port 1(veth27f79edb) entered blocking state  Nov 05 08:33:41 diamond02.xxx.xx kernel: cni0: port 1(veth27f79edb) entered forwarding state  Nov 05 08:33:41 diamond02.xxx.xx dhcpcd[573]: veth27f79edb: IAID 58:9b:78:38  Nov 05 08:33:41 diamond02.xxx.xx dhcpcd[573]: veth27f79edb: adding address fe80::5979:f76a:862:765a  Nov 05 08:33:41 diamond02.xxx.xx avahi-daemon[389]: Joining mDNS multicast group on interface veth27f79edb.IPv6 with address fe80::5979:f76a:862:765a.  Nov 05 08:33:41 diamond02.xxx.xx avahi-daemon[389]: New relevant interface veth27f79edb.IPv6 for mDNS.  Nov 05 08:33:41 diamond02.xxx.xx avahi-daemon[389]: Registering new address record for fe80::5979:f76a:862:765a on veth27f79edb.*.  Nov 05 08:33:41 diamond02.xxx.xx dhcpcd[573]: veth27f79edb: IAID 58:9b:78:38  Nov 05 08:33:41 diamond02.xxx.xx kubelet[1563]: map[string]interface {}{"cniVersion":"0.3.1", "hairpinMode":true, "ipMasq":false, "ipam":map[string]interface {}{"ranges":[][]map[string]interface {}{[]map[string]interface {}{map[string]interface {}{"subnet":"10.244.3.0/24"}}}, "routes":[]types.Route{types.Route{Dst:net.IPNet{IP:net.IP{0xa, 0xf4, 0x0, 0x0}, Mask:net.IPMask{0xff, 0xff, 0x0, 0x0}}, GW:net.IP(nil)}}, "type":"host-local"}, "isDefaultGateway":true, "isGateway":true, "mtu":(*uint)(0xcaa76c), "name":"cbr0", "type":"bridge"}  Nov 05 08:33:41 diamond02.xxx.xx systemd[9494]: var-lib-docker-overlay2-5e681f6bfcebe1b72e78d4af37e60f4032b31d883247f66631ddec92b8495b8b\x2dinit-merged.mount: Succeeded.  Nov 05 08:33:41 diamond02.xxx.xx systemd[1]: var-lib-docker-overlay2-5e681f6bfcebe1b72e78d4af37e60f4032b31d883247f66631ddec92b8495b8b\x2dinit-merged.mount: Succeeded.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: var-lib-docker-overlay2-5e681f6bfcebe1b72e78d4af37e60f4032b31d883247f66631ddec92b8495b8b-merged.mount: Succeeded.  Nov 05 08:33:42 diamond02.xxx.xx systemd[9494]: var-lib-docker-overlay2-5e681f6bfcebe1b72e78d4af37e60f4032b31d883247f66631ddec92b8495b8b-merged.mount: Succeeded.  Nov 05 08:33:42 diamond02.xxx.xx dockerd[578]: time="2021-11-05T08:33:42.283254485Z" level=info msg="shim docker-containerd-shim started" address=/containerd-shim/moby/1bcf46307ed16e46a25a86aa79dbe9a2b053ebe3042ee6cc08433e49213f2234/shim.sock debug=false pid=15718  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: libcontainer-15725-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: libcontainer-15725-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: Created slice libcontainer_15725_systemd_test_default.slice.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: Removed slice libcontainer_15725_systemd_test_default.slice.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: Started libcontainer container 1bcf46307ed16e46a25a86aa79dbe9a2b053ebe3042ee6cc08433e49213f2234.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: libcontainer-15749-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: libcontainer-15749-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: Created slice libcontainer_15749_systemd_test_default.slice.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: Removed slice libcontainer_15749_systemd_test_default.slice.  Nov 05 08:33:42 diamond02.xxx.xx dhcpcd[573]: veth27f79edb: soliciting an IPv6 router  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: libcontainer-15755-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: libcontainer-15755-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: Created slice libcontainer_15755_systemd_test_default.slice.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: Removed slice libcontainer_15755_systemd_test_default.slice.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: docker-1bcf46307ed16e46a25a86aa79dbe9a2b053ebe3042ee6cc08433e49213f2234.scope: Succeeded.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: docker-1bcf46307ed16e46a25a86aa79dbe9a2b053ebe3042ee6cc08433e49213f2234.scope: Consumed 39ms CPU time.  Nov 05 08:33:42 diamond02.xxx.xx dhcpcd[573]: veth27f79edb: soliciting a DHCP lease  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: libcontainer-15766-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: libcontainer-15766-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: Created slice libcontainer_15766_systemd_test_default.slice.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: Removed slice libcontainer_15766_systemd_test_default.slice.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: libcontainer-15778-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: libcontainer-15778-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: Created slice libcontainer_15778_systemd_test_default.slice.  Nov 05 08:33:42 diamond02.xxx.xx systemd[1]: Removed slice libcontainer_15778_systemd_test_default.slice.  Nov 05 08:33:43 diamond02.xxx.xx systemd[1]: libcontainer-15784-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:43 diamond02.xxx.xx systemd[1]: libcontainer-15784-systemd-test-default-dependencies.scope: Scope has no PIDs. Refusing.  Nov 05 08:33:43 diamond02.xxx.xx systemd[1]: Created slice libcontainer_15784_systemd_test_default.slice.  Nov 05 08:33:43 diamond02.xxx.xx systemd[1]: Removed slice libcontainer_15784_systemd_test_default.slice.  Nov 05 08:33:43 diamond02.xxx.xx dockerd[578]: time="2021-11-05T08:33:43.097966208Z" level=info msg="shim reaped" id=1bcf46307ed16e46a25a86aa79dbe9a2b053ebe3042ee6cc08433e49213f2234  Nov 05 08:33:43 diamond02.xxx.xx dockerd[578]: time="2021-11-05T08:33:43.107322948Z" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"  Nov 05 08:33:43 diamond02.xxx.xx systemd[9494]: var-lib-docker-overlay2-5e681f6bfcebe1b72e78d4af37e60f4032b31d883247f66631ddec92b8495b8b-merged.mount: Succeeded.  Nov 05 08:33:43 diamond02.xxx.xx systemd[1]: var-lib-docker-overlay2-5e681f6bfcebe1b72e78d4af37e60f4032b31d883247f66631ddec92b8495b8b-merged.mount: Succeeded.  Nov 05 08:33:43 diamond02.xxx.xx avahi-daemon[389]: Registering new address record for fe80::cc12:58ff:fe9b:7838 on veth27f79edb.*.  Nov 05 08:33:44 diamond02.xxx.xx kubelet[1563]: {"cniVersion":"0.3.1","hairpinMode":true,"ipMasq":false,"ipam":{"ranges":[[{"subnet":"10.244.3.0/24"}]],"routes":[{"dst":"10.244.0.0/16"}],"type":"host-local"},"isDefaultGateway":true,"isGateway":true,"mtu":1450,"name":"cbr0","type":"bridge"}I1105 08:33:44.040009    1563 scope.go:110] "RemoveContainer" containerID="1bcf46307ed16e46a25a86aa79dbe9a2b053ebe3042ee6cc08433e49213f2234"  

MudDatePicker DefaultValue plus DateChange

Posted: 10 Nov 2021 08:28 AM PST

I want to use MudDatePicker element in a way where I need to be able to set a default value on load but at the same time define a onChange event for it. I am trying to do this but error says "The component parameter is used two or more times for this component". Is there a way I can do this?

<MudDatePicker @bind-Date="@DefaultValue.Value" Label="Date" DateChanged="OnDateChange"          Required="true" Class="mb-3" />  

How to cast from UInt16 to NSNumber

Posted: 10 Nov 2021 08:28 AM PST

I have a UInt16 variable that I would like to pass to a legacy function that requires an NSNumber.

If I try:

var castAsNSNumber : NSNumber = myUInt16  

I get a compiler error 'UInt16' is not convertible to 'NSNumber'

Question

How can I recast this as an NSNumber?

No comments:

Post a Comment