Saturday, April 17, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Display polygon labels from leafletjs json file

Posted: 17 Apr 2021 07:53 AM PDT

You need help, there is a work lafleat map and geojson file, you need to display signatures within the polygons of one of the geojson values, as well as how I want to realize the display of the links of each polygon to a third-party resource, Unfortunately I can't publish the code here.

Why multiple increment at one line in C++ shows unexpected results

Posted: 17 Apr 2021 07:53 AM PDT

#include<stdio.h>    int main(){      int a =3;      printf("%d %d %d %d %d",++a,--a,a++,++a,++a);  }  

It prints the result -

4 4 3 4 4

Can anyone please explain?

How do I change the statistics test by category in the arsenal package?

Posted: 17 Apr 2021 07:53 AM PDT

I created a descriptive table with the arsenal pack, and it's like this:

library(arsenal)          mycontrols  <- tableby.control(test=TRUE, total=TRUE,                                     numeric.test="kwt", cat.test="chisq",                                     numeric.stats=c("meansd","median", "q1q3"),                                     cat.stats=c("countpct"),                                     stats.labels=list(meansd = "Mean (SD)", median='Median', q1q3='Q1,Q3'))      tab.test <- tableby(list(vs,am,gear) ~                             (mpg) +                             (disp) +                            (hp)                             ,                          data=mtcars,control=mycontrols                        )      summary(tab.test)  

So the script create multiple table and merge them. But i want to change statistics test some of category.(vs,am,gear) Maybe "am" p.value's comes from MANN-whitney-U not kruskal wallis test.
I will be glad for any help.

The number of contents added over the years, according to the type of content

Posted: 17 Apr 2021 07:53 AM PDT

I want to display in a graph two trend lines representing the number of contents added to the Netflix catalogue over the years, according to the type of content.

fig1 = plt.figure()  ax1 = fig1.add_subplot(111)  ax1.plot([df['year_added'], df[df['type'] == 'Movie']], 'green');    fig2 = plt.figure()  ax2 = fig2.add_subplot(111)  ax2.plot([df['year_added'], df[df['type'] == 'TV Show']], 'blue');```    I also try with this line:    

ax1.plot(df[df['type' == 'Movie'].groupby('year_added').count(),'green'])

  and also this :  

nb_sortie = df.groupby(['year_added'])['type'].sum() sns.relplot(x=nb_sortie, y="year_added", col="type", kind="line", data=df)

  [![enter image description here][1]][1]  [![enter image description here][2]][2]        [1]: https://i.stack.imgur.com/SD2fh.png    [2]: https://i.stack.imgur.com/ugAFg.png  

Script Linux Bash, print grep output based on number of words in line

Posted: 17 Apr 2021 07:52 AM PDT

I'm trying to write a scirpt for the bash shell. I'm given 4 parameters:

  1. path of a directory
  2. extension of a file
  3. a word
  4. a number

I have to look for all files and files of subdirectories of the path, for files with the given extension. Then, look in the files for the lines matching the word given, but only if the number of words in the line is bigger or equal to the number provided.
For example:
If localDirectory has: image.png script.sh text.txt.
And text.txt has:

This is a text file  It contains many words  This is an example for a simple text file  

Then give the command: ./example.sh localDirectory txt text 7
I should output: This is an example for a simple text file.

For now, my script looks like this:

if [ "$#" -ne 4 ];  then    echo "Not enough parameters"    exit 1  fi  find $1 -name "*.$2" -exec grep -wi $3  {} \;  

And it works just fine for the first 3 goals, I just don't know how to filter now the result such that the line has a greater or equal number of words as $4.

I could of course create a new file and output there, and then read from it and print only the relevant lines, but I would rather do this without creating new files.

I'm very new to shell scripting.

Any ideas?

How to remove the undefined object from array using angular?

Posted: 17 Apr 2021 07:52 AM PDT

let myArr=[{      "name": "",      "columns": [        {                    "data": "test1",          "type": "",                            },        undefined,        {          "data": "test1",          "type": "",        }      ],      "info": "value",          }]  

Above array of object having undefined or null values, I have to remove the undefined values.

Ubuntu 18.04 + OpenVPN + Xen

Posted: 17 Apr 2021 07:52 AM PDT

I'm running Ubuntu with the latest Xen Hypervisor and a xenbr0 (bridging mode for the eno1 physical interface with IP addresses 192.168.178.0/24) for the VMs.

On the same server, I'm running an OpenVPN server using a tap0 interface (10.8.0.0/24). I would like to put the Xen VMs in the OpenVPN network so that every user who connects via VPN and gets one of the 10.8.0.0/24 IP addresses can also connect to the Xen VMs.

My first idea was to simply add the tap0 interface of OpenVPN to the xenbr0 and assign static IP addresses from the range 10.8.0.0/24 to the VMs.

Bridge looks like that:

$ brctl show  bridge name     bridge id               STP enabled     interfaces  xenbr0          8000.1abdded27bec       no              eno1                                                          tap0                                                          vif6.0  

However, this is not working and I think I'm on the wrong way. How can I deploy the Xen VMs in the OpenVPN network?

Thank you!

Spring JPA : If length of rows achieves to value of greater than max List length what does happens?

Posted: 17 Apr 2021 07:52 AM PDT

If length of database rows achieves to value of greater than max java.util.List length and i try to get all data what does happens?

public interface StudentRepository extends CrudRepository<Student, Long> {      @Override      List<Log> findAll();  }  

Order of execution with rxjs asapscheduler

Posted: 17 Apr 2021 07:52 AM PDT

Considering I have the following code:

let Rx = window['rxjs'];  const { of,      queueScheduler,      asapScheduler,      asyncScheduler,      animationFrameScheduler  } = Rx;  const { observeOn, tap } = Rx.operators;  console.clear();      let source$ = of(1, 2, 3, asapScheduler).pipe(      tap((v) => {          console.log('tap ', v);      }),  )    source$.subscribe((v) => {      console.log('Value ', v);      Promise.resolve().then(() => {          console.log('Microtask value ', v);      });  });
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.2.1/rxjs.umd.js"></script>

Which I use asapScheduler operator.

As per the documentation,

asap will wait for the current synchronously executing code to end and then it will try to execute the given task as fast as possible.

What's the execution context of the above code? How do they work? I would not have expected that the tap3 to print at the last

How to set (value) of a forEach loop a variable

Posted: 17 Apr 2021 07:52 AM PDT

I have a forEach loop in my web app using NodeJS, to which I am very new to. I have tried using several different ways to do this, but am not figuring it out. I have also read other scenarios, but it does not seem to help.

I have a table that has 2 users. I would like to display both users. I can display one using results[0], so I want to use a loop to read over each value in the array. I can console.log the value, but I am unsure how to set the value as a variable that I can use outside of the loop. If I move res.render inside the loop, it gives an error that I can't set headers after they are sent to the client.

I have tried:

app.get("/", function(req, res) {  var q = "SELECT * FROM users";    connection.query(q, function(err, results) {  if(err) throw err;     results.forEach(function(value) {       console.log(value);  });    list = results.forEach(function(value){});   res.render("home.ejs", {list: list});    });   });  

and

app.get("/", function(req, res) {  var q = "SELECT * FROM users";    connection.query(q, function(err, results) {  if(err) throw err;     results = results.forEach(function(value) {       console.log(values);  });    list = results;   res.render("home.ejs", {list: list});    });   });  

and

app.get("/", function(req, res) {  var q = "SELECT * FROM users";    connection.query(q, function(err, results) {  if(err) throw err;     results.forEach(function(value) {   console.log(value);         list = value;   res.render("home.ejs", {list: list});  });    });   });  

AAPT: error: duplicate value for resource 'attr/brightness' with config ''.\n ","tool":"AAPT"}

Posted: 17 Apr 2021 07:52 AM PDT

I migrated my android old project to androidx to use the updated library and fix the dependencies. But it still causing below issues :

AAPT: error: duplicate value for resource 'attr/brightness' with config ''.\n ","tool":"AAPT"}

there any idea?

where does the screen end when using WIDTH? right or left? [duplicate]

Posted: 17 Apr 2021 07:52 AM PDT

i am trying to perform deleting enemies when reaching the edge of the screen width. how can I implement the collision of the character with the edge of the screen on the right ??

How can I bind to the last item in a list?

Posted: 17 Apr 2021 07:53 AM PDT

While using XAML in WPF, we can easily bind to the first item in a list as follows:

<TextBlock Text="{Binding Model.Persons[0].FullName}"/>  

But what if I wanted to bind to the last item? Let's say I don't know how many items the list may have or else I could easily have used that index.

<TextBlock Text="{Binding Model.Persons.Last.FullName}"/>  

or

Neither above does not work unfortunately. Does anyone have any idea how to bind to the last item?

Finding min in 2D Array

Posted: 17 Apr 2021 07:52 AM PDT

int main (void) {    const int table[a][b]={{4,2,7},{6,-8,-13}};  int minvals[a];  int i, j;    int min = table[0][0];    for (int i = 0; i < a; i++)      {      for (int j = 0; j < a; j++)      {       if (table[i][j] < min){       min = table[i][j];       printf("The row's lowest value is %d\n", min);       }      }      }  return (0);  }  

I am trying to find the minimum in each array when I run my code I get 2 and -8 as opposed to -13 anyone see why it would provide -8 and not -13?

Python regex - match pattern, then replace single character in it

Posted: 17 Apr 2021 07:51 AM PDT

I have successfully matched an apostrophe occurring betweem letters and numbers only. Within that pattern, I now want to replace only the apostrophe, not the entire matched pattern. The code:

import re    content = "MC_MC - 90's"  search = re.sub(r'([A-Za-z0-9]\'[A-Za-z0-9])', '%APOS', content)  print(search)  

Current output:

MC_MC - 9%APOS  

Desired output:

MC_MC - 90%APOSs  

What do I need to change?

Can't download a csv file from a website using urllib, when post requests with parameters comes into play

Posted: 17 Apr 2021 07:52 AM PDT

I'm trying to download a csv file from a webpage using urllib package. To download the csv file from that site it is necessary to send a post requests with appropriate parameters.

When I try using requests module, I can download the file flawlessly. However, when I try doing the same using urllib package, I also get a csv file but this time the file only contains headers. The body is missing.

Here is how to download that file manually from that site:

Site address: https://www.nyiso.com/custom-reports?report=dam_lbmp_zonal  Zones: CAPITL, CENTRL  Version: Latest  Format: CSV  Hit `Generate Report` button  

The following script only download the headers within the csv file:

import csv  import urllib.request  import urllib.parse    link = "http://dss.nyiso.com/dss_oasis/PublicReports"  params = {      'reportKey': 'DAM_LBMP_ZONE',      'startDate': '04/17/2021',      'endDate': '04/17/2021',      'version': 'L',      'dataFormat': 'CSV',      'filter': ['CAPITL','CENTRL'],  }    headers = {      'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36'  }  data = urllib.parse.urlencode(params).encode()  req = urllib.request.Request(link, data=data, headers=headers)  res = urllib.request.urlopen(req)  with open("output.csv","wb") as f:      f.write(res.read())  

How can I download a csv file using urllib package from a website?

Getting error while staring kibana v 7.12.0 on local on windows

Posted: 17 Apr 2021 07:53 AM PDT

I download the Kibana version 7.12.0, tried starting it locally from windows batch file. But I am getting the following error-

Unable to complete saved object migrations for the [.kibana] index. TypeError: Cannot read property 'error' of undefined

I am able to run Elastic Search v 7.12.0.

{    "name" : "DESKTOP-07QEN6L",    "cluster_name" : "elasticsearch",    "cluster_uuid" : "laDSNVpKQhWTIWEjdq2lDw",    "version" : {      "number" : "7.12.0",      "build_flavor" : "default",      "build_type" : "zip",      "build_hash" : "78722783c38caa25a70982b5b042074cde5d3b3a",      "build_date" : "2021-03-18T06:17:15.410153305Z",      "build_snapshot" : false,      "lucene_version" : "8.8.0",      "minimum_wire_compatibility_version" : "6.8.0",      "minimum_index_compatibility_version" : "6.0.0-beta1"    },    "tagline" : "You Know, for Search"  }  

I have Java 8 installed and configured in my Windows 64 bit system.

Can someone help me out? Is it a compatibility issue with Java 8? Do I need JAVA 11 or higher version? I saw an warning while starting up ELastic Search locally, about it supporting JAVA 11 or higher.

Is it possible to have values for class object in java, if yes how can we acquire it?

Posted: 17 Apr 2021 07:53 AM PDT

Let's say, I am initializing a class obj as follows:

                               <class> obj = <some value>;  

Is it possible to initialize as such I mean we initialize String and primitive values like that, But I mean for any class. And how can we get them so they can be used in some method of the same class?

sum of two decimals returns incorrect decimal [closed]

Posted: 17 Apr 2021 07:53 AM PDT

I'm building a dice simulator for Stake and am running into an issue when adding two decimals with a precision of 8. As you can see, my current bet, win and balance are all 8 point decimals, but for some reason when added together are returning an incorrect decimal (note last console log). can someone help me understand the addition of decimals isn't working properly?

var currentBet = Number(0.00000001).toFixed(8);  var balance = Number(0.50000000).toFixed(8);  var win = Number(currentBet * 2).toFixed(8);  var balancePlusWin = Number(balance + win).toFixed(8);  console.log(`balance: ${balance}`);  console.log(`win: ${win}`);  console.log(`balance + win: ${balancePlusWin}`);

toJson not working properly json serializer Unhandled Exception: Invalid argument: Instance of 'DietModel'

Posted: 17 Apr 2021 07:52 AM PDT

I am trying to save data on firestore but getting error while saving in toJson. i have created two models diet-model and TargetModel to store on firestore using json_serializable: ^4.0.0 and json_annotation: ^4.0.0 . TargetModel have List of diet models. error is run time error

Error:

Unhandled Exception: Invalid argument: Instance of 'DietModel'  [        ] E/flutter (23502): #0      convertPlatformException (package:cloud_firestore_platform_interface/src/method_channel/utils/exception.dart:13:5)  [        ] E/flutter (23502): #1      MethodChannelDocumentReference.set (package:cloud_firestore_platform_interface/src/method_channel/method_channel_document_reference.dart:43:13)  [        ] E/flutter (23502): <asynchronous suspension>  [        ] E/flutter (23502): #2      DietPageRepositoryImpl.setTarget (package:dance/services/firestore/firestore-impl/diet-page-repository-impl.dart:31:5)  [        ] E/flutter (23502): <asynchronous suspension>  [        ] E/flutter (23502): #3      DietPageViewModel.setTargetedModel (package:dance/viewmodels/diet-page-view-model/diet-page-view-model.dart:120:5)  [        ] E/flutter (23502): <asynchronous suspension>  

import 'package:dance/models/diet-model/diet-model.dart';  import 'package:json_annotation/json_annotation.dart';    part 'targeted-model.g.dart';    @JsonSerializable()  class TargetedModel {    List<DietModel> targetedBreakfast;    List<DietModel> targetedLunch;    List<DietModel> targetedSnacks;    List<DietModel> targetedDinner;      TargetedModel(this.targetedBreakfast, this.targetedLunch, this.targetedSnacks,        this.targetedDinner);      factory TargetedModel.fromJson(Map<String, dynamic> json) =>        _$TargetedModelFromJson(json);      Map<String, dynamic> toJson() => _$TargetedModelToJson(this);  }  

import 'package:json_annotation/json_annotation.dart';    part 'diet-model.g.dart';    @JsonSerializable()  class DietModel {    int calories;    String name;    int carbs;    int fat;    int protein;    bool selected;    int quantity;    String imageUrl;      DietModel();      factory DietModel.fromJson(Map<String, dynamic> json) =>        _$DietModelFromJson(json);      Map<String, dynamic> toJson() => _$DietModelToJson(this);  }  

Future<void> setTarget(DateTime date, TargetedModel model) async {      await _collectionReferenceTD.doc("$date").set(model.toJson()); // getting error here     }  

Why I cannot access the page after adding a migration, even if everything built successfully?

Posted: 17 Apr 2021 07:52 AM PDT

I wanna build a web app that contains a page where I can allocate courses to professors-I already created the login-logout/register pages using Identity API-, in order to do this, I am using Razor Pages Entity Framework (CRUD). I already had some migrations before and I want to add another migration called 'InitialCreate'. I typed the following commands in Packet Manager Console:

Add-Migration InitialCreate -Context ApplicationDbContext    Update-Database -Context ApplicationDbContext  

Everything built successfully, but when I run the code and trying to access the page 'AlocareMaterii" which uses the migration through my localhost (localhost:x/AlocareMaterii), I get the following error:

A database operation failed while processing the request.  SqlException: Cannot open database "razor_licenta_runtimeContext-a7b890ea-d1ed-4faa-afdf-88dcf8d382d4Trusted_Connection=True" requested by the login. The login failed. Login failed for user 'DESKTOP-3AH99PG\ninex'.  Use migrations to create the database for razor_licenta_runtimeContext  In Visual Studio, use the Package Manager Console to scaffold a new migration and apply it to the database:    PM> Add-Migration [migration name]  PM> Update-Database  Alternatively, you can scaffold a new migration and apply it from a command prompt at your project directory:    > dotnet ef migrations add [migration name]  > dotnet ef database update  

This is my 'appsettings.json' file:

{    "ConnectionStrings": {      "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-razor_licenta_runtime-53bc9b9d-9d6a-45d4-8429-2a2761773502;Trusted_Connection=True;MultipleActiveResultSets=true",      "razor_licenta_runtimeContext": "Server=(localdb)\\mssqllocaldb;Database=razor_licenta_runtimeContext-a7b890ea-d1ed-4faa-afdf-88dcf8d382d4Trusted_Connection=True;MultipleActiveResultSets=true"    },      "Logging": {      "LogLevel": {        "Default": "Information",        "Microsoft": "Warning",        "Microsoft.Hosting.Lifetime": "Information"      }    },    "AllowedHosts": "*"  }  

Echo date in a prettier way

Posted: 17 Apr 2021 07:51 AM PDT

I'm not too good with dates in php (or any other language) and would need some help to convert a date's format into something more readable.

The string currently looks like this:

2021-03-31T00:00:00.0000000+02:00  

But i would much rather prefer it to be similar to this when echo it:

2021-03-31 00:00:00  

I have done some more or less useless stuff with string manipulation, but there must be a better way?

Example:

substr('2021-03-31T00:00:00.0000000+02:00',0,10);  

How would one do this?

Is there a way to prevent rendering useEffect after page reload?

Posted: 17 Apr 2021 07:51 AM PDT

My useEffect has a fetch request inside it, and it renders and catches the error on every refresh. I need to use the catch to change a variable if the fetch request fails. Now the variable always changes when the page is refreshed. Is there a way to prevent this?

Visual Studio Community 2019 Publish Error

Posted: 17 Apr 2021 07:52 AM PDT

I trying to publish my application through a file system and it throws the following error.

screenshot

17-04-2021 09:41:43  System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.     --- End of inner exception stack trace ---  ---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.<---    Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.  

Please do let me know as am struggling with this issue.

How to use margins package to evaluate marginal affects at different values of the dependent variable

Posted: 17 Apr 2021 07:53 AM PDT

I am using the margins package (vignette) to well, calculate margins, with respect to an ordinal variable. The margins package is an attempt to "port the functionality of Stata's (closed source) margins". This video (around 4:25) shows that for an ordinal probit model in Stata, I can evaluate the marginal effect of a variable at different values of the ordinal variable, in my example x2.

I tried polr_1st_margins <- summary(margins(fit.polr, at = list(x2= 2:4))) and this works on the example data. For some weird reason, when I run it on my actual data I get the error: Error: Illegal factor levels for variable 'x2': "0", "1". In both cases x2 is a factor variable (otherwise polr won't run).

Alternatively, I get the error: Error in dat[, not_numeric, drop = FALSE] : incorrect number of dimensions even when the variable is there.

Does someone have an idea what could be going on?

Example code:

library(sure) # for residual function and sample data sets  library(MASS) # for polr function  library(margins)  rm(df1)  df1 <- df1  df1$x2 <- df2$y  df1$x3 <- df2$x  df1$y <- df3$x/10  fit.polr <- polr(x2 ~ x + x3, data = df1, method = "probit")  summary(margins(fit.polr))    polr_1st_margins <- summary(margins(fit.polr, at = list(x2= 2:4)))  

EDIT

I have decided to add a sample of my actual code.

fit.polr2 <- polr(ordinal_dep_var ~ Dummy + Continuous + Dummy2 + as.factor(industry) + Urbanisation_Dummy + Size_Dummy, data = df2, method = "probit", Hess=TRUE)  summary(margins(fit.polr2))    polr_1st_margins <- summary(margins(fit.polr2, at = list(ordinal_dep_var= 0:3)))    Error in dat[, not_numeric, drop = FALSE] :     incorrect number of dimensions  

Somehow, it does not find the variable, even though I can see that it is there.

DATA

df2 <- structure(list(ordinal_dep_var = structure(c(4L, 3L, 4L, 1L,   3L, 1L, 1L, 3L, 1L, 4L, 4L, 4L, 1L, 3L, 4L, 2L, 4L, 2L, 2L, 1L,   2L, 1L, 1L, 1L, 3L, 4L, 3L, 2L, 2L, 1L, 1L, 2L, 4L, 2L, 1L, 4L,   3L, 1L, 2L, 3L, 4L, 1L, 1L, 4L, 1L, 1L, 1L, 1L, 2L, 4L, 2L, 1L,   4L, 1L, 1L, 3L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 3L,   2L, 3L, 3L, 1L, 4L, 4L, 4L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L,   1L, 2L, 1L, 2L, 4L, 3L, 3L, 1L, 1L, 1L, 3L, 2L, 3L, 2L, 1L, 1L,   1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 4L, 3L, 2L, 2L, 3L, 1L, 1L, 1L,   1L, 3L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 3L, 1L, 1L, 1L, 2L, 1L,   1L, 1L, 1L, 1L, 1L, 4L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("0",   "1", "2", "3"), class = c("ordered", "factor")), Dummy = c(0,   0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1,   0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,   0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,   1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,   0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0,   0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0), Continuous = c(15.6862745098039,   41.6666666666667, 26.9230769230769, 14.8514851485149, 32.1428571428571,   20, 43.75, 0, 0, 0, 80, 100, 21.4285714285714, 23.8095238095238,   28.125, 0, 30.3030303030303, 25, 100, 100, 100, 13.3333333333333,   66.6666666666667, 33.3333333333333, 55.5555555555556, 72.2222222222222,   57.3033707865169, 17.7777777777778, 47.6190476190476, 17.7777777777778,   41.6666666666667, 40, 20, 8.33333333333333, 16.6666666666667,   40, 100, 0, 50, 0, 0, 7.69230769230769, 0, 0, 0, 0, 0, 0, 0,   33.3333333333333, 20, 1.84089414858646, 1.84089414858646, 1.84089414858646,   30, 20, 0, 33.3333333333333, 33.3333333333333, 0, 0, 0, 100,   50, 22.2222222222222, 0, 0, 50, 50, 46.1538461538462, 44.4444444444444,   0, 5.55555555555556, 0, 0, 47.3684210526316, 43.75, 18.1818181818182,   0, 42.8571428571429, 14.2857142857143, 0, 50, 0, 0, 50, 20, 50,   100, 0, 42.8571428571429, 20, 25, 33.3333333333333, 0, 0, 0,   66.6666666666667, 0, 25.9259259259259, 0, 33.3333333333333, 0,   100, 25, 0, 0, 10, 100, 50, 33.3333333333333, 75, 0, 0, 40, 0,   33.3333333333333, 28.5714285714286, 0, 0, 28.5714285714286, 0,   28.5714285714286, 0, 0, 9.09090909090909, 30, 66.6666666666667,   50, 0, 20, 50, 0, 33.3333333333333, 0, 66.6666666666667, 18.1818181818182,   28.5714285714286, 36.9230769230769, 14.2857142857143, 36.3636363636364,   0, 0, 7.69230769230769), Dummy2 = structure(c(0, 0, 0, 0, 1,   1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0,   0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1,   1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0,   0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1,   0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0,   1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0), label = "Gift/informal payment requested: tax inspectorate?", format.stata = "%14.0f", class = c("haven_labelled",   "vctrs_vctr", "double"), labels = c(Yes = 1, No = 2)), industry = structure(c(3,   7, 2, 7, 19, 17, 9, 7, 9, 11, 12, 10, 5, 5, 3, 12, 3, 5, 4, 1,   1, 11, 5, 7, 9, 9, 7, 9, 5, 9, 4, 7, 9, 11, 11, 22, 12, 21, 19,   11, 10, 7, 19, 23, 20, 20, 21, 24, 19, 1, 21, 21, 21, 21, 21,   21, 6, 6, 21, 3, 17, 19, 20, 12, 21, 20, 12, 10, 10, 21, 21,   19, 3, 21, 21, 10, 10, 21, 5, 20, 21, 19, 22, 15, 6, 21, 21,   10, 19, 21, 20, 3, 6, 10, 24, 24, 21, 23, 21, 21, 11, 21, 3,   3, 21, 24, 21, 1, 10, 22, 19, 17, 3, 20, 23, 1, 22, 21, 21, 23,   21, 23, 21, 22, 22, 21, 10, 13, 10, 15, 10, 24, 24, 7, 10, 10,   22, 21, 21, 23, 21, 22, 7, 21), label = "Industry", format.stata = "%34.0g", class = c("haven_labelled",   "vctrs_vctr", "double"), labels = c(Textiles = 1, Leather = 2,   Garments = 3, Agroindustry = 4, Food = 5, Beverages = 6, `Metals and machinery` = 7,   Electronics = 8, `Chemicals and pharmaceutics` = 9, Construction = 10,   `Wood and furniture` = 11, `Non-metallic and plastic materials` = 12,   Paper = 13, `Sport goods` = 14, `IT services` = 15, `Other manufacturing` = 16,   Telecommunications = 17, `Accounting and finance` = 18, `Advertising and marketing` = 19,   `Other services` = 20, `Retail and wholesale trade` = 21, `Hotels and restaurants` = 22,   Transport = 23, `Real estate and rental services` = 24, `Mining and quarrying` = 25,   `Auto and auto components` = 26, `Other transport equipment` = 27,   `Other unclassified` = 99)), Urbanisation_Dummy = structure(c(2L,   1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L,   3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 1L, 1L, 1L, 1L,   1L, 3L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 3L, 1L, 3L, 1L, 1L, 2L, 3L,   3L, 3L, 1L, 1L, 1L, 1L, 2L, 3L, 2L, 2L, 1L, 1L, 1L, 2L, 3L, 2L,   3L, 3L, 3L, 3L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,   2L, 1L, 2L, 3L, 2L, 2L, 3L, 1L, 2L, 3L, 1L, 1L, 1L, 1L, 1L, 1L,   3L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 3L, 2L, 1L, 1L, 2L,   2L, 1L, 1L, 3L, 1L, 3L, 2L, 1L, 1L, 1L, 1L, 2L, 3L, 1L, 2L, 3L,   1L, 2L, 1L, 3L, 1L, 1L, 3L, 3L, 1L, 3L, 3L, 2L, 3L, 1L, 1L), .Label = c("City > 250",   "50k-250k", "< 50k"), class = "factor"), Size_Dummy = structure(c(3L,   3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 3L, 3L, 3L, 2L, 2L, 3L, 3L,   3L, 1L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L,   3L, 3L, 3L, 3L, 3L, 2L, 3L, 1L, 2L, 3L, 3L, 2L, 1L, 1L, 1L, 3L,   3L, 2L, 1L, 1L, 1L, 1L, 1L, 3L, 2L, 3L, 3L, 3L, 1L, 2L, 1L, 1L,   1L, 1L, 1L, 3L, 3L, 1L, 3L, 3L, 1L, 3L, 3L, 3L, 1L, 1L, 1L, 1L,   1L, 3L, 1L, 3L, 2L, 1L, 1L, 1L, 1L, 1L, 3L, 2L, 3L, 3L, 1L, 3L,   1L, 1L, 1L, 3L, 3L, 2L, 3L, 1L, 2L, 1L, 3L, 1L, 3L, 3L, 3L, 3L,   3L, 3L, 3L, 1L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 3L, 1L, 3L, 3L, 3L,   2L, 3L, 3L, 1L, 3L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L), .Label = c("Employees: < 10",   "Employees: 10-19", "Employees: 20+"), class = "factor")), row.names = c(NA,   -144L), class = c("data.table", "data.frame"))  

VSCode extension to auto generate C docstring?

Posted: 17 Apr 2021 07:52 AM PDT

I'm starting to get into more advanced codding practices and came across the need to create full documentations for my libraries which I write in C in the VSCode IDE and in an effort to try and same time I'm looking for a way to auto generate C Sphinx style docstring in VSCode now there is a lot of support to do that for python as it seems but can't find anything for autogen C sphinx docsting

Any suggestions?

React JSX Select DefaultValue not taking effect

Posted: 17 Apr 2021 07:52 AM PDT

I've been looking at form elements in React and having checked the documentation (https://reactjs.org/docs/forms.html#the-select-tag) and answers on stackoverflow such as (How to set a default value in react-select and React JSX: selecting "selected" on selected <select> option).

I'm not creating a select component as such. I have a header component, and when I render the header, I have a select element in it. The select element is populated via an Ajax call and this might be why the default value is not being set.

My code looks like this:

useEffect(() => {    // do ajax call and set currenclyList  });  return (    <header className="row block plain center">      <div>        <h1>Shopping Cart</h1>      </div>      <div>        <select          className="dropdown"          onChange={handleChange}          defaultValue="USDGBP"        >          {Object.keys(currencyList).map((element) => {            return (              <option                key={element}                value={element}                data-price={currencyList[element]}              >                {element}              </option>            );          })}        </select>      </div>    </header>  );  

I have set the defaultValue="USDGBP", as I know that the dropdown list does get populated with that and several others eventually. But when the element is rendered, it is always set to the first item in the list.

How can I force this select element to find the USDGBP element and set that as the default value?

Installing wkhtmltopdf on Python 3.6 Alpine

Posted: 17 Apr 2021 07:53 AM PDT

Has anyone been able to install wkhtmltopdf on python:3.6.0-alpine.

I have tried all the solutions present on the internet. I need to use pdfkit which internally uses wkhtmltopython to convert html to pdf.

How do I return a sorted list of the sum of numbers in a list?

Posted: 17 Apr 2021 07:52 AM PDT

I have a list

numbers = [869, 1069, 1108, 1343, 389]  

and i want to sort them in ascending order of the sum of the digits(ex:8+6+9 for 869)

My input:

def s_num(nums):      result = [sum(int(digit) for digit in str(number)) for number in numbers]      return result       s_num = sorted(numbers,key=s_num)  print(s_num)  

However, for some reason my output is the same as my initial list

print(s_num)  [869, 1069, 1108, 1343, 389]  

How do i change my script to get the correct sorted list?

Why method overloading is the best example of static binding in Java?

Posted: 17 Apr 2021 07:52 AM PDT

In java, I know that we have some differences between static binding and dynamic binding and method overloading is the best example of static binding but I don't know why it is the method overloading instead of the the method overriding?

No comments:

Post a Comment