Saturday, July 3, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


How i can extract data from string in nodejs

Posted: 03 Jul 2021 02:55 PM PDT

I have a string: `PRESIDÊNCIA Decisão Monocrática

Processo Nº Protes-0101856-23.2021.5.01.0000 RelatorEDITH MARIA CORREA TOURINHO REQUERENTESINDICATO DOS TRABALHADORES NA INDUSTRIA DE ARTEFATOS DE BORRACHA DO ESTADO DO RIO DE JANEIRO ADVOGADOANDREA ALVES CRUZ(OAB: 94707/RJ) REQUERIDOSINDICATO DA I DE ART DE BORRACHA DO E DO R DE JANEIRO`

I need extract just Protes-0101856-23.2021.5.01.0000 how can i do this in nodejs

thanks :)

Storing unique values in the same table but with different parent values

Posted: 03 Jul 2021 02:54 PM PDT

  1. I have 2 tables Parent and Child.

  2. Child has a unique attribute(childNo)

  3. As long as 2 Children have different Parents, they should be able to have the same childNo.

  4. 2 Children with the same Parents should not have the same childNo

I can't think of a way to implement this as I'm getting a unique constraint violation.

enter image description here

Run nested node functions from command line with args?

Posted: 03 Jul 2021 02:54 PM PDT

The structure and content

With a directory structure that includes:

  • package.json
  • tasks.js

tasks.js contains:

console.log('hi')  module.exports = {      tasks: {          myFunc: myFunc      }  }  

and

function myFunc(arg1, arg2) {      return arg1 + arg2  }  

package.json includes:

"main": "tasks.js"  

When I'm in the same directory as tasks.js and package.json and run node . on the command line, it does output 'hi'.

The question

Without changing the structure of tasks.js, how can I call myFunc() from the command line with the two arguments that the function takes?

This is related to this other question. But it adds a couple levels of complexity:

  • how to call the function with its two args?
  • how to do it without changing the code above?
  • what do I do about this unexpected token error?
  • the exported function is nested within an object, unlike in the other post

I tried: node -e 'require("./myFunc")(2,2)' as suggested by the other post, but that gave me back Unexpected token '.'.

sort points of interest by distance between each other

Posted: 03 Jul 2021 02:54 PM PDT

I have an array with point-objects as an input. I want to sort these points, that I get an Array with the shortest route covering all the points. this is my code so far, but i havent figuered out, how to delete points, once they have been used.

public Point[] poiSort(Point[] poi){          poi = new Point[lenght+1];          poi[0] = points[0];          distances = new Double[lenght];          double Distance = verybignumber;          double Distancecompare;          for (int i = 1; i < leght+1; i++){              for (int j = 1; j < (lenght); j++){                  Distancecompare = points[i-1].getDistance(points[j]);                  if (Distance > Distancecompare){                      Distance = Distancecompare;                      poi[i] = points[j];                      distances[i-1] = Disstance;                  }              }          }          return poi;      }        

Prank User Detection/Prevention in Emergency App

Posted: 03 Jul 2021 02:52 PM PDT

I'm currently developing an android application that lets you send your current location to responders (an Admin version, if you will) and then display your location in a map interface on their end.

However, I'm having difficulties in implementing security measures for preventing and detecting Prank users from sending fake incidents that will prevent resources from being wasted.

What should be the best way to prevent and detect fraud reports on the admin side?

null is not an object (evaluating i.category._id)

Posted: 03 Jul 2021 02:52 PM PDT

I'm still learning react-native and trying to retrieve data from API but I got this error: error msg

the

initialState is set to ([])

   // Product container    const changeCtg = (ctg) => {      {        ctg === "all"          ? [setProductsCtg(initialState), setActive(true)]          : [              setProductsCtg(                products.filter((i) => i.category._id === ctg),                setActive(true)              ),            ];      }    };  

Create an Excel file with the name of sheets taken from a vector

Posted: 03 Jul 2021 02:54 PM PDT

Starting from the vector:

vector <- c("alfa", "beta", "gamma", "delta", "epsilon")  

I would like to create an Excel file with the name of sheet1 = alfa, the name of sheet2 = beta, etc.

Is there a way?

Actually, I need to export multiple dataframes in an .xlsx format and I use the package "writexl" and these instructions:

  sheets <- list("sheet1Name" = dataframe1, "sheet2Name" = dataframe2)    write_xlsx(sheets, "data.xlsx")     

but I have to write the "sheet*Name" manually, and I have more than 100 sheets... For this reason I would like to take their names from a vector.

k8s `selector` does not match template `labels`

Posted: 03 Jul 2021 02:52 PM PDT

I am pulling my hair out here. I deployed my template, deleted it, and then I go to deploy it again without any changes and am getting the following error:

The Deployment "blog" is invalid: spec.template.metadata.labels: Invalid value: map[string]string(nil): selector does not match template labels

My deployment yaml is below and as you can see the metadata and selector labels are both web, so I have no idea what the error is trying to tell me:

apiVersion: apps/v1  kind: Deployment  metadata:    name: blog    labels:      app: web  spec:    selector:      matchLabels:        app: web    template:      metadata:        labels:          app: web    replicas: 1    template:      spec:        containers:        - env:          image: test_blog:latest          imagePullPolicy: Always          name: blog          ports:          - containerPort: 8080  

Framer transform animation based on mouse movement

Posted: 03 Jul 2021 02:51 PM PDT

I'm trying to simulate the hover animation in the gallery over here - https://themes.themegoods.com/bookingo/demo/gallery-grid/

The rotateX and rotateY values here are changed based on mouse movement insider the over area (inside the image). I'm still getting familiar with framer motion API, but I don't see a way to get the mouse coordinates during whileHover to change the transform. Is there another way to achieve similar result using framer?

https://codesandbox.io/s/sample-6zrvx

Need guidance with Toxi Structure to list all distinct rows

Posted: 03 Jul 2021 02:53 PM PDT

I am learning SQL using MySQL and I need guidance facing one problem. I have a simple database model see image below: {database model]1

The column video_id represents the fk from the table xvideos_list, and the tables video_tags, video_tag_map, video_category, video_category_map, video_actor_actress, and video_actor_actress_map are the Toxi structure to organized details of each video row from the xvideos_list table. I created 3 views: vw_video_act, vw_video_tags, vw_video_categ for video actors, tags and categories respectively. These views join the map tables with the non-map tables, an example of a view below:

    CREATE       ALGORITHM = UNDEFINED       DEFINER = `root`@`localhost`       SQL SECURITY DEFINER  VIEW `freeamateur`.`vw_video_act` AS      SELECT           `vaam`.`idvideo_actor_actress_map` AS `idvideo_actor_actress_map`,          `vaam`.`video_id` AS `video_id`,          `vaam`.`video_actor_actress_id` AS `video_actor_actress_id`,          `vaa`.`idvideo_actor_actress` AS `idvideo_actor_actress`,          `vaa`.`name` AS `name`      FROM          (`freeamateur`.`video_actor_actress_map` `vaam`          LEFT JOIN `freeamateur`.`video_actor_actress` `vaa` ON ((`vaam`.`video_actor_actress_id` = `vaa`.`idvideo_actor_actress`)))  

The other two are exactly the same code just with their respective columns (see image above). My question is, how to get all the tags, categories and actors from a single video using the video_id ? I wrote a stored procedure to get these values however, I am not sure what I did is correct even if the result set seems to be right. The procedure below:

    CREATE DEFINER=`root`@`localhost` PROCEDURE `sel_video_details`(in video_id int)  BEGIN      SELECT vva.video_id,      GROUP_CONCAT(DISTINCT vvc.category_name SEPARATOR ', ') AS categ_list,      GROUP_CONCAT(DISTINCT vva.name SEPARATOR ', ') AS act_list,      GROUP_CONCAT(DISTINCT vvt.tag_name SEPARATOR ', ') AS tag_list      FROM vw_video_act vva      INNER JOIN vw_video_categ vvc       ON vva.video_id = vvc.video_id      INNER JOIN vw_video_tags vvt      ON vva.video_id = vvt.video_id      AND vvc.video_id = video_id      GROUP BY(vva.video_id);  END  

Result set: Result grid

Can someone help me?

Trying to find the longest substring without repeating characters

Posted: 03 Jul 2021 02:54 PM PDT

For example, if the string was pwwkew, the longest substring without repeating characters would be wke.

def lengthOfLongestSubstring(string):      count = 0      current_longest = 0      consideration = []      while count < len(string):          current_char = string[count:count+1]          consideration.append(current_char)          for i in range(len(consideration)):              if current_char == consideration[i]:                  current_longest = 0                  consideration.clear()                  consideration.append(current_char)          current_longest += 1          count += 1      return current_longest  

So, i iterate through the string one character at a time. At each character, I add it to my array consideration, and check if that current character already exists there. If it does, I reset the array consideration, make current longest zero, and leave in the current character in the array. If the current character isnt there then I increase the counter and the length of the current longest. It seems very logical to me, but this is wrong. Anyone know what gives?

searching a map in dart and returning all values matching search

Posted: 03 Jul 2021 02:54 PM PDT

I have a map, with multiple layers, some of the layers have an events field which may contain 0 or more event listings inside of it. Some of events are nested deeper into the map, while others are closer to the top layer.

The data is as follows: {data: {users: [{id: 16, friends: [{senderId: 16, receiverId: 17, userByReceiverid: {id: 17, events: [], friends: [{receiverId: 14, userByReceiverid: {id: 14, events: [{id: 3, photoUrl: none, name: hello, date: 1982-06-27, startTime: 01:00:00+00, endTime: 02:00:00+00, fee: $2.00, maxNumber: 10, ageRestriction: none, about: amazing, allowShare: false, private: false, timestamp: 2021-06-26T17:57:13.224383+00:00, senderId: 14}]}}, {receiverId: 20, userByReceiverid: {id: 20, events: []}}]}}], friendsByReceiverid: [{senderId: 20, receiverId: 16, user: {id: 20, events: [], friendsByReceiverid: [{receiverId: 20, user: {id: 14, events: [{id: 3, photoUrl: none, name: hello, date: 1982-06-27, startTime: 01:00:00+00, endTime: 02:00:00+00, fee: $2.00, maxNumber: 10, ageRestriction: none, about: amazing, allowShare: false, private: false, timestamp: 2021-06-26T17:57:13.224383+00:00, senderId: 14}]}}, {receiverId: 20, user: {id: 17, events: []}}]}}]}]}}

I want to search the Map and make a list that contains all the events that are unique, so no duplicates if possible.

How would I go about pulling out only the events field from a map at any given point?

How to solve simple optimization problem in R

Posted: 03 Jul 2021 02:53 PM PDT

I have three equations and I would like to solve for a parameter that minimizes the differences between them.

DifferenceA:   100/(1+d)^50 - 75/(1+d)^25  DifferenceB:   100/(1+d)^50 - 50/(1+d)^15  DifferenceC:   75/(1+d)^25 - 50/(1+d)^15  

I would like to solve for the parameter d* that minimizes the sum of the squared residuals in the above differences preferably using R where:

enter image description here

I haven't done optimization in R and was wondering what packages and how to set-up solving a simple minimization problem like this in R? thanks.

Why does program terminate without taking input?

Posted: 03 Jul 2021 02:54 PM PDT

This is sample of my program:

#include <stdio.h>  void sum();  int main()  {      char choice[4];      do      {          sum();          printf("\nDo You want to restart the program: yes or no:\n");          fgets(choice, 4, stdin); //error point      } while (choice[0] == 'y' || choice[0] == 'Y');      printf("\nThanking You");      return 0;  }  void sum()  {      int a = 3, b = 4;      printf("sum of two number is %d", a + b);  }  

In this program, only in the 1st iteration of while does it ask for input in choice and, on the next iteration the program auto terminates by taking any value in choice.

Following is the result after execution of code:

sum of two number is 7  Do You want to restart the program: yes or no:  yes  sum of two number is 7  Do You want to restart the program: yes or no:    Thanking You  [Program finished]  

I am unable to understand that it takes input in choice while I haven't used scanf() (which leaves the new line character in the buffer). It may be it takes input from buffer that may be whitespace or other characters, but I don't know from where it came?

onVerificationCompleted does not work and firebase

Posted: 03 Jul 2021 02:51 PM PDT

for authentication through the cell phone number in firebase and android studio The onVerificationCompleted method is not executed, which cannot get the verification code:

PhoneAuthProvider.OnVerificationStateChangedCallbacks callbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {                          @Override                          public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential)                           {//does not run on method calls                                String credential = phoneAuthCredential.getSmsCode();                      if(credential !=null){                        verification.setText(credential);                       sigIn(credential);                      }                      else{                          Toast.makeText(VerificationActivity.this,"Rechazado",Toast.LENGTH_SHORT).show();                      }                  }                            @Override                  public void onVerificationFailed(@NonNull FirebaseException e) {                      Toast.makeText(VerificationActivity.this,"fallida",Toast.LENGTH_LONG).show();                  }                            @Override                  public void onCodeSent(@NonNull String s, @NonNull                   PhoneAuthProvider.ForceResendingToken forceResendingToken) {                      super.onCodeSent(s, forceResendingToken);                      Toast.makeText(VerificationActivity.this,"codigo enviado",Toast.LENGTH_LONG).show();                      Id = s;                  }              };  

Can you tell me what may be happening? and a solution, please and thank you in advance

Object(...) is not a function while working with element-plus, argon template

Posted: 03 Jul 2021 02:54 PM PDT

I'm rookie with VueJS. I'm gonna work with argon-templates.

Could you explain details about how to fix? I tried to use argon plugins in main.js.

First, I installed npm module: element-plus(successful) Here's my code:

import Vue from "vue";  import ArgonDashboard from "./plugins/argon-dashboard";  ...    new Vue({router,ArgonDashboard,store,render: h => h(App)}).$mount("#app");  

And my browser raised following:

Uncaught TypeError: Object(...) is not a function at eval (index.esm.js?3fd4:1) at Module../node_modules/element-plus/lib/index.esm.js (app.js:4051)

Anybody helps.

Create fixtures from a list of countries in SQL

Posted: 03 Jul 2021 02:53 PM PDT

I have a country table with a list countries in it. And I want to get the output as possible fixtures like in a world cup.

Sample country table input -  -----  col  -----  eng  sa  aus    Output -  ------------  col1   col2  ------------  aus    eng  eng    sa  sa     aus  

I came up with the below solution with self join, but this creates duplicates in the fixtures like aus v eng and eng v aus.

select a.col as col1, b.col as col2      from country a      join country b      on a.col != b.col  

Another approach I tried was using LEAD function. This works, but is there a more efficient way to do it?

select     col1,     case when col2 is not null then col2         else (select top 1 col from country order by col)    end as col2  from      (select         col as col1,         lead(col,1) over (order by col) as col2       from country) t  

Requesting Images Returns 403 Response

Posted: 03 Jul 2021 02:52 PM PDT

I'm requesting an Image and It returns a 403 response. I tried using my User-Agent and other ones but It still returned 403. I know it's possible to get this image since tachiyomi uses web scrappers to get their images. My current code looks like this atm

headers = {"User-Agent": "a user agent"}  res= requests.get("https://s5.mkklcdnv6tempv3.com/mangakakalot/r1/read_bleach_manga_online_for_free2/chapter_673_father/1.jpg", headers=headers)  print(res.status_code)  

Is the way I'm requesting the image wrong? Or are there other parameters/headers I should add?

Solution:

Instead of using User-Agent as the header do

headers = {"Referer": "https://mangakakalot.com/"}  

Source

Task :app:compileDebugJavaWithJavac FAILED React native

Posted: 03 Jul 2021 02:54 PM PDT

I am new in react native facing some issues

Starting a Gradle Daemon, 1 busy and 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

Task :app:compileDebugJavaWithJavac FAILED 15 actionable tasks: 2 executed, 13 up-to-date

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches(). Unexpected lock protocol found in lock file. Expected 3, found 0.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 3m 21s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches(). Unexpected lock protocol found in lock file. Expected 3, found 0.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 3m 21s

at makeError (C:\Users\RDX\Desktop\AwesomeProject\node_modules\execa\index.js:174:9)  at C:\Users\RDX\Desktop\AwesomeProject\node_modules\execa\index.js:278:16  at processTicksAndRejections (internal/process/task_queues.js:95:5)  at async runOnAllDevices (C:\Users\RDX\Desktop\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)  at async Command.handleAction (C:\Users\RDX\Desktop\AwesomeProject\node_modules\@react-native-community\cli\build\index.js:186:9)  

info Run CLI with --verbose flag for more details.

Pass object and function to javascript class and return onSuccess and onError

Posted: 03 Jul 2021 02:54 PM PDT

I try to define a javascript class that will receive an object as a parameter and some self define callback functions like onSucess and onError and use those functions to return a response to the user.

Here is what I have tried so far

class User {        constructor(param) {          this.param = param;      }        static create(param) {          return new User(param);      }        onSuccess() {        }        onError() {        }        showForm() {        }  }  

And this is how I want to invoke the class

let user = User.create({      name: 'name_here',       email: 'user@email.com',      age: 37,      onSuccess: (response) => {        },      onError: (error) => {        }  })  user.showForm()  

My question now is how can I invoke a User class like this

let user = User.create({      name: 'name_here',       email: 'user@email.com',      age: 37,      onSuccess: (response) => {        },      onError: (error) => {        }  })  user.showForm()  

Though that may not be the proper way to define the class and its functions, but that how I want the class to be called.

I will appreciate any corrections or suggestions.

Thanks.

Imagine the class is like this:

class User {      constructor(param) {          Object.assign(this, param);      }        static create(param) {          return new User(param);      }    }  

and I want to invoke the User class like this:

let user = User.create({      name: 'name_here',      email: 'user@email.com',      age: 37,      onSuccess: (response) => {          alert("onSuccess");      },      onError: (error) => {          alert("error");      }  })  

Conditional anchor links

Posted: 03 Jul 2021 02:53 PM PDT

I have a table of contents that then scrolls to the various headings / subheadings.

Now other than the introduction, the other subheadings users need to be logged in to read.

If I use normal anchors, clicking on the heading will throw a 404 error for users... rather than scroll down to the 'Please log in' container.

Is there a simple and clean way to set this up so that if the anchor isn't found it reverts maybe to the container (possibly default anchor)?

// I had a good search around but couldn't find anything specific to this issue.

Airflow: Unable to get persistent logs using KubernetesExecutor and PV (official helm chart)

Posted: 03 Jul 2021 02:52 PM PDT

I feel a bit like an idiot but I cannot seem to get the logging working on persistent volumes when using the KubernetesExecutor and the freshly released official Helm chart.

After creating a simple PV and PVC manually, I changed the following on the bottom of values.yaml file:

logs:    persistence:      # Enable persistent volume for storing logs      enabled: true      # Volume size for logs      size: 100Gi      # If using a custom storageClass, pass name here      storageClassName:      ## the name of an existing PVC to use      existingClaim: airflow-logs  

This process is partly described in the official Helm documentation. Still, the airflow-scheduler pod crashes due to permission errors as i cannot write in the mounted logs folder: logs here.

When the persistent logging is turned off, all is working, except for task logging as these are deleted when the worker-pod is deleted.

Any help towards a solution would be greatly appreciated!

Finding letters mixed with numbers?

Posted: 03 Jul 2021 02:53 PM PDT

So I'm working with a dataset that has values of 16M instead of 16,000,000. How do I find the other currency denotations? This dataset is massive, so it's not feasible to manually check. Thank you!

Below are the first 250 samples. The structure of the dataset is as follows: country, year, GDP($), and classification of the data(GDP).

structure(list(country = c("Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba",   "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",   "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",   "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",   "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",   "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",   "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",   "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",   "Afghanistan"), year = c("1799", "1800", "1801", "1802", "1803",   "1804", "1805", "1806", "1807", "1808", "1809", "1810", "1811",   "1812", "1813", "1814", "1815", "1816", "1817", "1818", "1819",   "1820", "1821", "1822", "1823", "1824", "1825", "1826", "1827",   "1828", "1829", "1830", "1831", "1832", "1833", "1834", "1835",   "1836", "1837", "1838", "1839", "1840", "1841", "1842", "1843",   "1844", "1845", "1846", "1847", "1848", "1849", "1850", "1851",   "1852", "1853", "1854", "1855", "1856", "1857", "1858", "1859",   "1860", "1861", "1862", "1863", "1864", "1865", "1866", "1867",   "1868", "1869", "1870", "1871", "1872", "1873", "1874", "1875",   "1876", "1877", "1878", "1879", "1880", "1881", "1882", "1883",   "1884", "1885", "1886", "1887", "1888", "1889", "1890", "1891",   "1892", "1893", "1894", "1895", "1896", "1897", "1898", "1899",   "1900", "1901", "1902", "1903", "1904", "1905", "1906", "1907",   "1908", "1909", "1910", "1911", "1912", "1913", "1914", "1915",   "1916", "1917", "1918", "1919", "1920", "1921", "1922", "1923",   "1924", "1925", "1926", "1927", "1928", "1929", "1930", "1931",   "1932", "1933", "1934", "1935", "1936", "1937", "1938", "1939",   "1940", "1941", "1942", "1943", "1944", "1945", "1946", "1947",   "1948", "1949", "1950", "1951", "1952", "1953", "1954", "1955",   "1956", "1957", "1958", "1959", "1960", "1961", "1962", "1963",   "1964", "1965", "1966", "1967", "1968", "1969", "1970", "1971",   "1972", "1973", "1974", "1975", "1976", "1977", "1978", "1979",   "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987",   "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995",   "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003",   "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011",   "2012", "1799", "1800", "1801", "1802", "1803", "1804", "1805",   "1806", "1807", "1808", "1809", "1810", "1811", "1812", "1813",   "1814", "1815", "1816", "1817", "1818", "1819", "1820", "1821",   "1822", "1823", "1824", "1825", "1826", "1827", "1828", "1829",   "1830", "1831", "1832", "1833", "1834"), value = c("16.9M", "16.9M",   "16.9M", "16.9M", "16.9M", "16.9M", "16.9M", "16.9M", "16.9M",   "16.9M", "16.9M", "16.9M", "16.9M", "16.9M", "16.9M", "16.9M",   "16.9M", "16.9M", "16.9M", "16.9M", "16.9M", "17.1M", "17.3M",   "17.5M", "17.7M", "17.9M", "18.1M", "18.4M", "18.6M", "18.8M",   "19M", "19.3M", "19.5M", "19.7M", "19.9M", "20.2M", "20.4M",   "20.7M", "20.9M", "21.2M", "21.4M", "21.7M", "21.9M", "22.2M",   "22.4M", "22.7M", "23M", "23.3M", "23.5M", "23.8M", "24.1M",   "24.4M", "24.7M", "25M", "25.3M", "25.6M", "25.9M", "26.2M",   "26.5M", "26.8M", "27.1M", "27.4M", "27.8M", "28.1M", "28.4M",   "28.8M", "29.1M", "29.5M", "29.8M", "30.2M", "30.5M", "30.9M",   "31.3M", "31.6M", "32M", "32.4M", "32.8M", "33.1M", "33.5M",   "34M", "34.4M", "34.8M", "35.2M", "35.6M", "36M", "36.4M", "36.9M",   "37.3M", "37.8M", "38.2M", "38.7M", "39.1M", "39.6M", "40M",   "40.5M", "41M", "41.5M", "42M", "42.5M", "43M", "43.5M", "44M",   "44.5M", "45.1M", "45.6M", "46.2M", "46.7M", "47.3M", "47.8M",   "48.4M", "49M", "49.5M", "50.1M", "50.7M", "52.3M", "53.8M",   "55.4M", "57.1M", "58.8M", "60.5M", "62.3M", "64.2M", "66.1M",   "68.1M", "70.1M", "72.2M", "74.4M", "76.6M", "78.9M", "81.3M",   "83.7M", "86.2M", "88.8M", "91.4M", "94.2M", "97M", "99.9M",   "103M", "106M", "109M", "112M", "116M", "119M", "123M", "126M",   "130M", "134M", "138M", "142M", "146M", "151M", "155M", "162M",   "171M", "182M", "196M", "210M", "226M", "243M", "259M", "274M",   "287M", "298M", "308M", "317M", "327M", "337M", "347M", "358M",   "369M", "380M", "413M", "450M", "490M", "533M", "579M", "628M",   "679M", "734M", "795M", "861M", "934M", "1.02B", "1.1B", "1.2B",   "1.31B", "1.43B", "1.66B", "1.98B", "2.21B", "2.3B", "2.48B",   "2.61B", "2.79B", "3.02B", "3.1B", "3.16B", "3.43B", "3.7B",   "3.76B", "3.94B", "3.92B", "3.81B", "3.8B", "4.07B", "4.11B",   "4.13B", "4.23B", "4.07B", "3.79B", "3.58B", "3.9B", NA, NA,   "2.08B", "2.08B", "2.08B", "2.08B", "2.08B", "2.08B", "2.08B",   "2.08B", "2.08B", "2.08B", "2.08B", "2.08B", "2.08B", "2.08B",   "2.08B", "2.08B", "2.08B", "2.08B", "2.08B", "2.08B", "2.08B",   "2.1B", "2.12B", "2.13B", "2.15B", "2.17B", "2.19B", "2.2B",   "2.22B", "2.24B", "2.26B", "2.28B", "2.3B", "2.32B", "2.33B",   "2.35B"), dataset = c("GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP", "GDP",   "GDP")), row.names = c(NA, -250L), class = c("tbl_df", "tbl",   "data.frame"))  

How does "System.Messaging" system recognises the types of the objects it sends and receives?

Posted: 03 Jul 2021 02:54 PM PDT

Edit: root cause of the question

I'm working on an application, that uses System.Messaging and XML serialisation.

I would like to send an object, let's say Class1, having an ID field:

public class Class1{    public long Id1;  }  

I would also like to send another object, let's say Class16, having another ID field:

public class Class16{    public long Id16;  }  

In XML, both need to look like:

<HM>Human_Message    <ID>Own_Identifier</ID>  </HM>  

In order to achieve this, I'm working with following [Xml]-like configurations:

Class1:

[XmlRoot(ElementName = "HM")]  public class Class1{    [XmlElement(ElementName = "ID")]    public long Id1;  }  

Class16:

[XmlRoot(ElementName = "HM")]  public class Class16{    [XmlElement(ElementName = "ID")]    public long Id16;  }  

As you see, the XML body will indeed be equal for both classes.

Is this even possible?

Edit: original question

I have a basic class (simple class), from which there are several subclasses (about 27 of them), inheriting from it.

I'm using standard C# System.Messaging system for sending objects back and forth.

Very simplified:

Sending side:

I have a MessageQueue, doing:

subClass1 Obj1 = subClass1(...);  ...  Basic_Class Obj_To_Be_Sent = Basic_Class(Obj1);  System.Messaging.Message message = new System.Messaging.Message(Obj_To_Be_Sent);  obj_MessageQueue.Send(message, ...);  

When checking Obj_To_Be_Sent, the type is correct.

Once this is sent, when I have a look at Computer Management, Services and Applications, Message Queuing, ..., Properties, I see the message, but I can't verify if the type is still correct.

Receiving side:

I have an _xmlMessageFormatter, containing (amongst others):

System.Type[] messageTypes = new System.Type[27];  messageTypes[0] = typeof(SubClass1);  ...  messageTypes[15] = typeof(SubClass16);  ...  message = this._receiveQueue.Receive();  Basic_Class general = (Basic_Class)this._xmlMessageFormatter.Read(message);  Type objectType= general.GetType();  

To my surprise, objectType is wrong (it is believed to be SubClass16).

This application has worked fine before, but now something seems to fail. The biggest problem I have is that I don't know how to check the steps between sending the message and getting the type of the received message.

Does anybody have knowledge on Computer Management, Services and Applications, Message Queuing, ..., how can I check if the object type on the sending side is ok?
Does anybody have knowledge on _xmlFormatter.Read() and GetType()? (Already after the Read(), the watch-window mentions the Type of general to be wrong)

Thanks in advance

Edit after more investigation

I delete my own answer as the problem is not completely solved.

Meanwhile I've discovered that [XmlRoot] entries are causing the mentioned issues: I've been using the same [XmlRoot] entry for different classes.

Is there a way to differentiate?

For your information, I've already tried the following but it did not work:

Class1:

[XmlRoot(ElementName = "HM", DataType = "subClass1", Namespace="Namespace")]  public class subClass1 : Basic_Class  

Class2:

[XmlRoot(ElementName = "HM", DataType = "subClass16", Namespace="Namespace")]  public class subClass16 : Basic_Class  

while the _xmlFormatter.TargetTypes contained entries like:

Name = "subClass1" FullName="Namespace.Class1"  Name = "subClass16" FullName="Namespace.Class16"  

Does anybody have any ideas?

can't send viewable html file containing nav bar leading to multiple pages

Posted: 03 Jul 2021 02:53 PM PDT

I wrote something like this for different html pages, but doesn't show because the html files are local, how do I send them all? (not too complicated please, I'm a beginner)

<!DOCTYPE html>  <html style="background-color: grey">  <head>    <style>      #div1 {        background-image: linear-gradient(darkred, red);         border-radius: 15px;         padding: 10px;        font-family:"Lucida Handwriting", cursive;         color: white      }       .topnav {        background-color: #333;        overflow: hidden;        position: fixed;        top: 0;      }        /* Style the links inside the navigation bar */      .topnav a {        font-family:"Lucida Handwriting", cursive;        float: left;        color: #f2f2f2;        text-align: center;        padding: 1px 107px;        text-decoration: none;        font-size: 17px;      }            /* Change the color of links on hover */      .topnav a:hover {        background-color: grey;        color: black;      }            /* Add a color to the active/current link */      .topnav a.active {        background-color: darkred;        color: white;      }       .center {        display: block;        margin-left: auto;        margin-right: auto;        width: 50%;      }    </style>      </head>    <div class="topnav">      <a class="active" href="file:///C:/Users/Anas/Desktop/TNL1PROWEB/HTML/home.html">Accueil</a>      <a href="file:///C:/Users/Anas/Desktop/TNL1PROWEB/HTML/Classement.html">Classement</a>      <a href="file:///C:/Users/Anas/Desktop/TNL1PROWEB/HTML/stats.html">Statistiques</a>       <a href="file:///C:/Users/Anas/Desktop/TNL1PROWEB/HTML/Matchs&resultats.html">Matchs & Resultats</a>    </div>  

Pushing variables onto an array inside an object? [closed]

Posted: 03 Jul 2021 02:55 PM PDT

I am trying to push data at the end of the student tags array which is in an object, I was wondering how I could do this?

var tags = "2019 Student"      {    "first_name": "Thomas",    "last_name": "Lee",    "student_tags":       ["2020 Student"]  }  

FireBase Authentication mAuth.createUserWithEmailAndPassword(email, password) error

Posted: 03 Jul 2021 02:52 PM PDT

So I'm trying to add an Authentication and Sign in service to my app, I'm following all of the steps told on FireBase although I can't get through this part, it says that the error is

createUserWithEmailAndPassword(Java.lang.String, Java.lang.String) in FireBaseAuth cannot be applied to (Android.widget.text, Android.widget.text)

Thanks in advance for any help given. The code is the following:

public void Register(View view) {      Intent intent = new Intent(LoginActivity.this, BottomActivity.class);      startActivity(intent);      attemptLogin();        mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener( this, new OnCompleteListener<AuthResult>() {          @Override          public void onComplete(@NonNull Task<AuthResult> task) {              if (task.isSuccessful()) {                  Log.d( TAG, "createUserWithEmail:success" );                  FirebaseUser user = mAuth.getCurrentUser();                  updateUI( user );              } else {                  Log.w(TAG, "createUserWithEmail:failed");                  Toast.makeText(LoginActivity.this, "Authentication failed", Toast.LENGTH_SHORT).show();                  updateUI( null );              }          }      } );  }  

email/password:

private AutoCompleteTextView email;  private EditText password;  

Get div html with select value of dynamically created select in jquery

Posted: 03 Jul 2021 02:55 PM PDT

I dynamically created a div with select options in jQuery. Here's a sample.

<div id="myDiv">      <select id="mySelect">          <option selected value="0">A</option>          <option value="1">B</option>          <option value="2">C</option>          <option value="3">D</option>      </select>  </div>  

0 is the default selected value.

When I get html of the div like this $("#myDiv").html(), it gets the below.

<div id="myDiv">      <select id="mySelect">          <option selected value="0">A</option>          <option value="1">B</option>          <option value="2">C</option>          <option value="3">D</option>      </select>  </div>  

It's the same as the above code which is normal.

However, when I change the selected value to 2, $("#myDiv").html() is still getting same code. 0 is still the selected value.

How can I get the html of the div, with the dynamically changed value?

How to deactivate buttons in Django applications where all buttons are localized in a single base.html file?

Posted: 03 Jul 2021 02:52 PM PDT

On a Django website, where people create accounts and log into accounts to create profiles, I'm attempting to deactivate the Login Button after a user has already logged in. No logging in twice!

The HTML code for the buttons is all located in a 'base.html' file; there are other HTML files that are extensions to that file that represent each button. The deactivation should take place in the from the login view once the user has already logged in but how to code that? The HTML code is in the base.html, not the view?

Also, after initial registration, the Account Registration Button will also need to be deactivated for that user in all future logins. So I need to understand the general idea of how to do this!

base.html

{% load static %}  <!DOCTYPE html>  <html lang="en">     <head>      <title>{% block title %}OpnePE Base Template{% endblock %}</title>          <link rel="stylesheet" type="text/css" href="{% static "assets/css/default.css" %}">        </head>      <body>          <div id="page">              <div id="sidebar">                  {% block sidebar %}                    <p>                   <a href = "/accounts/login/"><button>Login</button>                   <a href = "/accounts/register/"><button>Account Registrration</button>                   <a href = "/accounts/profile/"><button>User Profile</button>                   <a href = "/admin/"> <button>Site Administration</button>                       </a>                </p>                  {% endblock %}              </div>                <div id="content">                {% block content %}This is the content area{% endblock %}                <img src="{% static "assets/images/MedicalSymbol.png" %}" width="120"/>              </div>          </div>    </body>  </html>   

The login button that extends the base.html is here. Login.html/

{% extends "base.html" %}  {% block content %}    {% if form.errors %}        <p class="error">Sorry, that's not a valid user name or password</p>     {% endif %}    <h3>Provider Enrollment Login</h3>    <form action=" /accounts/auth/" method="post">{% csrf_token %}      <label for="username">User name:</label>      <input type="text" name="username" value="" id="username">      <label for="password">Password:</label>      <input type="password" name="password" value="" id="password">      <input type="submit" value="login" />    </form>  {% endblock %}  

The urls associated with this are :

url(r'^accounts/login/$',            'openPE.views.login'),  url(r'^accounts/auth/$',             'openPE.views.auth_view'),  url(r'^accounts/logout/$',           'openPE.views.logout'),  url(r'^accounts/loggedin/$',         'openPE.views.loggedin'),  url(r'^accounts/invalid/$',          'openPE.views.invalid_login'),  url(r'^accounts/register/$',         'openPE.views.register_user'),  url(r'^accounts/register_success/$', 'openPE.views.register_success'),  

The views involved are :

def login(request):      '''       Pushes a dictionary object into it a csrf object and passes that to login.html.      '''      c = {}      c.update(csrf(request))      return render_to_response('login.html', c)     def register_user(request):      '''Provides form for processes the registration form.'''      if request.method == 'POST':          form = MyRegistrationForm(request.POST)          if form.is_valid():             form.save()               return HttpResponseRedirect('/accounts/register_success')        args = {}      args.update(csrf(request))      args['form'] = MyRegistrationForm()      return render_to_response('register.html', args)  

How do you get cimport to work in Cython?

Posted: 03 Jul 2021 02:54 PM PDT

I have a directory structure as so:

/my_module

init.py

A/

  __init__.py      a.pyx  

B/

  __init__.py      b.pyx  

In b.pyx I want to cimport functions from A.a. A regular python import works, but a cimport always fails.

Also, I'm compiling A/ and B/ separately because I couldn't figure out how to put a setup.py in the top module.

Can anyone help here?

No comments:

Post a Comment