Saturday, May 8, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


SPARQL query on HM land registry site based on first part of postcode

Posted: 08 May 2021 08:22 AM PDT

I'm trying to find out average house price data for a postcode area using the HM Land Registry open data SPARQL query via https://landregistry.data.gov.uk/app/qonsole, what the best way to do this if it's for a postcode sector (e.g. GL52)?

The 'transactions in a postcode' example code given on there shows how to search a full postcode and I have attempted to alter the code using STRSTARTS() on the VALUES ? postcode section but it's coming back with an error..

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>  prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>  prefix owl: <http://www.w3.org/2002/07/owl#>  prefix xsd: <http://www.w3.org/2001/XMLSchema#>  prefix sr: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>  prefix ukhpi: <http://landregistry.data.gov.uk/def/ukhpi/>  prefix lrppi: <http://landregistry.data.gov.uk/def/ppi/>  prefix skos: <http://www.w3.org/2004/02/skos/core#>  prefix lrcommon: <http://landregistry.data.gov.uk/def/common/>    # Returns the Price Paid data from the default graph for each transaction record having  # an address with the given postcode.  # The postcode to query is set using SPARQL 1.1's 'values' clause    SELECT ?paon ?saon ?street ?town ?county ?postcode ?amount ?date ?category  WHERE  {    VALUES ?postcode STRSTARTS({"GL52"^^xsd:string}, {"GL52"^^xsd:string})      ?addr lrcommon:postcode ?postcode.      ?transx lrppi:propertyAddress ?addr ;            lrppi:pricePaid ?amount ;            lrppi:transactionDate ?date ;            lrppi:transactionCategory/skos:prefLabel ?category.      OPTIONAL {?addr lrcommon:county ?county}    OPTIONAL {?addr lrcommon:paon ?paon}    OPTIONAL {?addr lrcommon:saon ?saon}    OPTIONAL {?addr lrcommon:street ?street}    OPTIONAL {?addr lrcommon:town ?town}  }  ORDER BY ?amount  

Error comes back as Encountered " "STRSTARTS" "STRSTARTS "" at line 18, column 20. Was expecting: "{" ...

Any suggestions would be appreciated!

Wanna send email with selenium and python

Posted: 08 May 2021 08:22 AM PDT

Hy friends! I want to automate Gmail with selenium and python, everything works fine, but the problem here is with file attachments. how could I handle it?

following are to be solved :

  1. click on the file attachment button in the email compose the body.
  2. select from the local files to uplad

following is my code:

 driver.find_element_by_xpath('//div[contains(text(),"Compose")]').click()      driver.find_element_by_xpath('//textarea[contains(@name,"to")]').send_keys('abubakkerhashmi123@gmail.com')      driver.find_element_by_xpath('//input[contains(@name,"subjectbox")]').send_keys('Test Mail')        bodyElem = driver.find_element_by_css_selector("div[aria-label='Message Body']") #this is where I get stuck and not sure what to do here      bodyElem.send_keys('A test email withh selenium')             driver.get('https://mail.google.com/mail/u/0/#sent')            attach_file=driver.find_elements_by_id(':qn')      attach_file.click()      print('do you me want to send try ?')      a=input('?')      if 'yes' in a :          sendElem = driver.find_element_by_xpath("//div[text()='Send']")          sendElem.click()  

Use diiferent css class when authenticated react

Posted: 08 May 2021 08:22 AM PDT

I'm kinda new to react I'm wondering how to use another CSS class when I'm authenticated

this is my how I tried to solve the problem

<section className={store.getState().auth.isAuthenticated ?"container2":"container"}>  

but the app always use the same style which is "container"

this is the full code of App.js

import React, {Fragment,useEffect,useState} from 'react';  import './App.css';  import Navbar from './components/layout/Navbar';  import Register from './components/auth/Register';  import Login from './components/auth/Login';  import Landing from './components/layout/Landing';  import {BrowserRouter as Router,Route,Switch} from 'react-router-dom';   import Alert from './components/layout/Alert';  import {loadUser} from './actions/auth';  import setAuthToken from './utils/setAuthToken';  import Dashboard from './components/dashboard/Dashboard';  import PrivateRoute from './components/routing/PrivateRoute';  import CreateProfile from './components/profile-forms/CreateProfile';  import Profiles from './components/profiles/Profiles';  import Profile from './components/profile/Profile';  import Posts from './components/posts/Posts';  import Post from './components/post/Post';  import PostsAdmin from './components/posts/PostsAdmin';  import EditProfile from './components/profile-forms/EditProfile';  import AddExperience from './components/profile-forms/AddExperience';  import AddEducation from './components/profile-forms/AddEducation';  import SideBar from './components/sideBar/SideBar'      //Redux  import {Provider} from 'react-redux';  import store from './store';      if(localStorage.token){    setAuthToken(localStorage.token);  }  const App =() => {    useEffect(() =>{      store.dispatch(loadUser());    },[]);    return (      <Provider store={store}>    <Router>      <Fragment>        <Navbar/>        <Route exact path ='/' component={Landing}/>        <section className={store.getState().auth.isAuthenticated ?"container2":"container"}>          <Alert/>          <switch>            <Route exact path="/register" component={Register}/>            <Route exact path="/login" component={Login}/>            <Route exact path='/profiles' component={Profiles}/>            <Route exact path='/Posts' component={Posts}/>            <Route exact path='/profile/:id' component={Profile}/>            <Route exact path='/posts/:id' component={Post}/>            <PrivateRoute exact path="/dashboard" component={Dashboard}/>            <PrivateRoute exact path="/admin" component={PostsAdmin}/>            <PrivateRoute exact path="/create-profile" component={CreateProfile}/>            <PrivateRoute exact path="/edit-profile" component={EditProfile}/>            <PrivateRoute exact path="/add-experience" component={AddExperience}/>            <PrivateRoute exact path="/add-education" component={AddEducation}/>                      </switch>        </section>      </Fragment>      </Router>      </Provider>    );  }      export default App    

CORS Policy problem when I try to connect from Angular to Nodejs backend

Posted: 08 May 2021 08:22 AM PDT

I´m trying to develop a backend basic server in NodeJS and the front in Angular 11, the fact is when I try to make a http get request to the backend, this is the error message in console:

Access to XMLHttpRequest at 'localhost:3000/api/personas' from origin 'http://localhost:4200' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.  

I´ve tried to config a reverse proxy in angular like this:

proxy.conf.json

{  "/localhost:3000*": {      "target": "http://localhost:3000",      "secure": false,      "logLevel": "debug"    }  }  

And the backend is set like this:

index.js (nodejs backend)

const express = require('express');  const path = require('path');  const methodOverride = require('method-override');  const cors = require('cors');    // Initialitations    const app = express();  require('./database');    // Settings    app.set('port', process.env.PORT || 3000);    // Middlewares    app.use(cors({      origin: 'http://localhost:4200'  }));  app.use(express.urlencoded({ extended: false }));  app.use(methodOverride('_method'));    // Global variables    // Routes    app.use('/api', require('./routes/persona'));    // Static files    app.use(express.static(path.join(__dirname, 'public')));    // Server init    app.listen(app.get('port'), () => {      console.log('Server on port: ', app.get('port'));  })  

i want to make a trigger, when i update a attribute of one of my table, that update records in another table, but it shows compilation error

Posted: 08 May 2021 08:22 AM PDT

This is my query, it created but with a compilation error, can someone explain what's wrong here?

CREATE OR REPLACE TRIGGER track_price_diff        2  AFTER UPDATE OF price ON product        3  FOR EACH ROW        4  DECLARE        5  P_ID NUMBER := (:OLD.p_id);        6  P_Name VARCHAR(20) := (:OLD.p_name);        7  Old_price NUMBER := (:OLD.price);        8  New_price NUMBER := (:NEW.price);        9  Difference NUMBER := (:NEW.price)-(:OLD.price);       10  Changed_date VARCHAR:= CURRENT_TIMESTAMP;       11  BEGIN       12  INSERT INTO track_prod_price VALUES (P_ID,P_Name,New_price,Old_price,Difference,Changed_date);       13  END;       14  /    Warning: Trigger created with compilation errors.  

Create a column name in data frame based on condition with python

Posted: 08 May 2021 08:21 AM PDT

I have a data frame like this:

       full path                               name      time   0    C:\Users\User\Desktop\Test1\1.txt          1.txt      10:20  1    C:\Users\User\Desktop\Test1\1.txt          1.txt      10:25  2    C:\Users\User\Desktop\Test1\2.txt          2.txt      10:50  2    C:\Users\User\Desktop\Test1\Test2\1.txt    1.txt      10:30  3    C:\Users\User\Desktop\Test1\1.txt          1.txt      10:40  5    C:\Users\User\Desktop\Test1\Test2\2.txt    2.txt      10:60  

and I'm using this code to compare rows (Erfan):

m1 = df["full path"].ne(df["full path"].shift(1, fill_value=df["full path"].iloc[0]))  m2 = df["name"].eq(df["name"].shift(fill_value=df["name"].iloc[0]))    folder = df["full path"].str.rsplit("\\", 2).str[-2]    df["time_when_path_changed"] = np.where(m1 & m2, df["time"] + " - " + folder, "")  

this code gives me this output:

        full path                               name      time    time_when_path_changed  0    C:\Users\User\Desktop\Test1\1.txt          1.txt      10:20  1    C:\Users\User\Desktop\Test1\1.txt          1.txt      10:25  2    C:\Users\User\Desktop\Test1\Test2\1.txt    1.txt      10:30       10:30 - Test2  3    C:\Users\User\Desktop\Test1\1.txt          1.txt      10:40       10:40 - Test1  4    C:\Users\User\Desktop\Test1\2.txt          2.txt      10:50  5    C:\Users\User\Desktop\Test1\Test2\1.txt    2.txt      10:60       10:60  - Test2  

What I'm really wanting is to create a column based on the folder path, for example if the path changed to Test2, then to create a column named Test2 and put "time" there, like below:

   full path                               name      time    moved to "Test2"   moved to "Test1"  0    C:\Users\User\Desktop\Test1\1.txt          1.txt      10:20  1    C:\Users\User\Desktop\Test1\1.txt          1.txt      10:25  2    C:\Users\User\Desktop\Test1\2.txt          2.txt      10:50  3    C:\Users\User\Desktop\Test1\Test2\1.txt    1.txt      10:30       10:30  5    C:\Users\User\Desktop\Test1\1.txt          1.txt      10:40                            10:40  5    C:\Users\User\Desktop\Test1\Test2\2.txt    2.txt      10:60       10:60  

Regex match every thing between two outer brackets

Posted: 08 May 2021 08:21 AM PDT

In a string like this [1 2 [A 4] [5]] how can I match everything in between both outer-brackets (excluding them), e.g. the result would be this match 1 2 [A 4] [5]. Note that I don't want to match the outer-brackets, I a interested only in what comes in between.

Hard time figuring out how to build a 'Service' Model

Posted: 08 May 2021 08:21 AM PDT

The topic is rather straightforward, but after reading through the docs, examples and some stackoverflow posts I still have not reached a conclusion.

Supposed I have two Models, Transaction and Service. The former keeps track of payments made to an entity. Either because someone purchased a product (single-step payment) or because someone purchased a Service (two-step payment, one Transaction payed in advance, another after the service is provided to the user).

class Transaction(models.Model):      class Provider(models.TextChoices):          MBWAY = "MBW", _("MBWay")          PAYPAL = "PP", _("PayPal")          REVOLUT = "REV", _("Revolut")          DEBIT = "DCC", _("Debit or Credit Card")        class Status(models.TextChoices):          PENDING = "P"          PROCESSING = "PR"          ACCEPTED = "A"          REJECTED = "R"          EXPIRED = "E"        id = models.BigAutoField(primary_key=True, editable=False)      user = models.ForeignKey(User, on_delete=models.SET(User.get_sentinel_user()))      provider = models.CharField(max_length=8, choices=Provider.choices)      status = models.CharField(max_length=8, choices=Status.choices)      value = models.MoneyField(max_digits=19, decimal_places=4, default_currency="EUR")      created_at = models.DateTimeField(auto_now_add=True)      updated_at = models.DateTimeField(auto_now=True)      data = models.JSONField(default=dict)  
class Service(models.Model):      id = models.BigAutoField(primary_key=True, editable=False)      user = models.ForeignKey(User, on_delete=models.SET(User.get_sentinel_user()))      signal = models.ForeignKey(          Transaction, unique=true, on_delete=models.PROTECT, related_name="service_signal"      )      remainder = models.ForeignKey(          Transaction, unique=true, on_delete=models.PROTECT, related_name="service_remainder"      )  

One Service has exactly two Transaction moments and each Transaction has exactly one Service. Should I use ForeignKey, ForeignKey, Unique or OneToOneField? I understand ForeignKey, Unique and OneToOneField are very similar, but do not understand how different they are other than one returning a QuerySet and another returning an Object when reverse queries are made.

Would someone help me figure this out?

Would I be better off creating a Purchase model which has OneToOneField to Transaction and Service Model which has a OneToOneField with Purchase and another OneToOneField with Transaction?

Thanks in advance.

Qt setText inside a function

Posted: 08 May 2021 08:21 AM PDT

I want to use setText to overwrite itself inside a loop in a function like this:

QString skanner::FSkan(QString fname)  {      QDir dir = fname;      QString abc = 0;      QDirIterator iterator(dir.absolutePath(), QDirIterator::Subdirectories);      while (iterator.hasNext()) {          QFile file(iterator.next());          QFileInfo f;          f.fileName();          if ( file.open( QIODevice::ReadOnly ) ){              ui->lineEdit_Output->setText(file.fileName());  

This won't work because it is not possible to access ui from MainWindow. How can I make it work?

JavaFX: Populating a TableView from ArrayList without creating a new scene

Posted: 08 May 2021 08:21 AM PDT

After a few hours of googling, I still have no idea how TableViews work. I have an ArrayList that reads a file and loads some data into it. I need to display the content of that ArrayList in a JavaFX table that I made in SceneBuilder. Everything is in one Scene with one controller because I have no idea how to pass values of variables between controllers (question for another day).

I know stuff like logging in etc could be done better, but right now I only need to get tableview working. (and then editing and deleting that... what have I gotten myself into).

The method I'm building is populateAnimalTableView().

Help me, StackOverflow, you are my only hope.

Main class

package tomsikr_seminarka;    import javafx.application.Application;  import javafx.event.EventHandler;  import javafx.fxml.FXMLLoader;  import javafx.scene.Parent;  import javafx.scene.Scene;  import javafx.stage.Stage;  import javafx.stage.WindowEvent;    public class Main extends Application {        @Override      public void start(Stage primaryStage) throws Exception{          Parent parent = FXMLLoader.load(getClass().getResource("dashboard2.fxml"));          Stage stage = new Stage();          Scene scene = new Scene(parent);          stage.setScene(scene);          stage.setTitle("Dashboard");          stage.setMinHeight(480);          stage.setMinWidth(640);            primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {              @Override              public void handle(WindowEvent t) {                  System.exit(0);              }          });          stage.show();      }        public static void main(String[] args) {          launch(args);      }  }  

Controller:

package tomsikr_seminarka;    import javafx.event.ActionEvent;  import javafx.event.Event;  import javafx.fxml.FXMLLoader;  import javafx.fxml.Initializable;  import javafx.geometry.Pos;  import javafx.scene.Parent;  import javafx.scene.Scene;  import javafx.scene.control.*;  import javafx.scene.control.cell.PropertyValueFactory;  import javafx.scene.layout.VBox;  import javafx.stage.Stage;    import java.io.IOException;  import java.net.URL;  import java.util.ArrayList;  import java.util.ResourceBundle;    public class Dashboard2Controller implements Initializable {      public String inputUserName;      public String inputPassword;      public String loggedInName;      public String loggedInPermission;      public boolean loggedIn;      public TextField usernameTextfield;      public PasswordField Passwordfield;      public Label loggedInStatusLabel;      public Button logoutButton;      public Button loginButton;      public TextField loggedInPrintBox;      public TextField loggedInNamePrintBox;      public TextField loggedInPermissionPrintBox;      public Tab animalsTab;        //Animals TableView      public TableColumn<Animals, Integer> animalColumn_id;      public TableColumn<Animals, String> animalColumn_species;      public TableColumn<Animals, String> animalColumn_category;      public TableColumn<Animals, String> animalColumn_name;      public TableColumn<Animals, Double> animalColumn_age;      public TableColumn<Animals, String> animalColumn_health;      public TableColumn<Animals, Double> animalColumn_weight;      public TableColumn<Animals, String> animalColumn_sex;      public TableColumn<Animals, String> animalColumn_notes;      public TableView animalsTable;        //Arraylists      private ArrayList<Users> usersList = new ArrayList<Users>();      private ArrayList<Animals> animalsList = new ArrayList<Animals>();        @Override      public void initialize(URL url, ResourceBundle resourceBundle) {          usernameTextfield.setText("");          Passwordfield.setText("");          Functions.readUsersFileToArrayList(usersList);          Functions.readAnimalsFileToArrayList(animalsList);          if(loggedIn == false){              logoutButton.setDisable(true);              loginButton.setDisable(false);              animalsTab.setDisable(true);          }else if(loggedIn == true){              logoutButton.setDisable(false);              loginButton.setDisable(true);          }      }        public void loginButtonPressed(ActionEvent actionEvent) {          inputUserName = usernameTextfield.getText();          inputPassword = Passwordfield.getText();          if (doNameAndPasswordMatch(inputUserName,inputPassword,usersList)){              System.out.println("DEBUG WARNING - login match");              loggedInStatusLabel.setText("Logged in");              loggedIn = true;              logoutButton.setDisable(false);              loginButton.setDisable(true);              loggedInPrintBox.setText(Boolean.toString(loggedIn));              loggedInNamePrintBox.setText(loggedInName);              loggedInPermissionPrintBox.setText(loggedInPermission);              animalsTab.setDisable(false);            }else{              loggedInStatusLabel.setText("Invalid username or password. Please try again");          }          usernameTextfield.clear();          Passwordfield.clear();      }        public void printUsersIntoConsole(ActionEvent actionEvent) {          Functions.printArrayListUsers(usersList);      }        public boolean doNameAndPasswordMatch(String enteredName, String enteredPassword, ArrayList<Users> usersList) {          boolean result = false;          boolean valid = false;          String hashedPassword;          System.out.println("Checking login info");          //System.out.println("DEBUG WARNING - Users array list size: " + usersList.size());            for (int i = 0; i < usersList.size(); i++) {              String name = usersList.get(i).name.trim();              String password = usersList.get(i).password.trim();              String permission = usersList.get(i).permission.trim();                System.out.println();              System.out.println("********************************************");              System.out.println("DEBUG WARNING - Checking user on index " + i);              System.out.println("DEBUG WARNING - tempName "+ name);              System.out.println("DEBUG WARNING - Entered name "+ enteredName);              System.out.println("DEBUG WARNING - tempPassword "+ password);              System.out.println("DEBUG WARNING - Entered password "+ enteredPassword);                hashedPassword = Functions.getHash(enteredPassword, "MD5").toUpperCase();              System.out.println("DEBUG WARNING - Entered hashed password "+ hashedPassword);                if ((enteredName.equals(name)) && (valid == false)) {                  System.out.println("DEBUG WARNING - Names match");                  if (password.equals(hashedPassword)) {                      valid = true;                      System.out.println("DEBUG WARNING - Passwords match");                      //System.out.println("DEBUG WARNING - valid " + valid);                      loggedInPermission = permission;                      loggedInName = name;                      break;                  } else {                      System.out.println("DEBUG WARNING - Passwords do not match");                      valid = false;                      //System.out.println("DEBUG WARNING - valid " + valid);                  }              }else{                  System.out.println("DEBUG WARNING - Names do not match");              }          }            //System.out.println("DEBUG WARNING - valid for return " + valid);          if (valid == true) {              result = true;          } else {              result = false;          }          return result;      }        public void populateAnimalTableView() throws IOException {          animalColumn_id.setCellValueFactory(new PropertyValueFactory<>("id"));          animalColumn_species.setCellValueFactory(new PropertyValueFactory<>("Species"));          animalColumn_category.setCellValueFactory(new PropertyValueFactory<>("Category"));          animalColumn_name.setCellValueFactory(new PropertyValueFactory<>("Name"));          animalColumn_age.setCellValueFactory(new PropertyValueFactory<>("Age"));          animalColumn_health.setCellValueFactory(new PropertyValueFactory<>("Health"));          animalColumn_weight.setCellValueFactory(new PropertyValueFactory<>("Weight"));          animalColumn_sex.setCellValueFactory(new PropertyValueFactory<>("Sex"));          animalColumn_notes.setCellValueFactory(new PropertyValueFactory<>("Notes"));            animalsTable.getColumns().add(animalColumn_id);          animalsTable.getColumns().add(animalColumn_species);          animalsTable.getColumns().add(animalColumn_category);          animalsTable.getColumns().add(animalColumn_name);          animalsTable.getColumns().add(animalColumn_age);          animalsTable.getColumns().add(animalColumn_health);          animalsTable.getColumns().add(animalColumn_weight);          animalsTable.getColumns().add(animalColumn_sex);          animalsTable.getColumns().add(animalColumn_notes);            for (Animals anim : animalsList){              animalsTable.getItems().add(anim);          }            VBox vbox = new VBox();          vbox.getChildren().addAll(animalsTable);          vbox.setSpacing(10);          vbox.setAlignment(Pos.CENTER);          Scene scene = new Scene(vbox);            FXMLLoader loader = new FXMLLoader(getClass().getResource("dashboard2.fxml"));          Parent root = loader.load();          Controller controller = loader.getController();            Stage stage = (Stage) animalsTable.getScene().getWindow();            stage.setScene(scene);          stage.show();      }        public void logoutButtonPressed(ActionEvent actionEvent) {          loggedIn = false;          loggedInName = "";          loggedInPermission = "";          loggedInPrintBox.setText(Boolean.toString(loggedIn));          loggedInNamePrintBox.setText(loggedInName);          loggedInPermissionPrintBox.setText(loggedInPermission);          loggedInStatusLabel.setText("Logged out");          usernameTextfield.clear();          Passwordfield.clear();      }        public void printAnimalsIntoConsole(ActionEvent actionEvent) {          Functions.printArrayListAnimals(animalsList);      }        public void tableTestTabClicked(Event event) {          TableView tableView = new TableView();      }  }  

dashboard2.fxml

<?xml version="1.0" encoding="UTF-8"?>    <?import javafx.scene.control.Button?>  <?import javafx.scene.control.Label?>  <?import javafx.scene.control.PasswordField?>  <?import javafx.scene.control.Tab?>  <?import javafx.scene.control.TabPane?>  <?import javafx.scene.control.TableColumn?>  <?import javafx.scene.control.TableView?>  <?import javafx.scene.control.TextField?>  <?import javafx.scene.control.TreeTableColumn?>  <?import javafx.scene.control.TreeTableView?>  <?import javafx.scene.layout.AnchorPane?>    <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="480.0" minWidth="640.0" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="tomsikr_seminarka.Dashboard2Controller">     <children>        <TabPane prefHeight="200.0" prefWidth="200.0" scaleShape="false" tabClosingPolicy="UNAVAILABLE" tabMaxWidth="64.0" tabMinWidth="64.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">          <tabs>              <Tab text="Account">                  <content>                      <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">                       <children>                          <Label fx:id="loggedInStatusLabel" layoutX="14.0" layoutY="14.0" text="Not logged in" />                          <TextField fx:id="usernameTextfield" layoutX="88.0" layoutY="58.0" />                          <Label layoutX="14.0" layoutY="62.0" text="Username" />                          <Label layoutX="14.0" layoutY="96.0" text="Password" />                          <PasswordField fx:id="Passwordfield" layoutX="88.0" layoutY="92.0" />                          <Button fx:id="loginButton" layoutX="131.0" layoutY="135.0" minWidth="64.0" mnemonicParsing="false" onAction="#loginButtonPressed" text="Log in" />                          <Button fx:id="logoutButton" layoutX="131.0" layoutY="172.0" minWidth="64.0" mnemonicParsing="false" onAction="#logoutButtonPressed" text="Log out" />                       </children></AnchorPane>                  </content>              </Tab>            <Tab fx:id="animalsTab" text="Animals">              <content>                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">                       <children>                          <TableView fx:id="animalsTable" layoutX="14.0" layoutY="14.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="16.0" AnchorPane.leftAnchor="16.0" AnchorPane.rightAnchor="16.0" AnchorPane.topAnchor="16.0">                            <columns>                              <TableColumn fx:id="animalColumn_id" maxWidth="24.0" minWidth="24.0" prefWidth="3.0" resizable="false" text="id" />                              <TableColumn fx:id="animalColumn_species" maxWidth="128.0" minWidth="32.0" prefWidth="64.0" text="Species" />                                <TableColumn fx:id="animalColumn_category" maxWidth="128.0" minWidth="32.0" prefWidth="64.0" text="Category" />                                <TableColumn fx:id="animalColumn_name" maxWidth="128.0" minWidth="32.0" prefWidth="64.0" text="Name" />                                <TableColumn fx:id="animalColumn_age" maxWidth="128.0" minWidth="32.0" prefWidth="64.0" text="Age" />                                <TableColumn fx:id="animalColumn_health" maxWidth="128.0" minWidth="32.0" prefWidth="64.0" text="Health" />                                <TableColumn fx:id="animalColumn_weight" maxWidth="128.0" minWidth="32.0" prefWidth="64.0" text="Weight" />                                <TableColumn fx:id="animalColumn_sex" maxWidth="128.0" minWidth="32.0" prefWidth="64.0" text="Sex" />                                <TableColumn fx:id="animalColumn_notes" maxWidth="128.0" minWidth="32.0" prefWidth="64.0" text="Notes" />                            </columns>                          </TableView>                       </children></AnchorPane>              </content>            </Tab>            <Tab text="Users">              <content>                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />              </content>            </Tab>              <Tab text="Debug">                <content>                  <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">                       <children>                          <Button fx:id="printUsersButton" layoutX="14.0" layoutY="22.0" mnemonicParsing="false" onAction="#printUsersIntoConsole" text="Print all users into console" />                          <TextField fx:id="loggedInPrintBox" layoutX="426.0" layoutY="22.0" />                          <TextField fx:id="loggedInNamePrintBox" layoutX="426.0" layoutY="67.0" />                          <TextField fx:id="loggedInPermissionPrintBox" layoutX="426.0" layoutY="106.0" />                          <Label layoutX="300.0" layoutY="26.0" text="Logged in" />                          <Label layoutX="300.0" layoutY="71.0" text="Logged In name" />                          <Label layoutX="300.0" layoutY="110.0" text="Logged in permission" />                          <Button fx:id="printAnimalsButton" layoutX="7.0" layoutY="58.0" mnemonicParsing="false" onAction="#printAnimalsIntoConsole" text="Print all animals into console" />                       </children>                    </AnchorPane>                </content>              </Tab>          </tabs>        </TabPane>        <TreeTableView layoutX="-178.0" layoutY="-200.0" prefHeight="200.0" prefWidth="200.0">          <columns>            <TreeTableColumn prefWidth="75.0" text="C1" />          </columns>        </TreeTableView>     </children>  </AnchorPane>  

Functions

package tomsikr_seminarka;    import javafx.application.Platform;  import javafx.event.ActionEvent;    import java.io.BufferedReader;  import java.io.File;  import java.io.FileReader;  import java.io.IOException;  import java.lang.reflect.Array;  import java.text.SimpleDateFormat;  import java.util.ArrayList;    public class Functions {      public static String usersConfPath = "./data/users.conf";      public static String animalsDBPath = "./data/animals.txt";      public static boolean loggedIn = false;      public static String adminPhoneNumber;        //private static ArrayList<Users> usersList = new ArrayList<Users>();      //private ArrayList<Animals> animalsList = new ArrayList<Animals>();      public static String loggedInPermission;      public static String loggedInName;        public static void readUsersFileToArrayList(ArrayList<Users> usersList) {          usersList.clear();          if(new File(usersConfPath).exists()) {              System.out.println("DEBUG WARNING - file users.conf exists");              try {                  BufferedReader bfr = new BufferedReader(new FileReader(usersConfPath));                  String line = bfr.readLine();                  while((line != null) && (!line.isEmpty())) {                      int id = 0;                      String name = "";                      String password = "";                      String permission = "";                      double age = 0;                      String phoneNumber = "";                        if(line.contains(",")) {                          String parts[] = line.split(",");                          name = parts[0].trim();                          password = parts[1].trim();                          password = password.toUpperCase();                          permission = parts[2].trim();                          age = Double.parseDouble(parts[3].trim());                          if(permission.equals("administrator")) {                              phoneNumber = parts[4].trim();                              adminPhoneNumber = phoneNumber;                          }else {                              phoneNumber = "";                          }                      }                      Users temp = new Users(name,password,permission,age,phoneNumber);                      /*System.out.println("Name: " + name);                      System.out.println("Permission: " + permission);                      System.out.println("Password: " + password);*/                        usersList.add(temp);                      //System.out.println("DEBUG WARNING - User added");                        line = bfr.readLine();                  }                  bfr.close();              }catch(IOException e){                  e.printStackTrace();              }              //System.out.println("DEBUG WARNING - All users loaded from config to arraylist");          }      }        public static void readAnimalsFileToArrayList(ArrayList<Animals> animalsList) {          if(new File(animalsDBPath).exists()) {              try {                  BufferedReader bfr = new BufferedReader(new FileReader(animalsDBPath));                  String line = bfr.readLine();                  while((line != null) && (!line.isEmpty())) {                      int id = 0;                      String species = "";                      String category = "";                      String name = "";                      double age = 0;                      String health = "";                      double weight = 0;                      String sex = "";                      String notes = "";                        //System.out.println("DEBUG WARNING - got this far 1");                      if(line.contains(",")) {                          //System.out.println("DEBUG WARNING - line " + line);                          String parts[] = line.split(",");                          //System.out.println("DEBUG WARNING - parts[].length " + parts.length);                          id = Integer.parseInt(parts[0].trim());                          species = parts[1].trim();                          category = parts[2].trim();                          name = parts[3].trim();                          age = Double.parseDouble(parts[4].trim());                          health = parts[5].trim();                          weight = Double.parseDouble(parts[6].trim());                          //System.out.println("DEBUG WARNING - got this far 2");                          sex = parts[7].trim();                          //System.out.println("DEBUG WARNING - got this far 3");                          notes = parts[8].trim();                      }                      Animals temp = new Animals(id,species,category,name,age,health,weight,sex,notes);                      animalsList.add(temp);                      //System.out.println("DEBUG WARNING - animal added");                        line = bfr.readLine();                  }                  bfr.close();              }catch(IOException e){                  e.printStackTrace();              }              //System.out.println("DEBUG WARNING - All animal records loaded from config to arraylist");          }      }        public static String getHash(String txt, String hashType) {          try {              java.security.MessageDigest md = java.security.MessageDigest.getInstance(hashType);              byte[] array = md.digest(txt.getBytes());              StringBuffer sb = new StringBuffer();              for (int i = 0; i < array.length; ++i) {                  sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));              }              return sb.toString();            } catch (java.security.NoSuchAlgorithmException e) {              e.printStackTrace();          }          return null;      }        public static void printArrayListUsers(ArrayList<Users> usersList) {          System.out.println();          System.out.println("Listing all loaded user data");          for(int i = 0; i<usersList.size(); i++) {              System.out.println("i: " + i + " - " + usersList.get(i).name);              System.out.println("i: " + i + " - " + usersList.get(i).password);              System.out.println("i: " + i + " - " + usersList.get(i).permission);              System.out.println("i: " + i + " - " + usersList.get(i).age);              System.out.println("i: " + i + " - " + usersList.get(i).phoneNumber);          }          int countRecords = usersList.size();          System.out.println("There are " + countRecords + " users in the database");          System.out.println();      }        public static void printArrayListAnimals(ArrayList<Animals> animalsList) {          System.out.println();          System.out.println("Listing all loaded animal records");          for(int i = 0; i<animalsList.size(); i++) {              System.out.println("id - " + animalsList.get(i).id);              System.out.println("species - " + animalsList.get(i).species);              System.out.println("category - " + animalsList.get(i).category);              System.out.println("name - " + animalsList.get(i).name);              System.out.println("age - " + animalsList.get(i).age);              System.out.println("health - " + animalsList.get(i).health);              System.out.println("weight - " + animalsList.get(i).weight);              System.out.println("sex - " + animalsList.get(i).sex);              System.out.println("notes - " + animalsList.get(i).notes);              System.out.println("********************************************************");          }          int countRecords = animalsList.size();          System.out.println("There are " + countRecords + " records in the database");          System.out.println();      }  }  

Animals class:

package tomsikr_seminarka;    public class Animals {      int id;      String species;      String category;      String name;      double age;      String health;      double weight;      String sex;      String notes;            public Animals(int id, String species, String category, String name, double age, String health, double weight, String sex, String notes) {          this.id = id;          this.species = species;          this.category = category;          this.name = name;          this.age = age;          this.health = health;          this.weight = weight;          this.sex = sex;          this.notes = notes;      }            public int getID() {          return id;      }      public String getSpecies() {          return species;      }      public String getCategory() {          return category;      }      public String getName() {          return name;      }      public double getAge() {          return age;      }      public String getHealth() {          return health;      }      public double getWeight() {          return weight;      }      public String getSex() {          return sex;      }      public String getNotes() {          return notes;         }            public void setID(int id) {          this.id = id;      }      public void setSpecies(String species) {          this.species = species;      }      public void setCategory(String category) {          this.category = category;      }      public void setName(String name) {          this.name = name;      }      public void setAge(double age) {          this.age = age;      }      public void setHealth(String health) {          this.health = health;      }      public void setWeight(double weight) {          this.weight = weight;      }      public void setSex(String sex) {          this.sex = sex;      }      public void setNotes(String notes) {          this.notes = notes;      }  }  

Users class

package tomsikr_seminarka;    public class Users {      String name;      String password;      String permission;      String phoneNumber;      double age;        public Users(String name, String password, String permission, double age, String phoneNumber) {          this.name = name;          this.password = password;          this.permission = permission;          this.phoneNumber = phoneNumber;          this.age = age;      }        public String getName() {          return name;      }        public void setName(String name) {          this.name = name;      }        public String getPassword() {          return password;      }        public void setPassword(String password) {          this.password = password;      }        public String getPermission() {          return permission;      }        public void setPermission(String permission) {          this.permission = permission;      }        public String getPhoneNumber() {          return phoneNumber;      }        public void setPhoneNumber(String phoneNumber) {          this.phoneNumber = phoneNumber;      }        public double getAge() {          return age;      }        public void setAge(double age) {          this.age = age;      }    }    

JavaFX 16, IntelliJ 2021.1

Dashboard2.fxml in SceneBuilder

Is Firebase SenderID Been Replace With Project Name?

Posted: 08 May 2021 08:21 AM PDT

I recently began receiving "FirebaseApp with name [SenderID] doesn't exist. Available app names: [appName], [DEFAULT]" when calling Firebase.FirebaseApp.GetInstance(senderID). Changing "senderID" to "appName" enabled the call to be made successfully. I have been using the "senderID" for years. Is this a new change by Firebase? When was it deployed? What happens to app versions that used the former? Fail?

I cannot install AngularJS in my system (windows 10)

Posted: 08 May 2021 08:21 AM PDT

Every time I am trying to download and install AngularJS from their official site angularjs.org, i am getting some weird textual code files on my screen. Can't figure out the issue and need a working solution asap.

Android emulator requires wipe data almost once a week after upgrading to Android studio 4.1.3

Posted: 08 May 2021 08:20 AM PDT

My React Native app use android (4.1.3) emulator for development on Win10. After upgrading to Android 4.1.3, almost once a week I have to wipe data on the emulator otherwise it is stuck not able to make connection to backend server. At this time, the data size used on the emulator is 4.6GB. After performing wipe data and size is back to 1.6GB, then the emulator starts to work again. The problem is that the configuration for the app has to be redo again. Is there way to clean the data size without wiping out app configuration? Tried to use show disk and delete a huge file under a fold but it seems not help.

enter image description here

How to calculate distance between more than two points with google distance-matrix api

Posted: 08 May 2021 08:22 AM PDT

Hello I want to calculate the distance between more than two points

Currently, I am using this but it calculates the distance between only two points source to destination but I want to calculate the full path distance Where user go through

Currently using this

"https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins="+originsLatLong+"&destinations="+destinationLatLong;              url = url+"&key="+googleMapKey;  

is there any way of showing icon for .py files?

Posted: 08 May 2021 08:22 AM PDT

Firstly, I opened the python file with notepad, and another day I right clicked the python file and opened it with python idle and from that day python files is not showing the python icon. which is not looking good. Can someone help me?? These are all python files

How to combine a surface and quiver plot in python in one plot

Posted: 08 May 2021 08:20 AM PDT

I have the following code that produces me one surface plot with a surface given as the z-coordinate with respect to a meshgrid X,Y.

This code also produces a vector field plot, as a separate figure with respect to the same coordinate system X,Y.

Is there a way for me to combine these two figures in one? Have the vector field either on the surface or at the bottom of the surface plot?

import numpy as np  import matplotlib.pyplot as plt  import grad_field   # first create the plot of the elevation surface  fig, ax = plt.subplots(subplot_kw={"projection": "3d"})  LNG = np.linspace(lngmin,lngmax,samples1)  LAT = np.linspace(latmin,latmax, samples2)  X, Y = np.meshgrid(LNG,LAT)  ax.plot_surface(X, Y, elev_mat)  plt.show()     # now create the vector field plot of the gradients  [gradx,grady] = grad_field.grad_field(elev_mat)  fig1, ax1 = plt.subplots()  ax1.set_title('Arrows scale with plot width, not view')  ax1.quiver(X, Y, gradx, grady, units='xy' ,scale=2, color='red')  plt.show()  

How can I find the highest occurrence of an item in an array of objects?

Posted: 08 May 2021 08:22 AM PDT

I have an array of objects and I would like to find the highest occurrence of an item in each object and return the frequency:

var arr = [{spot_id: 6, spot_no: 6, gate_id: 6}, {spot_id: 16, spot_no: 17, gate_id: 5}, {spot_id: 5, spot_no: 5, gate_id: 5}, {spot_id: 11, spot_no: 11, gate_id: 5}, {spot_id: 15, spot_no: 16, gate_id: 4}, {spot_id: 4, spot_no: 4, gate_id: 4}, {spot_id: 10, spot_no: 10, gate_id: 4}, {spot_id: 14, spot_no: 15, gate_id: 3}, {spot_id: 9, spot_no: 9, gate_id: 3}, {spot_id: 3, spot_no: 3, gate_id: 3}, {spot_id: 8, spot_no: 8, gate_id: 2}, {spot_id: 13, spot_no: 14, gate_id: 2}, {spot_id: 2, spot_no: 2, gate_id: 2}, {spot_id: 7, spot_no: 7, gate_id: 1}, {spot_id: 12, spot_no: 13, gate_id: 1}];  

I have tried to find using this code but it returns an object with values 1, 1, 1 for each field:

var items = arr.sort((a, b) =>    arr.filter(v => v.gate_id === a.gate_id).length -    arr.filter(v => v.gate_id === b.gate_id).length  ).pop();  

I want it to return the highest occurrence of gate_id which in this array is either 5,5,5 or 4,4,4 or 3,3,3 or 2,2,2, basically just one of them, i dont care which one and I want to return the frequency , in this case the frequency is 3 times.

how to keep adding elements from list1 to list2 until list2 is over? python

Posted: 08 May 2021 08:22 AM PDT

For example if i have:

list1 = [1, 2, 3]  list2 = [4, 5, 6, 7, 8, 9, 10, 11, 12]  

How to add elements from list1 to list2 in a loop until list2 is over, where output becomes:

list3 = [1, 4, 2, 5, 3, 6, 1, 7, 2, 8, 3, 9, 1, 10, 2, 11, 3, 12]  

charts.js Stacked Bar Graphs - selecting row and dataset selected

Posted: 08 May 2021 08:21 AM PDT

We created a stacked bar graph, but I need a way of identifying which bar and section/element of the bar I've selected. I can work out the bar no problem. so in the following image that would be 4 - so I can retrieve the label "Report Edit Complete":

Like this:

enter image description here

If I click on the pink I want to retrieve the label for the 3rd element/dataset "6-9 weeks". Is there a way I can do this?

trying to convert images to webp with imagemin-webp but not working

Posted: 08 May 2021 08:20 AM PDT

I found a code in a website for converting png, jpg to webp but it doesnt work for me. I have two jpg files in /images/ folder

const imagemin = require("imagemin"),    webp = require("imagemin-webp");  const outputFolder = "./images/webp";  const produceWebP = async () => {    await imagemin(["images/*.png"], {      destination: outputFolder,      plugins: [        webp({          lossless: true,        }),      ],    });    console.log("PNGs processed");    await imagemin(["images/*.{jpg,jpeg}"], {      destination: outputFolder,      plugins: [        webp({          quality: 65,        }),      ],    });    console.log("JPGs and JPEGs processed");  };  produceWebP();  

When i run node index.js i take the message you see in the photo

enter image description here

TYPO3 f:form with additional arguments, where submit not update the arguments

Posted: 08 May 2021 08:21 AM PDT

I am using TYPO3 10.4.15 My edit view:

f:section name="content">      <h1>Edit Album</h1>      <f:flashMessages />      <f:render partial="FormErrors" />      <f:form id='fNew' action="update" name="album" object="{album}" arguments="{mode:mode, disc:disc}" >      <f:render partial="Album/FormFields" arguments="{album:album, disc:disc}" />      <f:form.submit value="Save" />      </f:form>  </f:section>  </html>  

This is the relevant part of the partial formfields.html:

    <f:if condition='{disc}'>      <input type='text' name="disc[0][name][]" />      </f:if>  

The error_log with the disc structure looks:

 Update-Disc: array (    0 =>     array (      'name' => '',      'trackNum' => '1',      'track' =>       array (        0 =>             array (              'title' => '',              'duration' => '0',              'composer' => '',              'texter' => '',              'musicFile' => '',              'imageFile' => '',            ),          ),        ),      )   

And this is the "updateAction" part of the controller

/**   * action update   *    * @param \HGA\Album\Domain\Model\Album $album   * @param string $mode   * @param array $disc   * @return string|object|null|void   */  public function updateAction(\HGA\Album\Domain\Model\Album $album, $mode, $disc)  {      error_log("Update-Disc: " . var_export($disc, true) . " Mode: " . $mode, 0);      if ($mode == 'tracks') {         $this->editAction($album, $mode, $disc);      }      error_log("Update: " . var_export($album, true) . " Mode: " . $mode, 0);      $this->addFlashMessage('The object was updated. Please be aware that this action is publicly accessible unless you implement an access check. See https://docs.typo3.org/typo3cms/extensions/extension_builder/User/Index.html', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING);      $this->albumRepository->update($album);      $this->redirect('list');  }  

If I write something into the text input field and execute submit, I get the error_log you can see above. The value I have typed in the input field is missing. It is only the array, as I have send it to the view. The mode string will be transmitted correctly, but with the disc array is maybe something wrong!

The disc array is more complex, but I made it simple, because I need to understand how it works in general. I also need this additional disc array and can not doing it with the album object!

Thanks in advance for your help.

Proguard does not like scala object

Posted: 08 May 2021 08:22 AM PDT

After running proguard, when i check if methods are available on the obfuscated jar in a new project depending on this last. Desired classes are there but i can't have access to companion object.

Library side

trait KeepOpen  trait KeepOpenObj      trait MyTrait extends KeepOpen {    def a: Int  }  object MyTrait extends KeepOpenObj {    def apply(arg: Int): MyTrait = new MyTrait { val a = 1 }  }  

Depending project test.

import aaa.MyTrait    val arg = 1    def myTraitImpl: MyTrait = ??? // Type is well infered  def myTraitImpl2: MyTrait = MyTrait(arg) // MyTrait companion object is not detected preventing apply method usage    // But this works  def myTraitImpl3: MyTrait = (new MyTrait$)(arg) // Works  

Here are my keep options for classes :

  "-keep !final class * extends aaa.KeepOpen",    "-keep !final class * extends aaa.KeepOpen {*;}",    "-keep class * implements aaa.KeepOpenObj",    "-keep class * implements aaa.KeepOpenObj {*;}",  

trait of the library inherit from KeepOpen and object including companion one extends KeepOpenObj.

Exploring the jar non obfuscate and obfuscate, they both show two file MyTrait and MyTrait$ with expecting methods but its impossible to use companion object in the obfuscated case.

Moreover non companion object like those with main seems to work without any problem.

Update

I success to make infer companion object type and its associate methods adding following options :

-keepattributes Exceptions,InnerClasses,Signature,Deprecated,                  SourceFile,LineNumberTable,*Annotation*,EnclosingMethod  

But unfortunately i fall on the following error when compiling.

val myTrait = MyTrait(arg) // error : class aaa.MyTrait is not a value  

How can i have access to the companion object in the same way that with non obfuscate jar ?

Issue with plot in the likert package - superfluous row in image

Posted: 08 May 2021 08:21 AM PDT

I'm trying to make a likert plot using the 'likert' package by Jason Bryer, with a grouping variable that has 6 levels and two likert scale variables with 5 levels each:

plot(likert(likert_krise[,2:3], grouping = likert_krise$krise))

When I run the code, one of the levels of the grouping variables is displayed in two rows: the bars are in the first and the percentage levels in the second.

Can someone please explain to me what is happening here?

I find it difficult to make a minimal reproducible example, but here are my original data:

likert_krise <- structure(list(krise = structure(c(4L, 5L, 4L, 5L, 5L, 5L, 6L,   2L, 5L, 5L, 4L, 5L, 4L, 5L, 2L, 4L, 1L, 5L, 4L, 2L, 3L, 2L, 4L,   5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 3L, 3L, 4L, 5L, 4L, 5L,   5L, 5L, 5L, 4L, 5L, 3L, 5L, 2L, 5L, 4L, 5L, 5L, 3L, 4L, 2L, 5L,   5L, 5L, 6L, 2L, 4L, 4L, 4L, 3L, 5L, 4L, 1L, 3L, 3L, 3L, 5L, 4L,   4L, 3L, 6L, 5L, 4L, 3L, 2L, 5L, 4L, 4L, 4L, 3L, 5L, 3L, 2L, 3L,   5L, 3L, 3L, 3L, 4L, 2L, 3L, 2L, 5L, 2L, 3L, 3L, 3L, 4L, 3L, 3L,   3L, 2L, 5L, 5L, 5L, 5L, 5L, 3L, 4L, 5L, 1L, 3L, 3L, 4L, 5L, 3L,   5L, 5L, 5L, 5L, 5L, 6L, 4L, 5L, 5L, 4L, 5L, 3L, 5L, 4L, 2L, 2L,   1L, 2L, 3L, 1L, 2L, 2L, 3L, 2L, 3L, 1L, 1L, 3L, 2L, 2L, 1L, 2L,   3L, 3L, 1L, 3L, 3L, 3L, 3L, 2L, 1L, 2L, 3L, 2L, 5L, 3L, 3L, 3L,   2L, 2L, 5L, 3L, 4L, 2L, 3L, 5L, 3L, 2L, 4L, 2L, 2L, 5L, 2L, 3L,   2L, 3L, 2L, 3L, 3L, 3L, 3L, 2L, 5L, 2L, 5L, 6L, 5L, 3L, 5L, 5L,   4L, 5L, 3L, 5L, 6L, 5L, 5L, 3L, 5L, 3L, 5L, 4L, 5L, 5L, 5L, 3L,   5L, 6L, 6L, 6L, 5L, 5L, 3L, 4L, 5L, 5L, 6L, 5L, 3L, 5L, 3L, 5L,   5L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 4L, 5L, 2L, 5L, 5L, 4L, 5L, 5L,   3L, 5L, 4L, 5L, 5L, 4L, 5L, 5L, 5L, 4L, 5L, 4L, 4L, 4L, 1L, 5L,   5L, 2L, 5L, 5L, 5L, 4L, 5L, 4L, 5L, 3L, 4L, 4L, 5L, 3L, 5L, 5L,   3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 4L, 3L, 5L, 5L, 6L, 5L, 5L, 4L,   4L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 4L, 5L, 4L, 5L, 5L, 4L, 5L, 4L,   5L, 6L, 4L, 5L, 5L, 4L, 4L, 2L, 6L, 6L, 5L, 3L, 5L, 5L, 4L, 5L,   4L, 5L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 2L, 4L, 4L, 4L, 5L, 4L,   5L, 5L, 5L, 4L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 5L, 5L, 4L, 5L, 4L,   5L, 4L, 4L, 5L, 4L, 4L, 4L, 5L, 2L, 5L, 4L, 4L, 4L, 5L, 3L, 4L,   3L, 4L, 5L, 4L, 5L, 1L, 4L, 5L, 5L, 5L, 3L, 6L, 3L, 5L, 5L, 3L,   5L, 2L, 5L, 4L, 4L, 5L, 2L, 4L, 3L, 5L, 3L, 5L, 4L, 4L, 5L, 4L,   4L, 4L, 2L, 5L, 5L, 4L, 2L, 5L, 5L, 2L, 4L, 5L, 5L, 5L, 5L, 5L,   1L, 5L, 5L, 4L, 5L, 4L, 5L, 5L, 4L, 4L, 3L, 2L, 5L, 5L, 4L, 4L,   4L, 5L, 3L, 4L, 4L, 4L, 5L, 4L, 5L, 1L, 2L, 4L, 5L, 3L, 5L, 4L,   4L, 5L, 4L, 5L, 2L, 4L, 5L, 4L, 4L, 3L, 5L, 5L, 3L, 5L, 3L, 5L,   2L, 5L, 4L, 5L), .Label = c("Startet og sluttet før", "Startet før, sluttet under",   "Startet før, sluttet etter ", "Startet og sluttet under", "Startet under, sluttet etter",   "startet og sluttet etter"), class = "factor"), `Blir den mindreårige hørt?` = structure(c(4L,   3L, 3L, 3L, 4L, 4L, 4L, 3L, 4L, 4L, 4L, 3L, 4L, 3L, 3L, 5L, 3L,   3L, 4L, 3L, 3L, 1L, 5L, 3L, 4L, 3L, 4L, 4L, 2L, 3L, 2L, 2L, 3L,   4L, 2L, 3L, 4L, 3L, 3L, 3L, 4L, 3L, 2L, 4L, 3L, 4L, 3L, 3L, 3L,   2L, 3L, 3L, 3L, 4L, 4L, 3L, 1L, 3L, 2L, 3L, 3L, 3L, 1L, 4L, 3L,   3L, 3L, 4L, 3L, 3L, 4L, 3L, 2L, 4L, 3L, 4L, 4L, 4L, 4L, 4L, 1L,   3L, 5L, 4L, 3L, 3L, 4L, 4L, 4L, 3L, 3L, 4L, 3L, 4L, 2L, 4L, 4L,   4L, 1L, 3L, 2L, 4L, 4L, 3L, 2L, 3L, 3L, 3L, 4L, 3L, 4L, 3L, 3L,   3L, 4L, 3L, 4L, 4L, 3L, 3L, 4L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L,   4L, 1L, 3L, 4L, 4L, 2L, 4L, 5L, 3L, 4L, 4L, 4L, 3L, 4L, 2L, 2L,   3L, 4L, 3L, 3L, 3L, 4L, 2L, 4L, 3L, 3L, 4L, 4L, 3L, 3L, 4L, 2L,   4L, 3L, 3L, 4L, 4L, 4L, 4L, 3L, 4L, 3L, 2L, 3L, 5L, 4L, 2L, 4L,   3L, 4L, 4L, 3L, 2L, 4L, 4L, 4L, 4L, 4L, 4L, 3L, 4L, 3L, 4L, 4L,   4L, 5L, 4L, 4L, 3L, 4L, 3L, 4L, 3L, 3L, 3L, 4L, 3L, 3L, 5L, 4L,   4L, 3L, 4L, 4L, 4L, 4L, 3L, 5L, 3L, 5L, 5L, 3L, 2L, 3L, 3L, 4L,   3L, 3L, 2L, 4L, 3L, 2L, 3L, 3L, 4L, 4L, 4L, 1L, 4L, 4L, 3L, 3L,   4L, 2L, 4L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 3L, 4L, 2L, 4L, 4L,   2L, 3L, 4L, 3L, 3L, 3L, 4L, 3L, 4L, 3L, 4L, 3L, 4L, 4L, 5L, 3L,   3L, 3L, 4L, 4L, 3L, 4L, 3L, 2L, 4L, 2L, 4L, 3L, 5L, 4L, 3L, 4L,   4L, 3L, 4L, 3L, 2L, 2L, 2L, 5L, 3L, 4L, 4L, 2L, 4L, 4L, 3L, 4L,   3L, 4L, 2L, 4L, 3L, 3L, 3L, 3L, 2L, 3L, 4L, 4L, 4L, 4L, 4L, 2L,   2L, 3L, 4L, 3L, 4L, 4L, 4L, 5L, 3L, 2L, 3L, 2L, 3L, 3L, 3L, 4L,   3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 3L, 3L, 2L, 4L,   5L, 3L, 4L, 3L, 4L, 4L, 3L, 3L, 4L, 4L, 4L, 3L, 2L, 4L, 3L, 2L,   3L, 3L, 2L, 3L, 3L, 4L, 4L, 4L, 3L, 3L, 4L, 3L, 3L, 4L, 1L, 4L,   3L, 4L, 4L, 4L, 2L, 3L, 1L, 3L, 3L, 4L, 1L, 4L, 4L, 3L, 3L, 4L,   3L, 5L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 3L, 4L, 4L, 4L,   1L, 3L, 4L, 3L, 4L, 2L, 1L, 3L, 4L, 3L, 3L, 3L, 3L, 4L, 4L, 3L,   3L, 4L, 4L, 2L, 4L, 3L, 3L, 1L, 4L, 3L, 4L, 2L, 2L, 2L, 3L, 3L,   2L, 2L, 3L, 1L, 4L, 3L, 3L, 2L, 3L, 1L, 3L, 4L, 4L, 3L, 2L, 5L,   3L, 3L, 2L, 2L, 3L, 3L, 4L, 4L, 4L, 3L), .Label = c("I svært liten grad",   "I liten grad", "I noen grad", "I stor grad", "I svært stor grad"  ), class = "factor"), `Får den mindreårige fram sine synspunkter og argumenter i saken?` = structure(c(5L,   2L, 3L, 3L, 4L, 3L, 4L, 3L, 3L, 3L, 4L, 3L, 3L, 3L, 3L, 5L, 3L,   3L, 4L, 4L, 3L, 1L, 4L, 3L, 4L, 4L, 5L, 4L, 3L, 3L, 2L, 2L, 3L,   5L, 3L, 3L, 5L, 3L, 3L, 4L, 4L, 3L, 3L, 4L, 3L, 3L, 4L, 4L, 3L,   3L, 4L, 3L, 4L, 5L, 4L, 3L, 1L, 4L, 2L, 3L, 4L, 3L, 4L, 3L, 3L,   5L, 4L, 4L, 3L, 3L, 4L, 3L, 3L, 4L, 3L, 4L, 4L, 3L, 5L, 4L, 4L,   3L, 5L, 3L, 3L, 2L, 4L, 4L, 5L, 4L, 2L, 4L, 3L, 4L, 4L, 4L, 4L,   4L, 3L, 3L, 2L, 3L, 4L, 3L, 2L, 3L, 3L, 3L, 4L, 1L, 3L, 4L, 3L,   3L, 4L, 4L, 4L, 4L, 3L, 4L, 5L, 2L, 4L, 1L, 4L, 3L, 3L, 4L, 3L,   4L, 3L, 3L, 4L, 3L, 3L, 4L, 4L, 2L, 4L, 4L, 4L, 3L, 4L, 3L, 3L,   3L, 4L, 3L, 3L, 3L, 3L, 3L, 4L, 3L, 3L, 4L, 4L, 3L, 3L, 4L, 3L,   4L, 3L, 2L, 4L, 4L, 3L, 5L, 4L, 4L, 3L, 3L, 3L, 5L, 3L, 2L, 3L,   4L, 4L, 3L, 3L, 2L, 4L, 3L, 3L, 4L, 4L, 4L, 3L, 4L, 4L, 5L, 3L,   4L, 4L, 5L, 4L, 3L, 4L, 3L, 4L, 3L, 3L, 4L, 3L, 3L, 4L, 3L, 4L,   3L, 3L, 4L, 3L, 4L, 4L, 3L, 5L, 4L, 4L, 5L, 2L, 2L, 3L, 2L, 4L,   4L, 3L, 3L, 4L, 3L, 2L, 1L, 3L, 4L, 5L, 5L, 1L, 5L, 4L, 3L, 3L,   4L, 2L, 4L, 3L, 5L, 3L, 3L, 3L, 5L, 3L, 4L, 4L, 4L, 3L, 3L, 4L,   1L, 3L, 3L, 3L, 3L, 4L, 4L, 2L, 4L, 3L, 4L, 3L, 4L, 4L, 4L, 3L,   3L, 3L, 5L, 4L, 3L, 4L, 4L, 2L, 5L, 3L, 3L, 3L, 5L, 4L, 3L, 4L,   3L, 3L, 4L, 4L, 3L, 2L, 3L, 4L, 3L, 5L, 4L, 3L, 4L, 3L, 4L, 4L,   4L, 4L, 2L, 4L, 3L, 2L, 1L, 3L, 3L, 4L, 4L, 5L, 4L, 4L, 4L, 3L,   3L, 4L, 3L, 4L, 4L, 4L, 4L, 5L, 3L, 1L, 3L, 4L, 3L, 3L, 3L, 4L,   3L, 3L, 5L, 4L, 3L, 3L, 3L, 4L, 3L, 4L, 3L, 4L, 3L, 4L, 3L, 4L,   5L, 3L, 4L, 4L, 3L, 4L, 3L, 3L, 4L, 4L, 4L, 4L, 2L, 3L, 3L, 2L,   2L, 4L, 3L, 4L, 3L, 3L, 4L, 4L, 4L, 3L, 4L, 3L, 3L, 4L, 4L, 4L,   2L, 5L, 4L, 3L, 3L, 1L, 2L, 4L, 3L, 4L, 4L, 4L, 4L, 3L, 3L, 4L,   3L, 3L, 3L, 4L, 3L, 3L, 3L, 2L, 4L, 4L, 3L, 3L, 4L, 3L, 4L, 4L,   2L, 3L, 4L, 3L, 5L, 2L, 2L, 3L, 3L, 4L, 3L, 4L, 4L, 4L, 3L, 1L,   4L, 4L, 4L, 2L, 4L, 3L, 3L, 2L, 4L, 3L, 3L, 3L, 3L, 2L, 3L, 3L,   3L, 3L, 3L, 3L, 4L, 3L, 4L, 3L, 3L, 1L, 3L, 4L, 4L, 4L, 4L, 4L,   4L, 3L, 3L, 2L, 4L, 3L, 4L, 2L, 3L, 3L), .Label = c("I svært liten grad",   "I liten grad", "I noen grad", "I stor grad", "I svært stor grad"  ), class = "factor")), row.names = c(NA, -475L), class = "data.frame", na.action = structure(c(`5` = 5L,   `28` = 28L, `58` = 58L, `61` = 61L, `62` = 62L, `71` = 71L, `105` = 105L,   `115` = 115L, `127` = 127L, `135` = 135L, `138` = 138L, `139` = 139L,   `153` = 153L, `156` = 156L, `162` = 162L, `177` = 177L, `220` = 220L,   `225` = 225L, `226` = 226L, `234` = 234L, `253` = 253L, `256` = 256L,   `291` = 291L, `339` = 339L, `340` = 340L, `346` = 346L, `358` = 358L,   `367` = 367L, `382` = 382L, `417` = 417L, `424` = 424L, `426` = 426L,   `458` = 458L, `471` = 471L, `498` = 498L, `499` = 499L, `500` = 500L,   `501` = 501L, `502` = 502L, `504` = 504L, `505` = 505L, `506` = 506L,   `507` = 507L, `508` = 508L, `509` = 509L, `510` = 510L, `511` = 511L,   `512` = 512L, `513` = 513L, `514` = 514L, `515` = 515L, `516` = 516L,   `517` = 517L, `518` = 518L, `519` = 519L, `520` = 520L, `522` = 522L,   `523` = 523L, `524` = 524L, `525` = 525L, `526` = 526L, `527` = 527L,   `528` = 528L, `529` = 529L, `530` = 530L, `531` = 531L, `532` = 532L,   `533` = 533L, `534` = 534L, `536` = 536L, `537` = 537L, `538` = 538L,   `539` = 539L, `540` = 540L, `541` = 541L, `543` = 543L, `544` = 544L,   `545` = 545L, `547` = 547L, `549` = 549L, `550` = 550L, `551` = 551L,   `552` = 552L, `553` = 553L, `554` = 554L, `555` = 555L, `556` = 556L,   `557` = 557L, `558` = 558L, `559` = 559L, `560` = 560L, `562` = 562L,   `563` = 563L, `564` = 564L, `565` = 565L, `566` = 566L, `567` = 567L,   `568` = 568L, `569` = 569L, `570` = 570L, `571` = 571L, `572` = 572L,   `573` = 573L, `574` = 574L, `575` = 575L, `576` = 576L, `577` = 577L,   `578` = 578L, `579` = 579L, `580` = 580L, `581` = 581L, `582` = 582L,   `583` = 583L, `584` = 584L, `585` = 585L, `586` = 586L, `587` = 587L,   `588` = 588L, `589` = 589L, `590` = 590L, `592` = 592L, `593` = 593L,   `594` = 594L, `595` = 595L, `596` = 596L, `597` = 597L, `598` = 598L,   `599` = 599L, `600` = 600L, `601` = 601L, `602` = 602L, `603` = 603L,   `604` = 604L, `605` = 605L, `606` = 606L, `607` = 607L, `608` = 608L,   `609` = 609L, `611` = 611L, `612` = 612L, `613` = 613L, `614` = 614L,   `615` = 615L, `616` = 616L, `617` = 617L, `618` = 618L, `619` = 619L,   `620` = 620L, `621` = 621L, `623` = 623L, `624` = 624L, `625` = 625L,   `626` = 626L, `627` = 627L, `628` = 628L, `629` = 629L, `630` = 630L,   `631` = 631L, `632` = 632L, `633` = 633L, `634` = 634L, `636` = 636L,   `637` = 637L, `639` = 639L, `640` = 640L, `641` = 641L, `642` = 642L,   `643` = 643L), class = "omit"))  

How to delete a row in csv file in python? [duplicate]

Posted: 08 May 2021 08:20 AM PDT

I want to delete rows from a csv file as they are processed. My file:

1,Zname1,Zname2,Zname3  2,Yname1,Yname2,Yname3  3,Xname1,Xname2,Xname3  

I want to read row by row and delete the row which has been processed. So the file will be now:

2,Yname1,Yname2,Yname3  3,Xname1,Xname2,Xname3  

There solutions which are provided on other questions are:

  1. read the file
  2. use next() or any other way to skip the row and write the remaining rows in an updated file

I want to delete the row from the original file which was entered in .reader() method

My code:

 with open("file.txt","r") as file   reader=csv.reader(file)   for row in reader:       #process the row       #delete the row  

I have not been able to figure out how to delete/remove the row

I want the change to be in the original "file.txt" because i will be running the program many times and so each time it runs, "file.txt" will already be present and the program will start from where it ended the last time.....

How to display specific user information in a separate page using flask and flask-sqlalchemy?

Posted: 08 May 2021 08:20 AM PDT

I made only one table in my application. I want to display some information on the page admin.html and specific user information on info.html page. How should I give the query to show the particular user information on which client has clicked on the admin page. I want to display other attributes of my database like email, phone number, college name only on the info.html page. Here are my files:

database

class database(db.Model):      id=db.Column('user_id',db.Integer, primary_key=True)      name = db.Column(db.String(20))      text=db.Column(db.String(1000))      personality_score=db.Column(db.Integer)      skills_score=db.Column(db.Integer)      experience_score=db.Column(db.Integer)      total_score=db.Column(db.Integer)      college=db.Column(db.String(100))      email=db.Column(db.String(100))      phone_number=db.Column(db.String(100))  

app.py

@app.route('/admin')  def admin():      return render_template('admin.html',database=database.query.order_by(database.total_score.desc()).all())    @app.route('/info')  def info():      return render_template('info.html')  

admin.html

<table class="css-serial">           <tbody>              <tr>                 <th>Rank</th>                 <th>ID</th>                 <th>Name</th>                 <th>Profile Summary</th>                 <th>Personality Score</th>                 <th>Skills Score</th>                 <th>Experience Score</th>                 <th>Total Score</th>              </tr><tr>                 {% for data in database %}                    <td></td>                    <td>{{data.id}}</td>                    <td><a href=info>{{ data.name }}</a></td>                    <td>{{ data.text }}</td>                    <td>{{ data.personality_score }}</td>                    <td>{{data.skills_score}}</td>                    <td>{{data.experience_score}}</td>                    <td>{{data.total_score}}</td>                 </tr></tbody>                 {% endfor %}        </table>  

I have not written anything in the info.html file because I was not able to figure out how to fetch 'id' or data to display on that page.

How to fix this translate command?

Posted: 08 May 2021 08:21 AM PDT

why is this command not working? like what should i do to fix this?

@client.command(aliases = ["t"])  async def translate(ctx, lang_to, *,args):      lang_to = lang_to.lower()                  if lang_to not in googletrans.LANGUAGES and lang_to not in googletrans.LANGCODES:          await ctx.send("Invalid language to translate to")        text = ' '.join(args)      translator = googletrans.Translator()      text_translated = translator.translate(text, dest=lang_to).text      await ctx.send(text_translated)    error :-  Command raised an exception: ConnectTimeout: _ssl.c:1106: The handshake operation timed out  

Widget not responding to setOnClickFillInIntent and setPendingIntentTemplate

Posted: 08 May 2021 08:22 AM PDT

Click event not triggering in android widget in ListView

I have buttons in each row of the listview in a widget and i would like to make them clickable. I am using setPendingIntentTemplate and setOnClickFillInIntent and i was hoping that the onReceive method would be triggered?

        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.my_app_widget);            Intent intent = new Intent(context, MyWidgetRemoteViewsService.class);            rv.setRemoteAdapter(R.id.drinks_list, intent);            PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT);            rv.setPendingIntentTemplate(R.id.drinks_list, pendingIntent);            appWidgetManager.updateAppWidget(appWidgetId, rv);  

MyAppWidgetRemoteViewsFactory.java

public RemoteViews getViewAt(int position) {        RemoteViews drinks_view = new RemoteViews(mContext.getPackageName(), R.layout.drink_row);      drinks_view.setTextViewText(R.id.drink_name,  drinkItems.get(position).text);        Bundle extras = new Bundle();      extras.putInt(MyAppWidget.DRINK_UPDATE, position);      Intent fillInIntent = new Intent();      fillInIntent.putExtras(extras);        drinks_view.setOnClickFillInIntent(R.id.minusButton, fillInIntent);        return drinks_view;  }  

drink_row.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"      android:layout_width="wrap_content"      android:background="@drawable/whiteroundcorner"      android:layout_height="wrap_content">         <Button              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:id="@+id/minusButton"              android:backgroundTint="#27A9FF"              android:text="-"              android:clickable="true"              android:minWidth="60dp"              android:textColor="#FFFFFF"              android:layout_alignParentLeft="true">  </RelativeLayout>        public class MyWidgetRemoteViewsService extends RemoteViewsService {      @Override      public RemoteViewsFactory onGetViewFactory(Intent intent) {          return new MyAppWidgetRemoteViewsFactory(this.getApplicationContext(),intent);      }  }      <receiver android:name=".MyAppWidget">      <intent-filter>          <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />      </intent-filter>      <intent-filter>          <action android:name="com.developer.drinklogger.EXTRA_ITEM" />      </intent-filter>        <meta-data          android:name="android.appwidget.provider"          android:resource="@xml/my_app_widget_info" />  </receiver>  <service android:name=".MyWidgetRemoteViewsService"      android:permission="android.permission.BIND_REMOTEVIEWS"></service>  

Active Directory Password connection using JDBC(Java)

Posted: 08 May 2021 08:20 AM PDT

I am trying to connect to SQL server using Active Directory Password authentication mode. But on executing the code I get the Following error:

    [pool-2-thread-1] INFO com.microsoft.aad.adal4j.AuthenticationAuthority     - [Correlation ID: 2febb587-963f-462a-9937-98b05d3a3fc8] Instance       discovery was successful      [pool-2-thread-1] ERROR com.microsoft.aad.adal4j.AuthenticationContext -       [Correlation ID: 2febb587-963f-462a-9937-98b05d3a3fc8] Execution of       class com.microsoft.aad.adal4j.AcquireTokenCallable failed.      java.lang.ClassCastException: java.util.Collections$SingletonList cannot       be cast to java.lang.String      at com.nimbusds.oauth2.sdk.util.URLUtils.serializeParameters(URLUtils.java:88)      at com.microsoft.aad.adal4j.AdalTokenRequest.toOAuthRequest(AdalTokenRequest.java:160)      at com.microsoft.aad.adal4j.AdalTokenRequest.executeOAuthRequestAndProcessResponse(AdalTokenRequest.java:86)      at com.microsoft.aad.adal4j.AuthenticationContext.acquireTokenCommon(AuthenticationContext.java:930)  at com.microsoft.aad.adal4j.AcquireTokenCallable.execute(AcquireTokenCallable.java:70)  at com.microsoft.aad.adal4j.AcquireTokenCallable.execute(AcquireTokenCallable.java:38)  at com.microsoft.aad.adal4j.AdalCallable.call(AdalCallable.java:47)  at java.util.concurrent.FutureTask.run(Unknown Source)  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  at java.lang.Thread.run(Unknown Source)  Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: Failed to authenticate the user e9002802@ltfinc.net in Active Directory (Authentication=ActiveDirectoryPassword).  at com.microsoft.sqlserver.jdbc.SQLServerADAL4JUtils.getSqlFedAuthToken(SQLServerADAL4JUtils.java:57)  at com.microsoft.sqlserver.jdbc.SQLServerConnection.getFedAuthToken(SQLServerConnection.java:3853)  at com.microsoft.sqlserver.jdbc.SQLServerConnection.onFedAuthInfo(SQLServerConnection.java:3829)  at com.microsoft.sqlserver.jdbc.SQLServerConnection.processFedAuthInfo(SQLServerConnection.java:3797)  at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onFedAuthInfo(tdsparser.java:261)  at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:103)  at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4545)  at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3406)  at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:85)  at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3370)  at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7347)  at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2713)  at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2261)  at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1921)  at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1762)  at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1077)  at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnectionInternal(SQLServerDataSource.java:1025)  at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnection(SQLServerDataSource.java:69)  at main.AADUserPassword.main(AADUserPassword.java:22)    Caused by: java.util.concurrent.ExecutionException:     com.microsoft.aad.adal4j.AuthenticationException:     java.util.Collections$SingletonList cannot be cast to java.lang.String    at com.microsoft.sqlserver.jdbc.SQLServerADAL4JUtils.getSqlFedAuthToken(SQLServerADAL4JUtils.java:55)    ... 18 more  Caused by: com.microsoft.aad.adal4j.AuthenticationException: java.util.Collections$SingletonList cannot be cast to java.lang.String  at com.microsoft.sqlserver.jdbc.SQLServerADAL4JUtils.getSqlFedAuthToken(SQLServerADAL4JUtils.java:50)  ... 18 more  

I am not able to figure out, what exactly that exception(cannot cast to java.lang.string) means; also I have given correct username and password. I checked it using sql server management studio and it got connected. Please help. I am in a fix. Any help would be appreciated greatly.

Automatically scroll multiline TextFormField when it extends the maxLines attribute

Posted: 08 May 2021 08:22 AM PDT

I'm implementing a TextFormField with the maxLines attribute set to 3. How can I make the TextFormField scroll down once the user starts with his fourth line? At the moment the cursor is just not visible anymore until the user scrolls down by hand. Is there a way to do this automatically?

This behaviour is actually featured in the flutter_gallery app in the 'Text fields' example. Just type a long text to the 'Live story' input until it reaches the fourth line.
The important parts of my code actually look like this:

import 'package:flutter/material.dart';    class TextFormFieldDemo extends StatelessWidget {    @override    Widget build(BuildContext context) {      return new Scaffold(        body: new Form(          child: new TextFormField(            maxLines: 3,          ),        ),      );    }  }  

So far I have found no workaround for this issue.
This issue affects both iOS and android.

Fetch: POST JSON data

Posted: 08 May 2021 08:20 AM PDT

I'm trying to POST a JSON object using fetch.

From what I can understand, I need to attach a stringified object to the body of the request, e.g.:

fetch("/echo/json/",  {      headers: {        'Accept': 'application/json',        'Content-Type': 'application/json'      },      method: "POST",      body: JSON.stringify({a: 1, b: 2})  })  .then(function(res){ console.log(res) })  .catch(function(res){ console.log(res) })  

When using jsfiddle's JSON echo I'd expect to see the object I've sent ({a: 1, b: 2}) back, but this does not happen - chrome devtools doesn't even show the JSON as part of the request, which means that it's not being sent.

No comments:

Post a Comment