The reason the quarantine is lasting so long is because we have such an inexperienced president. Elect Biden to return back to normal?

The lock-downs, quarantines and deaths due to the virus is that it is a nasty virus and scientists, world organizations, experts and political leaders have been stumped from time to time in determining what is going on and how to respond. China created it, and they have not been forth-right is getting important information out. The WHO and CDC both have flubbed their responsibilities from time to time. World Leasers, state and local leaders have been playing politics and not listening to the ‘experts’ out there. And even the experts have made many mistakes about the virus. Biden would not have done any better. His mind is just not up to even simple daily tasks, let alone a large issue like this.

java – Return Http Response to the Main thread an start new activity (intent) using Loopj implementation

I am pretty new to Java programming.
I am doing a Http Request with Async using the implementation Loopj (com.loopj.android:android-async-http:1.4.9).

The OnSuccess and OnFailure of the AsyncHttpResponseHandler are working fine.

New I want to return the HttpRespone the Main thread and display it on a new Activity (intent).

I found the method „public void onPostProcessResponse“ but the description tells the following:
„Please note: post-processing does NOT run on the main thread, and thus any UI activities that you must perform should be properly dispatched to the app’s UI thread.“
(https://loopj.com/android-async-http/doc/com/loopj/android/http/AsyncHttpResponseHandler.html)

I really appreciate any help!!

Here is the code:

enter code herepackage com.example.myapplication;

enter code hereimport androidx.appcompat.app.AppCompatActivity;

enter code hereimport android.content.Intent;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.ResponseHandlerInterface;

import cz.msebera.android.httpclient.Header;
import cz.msebera.android.httpclient.HttpResponse;

    public class HttpRequest extends AppCompatActivity {

    private TextView eMail;
    private Button CallWebService;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_http_request);

        eMail = (TextView) findViewById(R.id.textView);
        CallWebService = (Button) findViewById(R.id.call_webservice);


        Intent get_Email = getIntent(); //
        String eMail_address = getIntent().getStringExtra("id_Email");
        eMail.setText(eMail_address);


        CallWebService.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            String url = "https://jsonplaceholder.typicode.com/posts/1"; //genutzte Bib:  implementation 'com.loopj.android:android-async-http:1.4.9'

            new AsyncHttpClient().get(url, new AsyncHttpResponseHandler() {
                @Override
                public void onSuccess(int statusCode, Header() headers, byte() responseBody) {
                    String urlResponse = new String(responseBody);
                    CallWebService.setText(urlResponse); 

                    //String currentString = urlResponse;
                    //String () separated =  currentString.split(",");
                    //CallWebService.setText(separated(1));


                }

                @Override
                public void onFailure(int statusCode, Header() headers, byte() responseBody, Throwable error) {
                    CallWebService.setText("Error"); //response Body: Enthält die Antwort der URL Abfrage in Byte -> Umwandlung in string nötig
                }
            });

            }
        });

    }


}

All the best,
Simon

sharepoint online – _api/search/query return 0 results always

I have a problem with my response i always getting 0 results.
Its happen not only in my api response, but also if i searching directly in sharepoint.
This is the api:

http://myweb/_api/search/query?selectproperties='Title'&querytext='n'&refinementfilters='fileExtension:or("docx","pdf","txt")'&startrow='0'&rowlimit='25'

scoping – How to return a variable name and value from within a self-contained function block?

Abstract: I have viewed other solutions on StackExchange but none actually address using a fully self-contained function to return name and value of a variable. The only function that works requires using SetAttributes(...) outside the function before using it: Display variable name instead of value

Goal: to create a completely self-contained function Block(...) or Module(...) that returns variable name and value without requiring using an outside function such as SetAttributes(...).

About the Code: Below is the code for four different attempts. The top two are globally scoped and work fine. Bottom two are written into a function block but do not work. The output is decorated with strings to give you an idea of how I intend to use it.

varname=123;

(* this works *)
Row({"Global Scope Defer: ","the name is ",Defer@varname," and value is -> ",varname})

(*this works *)
SetAttributes(ShowName,HoldAll);
ShowName(name_):=Row({"Global Scope SetAttributes HoldForm: ","the name is ",HoldForm@name," and value is -> ",ReleaseHold@name});
ShowName(varname)

(* this doesn't work *)
showDeferFunction(var_):=Block({pre,arrow},
pre="the name is ";
arrow=" and value is -> ";
Row({"Functional Scoping Defer: ",pre,Defer@var,arrow,var})
);
showDeferFunction(varname)

(* this doesn't work either *)
showHoldFormFunction(var_):=Block({pre,arrow},
pre="the name is ";
arrow=" and value is -> ";
SetAttributes(ShowName,HoldAll);
ShowName(name_):=Row({"Functional Scoping SetAttributes HoldForm: "pre,HoldForm@name,arrow,ReleaseHold@name});
ShowName(var)
);
showHoldFormFunction(varname)

The Output:

Global Scope Defer: the name is varname and value is -> 123
Global Scope SetAttributes HoldForm: the name is varname and value is -> 123
Functional Scoping Defer: the name is 123 and value is -> 123
Functional Scoping SetAttributes HoldForm: the name is 123 and value is -> 123

front end – Frontend/Backend Integration: Wait for a Google Cloud function to run and then return result

I am trying to create a tool that receives a user input on the front end, uses that input to run a Google Cloud function and then returns a link to the output, hosted on Google cloud as well.

How can you give updates that a process is being performed, and update the page when it is finished?

http functions – Should HTTPRequest return the same as curl in this case

The following shell script is used to access an IoT device that returns a JSON string, the content of which is not important for this question.

#!/bin/sh
secret= <not_telling>
id="e00fce688e6bcd0bad0763e7"
curl -k "https://api.particle.io/v1/devices/$id/peek" -d access_token=$<not_telling> -d args=5

I would like to reproduce this functionality in Mathematica

(* id and secret have been defined *)
req = HTTPRequest(
  "https://api.particle.io/v1/devices/" <> id <> "/peek",
  <|"Method" -> "POST", 
   "Query" -> {"args" -> "5", "access_token" -> secret}|>)
URLExecute@req

This code does successfully POST; however it behaves as if the “-d args=5” portion of the query is missing or ignored. I’m likely missing something trivial, but cannot place my finger on it.

wallet – Will my funds return?

It would be “back in your wallet”.

A transaction is basically an unlocking attempt of your funds (which succeeds if it ever confirms).

If your transaction doesn’t make it to a block before expiration this attempt will just have failed : you can at this point try to unlock it again by incentivizing the block generator a bit more (paying more fees).

algorithms – Given a list of integers and a target integer, return the number of triplets whose product is the target integer and two adjacent triplets

Let $n$ be the number of integers and $t$ be the target integer.
You can solve your problem in $O(n log n)$ time as follows:

For every $i=0, dots, n-1$, let $p = A(i) cdot A(i+1)$ and compute, in $O(log n)$ time, the number $eta(t/p)$ of integers in $A$ that are equal to $t/p$ (more on that later).
Then the number $gamma_i$ of triplets formed by $A(i)$, $A(i+1)$ and a non-adjacent element is $gamma_i = eta(t/p) – |{A(j)=t/p , : , i-1 le j le i+2 }|$.

It follows that the number of triplets of interest is $sum_{i=1}^{n-1} gamma_i$.

To find the values $eta(cdot)$ do a preprocessing in which you create a copy $B$ of $A$, sort $B$ in $O(n log n)$ time, and append an element with value $+infty$ to $B$ (this is just to avoid edge cases, $+infty$ can actually be any integer greater than $t$).

If $x notinmathbb{Z}$, $eta(x)=0$. Otherwise $eta(x)$ can be found in $O(log n)$ time by binary searching for the smallest indices $i$ and $j$ in $B$ such that $B(i)ge x$ and $B(j) > x$, respectively. Notice that $i$ and $j$ are always well defined and that $eta(x) = j-i$.

Testing function that return objects

My web app is built around classes that I call widgets. Their goal is to be reusable and modular, to suit different scenarios. For example, I have a widget called BreadcrumbWidget which has two functions:

  • addHome(): adds the “Home” breadcrumb.
  • addBreadcrumb($title, $url = null): adds any number of breadcrumbs.

I have this function in a separate class:

public function getBreadcrumbs()
{
    return (new BreadcrumWidget())
        ->addHome()
        ->addBreadcrumb($this->product->name); // The product's name is Foo
}

The above function returns a BreadcrumbWidget instance on which I can do ->toArray() and get the output:

(
    'widget_type' => 'breadcrumb',
    'list' => (
        (
            'text' => 'Home',
            'link' => '/some-link',
        ),
        (
            'text' => 'Foo',
            'link' => null,
        ),
    ),
)

I’m uncertain on how to best write tests for getBreadcrumbs(). I already have a test class for BreadcrumbWidget which checks that addHome and addBreadcrumb work as expected. For getBreadcrumbs() I’d need to test that the result contains the home and Foo breadcrumbs.

One possible approach would be to mock the BreadcrumbWidget class and define the following expectancies:

  1. addHome is called,
  2. addBreadcrumb is called with the string ‘Foo’.

Though this is currently not possible because BreadcrumbWidget is instantiated inside the function and presents a hard dependency. I’d probably need to have factories for all my widgets to enable such testing (and in getBreadcrumbs()‘s case inject the factory into the class where function is defined). Is this a common practice?

Another approach would be to compare the output of ->toArray() with an expected array.

What would be the better approach or does someone maybe know a better one?

** I’m using Mockery and I know about overload (see) which can mock hard dependencies, but I’d rather have a solution without it.

java – Return a 404 when a resource is not found in Spring Boot

I wrote this code in order to return a http status of not found to my users in case the resource is not present in the DB.

@RestController
public class ExampleController {

    public final ExampleService exampleService;

    @Autowired
    public ExampleController(ExampleService exampleService) {
        this.exampleService = exampleService;
    }

    @ResponseStatus(value = HttpStatus.NOT_FOUND)
    public class ResourceNotFoundException extends RuntimeException {
    }

    @GetMapping("/api/mappings/get-by-id/{id}")
    public ExampleDto getExampleById(@PathVariable String id) {
        Example example = exampleService.findById(id).orElse(null   );
        if (example == null) throw new ResourceNotFoundException();
        return new ExampleDto(example);
    }

}

I would like to know if this code can be considered good and robust enough or if it can be improved and how.