Thursday, November 4, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Can I sync from multiple sources (HDs) to the same place in Google Drive?

Posted: 04 Nov 2021 08:12 AM PDT

I want to organize my files in Google Drive like this:

Pictures- YYYYMMDD - TITLE

For instance: 20210201 - Travel to Bahamas

The thing is. I have multiple Hard Drives. In each of, I use the same nomenclature for the folders.

I would like that, in Google Drive. I have a folder "Pictures". With the sum of all the other folders.

For instance on my HD called: "Panasonic HD"

I have 3 folders. 20210101, 20210102, 20210103

And in another HD in another computer I have: "GOPRO HD"

With 2 folders: 20200301, 20200402

The final result in Google Drive would be the sum of those folders. Each syncing with the physical HD.

Is that possible?

How to generate random numbers without repetition in Javascript?

Posted: 04 Nov 2021 08:12 AM PDT

I want to generate a array of numbers from 0 to 10 randomly using JavaScript and each number can appear only once.

// example    const array = [0,1,2,3,4,5,6,7,8,9,10]    // result example     const newArray = [3,2,4,1,5,10,9,8,7,6]  

Problem inserting data into a sharepoint list

Posted: 04 Nov 2021 08:12 AM PDT

I'm using MS Access to insert data into a sharepoint list. I created the following SQL query to do this:

INSERT INTO [SP List] ( Title, Date, Name )  SELECT local.ID, local.Date, local.Name  FROM local;  

However, when running this query, it inserts only the value of the column "Title" of Sharepoint. The value of all other columns are always entered in blank.

Even if I open the sharepoint table inside Access and insert a new row manually, typing the values ​​of each column, only the column "Title" receives those values. The other columns always remains in blank.

Can someone help me?

Firebase remove authenticated users created with "test phone numbers" after some time?

Posted: 04 Nov 2021 08:12 AM PDT

I am using smartphone authentication feature from firebase to register my users, but some of my users do not receive SMS codes in their mobile phones(signal problems...), and sometimes i really need these customers, so i create a test SMS code (using the real phone number, so they can receive SMS in the future). When they authenticate with the fake SMS Code, firebase create an ID with an UID and i can login again later with no problems, but happened that 3 times these users created with the fake number feature and with an valid and registered UID were deleted from the authentication list after some time, i cant find them anymore, and when i register them again, a new UID is generated, is this a real behavior of firebase, exclude test numbers UID generated after some time?

Angular Ngrx button logic

Posted: 04 Nov 2021 08:12 AM PDT

I would like to know if it is possible, to have my ngrx facade methods working without assigning them to the buttons ?

A ngrx facade is the place where we make the disptach.

I ask this to make my components usable in several places, because if I assign totofacade to a button I can't make it usable in other places

ts.file

cancel() {  this.toto.facade.delete(); // example code  }    update() {  this.toto.facade.update(); // example code  }  

How do I install libcurl for Visual Studio 2019 for C++?

Posted: 04 Nov 2021 08:12 AM PDT

can someone tell me how to install libcurl for C++? I have been seeking for videos and other but they really didn't help. Thanks.

Im trying to build pacman with JS but im getting an error that says cannot read properties of undefined

Posted: 04 Nov 2021 08:11 AM PDT

im trying to build a aimple pacman game before i start learning react but i keep getting three errors that says the errors

if you can't see the image these are the errors:

cannot read properties of undefined (reading 'add' ) cannot read properties of undefined (reading 'classList' ) cannot read properties of undefined (reading 'remove' )

JS code :

const grid = document.querySelector('.grid');  const width = 28;  let squares = [];  const layout = [      1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,      1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,      1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,0,1,      1,3,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,3,1,      1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,0,1,      1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,      1,0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,1,      1,0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,1,      1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,      1,1,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,      1,1,1,1,1,1,0,1,1,4,4,4,4,4,4,4,4,4,4,1,1,0,1,1,1,1,1,1,      1,1,1,1,1,1,0,1,1,4,1,1,1,2,2,1,1,1,4,1,1,0,1,1,1,1,1,1,      1,1,1,1,1,1,0,1,1,4,1,1,2,2,2,2,1,1,4,1,1,0,1,1,1,1,1,1,      4,4,4,4,4,4,0,0,0,4,1,1,1,1,1,1,1,1,4,0,0,0,4,4,4,4,4,4,      1,1,1,1,1,1,0,1,1,4,1,1,1,1,1,1,1,1,4,1,1,0,1,1,1,1,1,1,      1,1,1,1,1,1,0,1,1,4,1,1,1,1,1,1,1,1,4,1,1,0,1,1,1,1,1,1,      1,1,1,1,1,1,0,1,1,4,1,1,1,1,1,1,1,1,4,1,1,0,1,1,1,1,1,1,      1,0,0,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,1,      1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,0,1,      1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,0,1,      1,3,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,3,1,      1,1,1,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,1,1,0,1,1,1,      1,1,1,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,1,1,0,1,1,1,      1,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,      1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,      1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,      1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,      1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1  ];    function createBoard() {      for (let i = 0; i < layout.length; i++) {          const square = document.createElement('div');          grid.appendChild(square);          squares.push(square);            if (layout[i] === 0) {              squares[i].classList.add('pac-dot');          } else if (layout[i] === 1) {              squares[i].classList.add('wall');          } else if (layout[i] === 2) {              squares[i].classList.add('ghost-lair');          } else if (layout[i] === 3) {              squares[i].classList.add('power-pallets');          }      }  }    createBoard();    class ghost {      constructor(name, startPosition, speed) {          this.name = name;          this.startPosition = startPosition;          this.position = startPosition;          this.speed = speed;          this.isScared = false;      }  }    const ghosts = [      new ghost ('red', 348, 250),      new ghost ('blue', 349, 250),      new ghost ('pink', 350, 250),      new ghost ('yellow', 351, 250)  ]    ghosts.forEach( (ghost) => {      squares[ghost.position].classList.add(ghost.name);      squares[ghost.position].classList.add('ghost');  })    function moveGhost(ghost) {      let random = Math.floor( Math.random() * 4) + 1;      const allDirections = [-1, +1, -width, +width];      let direction = allDirections[random];        //      setInterval( () => {          if (!squares[ghost.position + direction].classList.contains('wall')) {              //remove the ghost from the old position              squares[ghost.position].classList.remove(ghost.name)              squares[ghost.position].classList.remove('ghost')              //update the ghost position              squares[ghost.position] += direction;              //add the ghost to the grid              squares[ghost.position].classList.add(ghost.name);              squares[ghost.position].classList.add('ghost');          } else {              direction = allDirections[Math.floor(Math.random() * allDirections.length)]          }      }, 2500)  }    ghosts.forEach(ghost => moveGhost(ghost))  

CSS Code:

.grid {      width: 420px;      height: 420px;      border: 1px solid black;      display: flex;      flex-wrap: wrap;  }    .grid > * {      box-sizing: border-box;      width: 15px;      height: 15px;      border: 1px solid green; /*delete or change color and opacity*/  }    .pac-dot {      border: 5px solid #fff;      background: greenyellow;  }    .wall {      background: blue;  }    .power-pallets {      background: green;      border-radius: 7.5px;  }    .ghost-lair {      background-color: #fff;  }    .ghost {      border-radius: 7.5px;  }    .red {      background: red;  }    .blue {      background-color: aqua;  }    .pink {      background-color: palevioletred;  }    .yellow {      background-color: yellow;  }  

HTML Code:

<div class="grid"></div>  

How to download a GIF created with GIF.js?

Posted: 04 Nov 2021 08:11 AM PDT

I have a GIF.js GIF which if I call the .render() opens in a new window, but I can not find documentation on how to have a simple button that allows the client to download the .gif file. Can someone please explain to me how it works?

Suppose I want to download the example GIF. How would I go about it?

var gif = new GIF({    workers: 2,    quality: 10  });    // add a image element  gif.addFrame(imageElement);    // or a canvas element  gif.addFrame(canvasElement, {delay: 200});    // or copy the pixels from a canvas context  gif.addFrame(ctx, {copy: true});    gif.on('finished', function(blob) {    window.open(URL.createObjectURL(blob));  });    gif.render();  

Toggle between checkbuttons

Posted: 04 Nov 2021 08:11 AM PDT

why is this not working?

I need to set true one or another never the two checkbuttons at the same time.

this is not working, i cant understand why? any ideas?

from tkinter import *      root = Tk()  w, h = root.winfo_screenwidth(), root.winfo_screenheight()  root.geometry("%dx%d+0+0" % (w, h))      def getbrowserfunc(var):      if var=="v1":          valbrow1.set(True)          valbrow2.set(False)      elif var=="v2":          valbrow1.set(False)          valbrow2.set(True)      valbrow2 = IntVar()  valbrow2.set(True)  valbrow1 = IntVar()  valbrow1.set(False)    checkbrowser = Checkbutton(root, fg="blue", selectcolor="red", text="Open in Browser", variable=valbrow1, command=getbrowserfunc("v1"))  checkbrowser.grid(row=0, column=1, pady=2)    checkbrowser2 = Checkbutton(root, fg="blue", selectcolor="red", text="Open in place", variable=valbrow2,command=getbrowserfunc("v2"))  checkbrowser2.grid(row=0, column=0, pady=2)  checkbrowser2.select()        if __name__ == '__main__':      root.mainloop()  

AWS SNS How to Subscribe to HTTPS Endpoint

Posted: 04 Nov 2021 08:11 AM PDT

I want to know how to use aws-sns service to create http / HTTPS Endpoint subscriptions. Who can give a complete process, including creating terminal nodes, and I hope to write code in Python. I look forward to your answers. Thank you

Show calendar request when creating event with O365 Graph Api

Posted: 04 Nov 2021 08:11 AM PDT

I am using the Microsoft.Graph v4.9.0 nuget package to generate events in a users calendar. The event is successfully created and is visible in the calendar of the target user, however there is no notification in the inbox for him that a new event has been created.

The goal would be to have an invitation for the new event which he can Accept/Decline/Mark as Tentative..

The code for calling the api is quite simple:

var newEvent = new Event() {}; //omitted, see the serialized value below    var graphResult =      await _graphServiceClient            .Users[userId]            .Calendar            .Events            .Request()            .AddAsync(newEvent);  

This is how the newEvent looks like:

{      "AllowNewTimeProposals": false,      "Attendees": [{              "Type": "Required",              "EmailAddress": {                  "Address": "internal_user@mycompany.com",                  "Name": "internal user",                  "ODataType": "microsoft.graph.emailAddress"              },              "ODataType": "microsoft.graph.attendee"          }, {              "Type": "Required",              "EmailAddress": {                  "Address": "external_user@notmycompany.com",                  "Name": "external user",                  "ODataType": "microsoft.graph.emailAddress"              },              "ODataType": "microsoft.graph.attendee"          }      ],      "Body": {          "Content": "<html>Test event</html>",          "ContentType": "Html",          "ODataType": "microsoft.graph.itemBody"      },      "End": {          "DateTime": "2021-11-09T11:00:00.0000000",          "TimeZone": "Central Europe Standard Time",          "ODataType": "microsoft.graph.dateTimeTimeZone"      },      "HasAttachments": false,      "Importance": "Normal",      "IsOnlineMeeting": false,      "IsOrganizer": false,      "IsReminderOn": false,      "Location": {          "DisplayName": "",          "ODataType": "microsoft.graph.location"      },      "Organizer": {          "EmailAddress": {              "Address": "external_user@notmycompany.com",              "Name": "external user",              "ODataType": "microsoft.graph.emailAddress"          },          "ODataType": "microsoft.graph.recipient"      },      "ReminderMinutesBeforeStart": 0,      "ResponseRequested": true,      "ShowAs": "Tentative",      "Start": {          "DateTime": "2021-11-09T10:00:00.0000000",          "TimeZone": "Central Europe Standard Time",          "ODataType": "microsoft.graph.dateTimeTimeZone"      },      "Subject": "Test event",      "Type": "SingleInstance",      "ODataType": "microsoft.graph.event"  }    

The organizer of the event is a user who is not part of the company, so he has an external email address (for example from gmail). As I read here on SO that it might be a problem if the organizer is the same as we are creating an entry for: related stackoverflow question

The internal user is a member of the company with the graph api we are using. (The event is generated inside his calendar)

They are both added to the event as attendees.

Then strange thing is that if I save the event from the calendar in Outlook as an .ics file the organizer is not the external user, but the internal one.

ATTENDEE;CN="External user";RSVP=TRUE:external_user@notmycompany.com  ORGANIZER;CN="Internal user":mailto:internal_user@mycompany.com  

I am kind of clueless what to try now to have a Calendar notification in the inbox for the internal user.

AttributeError: First letter of class name <mytodo.kv> is in lowercase

Posted: 04 Nov 2021 08:11 AM PDT

I am new to both Python and KivyMD. I am working on a personal project which is a ToDo app. I have a main.py and helpers.py(for styles) and my app was running(just have few buttons and text fields for now). Now I moved the styles to .kv file. When I run I see the following error: raise AttributeError( AttributeError: First letter of class name <mytodo.kv> is in lowercase

  • Main.py

    from kivymd.app import MDApp

    from kivy.lang import Builder

    class MyToDo(MDApp):

     def build(self):       self.theme_cls.theme_style = "Dark"       self.theme_cls.primary_palette = "Amber"       self.theme_cls.primary_hue = "A700"         return Builder.load_string('mytodo.kv')     def add_task_high(self):       print("Save the task as severity 1 in the DB and show in list")     def call(self, obj):       if obj.icon == "priority-high":           self.add_task_high()       elif obj.icon == "priority-low":           print("Save the task as severity 2 in the DB")       else:           print("Mark the task as done in the DB")  

    if name == "main": MyToDo().run()

  • mytodo.kv

:

MDTextField:      id: textfield      hint_text: 'Add Task'      font_size: 15      required: True      pos_hint: {'center_x': 0.2, 'center_y': 0.1}      size_hint: 0.35, 0.15      multiline: True    MDFloatingActionButtonSpeedDial:      data: {'Top Priority': 'priority-high', 'Low Priority': 'priority-low', 'Accomplished': 'check'}      rotation_root_button: True      callback: app.call    MDFloatingActionButton:      icon: 'priority-high'      pos_hint: {"center_x": .2, "center_y": .9}      size_hint_x: None      width: 200  

How to return result based on a string found on a list?

Posted: 04 Nov 2021 08:12 AM PDT

I'm trying to return all data from my excel sheet from the column TOURNAMENT that has the string FIFA. I keep getting no results back and am not sure how to fix this. Below is a sample of data from my excel. Any insight would be helpful thank you

My excel: enter image description here

import pandas as pd  import numpy as np    filename = ("results.csv")  df = pd.read_csv(filename)      #convert to datetime format  df['date'] = pd.to_datetime(df['date'], format='%Y/%M/%D')    #Which country has scored the most goals in FIFA events (qualifiers, cups, etc.) since 2010?  #To get the most goals by sum  df['total_score'] = df['home_score'] + df['away_score']      #Not sure how to check all data with the string "FIFA" in the column "Tournament"   sub_df = df[(df['date'].dt.year >= 2010)]    if "FIFA" in df['tournament']:    sub_df2 = sub_df[sub_df['total_score'] == sub_df['total_score'].max()]      print(sub_df2)  else:    print("no results")  

Is better to use a for over a list or multiple access to database

Posted: 04 Nov 2021 08:11 AM PDT

I'm having a doubt over the better implementation of a method that is often used. The solution in production as the following form:

public List<Element> method(String text) {            List<Element> element = select * from element e where e.text like text          return element          }  

the new implementation instead load the complete list 1 time

List<Element> allElement =select * from element  

and the method become something like

    public List<Element> method(String text) {            List<Element> element;           for Element e : allElement{            if e.text.contains(text) element.add(e)          }          return element          }  

Which one is the better solution?

pip script not running

Posted: 04 Nov 2021 08:12 AM PDT

i use this command to uploade pypi pkg

python2 setup.py sdist  python2 setup.py bdist_wheel  python2 -m twine upload dist/* --skip-exis    

my pkg https://pypi.org/project/abir/0.1/

when I inatall pip install abir in install successfully but when i run abir it show me this error can any one help me to fix this problem

/data/data/com.termux/files/usr/bin/abir: line 2: import: command not found  /data/data/com.termux/files/usr/bin/abir: line 3: from: command not found  /data/data/com.termux/files/usr/bin/abir: line 4: try:: command not found  /data/data/com.termux/files/usr/bin/abir: line 5: import: command not found  /data/data/com.termux/files/usr/bin/abir: line 6: except: command not found  /data/data/com.termux/files/usr/bin/abir: line 7: syntax error near unexpected token `'pip2 install mechanize''  /data/data/com.termux/files/usr/bin/abir: line 7: `    os.system('pip2 install mechanize')'  

Chek that pypi file and tell me the answer this script version is python2.7

My setup.py file

import setuptools  with open("README.md", "r") as fh:      long_description = fh.read()  setuptools.setup(       name='abir',       version='0.1',       scripts=['abir'] ,       author="ABIR HOSSAIN",       author_email="abirhossain200019@gmail.com",       description="this is a test file",       long_description=long_description,     long_description_content_type="text/markdown",       url="https://github.com/ABIRHOSSAIN10/test",       packages=setuptools.find_packages(),       classifiers=[           "Programming Language :: Python :: 2.7",           "License :: OSI Approved :: MIT License",           "Operating System :: OS Independent",       ],   )  

Multi line chart with ApexChart and react?

Posted: 04 Nov 2021 08:12 AM PDT

I am first time using React-ApexChart. I can not find example to multi line chart even from net. Can I have an example or link to example?

Generating CSV in Rails from crossed Model

Posted: 04 Nov 2021 08:12 AM PDT

I have a method to_csv which collect the guest_id from a Booking table, but instead of returning the guest_id, i would like to retrieve the first_name and last_name as well as the email from the User table and put each of them in a row in a csv file. My method looks as follow:

def self.to_csv      attributes = %w[guest_id]      CSV.generate(headers: true) do |csv|        csv << attributes        all.each do |contact|          csv << attributes.map { |attr| contact.send(attr) }        end      end    end  

Does anybody know how i could do this please ?

Pandas Groupby range of dates which cross midnight

Posted: 04 Nov 2021 08:11 AM PDT

I have a list of dates and times in a Pandas DataFrame. For each date / time, an activity was done (this is classed as "main" or "additional" within the dataframe.

    df = pd.DataFrame([[2021-10-30, 10:37:00, Main , 10 , Day], [2021-10-30, 11:11:00, Main, 11, Day]], columns=[Date, Time, Additional, Hour, Shift])  

DataFrame Example

The data consists of two sets of workers, who work a day shift (6am to 6pm) or night shift (6pm to 6am).

I am looking to group the data and sum the total activities done by each group of workers.

I was able to almost complete this with Pandas groupby() function

df = pd.DataFrame(data)  df['Shift'] = df['Hour'].between(6,18)  df['Shift'] = np.where(df['Shift'], 'Night', 'Day')  df = df.groupby(['ID_Date', '6-6 Shift', 'Additional']).size().reset_index(name='Target Count')  df['Cumulative Total'] = df['Target Count'].cumsum()  

The issue I have, is that the nightshift can work for example on the 02-Nov from midnight to 6am, and also 6pm to midnight. This is technically two (2) separate shifts, but the groupby function I have used groups this per day, which joins the sum() together.

Ideally, I would group the data for night shift from for 01-Nov (6pm) to 02-Nov (6am)

PySpark Error: cannot resolve '`timestamp`'

Posted: 04 Nov 2021 08:12 AM PDT

I have to find the exact hour that most checkins occur in the Yelp dataset but I'm running up against this error for some reason. Here is my code so far:

from pyspark.sql.functions import udf  from pyspark.sql.functions import explode  from pyspark.sql.types import IntegerType  from pyspark.sql.types import ArrayType,StringType  from pyspark.sql import functions as F    square_udf_int = udf(lambda z: square(z), IntegerType())    checkin = spark.read.json('yelp_academic_dataset_checkin.json.gz')  datesplit = udf(lambda x: x.split(','),ArrayType(StringType()))  checkin.select('business_id',datesplit('date').alias('dates')).withColumn('checkin_date',explode('dates'))  datesplit = udf(lambda x: x.split(','),ArrayType(StringType()))  dates = checkin.select('business_id',datesplit('date').alias('dates')).withColumn('checkin_date',explode('dates'))  dates = dates.select("checkin_date")  dates.withColumn("checkin_date", F.date_trunc('checkin_date',                     F.to_timestamp("timestamp", "yyyy-MM-dd HH:mm:ss 'UTC'"))).show(truncate=0)  

And the error:

Py4JJavaError: An error occurred while calling o1112.withColumn.  : org.apache.spark.sql.AnalysisException: cannot resolve '`timestamp`' given input columns: [checkin_date];;  'Project [date_trunc(checkin_date, to_timestamp('timestamp, Some(yyyy-MM-dd HH:mm:ss 'UTC')), Some(Etc/UTC)) AS checkin_date#190]  +- Project [checkin_date#176]     +- Project [business_id#6, dates#172, checkin_date#176]        +- Generate explode(dates#172), false, [checkin_date#176]           +- Project [business_id#6, <lambda>(date#7) AS dates#172]              +- Relation[business_id#6,date#7] json  

dates is just a Spark dataframe with one column named: "checkin_date" with only datetimes, so I'm not sure why this isn't working.

Difference between two dates in years days hours minutes format

Posted: 04 Nov 2021 08:11 AM PDT

I am trying to find out difference between two days "xx years xx days xx hours xx minutes" format. My start date is in A column and end date is in B. Calculating difference in C column.

I am using B1-A1 formula in C column and using custom format "yy" years "dd" days "hh" hours "mm" minutes" in C column. It works fine if the start and end years are different. But if it is same, C column reporting incorrect years and days. (showing as 99 years and 30 days).

How to fix it ?

Sample google sheet link

Creation of table from lists elements containing lsmeans() statistics

Posted: 04 Nov 2021 08:12 AM PDT

I am trying to build some tables, each for every elemnt (13 in total) of a list containing statistics from an lsmeans statistics, computed via this commands lines

md <- out_long %>%    group_by(signals) %>%    do(fit = lmerTest::lmer(value ~ COND + (1 |ID), data = .)) %>%     pull(fit) %>%     lapply(., function(m) lsmeans(m, pairwise ~ COND, adjust="tukey"))  

Each element contains the following statistics (i.e. the first one):

$lsmeans   COND    lsmean    SE   df lower.CL upper.CL   NEG-CTR  2.471 0.772 38.9    0.909     4.03   NEG-NOC  3.024 0.772 38.9    1.463     4.59   NEU-NOC  0.711 0.772 38.9   -0.850     2.27    Degrees-of-freedom method: kenward-roger   Confidence level used: 0.95     $contrasts   contrast              estimate    SE df t.ratio p.value   (NEG-CTR) - (NEG-NOC)   -0.554 0.644 48  -0.860  0.6678   (NEG-CTR) - (NEU-NOC)    1.760 0.644 48   2.735  0.0233   (NEG-NOC) - (NEU-NOC)    2.314 0.644 48   3.595  0.0022    Degrees-of-freedom method: kenward-roger   P value adjustment: tukey method for comparing a family of 3 estimates   

Desired outcome

In the case I need to build elegant tables for them, or specifically one single table for each elements, including both lsmeans statistics and constrast ones, how should I proceed?

Here the data I'm working on

> dput(head(out_long,50))  structure(list(ID = c("01", "01", "01", "04", "04", "04", "06",   "06", "06", "07", "07", "07", "08", "08", "08", "09", "09", "09",   "10", "10", "10", "11", "11", "11", "12", "12", "12", "13", "13",   "13", "15", "15", "15", "16", "16", "16", "17", "17", "17", "18",   "18", "18", "19", "19", "19", "21", "21", "21", "22", "22"),       GR = c("RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP",       "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP",       "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP",       "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP",       "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP", "RP",       "RP"), SES = c("V", "V", "V", "V", "V", "V", "V", "V", "V",       "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V",       "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V",       "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V",       "V", "V", "V", "V", "V"), COND = c("NEG-CTR", "NEG-NOC",       "NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",       "NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",       "NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",       "NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",       "NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",       "NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",       "NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC",       "NEU-NOC", "NEG-CTR", "NEG-NOC", "NEU-NOC", "NEG-CTR", "NEG-NOC"      ), signals = c("P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",       "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",       "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",       "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",       "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",       "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",       "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz", "P3FCz",       "P3FCz", "P3FCz", "P3FCz"), value = c(-11.6312151716924,       -11.1438413285935, -3.99591470944713, -0.314155675382471,       0.238885648959708, 5.03749946898385, -0.213621915029167,       -2.96032491743069, -1.97168681693488, -2.83109425298642,       1.09291198163802, -6.692991645215, 4.23849942428043, 2.9898889629932,       3.5510699900835, 9.57481668808606, 5.4167795618285, 1.7067607715475,       -6.13036076093477, -2.82955734597919, -2.50672211111696,       0.528517585832501, 8.16418133488309, 1.88777321897925, -7.73588468896919,       -9.83058052401056, -6.97442700196932, 1.27327945355082, 2.11962397764132,       0.524299677616254, -1.83310726842883, 0.658810483381172,       -0.261373488428192, 4.37524298634374, 0.625555654900511,       3.19617639836154, 0.0405517582137798, -3.29357103412113,       -0.381435057304614, -5.73445509910268, -6.1129152355645,       -2.45744234877604, 2.95352732001065, 0.527721249096473, 1.91803490989119,       -3.46703346467546, -2.40438419043702, -5.35374408162217,       -7.27028665849262, -7.1532211375959)), row.names = c(NA,   -50L), class = c("tbl_df", "tbl", "data.frame"))  >   

Is there a way to reload a screen in React-Native one time after it loads?

Posted: 04 Nov 2021 08:11 AM PDT

I have a react native screen with a joystick component I made but on first load up the joystick doesn't work as intended but works perfectly fine when page is reloaded. Is there any way to set it to reload once quickly one time when it opens?

Why do I receive a "signal SIGSEGV, segmentation fault" when I try to delete last elements from doubly linked list?

Posted: 04 Nov 2021 08:12 AM PDT

This is a programming assignment from university. The main program was given to me by the professor. I have to create the dlist.h. When I debug, I receive this segmentation error. I also have this:

get (dl=..., val=<error reading variable>) at dlist.h:37  
#include <iostream>  #include <exception>            struct DListElem {          //element of the list      int info;      DListElem * prev;      DListElem * next;  };        struct DList{               //just stores pointers to first and last elements of the list      DListElem * first;      DListElem * last;  };      void initializeDList(DList & dl){  //Iinitializes dl as empty list        dl.first = nullptr;      dl.last = nullptr;  }    void put(DList& dl, int val){  //insert a new element with value val at the beginning of the list.        DListElem* front_elem = new DListElem;      front_elem ->info = val;      front_elem -> prev = nullptr;      front_elem -> next = dl.first;      dl.first = front_elem;                    if(dl.last==NULL) dl.last=dl.first;  }    bool get(DList& dl, int& val){      /*Removes an item (if possible) from the end of the list. The value of the last       element is returned by the val parameter, the memory for the list element       is released. The return value indicates whether an item could be retrieved,       i.e. it returns false for an empty list and true otherwise.*/            if(dl.last==nullptr) return false;      if (dl.first==dl.last){             //if there is only 1 element          val = dl.last -> info;          DListElem* buffer = new DListElem;          buffer = dl.last;          dl.last = nullptr;          dl.first = nullptr;           delete (buffer);      }      else{          val = dl.last -> info;          DListElem* buffer = new DListElem;          buffer = dl.last;          dl.last = dl.last -> prev;          dl.last -> next = nullptr;         //this part seems to still be the problem          delete (buffer);                };      return true;  }  

And this is my main program:

 #include <iostream>   #include "dlist.h"   using namespace std;     int main (int argc, char *argv[])  {    DList queue;  initializeDList (queue);  

inserts 5 values

 for (int i = 1; i <= 5; i++) {   cout << "put: " << 10 * i << endl;    put (queue, 10 * i);   }   

removes 3 values and prints them to console

for (int j = 1; j <= 3; j++){      int value;          if (get (queue, value))      cout << "     get: " << value << endl;  }  

I guess these are necessary:

  cin.sync ();    cin.get ();    return 0;    }  

Cannot find module coa/compile.js

Posted: 04 Nov 2021 08:12 AM PDT

I'm running yarn in a project created with create-react-app, but I'm getting this error:

Exit code: 1  Command: start /B node compile.js & node compile.js  Arguments:   Directory: uber-web/node_modules/coa  Output:  /bin/sh: 1: start: not found  internal/modules/cjs/loader.js:905    throw err;    ^    Error: Cannot find module 'uber-web/node_modules/coa/compile.js'      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)      at Function.Module._load (internal/modules/cjs/loader.js:746:27)      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)      at internal/main/run_main_module.js:17:47 {  

I've already uninstalled all the .lock and node_module folder, but it still doesn't work.

OData Connected Service - update Endpoint configuration without rebuilding my project

Posted: 04 Nov 2021 08:11 AM PDT

I have made a console app (.NET Framework 4.8) where I use OData Connected services. I configured my endpoint where I chose the address for metadata.xml file (locally stored in my PC).

The problem we are facing now is that when a new element is added to our OData service, we need to download a new metadata file, change the configuration and rebuild the app.

Is there a way that this metadata file can "automatically" be added to the configuration? Also, after the project is built and them, who have added a new element, do not necessarily have access neither to Visual Studio or the source code?


What I mean by changing an element:

We have a service with pre-defined standard objects, e.g. File, Document... There are some standard attributes to these object, however users can add their own custom attributes as well.

My input to the console app is an XML file that contains these objects with their attribute names and values. In my app I create a new object (e.g. File) and add each attribute value to it using System.Reflective. That means that the property names are not hard-coded in the app, but I find them from text strings.

Repartitioned data bottlenecks in few tasks in Spark

Posted: 04 Nov 2021 08:12 AM PDT

I have a simple spark job which does the following

val dfIn  = spark.read.parquet(PATH_IN)  val dfOut = dfIn.repartition(col1, col2, col3)  dfOut.write.mode(SaveMode.Append).partitionBy(col1, col2, col3).parquet(PATH_OUT)  

I noticed in this job big performance deterioration. Inspecting the Spark UI showed that the write bottlenecked in a few tasks which showed huge memory spill and much bigger output size compared to the fast partitions.

So I suspected that this issue is caused by the data skew and changed the way the data is repartitioned to

import org.apache.spark.sql.functions.rand  val dfOut = dfIn.withColumn("rand", rand()).repartitionByRange(col1, col2, col3, $"rand")  

however this did not help to resolve the performance issues. In the Spark UI you can see now that the data is very evenly distributed across ALL partitions (based on the output size). But still a few tasks are very long running.

I have no ideas what else could cause this and would be thankful for any ideas.

Add multiple values in bag using authzforce

Posted: 04 Nov 2021 08:11 AM PDT

I'm aware there is already a question here on stackoverflow where this is discussed, but I still have trouble to send the correct values to Bag.newAttributeBag and was hoping for some help.

final Collection<StringValue> subjectList = new ArrayList<>();        subjectList.add("123456");      subjectList.add("John Smith");    final AttributeFqn subjectIdAttributeId = AttributeFqns.newInstance(XACML_1_0_ACCESS_SUBJECT.value(), Optional.empty(), XacmlAttributeId.XACML_1_0_SUBJECT_ID.value());  final AttributeBag<?> subjectIdAttributeValues = Bags.newAttributeBag(StandardDatatypes.STRING, subjectList);  requestBuilder.putNamedAttributeIfAbsent(subjectIdAttributeId, subjectIdAttributeValues);  

If I use Collection StringValue I get an error on subjectList.add

The method add(StringValue) in the type Collection is not applicable for the arguments (String)

If I use Collection<String> I get an error on newAttributeBag. How can I add multiple values to my Bag.newAttributeBag?

The method newAttributeBag(Datatype, Collection) in the type Bags is not applicable for the arguments (AttributeDatatype, Collection)

How to extract cartopy figure as numpy array and remove transparent borders?

Posted: 04 Nov 2021 08:12 AM PDT

I am using cartopy to plot some part of the world, and try to extract the matplotlib figure as a numpy array made of the values of the figure's pixels. However, it seems that the figure is padded with some white borders ([255 255 255 0]) that I want to get rid of. How can I proceed?

Here is a sample code:

import matplotlib.pyplot as plt  import numpy as np    import cartopy  import cartopy.crs as ccrs  import cartopy.feature as cfeature    import io    MIN_LAT = 19  MAX_LAT = 53  MIN_LON = -20  MAX_LON = 41    # Map    fig = plt.figure()  proj = ccrs.PlateCarree(central_longitude=0)      ax=plt.axes(projection=proj)    ax.add_feature(cfeature.LAND, color='lightgray')  ax.add_feature(cfeature.OCEAN)    # Select area  ax.set_extent([MIN_LON, MAX_LON, MIN_LAT, MAX_LAT], crs=proj)    io_buf = io.BytesIO()  fig.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0)  fig.savefig(io_buf, format='raw')  io_buf.seek(0)  img_arr = np.reshape(np.frombuffer(io_buf.getvalue(), dtype=np.uint8),                       newshape=(int(fig.bbox.bounds[3]), int(fig.bbox.bounds[2]), -1))  io_buf.close()    print(img_arr)  

The displayed image is the below one: enter image description here

The img_arr variable contains:

[[[255 255 255   0]    [255 255 255   0]    [255 255 255   0]    ...    [255 255 255   0]    [255 255 255   0]    [255 255 255   0]]  

I expect the variable img_array containing only [211, 211, 211, 255] and [151, 182, 225, 255] values as they are values of pixels representing continents and oceans/seas in the above map.

Based on this answer (Matplotlib projection remove margin), I tried to add this:

fig.subplots_adjust(left=0, right=1, bottom=0, top=1)  

but it did not help.

Where is Dart's SDK located within /flutter folder?

Posted: 04 Nov 2021 08:11 AM PDT

Software

MacOS Sierra 10.12.6  Android Studio 3.1.2  Flutter 0.3.2 • channel beta  Tools • Dart 2.0.0-dev.48.0.flutter-fe606f890b  Flutter doctor (no problems found)  

Problem

Dart's SDK is supposed to be bundled when Flutter is downloaded according to the documentation:

"The Dart SDK is bundled with Flutter; it is not necessary to install Dart separately"

However, I opened an existing Flutter project with Android Studio and it suggested me to either "Download Dart SDK" or "Open Dart settings":

Image of Android Studio suggesting to "download Dart SDK"

Apparently, I need to "Open Dart settings" and tell Android Studio where to find the Dart' SDK. However, it can't find it within the flutter/ directory.

Should I always use the AndAlso and OrElse operators?

Posted: 04 Nov 2021 08:12 AM PDT

Is there ever a circumstance in which I would not want to use the AndAlso operator rather than the And operator? …or in which I would not want to use the OrElse operator rather than the Or operator?

No comments:

Post a Comment