Thursday, May 13, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Heroku Laravel 500 (Internal Server Error) oauth-public.key does not exist

Posted: 13 May 2021 08:59 AM PDT

I uploaded a question board using Laravel, Vue, RESTful API on Heroku. When I log in and add a question, I get a 500 (Internal Server Error) called "Key path \"file:///app/storage/oauth-public.key\" does not exist or is not readable".

Github: https://github.com/2020software/Sample-Vuedev

Heroku Question board: https://samplevueqa.herokuapp.com/

Login id : text@example.com Login pw: password

Thank you for those who have solved the same problem!

SHA3 Function Properties

Posted: 13 May 2021 08:58 AM PDT

For

  1. Theta
  2. Rho
  3. Pi
  4. Chi
  5. Iota

Do you know which provide permutation, non-linearity and substitution? And how could I figure out if a function provides permutations/non-linearity/substitution.

Specify the output per topic to a specific number of words

Posted: 13 May 2021 08:58 AM PDT

After conducting a lda topic modeling in R some words have the same beta value. They are therefore listed together when plotting the results. This leads to overlapping and sometimes unreadable results.

Is there a way to limit the amount of words displayed per topic to a specific number? In my dummy data set, some words have the same beta values. I would like to tell R that it should only display 3 words per topic, or any specified number according to necessity.

Currently the code I am using to plot the results looks like this:

top_terms %>% # take the top terms        group_by(topic) %>%        mutate(top_term = term[which.max(beta)]) %>%         mutate(term = reorder(term, beta)) %>%         head(3) %>% # I tried this but that only works for the first topic        ggplot(aes(term, beta, fill = factor(topic))) +         geom_col(show.legend = FALSE) +         facet_wrap(~ top_term, scales = "free") +         labs(x = NULL, y = "Beta") + # no x label, change y label        coord_flip() # turn bars sideways  

I tried to solve the issue with head(3) which worked, but only for the first topic. What I would need is something similar, which doesn't ignore all the other topics.

Best regards. Stay safe, stay healthy.

Note: top_terms is a tibble.

Sample data:

topic   term      beta  (int)   (chr)     (dbl)   1       book      0,9876   1       page      0,9765  1       chapter   0,9654  1       author    0,9654  2       sports    0,8765  2       soccer    0,8654  2       champions   0,8543  2       victory   0,8543  3       music     0,9543  3       song      0,8678  3       artist    0,7231  3       concert   0,7231  4       movie     0,9846  4       cinema    0,9647  4       cast      0,8878  4       story     0,8878   

random a number from normalized list with dependency

Posted: 13 May 2021 08:58 AM PDT

I have a list of nurmalize numbers, the sum of the list is 1. for example:

[0.3, 0.5, 0.2]  

I what to random an index but with the following condition:

  1. index 0 has 30% chance to be chosen
  2. index 1 has 50% chance to be chosen
  3. index 2 has 20% chance to be chosen

how can I do so with numpy of random?

I am integrating the android SDK of my project with Yodo1MAS games but i got issue related sync

Posted: 13 May 2021 08:58 AM PDT

I am working on a Yodo1MAS project and when i import

protected void onCreate() {      super.onCreate();      Yodo1Mas.getInstance().init(this, "com.game.app ID", new Yodo1Mas.InitListener() {          @Override          public void onMasInitSuccessful() {          }            @Override          public void onMasInitFailed(@NonNull Yodo1MasError error) {          }      });    }  

i got issue related Yodo1Mas. Anyone please help me to resolve this issue.

Kendo Gantt Timeline in 30 minute increments?

Posted: 13 May 2021 08:57 AM PDT

I am using the Kendo Gantt chart with ASP.NET MVC Core, and I would like to get the Day view timeline to show in 30 minute increments vs. 1 hour increments. The working hours I'm trying to display for each day are 7:00 AM to 3:30 PM, but I cannot get that 3:30 PM end of day to display.

Here is an example of getting a time header template using the jquery kendo gantt chart

<div id="gantt"></div>  <script>  $("#gantt").kendoGantt({    dataSource: [{      id: 1,      orderId: 0,      parentId: null,      title: "Task1",      start: new Date("2014/6/17 9:00"),      end: new Date("2014/6/17 11:00")    }],    views: [      { type: "day", timeHeaderTemplate: kendo.template("#=kendo.toString(start, 'T')#") },      { type: "week" },      { type: "month" }    ]  });  </script>  

However, I can't figure out how get that template to show the 30 minute increments, or if there is a different way to accomplish this. Essentially, I want it to look like the Kendo Scheduler Timeline view shown here: Timeline example with 30 minute increments

Where statement in my query is supposed to pull only todays and yesterdays dates, but is still pulling older dates

Posted: 13 May 2021 08:59 AM PDT

I am looking to only pull data from the past 24 hours. The where statement I am using, in theory, should only pull from those productiondates. However, I am still having week-old productiondates populate. Any thoughts on how to improve this, or am I doing it wrong? I am using periscope.

select example1,       example2,       example3,      productiondate,      example4,       example5  from final  where exampleX = exampleY or exampleX is null  and productiondate  > DATEADD(day,-1, GETDATE())  and example1 <> 'XXX'  and example2 <> 'YYY'  and example2 <> 'ZZZ'      order by 2  

Elastic Beanstalk not using my Procfile during deploy

Posted: 13 May 2021 08:58 AM PDT

I am trying to run some commands in a Procfile (located in my root, also tried placing it in any relevant directory that could be the root to no avail). Ideally, I would like to see this log:

2021-01-27 19:04:05 INFO Instance deployment successfully used commands in the 'Procfile' to start your application

Environment:

Elastic Beanstalk Python 3.6 running on 64bit Amazon Linux/2.10.0

Conditional material style in form field

Posted: 13 May 2021 08:58 AM PDT

In Angular, how can I render a material style conditionally?

For example, I want to only apply the style

.mat-form-field-appearance-outline .mat-form-field-infix{      padding-right: 2.3em;  }  

to my second form field and only when both input boxes have input.

See below:

enter image description here

As you can see, the padding right is being applied to the Email form field as well. However, I only want this padding to be applied to the bottom form field, when both input boxes have input, so the text does not go over the submit button.

My .html:

    <mat-form-field appearance="outline" hideRequiredMarker>          <mat-label>Email</mat-label>          <input               matInput               [(ngModel)]="emailLoginInput"              style="caret-color: white"           />      </mat-form-field>      <mat-form-field appearance="outline" hideRequiredMarker>          <mat-label>Password</mat-label>          <input              matInput              [(ngModel)]="passwordLoginInput"              type="password"              style="caret-color: white"          />          <div              [ngStyle]="{'visibility': passwordLoginInput.length && emailLoginInput.length ? 'visible' : 'hidden'}"              class="continue-button"              (click)="loginAccount()"          >              <img                  src="../../../assets/login/login-arrow.svg"                  alt="Continue"              />          </div>      </mat-form-field>  

How can I achieve this?

Thank you in advance.

How to apply css on sub class

Posted: 13 May 2021 08:59 AM PDT

   <main>              <div class="first-scheme">                  <div class = "row">                      <div class="col-sm-12">                          <p>Hello World</p>                          <button type="submit" formtarget="_blank" class="btn-sm">Read More</button>                      </div>                  </div>              </div>  

i want apply css on first-scheme

.first-scheme{  margin-top: 10px;  height: 250px;  width: 450px;  background:black;  color: white;  

}

when i try to this css but no effect on page

Not able to run the query since mysql is considering the string as column name

Posted: 13 May 2021 08:59 AM PDT

I am trying to insert data into my sql table using data stored in the list The code I am using is:

    for index, row in df.iterrows():          cursor.execute("INSERT INTO final_attendance (Fac_id,Subject,Name,roll_id) VALUES ({fac}, {sub}, {name}, {roll})".format(                         fac = row['Fac_id'],                         sub = row['Subject'],                         name = row['Name'],                         roll = row['roll_id']))  

But when I run this code sql considers the data stored in the list as a column name rather than normal Varchar

for Example: The correct sql syntax to input data is

INSERT INTO final_attendance (Fac_id, Subject, Name, roll_id)   VALUES ("PRD", "CSE", "Tanmay Pardhi", 59)  

But what my code writes is

INSERT INTO final_attendance (Fac_id, Subject, Name, roll_id)   VALUES (PRD, CSE, Tanmay Pardhi, 59)  

And so it considers PRD as a column name Error on execution is "Unknown column 'PRD' in 'field list"

Thanks in advance!

Permission denied [closed]

Posted: 13 May 2021 08:58 AM PDT

Super basic issue in ubuntu -- downloaded a zip file. Moved it to my working folder (20210513-eman-practice). Currently trying to unzip the folder (eman.zip) but permission is denied:

(qiime2-2021.4) user@DESKTOP-B4U4UA2:~/20210513-eman-practice$ unzip eman.zip  error:  cannot open zipfile [ eman.zip ]          Permission denied  error:  cannot open zipfile [ eman.zip.zip ]          Permission denied  unzip:  cannot find or open eman.zip, eman.zip.zip or eman.zip.ZIP.  

I manually unzipped it and put files into a separate folder (eman). When I try the ls command on this folder:

ls: cannot open directory 'eman': Permission denied  

Very new to command line. How do I give myself permission (novice friendly please!) ?

How to use HTTP_REFERER in PHP

Posted: 13 May 2021 08:59 AM PDT

I know this may be a duplicate of another link on here but I am not able to find a fix for my code.

I am trying to make a puzzle for my friends and family can try to do and I need a way to track what website they just came from so I know whether to send them to the next puzzle/win screen, or to send them to a page effectively saying they are cheaters. I am trying to use $_SERVER[HTTP_REFERER] to make this easier for me, but I want to echo out the address that the user is coming from to test my code, and I keep getting an index error.

MY CODE:

<?php  $_SERVERADDR=$_SERVER['HTTP_REFERER'];  echo "$_SERVERADDR";  ?>  

I keep getting an index error on this line $_SERVERADDR=$_SERVER['HTTP_REFERER'];

Can anyone help out?

how to get/set component size dinamically

Posted: 13 May 2021 08:57 AM PDT

I have a DIV container that has a paragraph and another inner DIV displayed in line. Inner DIV is unknown but it's always the same and not gonna change. I can sent min-width if needed. Now based on outer DIV size I need to either cut (with three dots) or show full paragraph string. But I have to set paragraph width in css to show that three dots when outer div size is too small.

<div className="divOuter">    <p>very long string</p>    <div className="divInner">some div stuff</div>  </div>    .p {    position: relative;    float: left;    text-overflow: ellipsis;    overflow: hidden;     width: ?????;               // what do I set here?????    white-space: nowrap;  }    .divInner {    display: flex;    float: right;    align-items: center;  }      |--------------------------------------|  |very long string        some div stuff|  |--------------------------------------|    need to get this when outer DIV resized:  |------------------------------|  |very long st... some div stuff|  |------------------------------|  

How to open the youtube link from a youtube video embed in a PyQt5 Widget in Python?

Posted: 13 May 2021 08:59 AM PDT

Environment:

Python 3.7 PyQT5 5.15.2

I have a GUI with some links and Youtube videos embed inside a QWidget.

A GUI is a user interface. I've done mine for my software with Python PyQT5. I want to show some video tutorials from YOutube inside my GUI.

So I incorporate the youtube iframe HTML code inside a Qwidget (vlayout & webview, see code below).

The GUI is loading fine, and the videos are playing well. But they are too small. So my users will click on the youtube link over the video:

enter image description here

When I click on this Youtube link when playing the video, it supposes to open a youtube video page from my browser. It is useful to watch it directly from youtube instead of from my GUI. But the link doesn't work. it doesn't do anything. Something is wrong.

SO I tried to play with 'setOpenExternalLinks' & 'centralwid', but it doesn't work. The widget for my youtube doesn't have this attribute.

AttributeError: 'QWidget' object has no attribute 'setOpenExternalLinks'  

Why?

Here is the code of some youtube videos and labels:

# Code for 1 Youtube video and its QtWidget  # ======================================================================================  self.centralwid = QtWidgets.QWidget(self.tab_run)  self.centralwid.setGeometry(QtCore.QRect(60, 40, 410, 258))  self.centralwid.setObjectName("centralwid")  self.label_loading_browsers = QtWidgets.QLabel(self.centralwid)  # ===================== HERE IS THE CODE FOR IFRAM YOUTUBE ============================  self.vlayout = QtWidgets.QVBoxLayout()  self.webview = QtWebEngineWidgets.QWebEngineView()  self.webview.settings().setAttribute(QWebEngineSettings.FullScreenSupportEnabled, True)  self.webview.page().fullScreenRequested.connect(lambda request: request.accept())  baseUrl = "local"  htmlString = """                  <iframe width="350" height="212" src="https://www.youtube.com/embed/g8NVwN0_mks?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>                          """    self.webview.setHtml(htmlString, QUrl(baseUrl))  self.vlayout.addWidget(self.webview)  self.centralwid.setLayout(self.vlayout)  

I search for all the properties and methods of my object qwidget. I added these 2 lines but it didn't change anything:

self.webview.settings().setAttribute(QWebEngineSettings.LocalContentCanAccessRemoteUrls, True)  self.webview.settings().setAttribute(QWebEngineSettings.AllowRunningInsecureContent, True)  

Here is MiniMum Reproductable COde (just copy paste in a py file and execute, you may need to resize window of gui to see the video)

import sys  from PyQt5 import QtWidgets  from PyQt5 import QtCore  from PyQt5.QtWidgets import QApplication, QLabel, QMainWindow  from PyQt5.QtCore import QUrl, Qt  from PyQt5 import QtWebEngineWidgets  from PyQt5.QtWebEngineWidgets import QWebEngineSettings    # Subclass QMainWindow to customise your application's main window  class MainWindow(QMainWindow):        def __init__(self, *args, **kwargs):          super(MainWindow, self).__init__(*args, **kwargs)            self.setWindowTitle("My Awesome App")            label = QLabel("This is a PyQt5 window!")            # The `Qt` namespace has a lot of attributes to customise          # widgets. See: http://doc.qt.io/qt-5/qt.html          label.setAlignment(Qt.AlignCenter)            # Set the central widget of the Window. Widget will expand          # to take up all the space in the window by default.          self.setCentralWidget(label)            # Code for 1 Youtube video and its QtWidget          # ======================================================================================            self.centralwid = QtWidgets.QWidget(self)          self.centralwid.setGeometry(QtCore.QRect(60, 40, 410, 258))          self.centralwid.setObjectName("centralwid")          self.label_loading_browsers = QtWidgets.QLabel(self.centralwid)          # ===================== HERE IS THE CODE FOR IFRAM YOUTUBE ============================          self.vlayout = QtWidgets.QVBoxLayout()          self.webview = QtWebEngineWidgets.QWebEngineView()          self.webview.settings().setAttribute(QWebEngineSettings.FullScreenSupportEnabled, True)                  self.webview.settings().setAttribute(QWebEngineSettings.LocalContentCanAccessRemoteUrls, True)          self.webview.settings().setAttribute(QWebEngineSettings.AllowRunningInsecureContent, True)          self.webview.page().fullScreenRequested.connect(lambda request: request.accept())          baseUrl = "local"          htmlString = """                          <iframe width="350" height="212" src="https://www.youtube.com/embed/g8NVwN0_mks?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>                                  """            self.webview.setHtml(htmlString, QUrl(baseUrl))          self.vlayout.addWidget(self.webview)          self.centralwid.setLayout(self.vlayout)      app = QApplication(sys.argv)    window = MainWindow()  window.show()    app.exec_()  

Derive keywords from search text

Posted: 13 May 2021 08:58 AM PDT

I am trying to generate keywords to search and display some content from the database.I have given a sample search text and keywords that I would like to derive from the keyword. Can someone guide me on how to implement the logic to get the keywords from a dynamic search string as shown below?

var searchText='My name is John santose mayer'    var Keywords={       1: 'My name is John santose mayer',      2: 'My name is johns santose',      3: 'My name is John',      4: 'My name is',      5: 'My name'      6: 'My'    }  

What approach should i use to inform the user that the email is already being used

Posted: 13 May 2021 08:58 AM PDT

Im building a .net api using razor pages and i want to validate the email input during creation so theres no email duplicates being stored into the database. I was using the UNIQUE parameter in my database design but that brought little success. This is my current User class that i scaffolded using razor pages (CRUD).

public class User  {      [Required]      public int ID { get; set; }        [Required,           StringLength(20, MinimumLength = 2,           ErrorMessage ="Name has to be between 2 and 20 characters long")]      public string Name { get; set; }        [Required,           DataType(DataType.EmailAddress),           RegularExpression(@"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*"+ "@"+ @"((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$",          ErrorMessage = "Invalid Email Format")]      public string Email { get; set; }              [Required,           DataType(DataType.Date),           Display(Name = "Date Of Birth")]       public DateTime DateOfBirth { get; set; }        [Display(Name = "Additional Info"),           DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}",           ApplyFormatInEditMode = true)]      public string AdditionalInfo { get; set; }        [Required,           StringLength(24, MinimumLength = 8,           ErrorMessage = "Password has to be between 8 and 24 characters long"),           DataType(DataType.Password)]      public string Password { get; set; }    }  

so i tried the UNIQUE property in my SQL database like this.

CREATE TABLE [dbo].[User] (  [ID]             INT            IDENTITY (1, 1) NOT NULL,  [Name]           NVARCHAR (20)  NOT NULL,  [Email]          NVARCHAR (50) NOT NULL UNIQUE,  [DateOfBirth]    DATETIME2 (7)  NOT NULL,  [AdditionalInfo] NVARCHAR (100) NULL,  [Password]       NVARCHAR (28) NOT NULL,  CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED ([ID] ASC));  

What's best practice in a scenario like this to check if the Email is already in use ?

Python value error. Fermentation plot needs more work

Posted: 13 May 2021 08:58 AM PDT

I am trying to write a program that takes columns from an excel file and plots them. The plot has multiple axes, and is data from a fermentation. I have had help with the code for the plot, but I cannot get it to work with the data. Is python reading the columns as strings? Here comes the code:

import pandas as pd  import numpy as np  import matplotlib.pyplot as plt  #Insert complete path to the excel file and index of the worksheet 9Mar2021_batch  df = pd.read_excel("9Mar2021_batch.xlsx", sheet_name = 1 )  df.columns = df.columns.str.strip()#aparrently there are some spaces in the excel file, this   strips those out.  # insert the name of the column as a string in brackets  Time = list(df['Time'])  pH = list(df['pH'])   DO = list(df['DO'])  Agit = list(df['Agit'])  GasFlow = list(df['GasFlow'])  Temp = list(df['Temp'])  In [5]:  #%% Writing  data    time = [Time] # Hours    temperature = [Temp] # dC    agitation = [Agit] # rpm    DO = [DO] # %    pH = [pH] # pH    gas_flow = [GasFlow]  #vvm    #%% Set up the plot     fig, host = plt.subplots(figsize=(8,5)) # (width, height) in inches      # Define the number of secondary axis here        par1 = host.twinx()    par2 = host.twinx()    par3 = host.twinx()    par4 = host.twinx()    # Define the limits of each axis plot here    host.set_xlim(0, 48)      # Time (check maximum hours)    host.set_ylim(0, 30)     # Temperature    par1.set_ylim(100, 800)  # Agitation    par2.set_ylim(0, 110)    # DO    par3.set_ylim(3, 7)      # pH    par4.set_ylim(0, 30)  # gas_flow      # Set the label of the different  axis here    host.set_xlabel("Time")    host.set_ylabel("Temperature")    par1.set_ylabel("Agitation")    par2.set_ylabel("DO")    par3.set_ylabel("pH")    par4.set_ylabel("gas_flow")      # Set the colormaps     color1 = plt.cm.plasma(0)     color2 = plt.cm.plasma(0.25)    color3 = plt.cm.plasma(0.5)    color4 = plt.cm.plasma(0.75)    color5 = plt.cm.plasma(0.9)    # Plot the data    p1, = host.plot(time, temperature,    color=color1, label="Temperature")    p2, = par1.plot(time, agitation,    color=color2, label="Agitation")    p3, = par2.plot(time, DO, color=color3, label="DO")    p4, = par3.plot(time, pH, color=color4, label="pH")    p5, = par4.plot(time, gas_flow, color=color5, label="Gas_flow")    lns = [p1, p2, p3, p4, p5]    host.legend(handles=lns, loc='best')        # right, left, top, bottom    par2.spines['right'].set_position(('outward', 60))    par3.spines['right'].set_position(('outward', 120))    par4.spines['right'].set_position(('outward', 180))      # no x-ticks                     par2.xaxis.set_ticks([])    par3.xaxis.set_ticks([])    par4.xaxis.set_ticks([])          host.yaxis.label.set_color(p1.get_color())    par1.yaxis.label.set_color(p2.get_color())    par2.yaxis.label.set_color(p3.get_color())    par3.yaxis.label.set_color(p4.get_color())    par4.yaxis.label.set_color(p5.get_color())          # Adjust spacings w.r.t. figsize    fig.tight_layout()                #%% Save the figure    plt.savefig("fermentation_profile.pdf")  

And the error:

ValueError                                Traceback (most recent call last)  <ipython-input-5-97e016dc1996> in <module>       72 # Plot the data       73   ---> 74 p1, = host.plot(time, temperature,    color=color1, label="Temperature")       75        76 p2, = par1.plot(time, agitation,    color=color2, label="Agitation")    ValueError: too many values to unpack (expected 1)  

Setting environment variable with special characters through conda in powershell

Posted: 13 May 2021 08:59 AM PDT

How do you set an environment variable through conda in powershell when the value has special characters? For example, if I run

conda env config vars set AZURE_CON_STRING="DefaultEndpointsProtocol=https;AccountName=anaccount;AccountKey=7mAi16vv4iyJtp8wPLxGf0ynaergfaergergeargaerg+pmWfKfTcoom/j6Ki7aviFS/f4RSyN3gergeru1aEiw==;EndpointSuffix=core.windows.net"  

The resulting environment variable is just core.windows.net instead of the full string.

Using single quotes gives the same result. I have also tried enclosing with backtick (`) and @" "@ but to no avail.

Python parser output from command

Posted: 13 May 2021 08:58 AM PDT

I retrive this output with a curl command:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><restQueuedBuild planKey="project-build001" buildNumber="123" buildResultKey="project-build001-123"><triggerReason>Manual build</triggerReason><link href="https://mybamboo.server.com/rest/api/latest/result/project-build001-123" rel="self"/></restQueuedBuild>  

How to get in buildNumber volue 123 in python?

How to implement hierarchical RBAC in laravel

Posted: 13 May 2021 08:59 AM PDT

I already checked the Laravel-permission by Spatie but I can not find a native way to implement the concept of parent role which inherent child role permissions. I was using such concept in Yii2 but I can not able o switch such feature to Laravel. I there is a Laravel package with able to do this I will be appreciate or if there is a way to do it manually also ok. Here is how it is implemented in Yii2 framework Yii2 autherization enter image description here

How to use read_line function with Rust's serialport crate

Posted: 13 May 2021 08:58 AM PDT

I am working with the serialport crate on a raspberry. The given example with port.read works fine. However port.read_to_end or port.read_to_string does not work, I get a timeout. Can anybody explain this behavior? The two functions read all bytes until EOF. I am sending test strings with null termination.

I am more interested in a read_line function. But this is not directly supported with the serialport crate, is it? Can I use the BufRead trait for this?

How to subclass QML Window?

Posted: 13 May 2021 08:57 AM PDT

I need to add some features in c++. But I struggle how to properly create my own QML window type. I have tried to subclass QQuickWindow and register my new type and use it in My QML project. But when starting it show error, that I can not set opacity

mywindow.h

#include <QQuickItem>  #include <QQuickWindow>  #include <QWindow>  #include <QApplication>  #include <QObject>   class MyWindow : public QQuickWindow {     Q_OBJECT  public:     MyWindow(QQuickWindow *parent=nullptr);   public slots:     Q_INVOKABLE void mycppFeature();  

mywindow.cpp

#include "reminderwindow.h"  MyWindow::MyWindow(QQuickWindow *parent):QQuickWindow(parent){  }  

main.cpp

qmlRegisterType<MyWindow>("com.organization.my", 1, 0, "MyWindow");  

SplashWindow.qml

import QtQuick 2.0  import QtQuick.Controls 2.5  import QtQuick.Window 2.15  import com.organization.my 1.0  MyWindow{     opacity: 0.8  

MyWindow is find but the error is "MyWindow.opacity" is not available in com.organizatino.my 1.0. I believe I do not know how to properly subclass the QML Window type. I use it besides the main ApplicationWindow When I use it without opacity, it works properly

sample from randomly generated numbers?

Posted: 13 May 2021 08:57 AM PDT

There is a program that needs to get 100 samples from 1000 randomly generated number distributed in [1, 500]. How can do I get a random sample from the output?

I wrote the following:

N = 1000  x = 1 + 500 * np.random.rand(N)   sp_x = random.sample(x, 100)  

I am getting an error:

TypeError: Population must be a sequence or set.  For dicts, use list(d).  

is it possible to achieve dynamic scheduling of a task for each user at different time in spring boot/java

Posted: 13 May 2021 08:59 AM PDT

We have an REST API "/schedule" for scheduling a call to 3rd party API . when one User login and set his scheduler time to 1 minute for a task then it is set for every user (using shceduledExecutorService with method name scheduleAtFixedRate)

TaskUtils mytask1 = new TaskUtils(this);                scheduledExecutorService = Executors.newScheduledThreadPool(1);                futureTask = scheduledExecutorService.scheduleAtFixedRate(mytask1, 0, time, TimeUnit.MILLISECONDS);  

but this is not the actual requirement. Let's understand the requirement with an example. Example & Requirement : user1 login and schedule a task at a time difference of 1 minute . when user2 login he want to scheduler the task at 1 hour. So, execution should be like that the scheduled task execute at different time for different users.

Set custom template for custom post type for Wordpress Admin Post Page

Posted: 13 May 2021 08:59 AM PDT

I am currently on WordPress 5.6.2 and developing a plugin.

I need to set a custom template for a custom post type.

My custom post type is reseller_r_limit.

My current page when I click on Add new button, it looks like http://localhost/project/wp-admin/post-new.php?post_type=reseller_r_limit.

I have referred to many similar questions and I got to know that we need to use single-{post_type}.php. I did so and my plugin folder hierarchy looks like this:

reseller program      --> reseller_program.php     --> templates       --> single-reseller_r_limit.php  

The content under single-reseller_r_limit.php looks like below with a simple echo message:

<?php    echo "Hey";  

I registered the post_type using register_post_type as below:

add_action('init','reseller_limit_post_type');    function reseller_limit_post_type(){      register_post_type('reseller_r_limit',          array(              'labels'      => array(                  'name'          => __('Reseller Redeem Limits'),                  'singular_name' => __('Reseller Redeem Limits'),              ),              'public'      => false,              'has_archive' => true,              'show_ui' => true,              'show_in_nav_menus' => false,              'show_in_admin_bar' => true,              'publicly_queryable'  => false,              'exclude_from_search' => true,              'hierarchical'        => true,              'rewrite'             => false,              'query_var'           => false,          )      );  }  

The issue is I am still not able to see the Hey when I click on add new button which means Wordpress is still unable to find the template file and it directly takes me to adding a new usual post. Can anyone let me know where I am going wrong?

Plotting graphs lines based on Long format using Plotly in python

Posted: 13 May 2021 08:57 AM PDT

MY dataset looks like attached below

|CREDIT_ENTITY TENOR    SPREAD  SNAPSHOT_DATE|    |ABC              1Y    127.161 14/09/2017|    |ABC              3Y    150.161 14/09/2017|    |ABC              5Y    180.161 14/09/2017|    |ABC              7Y    111.161 14/09/2017|    |ABC              10Y   128.161 14/09/2017|    |ABC              1Y    123.161 15/09/2017|    |ABC              3Y    145.161 15/09/2017|    |ABC              5Y    196.161 15/09/2017|    |ABC              7Y    111.161 15/09/2017|    |ABC              10Y   134.161 15/09/2017|    |ABC              1Y    109.161 25/09/2017|    |ABC              3Y    190.161 25/09/2017|    |ABC              5Y    180.161 25/09/2017|    |ABC              7Y    127.161 25/09/2017|    |ABC              10Y   170.161 25/09/2017|  

I would like to plot a graph for such dataset having a curve for each tenor. I use the following command.

import pandas as pd  import plotly.express as px    fig = px.line(Final_DF, x="SNAPSHOT_DATE", y="SPREAD", color="TENOR")  fig.show()  

However on plotting the graph, I get a different curve for each date that is really weird.

I would like to ask if someone can help? Thank you

Android: How to Add Library 'Gradle: com.google.android.support:wearable:2.8.1@aar' to classpath

Posted: 13 May 2021 08:58 AM PDT

I have this import in my class:

import com.google.android.wearable.intent.RemoteIntent;  

But am getting an error:

Cannot resolve symbol 'RemoteIntent'  

The red lightbulb recommendation is to:

Add Library 'Gradle: com.google.android.support:wearable:2.8.1@aar' to classpath  

But when I click on it nothing happens.

And this line in my mobile app gradle dependencies:

compileOnly 'com.google.android.wearable:wearable:2.8.1'  

What am I doing wrong?

When I try to build I get this error:

package com.google.android.wearable.intent does not exist error  

I was following the Android WearVerifyRemoteApp Sample in GitHub.

UPDATE

I see in the projects view that the files are there, so I wonder why they're not being recognized. enter image description here

How to let Cypress return custom errors or messages

Posted: 13 May 2021 08:58 AM PDT

I'm looking for a way to create a custom message instead of the standard messages. What I have is this piece of code (scrambled a bit):

Cypress.Commands.add('authenticate', {prevSubject: 'optional'}, (_, fixture) => {    return cy.fixture(fixture).then(credentials => {      cy        .apiRequest('scrambled/url/here', {          method: 'post',          authorizationMethod: 'Basic',          token: apiOauthSecret,          data: credentials        })        .then(resp => {          expect(resp.status)            .to            .eq(201, 'Unable to authenticate, login failed')          storeTokenInSession(resp.body)        })    })  })  

That code results in a error like this: https://i.stack.imgur.com/l2j4o.png

If I fix the code so the result is okay the result looks like this: https://i.stack.imgur.com/Pr1iA.png

As you see the message should be displayed if the eq() fails instead of when the eq() succeeds.

I want to show the message only if the check fails, but I also want the test to break and stop.

Do you people have any idea how to get this working? I already looked into using cy.log() and the solution shown here.

CComboBox Sorting

Posted: 13 May 2021 08:58 AM PDT

So I am attempting to cut my CPP teeth on an existing application.

I ran into a bit of a snag. My combobox items are being added in order as you can see below. However, the output is

[1,10,11,12,13,14,15,2,3,4,5,6,7,8,9]  

I have looked at the CComboBox documentation here. Yet, I still am confused as to why this is producing this result.

for (int i = 1; i <= m_pPage2->GetNumberColumns(); i++)  {      CString szColNum;      szColNum.Format (_T("%d"), i);      m_cSubColumn.AddString(szColNum);  }  

No comments:

Post a Comment