Friday, July 30, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


AVG Tech Support Number ☎145898747777௹ || Dial now

Posted: 30 Jul 2021 08:33 AM PDT

AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now AVG Tech Support Number ☎145898747777௹ || Dial now

Is this case a two-edge-connected graph

Posted: 30 Jul 2021 08:33 AM PDT

I am doing some training, there is a test case I can not pass, I think it is a false case for two-edge-connected Graphy, but the answer says it is true

  "edges": [      [1, 2, 3, 5],      [0, 2],      [0, 1],      [0, 4, 5],      [3, 5],      [3, 4, 0]    ]  

if I remove edges[0], the graph will be split into 2 parts 1-2 and 3-4-5. So it is not two - edge - connected

By definition: a graph is connected if for every one of its edges, the edge's removal from the graph does not cause the graph to be disconnected. If removal of any single edge disconnects the graph, then it is not a two-edge-connected.

A graph is connected if, for every pair of vertices in the graph, there is a path of one or more edges connecting the given vertices. A graph that isn't connected is said to be disconnected.

Any thought helps!

Bootstrap Cards does not show correctly when using J Query

Posted: 30 Jul 2021 08:32 AM PDT

I trying to create a dynamic html page where the data will come from JSON data. I trying to put three column in a row but I am getting one column for one row. I wondering what is wrong with my code. Appreciates that someone can give me some pointer.

window.onload=function loadDoc() {    var url ="SK_movie_world_movies.json";  $.getJSON(url, function(data){      $.each(data,function(i,item)      {          //alert(item.Title);          let name=item.Title;          let ca_st=item.cast;          let dir=item.director;          let gen=item.genre;          let dur=item.duration;          let lang=item.language;          let syn=item.synopsis;          let pic=item.image;          let id=item.MoveID;                        $(".movie_container").append(          `<div class="col-md-4 mb-5">          <div class="card">          <div class="text-center"><img src="${pic}" alt="${id}" class="card-img-top"></div>          <div class="card-body">          <h5 class="card-title text-center">${name}</h5>          <p class="card-text">Cast: ${ca_st}</p>          <p class="card-text">Director: ${dir}</p>          <p class="card-text">Genre: ${gen}</p>          <p class="card-text">Duration: ${dur}</p>          <p class="card-text">Language: ${lang}</p>          <div class="text-center">          <a href="#" class="btn btn-primary">View Detail</a>          </div>          </div>          </div>          </div>                      `);               });                  })  

}

How can I place PHP anonymous function to execute CSS inside another function in Wordpress

Posted: 30 Jul 2021 08:32 AM PDT

I am not a programmer so I'm sure this is a no brainer. I am trying to disable a popup if Wordpress users are not logged in. I am using CSS to disable the popup for a specific Woocommerce plugin. The CSS code works fine if I use it by itself. However, when I try to use it with the PHP function to check if users are logged in it does nothing. Any help would be greatly appreciated.

add_action('disable_popup','check_if_logged_in');    function check_if_logged_in()  {   if (! is_user_logged_in())        {                    add_action( 'wp_head', function () { ?>      <style>      .ex-fdlist .exwf-order-method { display: none; }      </style>  <?php });   }  }  

How to change the npm version of my local machine? (MacOs)

Posted: 30 Jul 2021 08:32 AM PDT

I previously have an npm(6.14.13) installed on my computer under usr/local/bin, which should be the default location. To avoid the permission issue to install some packages globally without using sudo. I followed the instruction on npm Docs to manually change npm's default directory https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally. I want to update my npm version, so I type npm install -g npm@latest on the terminal. It downloads the latest npm on Users/jimmytan666/.npm-global/lib/node_modules. The npm version of this is the latest one. But it also means now I have 2 npm installed on different locations on my computer. When I check the version using npm -v, it shows the older one (6.14.13). I am not sure how to solve the issue. Thanks.enter image description here enter image description here

System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time

Posted: 30 Jul 2021 08:32 AM PDT

I have a functionality to call rest services from my web application. I am doing this in c#.net code

My Code

using (var client = new HttpClient())   {    client.DefaultRequestHeaders.Accept.Add(new    MediaTypeWithQualityHeaderValue("application/json"));      var byteArray = Encoding.ASCII.GetBytes("abc:defg!");      client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));      client.DefaultRequestHeaders.Add("CSRF_NONCE", a.NonceValue);       var message = await client.PostAsync("hostname/Windchill/servlet/odata/v3/ProdMgmt/Parts('OR:wt.part.WTPart:123456')/PTC.ProdMgmt.GetPartStructure?$expand=Components($select=PartName,PartNumber;$expand=PartUse($select=FindNumber,LineNumber,Quantity,Unit);$levels=1)", null);    }  
  1. I can call it successfully from my local machine but when I try to call it after deploying to the Test server (Windows Server), I get the below error.

    System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.Sockets.Socket.g__WaitForConnectWithCancellation|283_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.DefaultConnectAsync(SocketsHttpConnectionContext context, CancellationToken cancellationToken) at System.Net.Http.ConnectHelper.ConnectAsync(Func3 callback, DnsEndPoint endPoint, HttpRequestMessage requestMessage, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.ConnectHelper.ConnectAsync(Func3 callback, DnsEndPoint endPoint, HttpRequestMessage requestMessage, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken)

I tried doing the below to make it functional but nothing has worked.

  1. "A connection attempt failed because the connected party did not properly respond after a period of time" using WebClient

  2. Added the below code in the constructor method

ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

  1. My Test server uses proxy settings in the browser to access the rest services url. So I tried adding Proxy details in my code.

    WebProxy proxy = new WebProxy { Address = new Uri($"http://x.x.x.x:xxxx"), }; ServicePointManager.Expect100Continue = false; ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; HttpClientHandler clientHandler = new HttpClientHandler() { AllowAutoRedirect = true, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, Proxy = proxy, }; using (var client = new HttpClient(clientHandler))

Any help is much appreciated.

What query languages can I use in XML apart from XPath and CSS?

Posted: 30 Jul 2021 08:32 AM PDT

I am looking for a query language that allows accessing XML elements and attributes in a simplified way compared to XPath or CSS.

For example instead of using XPath //*[local-name()='users']/[local-name()='user']/[local-name()='name' and text()='Bob'] I would like to use something less powerful but more novice-user friendly and intuitive i.e. users_user_name_text=Bob

What options do I have apart from XPath and CSS?

Odd behavior with RPAD

Posted: 30 Jul 2021 08:32 AM PDT

I've come across some odd behavior related to RPAD ... figured I'm missing something obvious, hoping somebody can help me out.

I'm just trying to format some simple output ... and reduced the test case to very simple case:

  set serverout on    declare       lc_wid  CONSTANT  number := 10;       lc_sep  CONSTANT  varchar2(10) := ' : ';              lc_NOCOLOR  CONSTANT varchar2(100) := chr(27)||'[0m';       lc_RED      CONSTANT varchar2(100) := chr(27)||'[32m'||chr(27)||'[1;31m';       lc_GREEN    CONSTANT varchar2(100) := chr(27)||'[32m'||chr(27)||'[1;32m';       lc_YELLOW   CONSTANT varchar2(100) := chr(27)||'[32m'||chr(27)||'[1;33m';    begin       dbms_output.put_line ( lc_sep || lc_GREEN || 'test'                       || lc_NOCOLOR || lc_sep );       dbms_output.put_line ( lc_sep             || 'test'                                     || lc_sep );       dbms_output.put_line ( lc_sep || lc_GREEN || rpad('test'     ,lc_wid,' ') || lc_NOCOLOR || lc_sep );       dbms_output.put_line ( lc_sep             || rpad('test'     ,lc_wid,' ')               || lc_sep );       dbms_output.put_line ( lc_sep || lc_GREEN || rpad('testing'  ,lc_wid,' ') || lc_NOCOLOR || lc_sep );       dbms_output.put_line ( lc_sep             || rpad('testing'  ,lc_wid,' ')               || lc_sep );       dbms_output.put_line ( lc_sep || lc_GREEN || rpad('something',lc_wid,' ') || lc_NOCOLOR || lc_sep );       dbms_output.put_line ( lc_sep             || rpad('something',lc_wid,' ')               || lc_sep );    end;    /  

(Yep, I'm mucking with colors! fun ... )

That spits out the following:

enter image description here

as you can see, the short text with no RPAD aligns fine ... and the longer text with rpad aligns fine, however, the "test" and "testing" text are doing something "different" ... O.o

now if I change rpad to pad with "." . it works fine .

  set serverout on    declare       lc_wid  CONSTANT  number := 10;       lc_sep  CONSTANT  varchar2(10) := ' : ';              lc_NOCOLOR  CONSTANT varchar2(100) := chr(27)||'[0m';       lc_RED      CONSTANT varchar2(100) := chr(27)||'[32m'||chr(27)||'[1;31m';       lc_GREEN    CONSTANT varchar2(100) := chr(27)||'[32m'||chr(27)||'[1;32m';       lc_YELLOW   CONSTANT varchar2(100) := chr(27)||'[32m'||chr(27)||'[1;33m';    begin       dbms_output.put_line ( lc_sep || lc_GREEN || 'test'                       || lc_NOCOLOR || lc_sep );       dbms_output.put_line ( lc_sep             || 'test'                                     || lc_sep );       dbms_output.put_line ( lc_sep || lc_GREEN || rpad('test'     ,lc_wid,'.') || lc_NOCOLOR || lc_sep );       dbms_output.put_line ( lc_sep             || rpad('test'     ,lc_wid,'.')               || lc_sep );       dbms_output.put_line ( lc_sep || lc_GREEN || rpad('testing'  ,lc_wid,'.') || lc_NOCOLOR || lc_sep );       dbms_output.put_line ( lc_sep             || rpad('testing'  ,lc_wid,'.')               || lc_sep );       dbms_output.put_line ( lc_sep || lc_GREEN || rpad('something',lc_wid,'.') || lc_NOCOLOR || lc_sep );       dbms_output.put_line ( lc_sep             || rpad('something',lc_wid,'.')               || lc_sep );    end;    /  

enter image description here

so ... it seems short text doesn't work properly with those color codes AND RPAD ... but I'm wondering why ? Trying to understand what's going on here.

Return data from a screen on Flutter, without using Navigator.pop

Posted: 30 Jul 2021 08:32 AM PDT

I have a DetailPage that must return something to the code that called it. The documentation Return data from a screen explains that you must call Navigator.pop(context, whateverYouMustReturn) on some button.

So far so good, but what happens if the user clicks on the back button on the AppBar instead?? How do I return something then??

PS I'm using Navigator 1.0, btw

create a Doubly LinkedList form a list in python

Posted: 30 Jul 2021 08:32 AM PDT

I want to create a Doubly Linked list from list in python. The code is not working, can you please explain where I did the mistake.

Here's my code

class Node:  def __init__(self, data):      self.data = data      self.next = None      self.prev = None      class DoublyList:      def __init__(self, a):          self.head = None          self.tail = None          self.head.next = self.head.prev = self.head          self.size = 0        for i in a:          n = Node(i)          if (self.head is None):              self.head = n              tail = n          else:              tail.next = n              tail = n    def showList(self):          current = self.head                    while current is not None:              print(current.data)              current = current.next  

testing

lst = [10, 20, 30]  d = DoublyList(lst)  d.showList()  

state not changing on onChange event in react?

Posted: 30 Jul 2021 08:33 AM PDT

This is my code:

function AddPost() {      const [file, setFile] = useState({})      const handleChange = (event) => {          setFile(event.target.files[0]);          console.log(file);      }      return (          <div>              <TextField type='file' onChange={handleChange} label='image' variant='outlined' />          </div>      )  }  

I am not getting file info. on console, while i select file . Instead of that I am getting empty object why ?

Why is it needed to give getchar() value of an integer variable in order to have putchar() print all characters?

Posted: 30 Jul 2021 08:32 AM PDT

I am learning C from the book "The C Programming Language"; my question is about something I observed while trying to reformulate with few lines of code regarding input and output: why is it needed to give the getchar() function a value of a certain integer in order to have it store all the text in the input? For example with this code putchar() is printing all that I type;

int c;    while ((c = getchar()) != EOF)      putchar(c)  

But, why isn't it the same if I write:

while (getchar() != EOF)      putchar(getchar());  

In the latter case, for example, if I write "okok", the program is then printing "kk".

I think the reason is within some property of getchar(), that I wasn't able to get; for example, if I write a character counting program, and I want to exclude new lines, I also observed that it's working if I write it as:

int nc, c;    nc = 0;  while ((c = getchar()) != EOF)      if (c != '\n')          ++nc;  printf("%d", nc);  

But it's not able instead to distinguish correctly the '\n' when using getchar() directly instead of c integer:

while ((c = gethar()) != EOF)      if (getchar() != '\n')          ++nc;  printf("%d", nc);  

My purpose it is just to understand, as I wouldn't like to learn this just by memory, and in the book it is written that getchar() is working using int values, so I wonder if there is something that I missed about properties of getchar() despite reading several times, also searching in different questions in stack overflow regarding the getchar() topic.

Apple Receipt Verification

Posted: 30 Jul 2021 08:32 AM PDT

I am making a mobile app with React Native (it is not submitted yet)

I want to verify apple payment according the this page (https://developer.apple.com/documentation/appstorereceipts/verifyreceipt)

I'm making test with Postman to post data but getting response "status": 21002.

My request:

"receipt-data" : "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",  "password": "702a98fc92d0460bbd6aaf18c9b1ae0d",  "exclude-old-transactions" : false  }  

And response:

"status": 21002  }  

I tried both https://buy.itunes.apple.com/verifyReceipt and https://sandbox.itunes.apple.com/verifyReceipt but response didn't change.

I created secret key for app. How can I verify receipt, what is the missing for verification?

SQL OpenQuery with linked Oracle Database using Parenthesis

Posted: 30 Jul 2021 08:32 AM PDT

I'm trying to run a simple query in SQL Server Management Studio 18 via an OpenQuery to a linked Oracle database. The query I need to run on the linked server has parenthesis in the query.

I'm getting an error:

Missing right side of parenthesis

It works fine when not apart of an OpenQuery so what am I doing wrong?

SELECT *   FROM OPENQUERY([linked_server],                 'SELECT                       PATIENT_SSN,                      SPONSOR_SSN,                      FMPSSN,                        FMP,                      DOB AS Date_Of_Birth,                      DATE_ENTERED_INTO_FILE AS Date_Registered,                      SUBSTRING(NAME FROM 1 FOR LOCATE(",", NAME, 1)-1) AS Last_Name,                      ETHNIC_BACKGROUND_CODE AS Ethnic_Code,                       SEX AS Gender,                        MARITAL_STATUS_NAME AS Marital_Status,                      PHONE AS Phone_Number,                       STREET_ADDRESS AS Address_Street,                       CITY AS Address_City,                       STATE_NAME AS Address_State,                       ZIP_CODE AS Address_Zip,                        DOD_ID_ AS DOD_Deers_ID,                      IEN AS IEN_ID,                       PATIENT_CATEGORY_NAME AS PAT_CAT,                      DMIS_ID AS DMIS_ID,                      PERSON_ID AS Patient_ID,                         BRANCH_OF_SERVICE_LAST_NAME AS Branch_ID,                       LAST_UPDATE_TIMESTAMP AS Rec_Updated_Date                    FROM                       my_table')  

How to make pause/play button work in tkinter video

Posted: 30 Jul 2021 08:32 AM PDT

I add 2 buttons in tkinter window and add to def play and pause to pause video.mp4 with no luck any help please.

Here is my code:

def show_frame():            _, frame = cap.read()      cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)      img = Image.fromarray(cv2image)      imgtk = ImageTk.PhotoImage(image=img)      lmain.imgtk = imgtk      lmain.configure(image=imgtk)      lmain.after(10, show_frame)  

Why does my WSL Ubuntu point to a different Python Version?

Posted: 30 Jul 2021 08:32 AM PDT

This is the first time I have installed Ubuntu and Python in my Windows laptop, and upon checking, it seems that my Python version is 3.8.5.

python3 --version  

Ubuntu WSL

However, when I check my cmd, and run

python --version  

I'm getting 3.7.9. Just curious as to what the difference is as I don't remember installing 3.8.5

CMD

Output a skill and a field that shows if the person has this skill and also if he does not have this skill

Posted: 30 Jul 2021 08:33 AM PDT

I'm new to mysql and stuck. I found similar questions but they did not answer my qeustion or I didn't understand them. I want to combine three tables, a person_table which has the person, a skill_table which has the skill and a person_skill table that has both the person and the skill. I want to output a name, a skill and a field that shows if the person has this skill and also if he does not have this skill.

I have the following 3 tables in my database:

person_table:

| id   | person_name | person_id |  |:----:|:-----------:|:---------:|  | 1    | user1       | 1         |         | 2    | user2       | 2         |        

skill_table:

|id      | skill_name | skill_id  |   |:------:|:----------:|:---------:|  | 1      | skill1     | 3           | 2      | skill2     | 4           

person_skill_table:

| id       | person_id | skill_id |  | :------: | :-------: | :------: |  | 1        | 1         | 3          | 2        | 1         | 4          

I want a query that gives me this result, my below example does not:

| id       | person_name | skill_name  | excist |   | :------: | :----------:| :---------: | :-----:|  | 1        | user1       | skill1      |  YES     | 2        | user1       | skill2      |  YES     | 3        | user2       | skill1      |  NO      | 4        | user2       | skill2      |  NO      

The query that I have:

SELECT person_table.person_name, skill_table.skill_name,  CASE WHEN (skill_table.skill_id = person_skill_table.skill_id AND             person_table.person_id = person_skill_table.person_id )              THEN "YES"              ELSE "NO"   END AS excist   FROM person_table   JOIN skill_table   JOIN person_skill_table   GROUP BY person_table.person_name, skill_table.skill_name  

My code produces this result:

| id       | person_name | skill_name  | excist |   | :------: | :----------:| :---------: | :-----:|  | 1        | user1       | skill1      |  YES     | 2        | user1       | skill2      |  NO     | 3        | user2       | skill1      |  NO      | 4        | user2       | skill2      |  NO      

How can I achieve this?

Any help would be greatly appreciated.

Fetching Cart Products from the Server According to ID - Node.Js/Mongodb/Express

Posted: 30 Jul 2021 08:32 AM PDT

I tried to fetched data(more than one) from mongo db database according to the id and it doesn't work. I'll be thankful to you If you can help me to fix that issue.

static fetchCart(itemArr){      const userCart = [...itemArr]      const db = getDb();      const fetchedCart = [];      for (var i=0; i<userCart.length; i++){        const item = userCart[i];        db.collection("products")        .findOne({ _id: new mogoDb.ObjectId(item.productId) })        .then((prod) => {          fetchedCart.push(prod);        })        .catch((err) => {          console.log(err);        });      }      return fetchedCart;    }  

The apk file made with buildozer does not start

Posted: 30 Jul 2021 08:32 AM PDT

Converting the main file.py in the apk using buildozer is successful, but for some reason my file does not run on the phone. Here is my import:

from kivy.app import App  from kivy.uix.boxlayout import BoxLayout  from kivy.uix.anchorlayout import AnchorLayout  from kivy.uix.floatlayout import FloatLayout  from kivy.lang import Builder  from kivy.uix.button import Button  from kivy.config import Config  from kivy.core.window import Window  from kivy.uix.image import Image  from kivy.uix.widget import Widget  from kivy.uix.label import Label  from kivy.uix.textinput import TextInput  from kivy.uix.progressbar import ProgressBar  from kivy.uix.image import AsyncImage  import requests  from bs4 import BeautifulSoup  import urllib.request  import string  import httplib2  import os  import os.path  import shutil  import itertools  import random  from pyaspeller import YandexSpeller  import threading  

As I read on the forums, the problem may be in beautifulsoup but I do not know how to solve this problem, please help me!

Here is my log: (https://i.stack.imgur.com/VyyXO.jpg)

How can I create a series of density contours in a row ( i.e. subplots)

Posted: 30 Jul 2021 08:32 AM PDT

I can create a density contour plot with

from astropy.table import Table, join  import numpy as np  import matplotlib.pyplot as plt  import seaborn as sns  import pandas as pd  from scipy import stats    # CLEAN Data  RErange = Table.read('../../GAMA_Data/REMassEClassEmeasure.fits')  RErange = RErange[RErange['SurfaceDensityFlag'] == 0]  #RErange = RErange[RErange['SurfaceDensity'] < 50]  RErange = RErange[RErange['AGEDenParFlag'] == 0]  RErange = RErange[RErange['CountInCylFlag'] == 0]  RErange = RErange[RErange['uminusr']> 0.001]    print(RErange.colnames)    yfield = 'uminusr'  xfield ='logmstar'    # set seaborn style  #sns.set_style("white")    df = RErange.to_pandas()  sns.displot(df, x='logmstar', y='uminusr', kind="kde")    plt.show()  

But how can I create a number of them ( 3 in in a line ) as per subplots? as seaborn displot does not seem to have an axis facility.

Solution does not have to use seaborn.

How to read the zsh shell variables

Posted: 30 Jul 2021 08:32 AM PDT

I am running my go program, from zsh. The program needs to read $fpath variables. But trying to read fpath on Os.Env, but it is returning empty string(ie. like the variable does not exist).

I am not sure why this should be happening since the variable is already available in the shell. What could be an explanation for this?

Also, any solutions to how can the above be accomplished within the go program?

R Function 'box::help()' Cannot Generate Help File: "Invalid Argument"

Posted: 30 Jul 2021 08:32 AM PDT

Motivation

My colleagues and I routinely create ad hoc scripts in R, to perform ETL on proprietary data and generate automated reports for clients. I am attempting to standardize our approach, for the sake of consistency, modularity, and reusability.

In particular, I want to consolidate our most commonly used functions in a central directory, and to access them as if they were functions from a proprietary R package. However, I am quite raw as an R developer, and my teammates are even less experienced in R development. As such, the development of a formal package is unfeasible for the moment.

Approach

Fortunately, the box package, by Stack Overflow's very own Konrad Rudolph, provides (among other modularity) an accessible approach to approximate the behavior of an R package. Unlike the rigorous development process outlined by the RStudio team, box requires only that one create a regular .R file, in a meaningful location, with roxygen2 documentation (#') and explicit @exports:

Writing modules

The module bio/seq, which we have used in the previous section, is implemented in the file bio/seq.r. The file seq.r is, by and large, a normal R source file, which happens to live in a directory named bio.

In fact, there are only three things worth mentioning:

  1. Documentation. Functions in the module file can be documented using 'roxygen2' syntax. It works the same as for packages. The 'box' package parses the
    documentation and makes it available via box::help. Displaying module help requires that 'roxygen2' is installed.

  2. Export declarations. Similar to packages, modules explicitly need to declare which names they export; they do this using the annotation comment #' @export in front of the name. Again, this works similarly to 'roxygen2' (but does not require having that package installed).

At the moment, I am tinkering around with a particular module, as "imported" into a script. While the "import" itself works seamlessly, I cannot seem to access the documentation for my functions.

Code

I am experimenting with box on a Lenovo ThinkPad running Windows 10. I have created a script, aptly titled Script.R, whose location serves as my working directory. My module exists in the relative subdirectory ./Resources/Modules as the humble file time.R, reproduced here:

###########################  ## Relative Date Windows ##  ###########################    #' @title Past Day of Week  #' @description Determine the date of the given weekday that fell a given number  #'   of weeks before the given date.  #' @param from \code{Date} object. The point of reference, from which we go  #'   backwards. Defaults to current \code{Sys.Date()}.  #' @param back \code{integer}. The number of weeks to go backward from the point  #'   of reference; negative values go forward. Defaults to \code{1}, for last  #'   week. Weeks begin on \code{"Monday"}.  #' @param weekday \code{character}. The weekday within the week targeted by  #'   \code{back}; one of \code{c("Monday", "Tuesday", "Wednesday", "Thursday",  #'   "Friday", "Saturday", "Sunday")}.  #' @export  #' @return The date of the \code{weekday} falling in the week \code{back} weeks  #'   prior to the week in which \code{from} falls. Defaults to \code{"Monday"}.  past_weekday <- function(from = Sys.Date(),                           back = 1,                           weekday = c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")                           ) {    cycle <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")        from <- as.Date(from)    back <- as.integer(back)        weekday_index <- (which(cycle == weekday[1]) - 1) %% 7        from_index <- (which(cycle == "Sunday") + as.POSIXlt(from)$wday - 1) %% 7        weekdate <- as.Date(from) - lubridate::days(from_index) - lubridate::weeks(as.numeric(back)) + lubridate::days(weekday_index)        return(as.Date(weekdate))  }    

Observe the roxygen2 documentation, as indicated by the special #' comments and @ tags. The documentation for past_weekday() is of far greater interest to me than the function itself.

Last and certainly least, here is reproduced Script.R itself:

# Set the working directory to the location of this very script.  setwd(this.path::this.dir())    # Access the functions in 'time.R' by relative location.  box::use(Resources/Modules/time)    # Run the function with its default values.  time$past_weekday()    # View the help page for the function.  box::help(time$past_weekday)  

In theory, that final line will display the documentation for past_weekday(), via box::help():

enter image description here

The box vignette gives a simple example to that effect:

We can also display the interactive help for individual names using the box::help function, e.g.:

 box::help(seq$revcomp)  

Problem

The first three lines of Script.R give me exactly what I desire. That is, they load time into R as an environment, from which I can access past_weekday() via time$past_weekday(). This module$function() syntax is analogous to the qualification of functions from formal packages: package::function(). Indeed, past_weekday() itself works just as expected:

time$past_weekday()  # [1] "2021-07-19"  

However, when I attempt to interactively access the documentation

box::help(time$past_weekday)  

the console displays the following warnings

Warning messages:  1: In utils::packageDescription(package, fields = "Version") :    no package 'PKG' was found  2: In file.create(to[okay]) :    cannot create file 'C:\Users\greg\AppData\Local\Temp\RtmpYBTTyG/.R/doc/html/module:Resources/Modules/time.html', reason 'Invalid argument'  

and the interactive help window is empty but for this error message:

enter image description here

For my team, this could prove a serious issue. Since we often rely on useful functions written by each other, it is crucial that any user on our team be able to easily access clear documentation by the author of the function...just as the user is accustomed to doing with formal R packages. Without this ability, the user must either bug the author for clarification, or blunder ahead without a clear understanding of the function's purpose and limitations.

Suspicions

When I read the warning

In file.create(to[okay]) :  cannot create file 'C:\Users\greg\AppData\Local\Temp\RtmpYBTTyG/.R/doc/html/module:Resources/Modules/time.html', reason 'Invalid argument'  

I was drawn to the filepath

C:\Users\greg\AppData\Local\Temp\RtmpYBTTyG/.R/doc/html/module:Resources/Modules/time.html  

as the cause for an Invalid argument to file.create(). To my knowledge, a directory name .../module:Resources/... containing a colon : is illegal on Windows and elsewhere.

Indeed, when I supply another illegal filepath ./illegal:directory:name/missing.txt to file.create()

file.create('./illegal:directory:name/missing.txt')  # [1] FALSE  

I get the same warning:

Warning message:  In file.create("./illegal:directory:name/missing.txt") :    cannot create file './illegal:directory:name/missing.txt', reason 'Invalid argument'  

The culprit appears to be this line in help.R:

display_help(doc, paste0('module:', mod_name), help_type)  #                               ^  #                             Here  

However, this seems far too simple a diagnosis. Frankly, I would be shocked to find so elementary an oversight within a package designed by a programmer as experienced as Konrad, who has almost 500K reputation on Stack Overflow.

What am I missing?


Update

I tried it on my Mac, and it actually worked! While I still got the first (rather odd) warning message on the console

Warning message:  In utils::packageDescription(package, fields = "Version") :    no package 'PKG' was found  

the interactive help window displays the intended documentation:

enter image description here

Naturally, this does not exactly solve my problem—the scripts will be executed on a VM running Windows, just like my Lenovo and every other computer used at my company. However, it does support the hypothesis that this issue is specific to box on Windows.

googlesheet script question about mapping specific range

Posted: 30 Jul 2021 08:32 AM PDT

I have this onEdit function that goes over the sheet, looks at the cell value under NAME column, finds its position in another cell under LIST column and outputs this position in the POSITION column. I am trying to find a way to limit this in a specific range, more specifically to exclude the 1st row (row 1) from this indexing, since if i add a row above the LIST, NAME and POSITION the function fails with TypeError: Cannot read property 'toString' of undefined.

Heres my function -

const ss = SpreadsheetApp.getActive();  const sh = ss.getSheetByName('sheet1');  const [hA, ...vs] = sh.getDataRange().getValues();     function onEdit() {        var r = ss.getActiveCell();      if( r.getColumn() > 7 ) {            let idx = {};      hA.forEach((h, i) => { idx[h] = i; });      let vO1 = vs.map((r, i) => {        var tes = [r[idx['LIST']].toString().split(',').indexOf( r[idx['NAME']] ) +1]        return (tes == 0) ? [''] : tes;      });      sh.getRange(2, idx['POSITION'] + 1, vO1.length, vO1[0].length).setValues(vO1);   }  }  

Cannot use ST_GeomFromGeoJSON even when JSON-C is installed

Posted: 30 Jul 2021 08:33 AM PDT

I have a Postgres database with the Postgis extension created on it.

I want to use the ST_GeomFromGeoJSON function. The docs state:

If you do not have JSON-C enabled, you will get an error notice instead of seeing an output. To enable JSON-C, run configure --with-jsondir=/path/to/json-c. See Section 2.2.3, "Build configuration" for details.

So I ensure that I have JSON-C installed and I configure Postgis with it...

# install json-c  curl -L --output /tmp/json-c.tar.gz https://s3.amazonaws.com/json-c_releases/releases/json-c-0.10-nodoc.tar.gz  tar -xvf /tmp/json-c.tar.gz -C /tmp/  mkdir -p /var/lib/include  cp -r /tmp/json-c-0.10 /var/lib/include/json-c    # install postgis  curl https://download.osgeo.org/postgis/source/postgis-3.0.3.tar.gz -o ./postgis-3.0.3.tar.gz \      && tar xvzf postgis-3.0.3.tar.gz    # configure postgis  cd /tmp/postgis-3.0.3  ./configure --without-raster --with-jsondir=/var/lib \      && make \      && make install    

then, I run the following in the database

postgres=# create extension postgis;  CREATE EXTENSION  postgres=# select ST_GeomFromGeoJSON('{"type": "Point", "coordinates": [0,0]}');  ERROR:  You need JSON-C for ST_GeomFromGeoJSON  

Why am I getting that error? I am including JSON-C when I am configure postgis, no? Am I missing something in my installation steps?

Postgres: 12.7

Postgis: 3.0.3

How can I mark a course as completed for a specific user in LearnDash? I want a function that will mark all lessons, topics, quizzes as complete

Posted: 30 Jul 2021 08:32 AM PDT

I found the "learndash_mark_complete" but it shows a button to complete. I want to complete it programatically for a few users in a few courses

Is it possible to verify Sliding text using appium

Posted: 30 Jul 2021 08:32 AM PDT

I've a sliding animation text as title. Now i want to verify if sliding animation is working and text is correct.

Tools is of course appium and device is android.

I searched but didn't get any answer. Note that, i can verify normal text using appium.

Autodetect IP address of Rhode and Schwarz oscilloscope

Posted: 30 Jul 2021 08:32 AM PDT

I'm trying to make a python code that will autodetect the IP address of Rhode and Schwarz oscilloscope or any test equipment that is connected to my laptop using Ethernet connection.

The IP address of R&S scope at my work place are always starting by the same two numbers 169.254.X.X but the trick is that the IP address of the scope appears in the arp -a report only when I access the scope using its IP address in my the browser. After that the IP shows up in arp report but before nothing the IP address isn't there.

So I wrote the following piece of code thinking it would work but it doesn't since the IP address is not shown before typing the IP address in URL bar of the browser. My goal is to determine the IP address of the scope just by clicking one button on my computer rather than tapping the touchscreen of the scope to find out what is the IP of the equipment.

import tkinter as tk  import time  import threading  import queue  import subprocess    root = tk.Tk()  root.title("SCPI test")  canvas1 = tk.Canvas(root, width=200, height=140, bg='lightsteelblue2', relief='raised')  canvas1.pack()    q1 = queue.Queue()  q2 = queue.Queue()      def auto_detect_ip(num1, num2, num3, num4):      ping_list = []      ping_ok_list = []      t1 = time.time()      for i in range(num1, num2, -1):          for j in range(num3, num4, -1):              temp = "169.254." + str(i) + "." + str(j)              # temp = "192.168.1.1"              try:                  p = subprocess.run(["ping", "-n", "1", temp], stdout=subprocess.PIPE, timeout=float(timeout_value))                  # p = subprocess.run(["ping", "-n", "1", temp], stdout=subprocess.PIPE, timeout=0.006)                  return_code = p.returncode                  print("return_code :", return_code)                  if return_code == 0:                      print("ip_address :", temp)                      ping_ok_list.append(temp)                      break              except subprocess.TimeoutExpired:                  pass              time.sleep(0.00001)          else:              continue          break      len_list_ping = len(ping_list)      print("len_list_ping :", len_list_ping)      print("ping_ok_list :", ping_ok_list)      t2 = time.time()      print("time :", t2 - t1)      if num4 == 0:          q1.put(ping_ok_list)      else:          q2.put(ping_ok_list)       def launch_thread():      print("scan running")      thread_1 = threading.Thread(target=auto_detect_ip, args=(254, 0, 128, 0))      thread_2 = threading.Thread(target=auto_detect_ip, args=(254, 0, 254, 128))      thread_1.setDaemon(True)      thread_2.setDaemon(True)      thread_1.start()      thread_2.start()      def found_rs_scope():      launch_thread()      ping_ok_list = q1.get() + q2.get      print("IP_list :", ping_ok_list)  

My solution was to scan each IP address to find the scope one but since the IP doesn't appear in the arp -a in the prompt before accessing the scope through the browser. So there is no match during the scan and the IP isn't found. I think it should be doable but I just don't know how to do it. Also I would like to be able to find the IP address of the scope without requiring admin rights.

Edit: I checked the port used by oscilloscope and it is 5025 as bfris mentioned in his answer. enter image description here

How can we keep watching a large log file and output the last 10 lines using node.js without using external package and tail -f?

Posted: 30 Jul 2021 08:32 AM PDT

I am having a large log file on my server and I want to keep watching that log file and get only last 10 lines of that log file without using the tail -f or any other packages which provides the same functionality as tail -f in unix.

We can do this by just traversing the log file from start and get last 10 lines but in case of large log file it will create a problem.

Let me know if there is any other alternatives ?

Thanks!

Cannot create the react app , found 1 low severity vulnerability

Posted: 30 Jul 2021 08:32 AM PDT

while creating app using box ** npx create-react-app my-app**, After that CMD is freezed, nothing is happened.even after waiting more than 30mins nothing happened.

Only node modules, package.json, package.lock.json is created.no others files created.

I'm using windows 10 64bit Node version 12.18.3 LTS NPM version 6.14.6

TIA

What's the point of <button type="button">?

Posted: 30 Jul 2021 08:33 AM PDT

Is <button type="button> any different from a simple <button> with a blank or missing type attribute? MDN and the HTML5 spec say that type=button is for buttons whose purpose is to trigger custom JavaScript, but isn't that also what a <button> does by default?

No comments:

Post a Comment