问:
getting null pointer exception for Bundle.getString while sending data from one fragment to another fragment
I am trying to send the data from one fragment to another using bundle but it is showing me this error:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference

// This is my signup fragment

```<code>public class signupFragment extends Fragment {

    private AutoCompleteTextView autoCompleteTextView;
    private EditText name,address,phone,alt_phone;
    private CountryCodePicker ccp;
    private ImageView user_dp;
    private Button signup_btn;
    private NavController navController;
    private Uri imageUri;

    public signupFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View layoutSignup= inflater.inflate(R.layout.fragment_signup, container, false);
        ((AppCompatActivity)getActivity()).getSupportActionBar().hide();
        return layoutSignup;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        autoCompleteTextView = view.findViewById(R.id.auto_signup);
        name = view.findViewById(R.id.name_signup);
        address = view.findViewById(R.id.address_signup);
        phone = view.findViewById(R.id.phone_signup);
        alt_phone = view.findViewById(R.id.alt_phone_signup);
        ccp = view.findViewById(R.id.ccp_signup);
        user_dp = view.findViewById(R.id.img_signup);
        signup_btn = view.findViewById(R.id.btn_signup);

        navController = Navigation.findNavController(view);

        ccp.registerCarrierNumberEditText(phone);

        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.user_type, R.layout.dropdown_register);
        autoCompleteTextView.setAdapter(adapter);

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

                Bundle bundle = new Bundle();
                bundle.putString("name",name.getText().toString());
                bundle.putString("phone",ccp.getFullNumberWithPlus().replace(" ",""));
                bundle.putString("user_type",autoCompleteTextView.getText().toString());
                bundle.putString("alt_phone",alt_phone.getText().toString());
                bundle.putString("address",address.getText().toString());
                bundle.putString("dp_url",user_dp.getResources().toString());

                otpFragment OtpFragment = new otpFragment();
                OtpFragment.setArguments(bundle);

               getFragmentManager().beginTransaction().replace(R.id.fragmentContainerView2,OtpFragment).commit();

                navController.navigate(R.id.action_signupFragment_to_otpFragment);
            }
        });

        user_dp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                setimage();
            }
        });

    }

    // This is to select the image from the mobile
    private void setimage() {

        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(intent,100);
    }

    // This is to set the image and to check if we got an image or not
    @Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if(requestCode==100 && data!=null && data.getData()!=null){

            imageUri = data.getData();
            user_dp.setImageURI(imageUri);

        }
    }

}
</code>```

// This is my otp fragment

```<code>public class otpFragment extends Fragment {

    private Button verify_otp_btn;
    private EditText edt_otp;
    private TextView resend_otp;
    private FirebaseAuth mAuth;
    private String dp_url="";
    private String name="";
    private String phoneNumber="";
    private String otpid="";
    private String user_type="";
    private String user_id="";
    private String alt_phone="";
    private String address="";
    private NavController navController;

    // firebase declaration
    private FirebaseFirestore firestore;

    public otpFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View layoutOtp= inflater.inflate(R.layout.fragment_otp, container, false);
        ((AppCompatActivity)getActivity()).getSupportActionBar().hide();
        return layoutOtp;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        verify_otp_btn= view.findViewById(R.id.verify_otp_btn);
        edt_otp= view.findViewById(R.id.code_otp);
        resend_otp=view.findViewById(R.id.resend_otp);

        navController= Navigation.findNavController(view);

        Bundle result;
        result = this.getArguments();

        name = result.getString("name");
            phoneNumber = result.getString("phone");
            user_type = result.getString("user_type");
            alt_phone = result.getString("alt_phone");
            address = result.getString("address");
            dp_url = result.getString("dp_url");

        Log.d("phone no",phoneNumber+" this is ");
        Log.d("phone no",name+" this is ");
        Log.d("phone no",user_type+" this is ");
        Log.d("phone no",alt_phone+" this is ");
        Log.d("phone no",address+" this is ");
        Log.d("phone no",dp_url+" this is ");

        verify_otp();

}
</code>```

Body:
I am trying to send the data from one fragment to another using bundle but it is showing me this error:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference

// This is my signup fragment

public class signupFragment extends Fragment {

    private AutoCompleteTextView autoCompleteTextView;
    private EditText name,address,phone,alt_phone;
    private CountryCodePicker ccp;
    private ImageView user_dp;
    private Button signup_btn;
    private NavController navController;
    private Uri imageUri;

    public signupFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View layoutSignup= inflater.inflate(R.layout.fragment_signup, container, false);
        ((AppCompatActivity)getActivity()).getSupportActionBar().hide();
        return layoutSignup;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        autoCompleteTextView = view.findViewById(R.id.auto_signup);
        name = view.findViewById(R.id.name_signup);
        address = view.findViewById(R.id.address_signup);
        phone = view.findViewById(R.id.phone_signup);
        alt_phone = view.findViewById(R.id.alt_phone_signup);
        ccp = view.findViewById(R.id.ccp_signup);
        user_dp = view.findViewById(R.id.img_signup);
        signup_btn = view.findViewById(R.id.btn_signup);

        navController = Navigation.findNavController(view);

        ccp.registerCarrierNumberEditText(phone);

        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.user_type, R.layout.dropdown_register);
        autoCompleteTextView.setAdapter(adapter);

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

                Bundle bundle = new Bundle();
                bundle.putString("name",name.getText().toString());
                bundle.putString("phone",ccp.getFullNumberWithPlus().replace(" ",""));
                bundle.putString("user_type",autoCompleteTextView.getText().toString());
                bundle.putString("alt_phone",alt_phone.getText().toString());
                bundle.putString("address",address.getText().toString());
                bundle.putString("dp_url",user_dp.getResources().toString());

                otpFragment OtpFragment = new otpFragment();
                OtpFragment.setArguments(bundle);

               getFragmentManager().beginTransaction().replace(R.id.fragmentContainerView2,OtpFragment).commit();

                navController.navigate(R.id.action_signupFragment_to_otpFragment);
            }
        });

        user_dp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                setimage();
            }
        });

    }

    // This is to select the image from the mobile
    private void setimage() {

        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(intent,100);
    }

    // This is to set the image and to check if we got an image or not
    @Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if(requestCode==100 && data!=null && data.getData()!=null){

            imageUri = data.getData();
            user_dp.setImageURI(imageUri);

        }
    }

}

// This is my otp fragment

public class otpFragment extends Fragment {

    private Button verify_otp_btn;
    private EditText edt_otp;
    private TextView resend_otp;
    private FirebaseAuth mAuth;
    private String dp_url="";
    private String name="";
    private String phoneNumber="";
    private String otpid="";
    private String user_type="";
    private String user_id="";
    private String alt_phone="";
    private String address="";
    private NavController navController;

    // firebase declaration
    private FirebaseFirestore firestore;

    public otpFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View layoutOtp= inflater.inflate(R.layout.fragment_otp, container, false);
        ((AppCompatActivity)getActivity()).getSupportActionBar().hide();
        return layoutOtp;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        verify_otp_btn= view.findViewById(R.id.verify_otp_btn);
        edt_otp= view.findViewById(R.id.code_otp);
        resend_otp=view.findViewById(R.id.resend_otp);

        navController= Navigation.findNavController(view);

        Bundle result;
        result = this.getArguments();

        name = result.getString("name");
            phoneNumber = result.getString("phone");
            user_type = result.getString("user_type");
            alt_phone = result.getString("alt_phone");
            address = result.getString("address");
            dp_url = result.getString("dp_url");

        Log.d("phone no",phoneNumber+" this is ");
        Log.d("phone no",name+" this is ");
        Log.d("phone no",user_type+" this is ");
        Log.d("phone no",alt_phone+" this is ");
        Log.d("phone no",address+" this is ");
        Log.d("phone no",dp_url+" this is ");

        verify_otp();

}


来源: stackexchange

问:
Firebase UpdateData failing with Nested Codable Types for SwiftUI
I am currently trying to update a firestorm doc using the following models in SwiftUI.

```<code>public struct Session: Codable {
    @DocumentID var id: String?
    var runs: [Run]
}

struct Run: Codable, Hashable{
    @DocumentID var id: String? = UUID().uuidString
    var thing: Thing
}

struct Thing: Hashable, Codable {
    @DocumentID var id: String?
    let thingName: String

}
</code>```

I am then trying to append to the list of runs in a firestorm Session doc like so:

```<code>func logRun(run: Run) {
        let sessionDocRef = Firestore.firestore().collection("sessions").document(self.sessionData.sessionId ?? "")
        do {
            try sessionDocRef.updateData([
                "runs": FieldValue.arrayUnion([run])
                            ])
        } catch {
            print(error)
        }
}
</code>```

However, this is giving the following issue. I have no issues posting the Run as its own document and it includes a Codable type (Thing). However, if I go up a level and try to update a Session which includes a Run which includes a Thing, then I hit this error. Any ideas?

```<code>Terminating app due to uncaught exception 'FIRInvalidArgumentException', reason: 'Unsupported type: __SwiftValue'```
```

ContentLicense: CC BY-SA 4.0

Body:
I am currently trying to update a firestorm doc using the following models in SwiftUI.

public struct Session: Codable {
    @DocumentID var id: String?
    var runs: [Run]
}

struct Run: Codable, Hashable{
    @DocumentID var id: String? = UUID().uuidString
    var thing: Thing
}

struct Thing: Hashable, Codable {
    @DocumentID var id: String?
    let thingName: String

}

I am then trying to append to the list of runs in a firestorm Session doc like so:

func logRun(run: Run) {
        let sessionDocRef = Firestore.firestore().collection("sessions").document(self.sessionData.sessionId ?? "")
        do {
            try sessionDocRef.updateData([
                "runs": FieldValue.arrayUnion([run])
                            ])
        } catch {
            print(error)
        }
}

However, this is giving the following issue. I have no issues posting the Run as its own document and it includes a Codable type (Thing). However, if I go up a level and try to update a Session which includes a Run which includes a Thing, then I hit this error. Any ideas?

Terminating app due to uncaught exception 'FIRInvalidArgumentException', reason: 'Unsupported type: __SwiftValue'```


问:
Set global variable value within a job in gitlab yml file
I have two jobs : first one is "test" and the second one is "push". test job is allowed to fail (allow_failure: true) I only wanna run the push job if the test job is success.

One option is to save the variable to a file and use it through artifact. But what I'm interested in is that is if there's a way achieving this without the file, like having global var and update the value in the test job if it's a success, but apparently modifying global variables from the job scope is not possible. Any suggestions?


问:
Why does this piecewise linear mixed model not produce equal estimates at the knot
I am wondering if someone could help me interpret my piecewise lmm results. Why does ggpredict() produce different estimates for the knot at 10 weeks (end of tx; see ‘0’ in graph at end)? I've structured the data like so:

```<code>bpiDat <- bpiDat %>%
        mutate(baseToEndTx = ifelse(week <= 10, week, 1)) %>%
        mutate(endOfTxToFu = case_when(
                week <= 10 ~ 0,
                week == 18 ~ 8,
                week == 26 ~ 16,
                week == 34 ~ 24
        )) %>%
        select(id, treatment, baseHamd, week, baseToEndTx, endOfTxToFu,
               painInterferenceMean, painSeverityMean, bpiTotal) %>%
        mutate(baseHamd = scale(baseHamd, scale=F))
</code>```

Which looks like this:

```<code>id treatment  baseHamd week baseToEndTx endOfTxToFu painSeverityMean
1 1 4.92529343  0   0   0   6.75
1 1 4.92529343  2   2   0   7.25
1 1 4.92529343  4   4   0   8.00
1 1 4.92529343  6   6   0   NA
1 1 4.92529343  8   8   0   8.25
1 1 4.92529343  10  10  0   8.00
1 1 4.92529343  18  1   8   8.25
1 1 4.92529343  26  1   16  8.25
1   4.92529343  34  1   24  8.00
</code>```

The best fitting model:

```<code>model8 <- lme(painSeverityMean ~ baseHamd + baseToEndTx*treatment + endOfTxToFu + I(endOfTxToFu^2)*treatment,
              data = bpiDat,
              method = "REML",
              na.action = "na.exclude",
              random = ~baseToEndTx | id)
</code>```

This is how I’m visualizing:

```<code>test1 <- ggpredict(model8, c("baseToEndTx", "treatment"), ci.lvl = NA) %>%
        mutate(x = x - 10) %>%
        mutate(phase = "duringTx")

test2 <- ggpredict(model8, c("endOfTxToFu", "treatment"), ci.lvl = NA) %>%
        mutate(phase = "followUp")

t <- rbind(test1, test2)

t <- t %>%
        pivot_wider(names_from = "phase",
                    values_from = "predicted")

ggplot(t) +
        geom_smooth(aes(x,duringTx,col=group),method="lm",se=FALSE) +
        geom_smooth(aes(x,followUp,col=group),method="lm",se=FALSE) +
        geom_point(aes(x,duringTx,col=group)) +
        geom_point(aes(x,followUp,col=group)) +
        ylim(2,6)
</code>```

Which produces this:
￼

Body:
I am wondering if someone could help me interpret my piecewise lmm results. Why does ggpredict() produce different estimates for the knot at 10 weeks (end of tx; see ‘0’ in graph at end)? I've structured the data like so:

bpiDat <- bpiDat %>%
        mutate(baseToEndTx = ifelse(week <= 10, week, 1)) %>%
        mutate(endOfTxToFu = case_when(
                week <= 10 ~ 0,
                week == 18 ~ 8,
                week == 26 ~ 16,
                week == 34 ~ 24
        )) %>%
        select(id, treatment, baseHamd, week, baseToEndTx, endOfTxToFu,
               painInterferenceMean, painSeverityMean, bpiTotal) %>%
        mutate(baseHamd = scale(baseHamd, scale=F))

Which looks like this:

id treatment  baseHamd week baseToEndTx endOfTxToFu painSeverityMean
1 1 4.92529343  0   0   0   6.75
1 1 4.92529343  2   2   0   7.25
1 1 4.92529343  4   4   0   8.00
1 1 4.92529343  6   6   0   NA
1 1 4.92529343  8   8   0   8.25
1 1 4.92529343  10  10  0   8.00
1 1 4.92529343  18  1   8   8.25
1 1 4.92529343  26  1   16  8.25
1   4.92529343  34  1   24  8.00

The best fitting model:

model8 <- lme(painSeverityMean ~ baseHamd + baseToEndTx*treatment + endOfTxToFu + I(endOfTxToFu^2)*treatment,
              data = bpiDat,
              method = "REML",
              na.action = "na.exclude",
              random = ~baseToEndTx | id)

This is how I’m visualizing:

test1 <- ggpredict(model8, c("baseToEndTx", "treatment"), ci.lvl = NA) %>%
        mutate(x = x - 10) %>%
        mutate(phase = "duringTx")

test2 <- ggpredict(model8, c("endOfTxToFu", "treatment"), ci.lvl = NA) %>%
        mutate(phase = "followUp")

t <- rbind(test1, test2)

t <- t %>%
        pivot_wider(names_from = "phase",
                    values_from = "predicted")

ggplot(t) +
        geom_smooth(aes(x,duringTx,col=group),method="lm",se=FALSE) +
        geom_smooth(aes(x,followUp,col=group),method="lm",se=FALSE) +
        geom_point(aes(x,duringTx,col=group)) +
        geom_point(aes(x,followUp,col=group)) +
        ylim(2,6)

Which produces this:
￼


问:
When using Rcpp, I get "error: no viable overloaded '='. How can I resolve this?
I am using Rcpp, and I'm struggling to resolve the "error: no viable overloaded '='. I believe that I'm using the correct set-up, where I load the R package mvtnorm, which contains the rmvnorm function.

R script:

```<code>library(mvtnorm)
Rcpp::sourceCpp("algorithm.cpp")
</code>```

algorithm.cpp:

```<code>// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
#include <RcppArmadilloExtensions/sample.h>

using namespace Rcpp;
using namespace arma;

arma::colvec algorithm() {

Environment myEnv = Environment::global_env();
Rcpp::Function rmvnorm = myEnv["rmvnorm"];

int p = 3;
arma::colvec test = arma::zeros(p);
test = rmvnorm(1, arma::zeros(p), arma::eye(p, p));

return test;
}
</code>```

Error from VSCode:

```<code>error: no viable overloaded '='
test = rmvnorm(1, arma::zeros(p), arma::eye(p, p));
</code>```

Then, I get the aforementioned error. I am found numerous posts that describe the same error, but none of the proposed solutions seem applicable; moreover, this error appears to be thrown for many reasons.

I tried the code provided in my post. I also referenced this article, which did not resolve my issue.

Body:
I am using Rcpp, and I'm struggling to resolve the "error: no viable overloaded '='. I believe that I'm using the correct set-up, where I load the R package mvtnorm, which contains the rmvnorm function.

R script:

library(mvtnorm)
Rcpp::sourceCpp("algorithm.cpp")

algorithm.cpp:

// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
#include <RcppArmadilloExtensions/sample.h>

using namespace Rcpp;
using namespace arma;

arma::colvec algorithm() {

Environment myEnv = Environment::global_env();
Rcpp::Function rmvnorm = myEnv["rmvnorm"];

int p = 3;
arma::colvec test = arma::zeros(p);
test = rmvnorm(1, arma::zeros(p), arma::eye(p, p));

return test;
}

Error from VSCode:

error: no viable overloaded '='
test = rmvnorm(1, arma::zeros(p), arma::eye(p, p));

Then, I get the aforementioned error. I am found numerous posts that describe the same error, but none of the proposed solutions seem applicable; moreover, this error appears to be thrown for many reasons.

I tried the code provided in my post. I also referenced this article, which did not resolve my issue.


问:
Sort by filter category by discount magento 2
I need to include in the magento 2 filter in the category page, which validates the discounted products in the ASC order.

I managed to do a "where" the problem but it changes the condition of the previous select

should i do some merge?
if so then i also need those with discounts with those in the merge not to be duplicated

Any idea?

```<code><?php
namespace Dizy\Sorting\Plugin\Product\ProductList;

class Toolbar
{
    /**
    * Plugin
    *
    * @param \Magento\Catalog\Block\Product\ProductList\Toolbar $subject
    * @param \Closure $proceed
    * @param \Magento\Framework\Data\Collection $collection
    * @return \Magento\Catalog\Block\Product\ProductList\Toolbar
    */
    public function aroundSetCollection(
        \Magento\Catalog\Block\Product\ProductList\Toolbar $toolbar,
        \Closure $proceed,
        $collection
    ) {
        $this->_collection = $collection;
        $currentOrder = $toolbar->getCurrentOrder();
        $currentDirection = $toolbar->getCurrentDirection();
        $result = $proceed($collection);

        if ($currentOrder) {
            switch ($currentOrder) {
            case 'discount':
                $nmaxmumDiscountPercentage = 100;
                $nMinimumDiscountPercentage = 0;
                $this->_collection->getSelect()->where('ROUND(((price_index.price - price_index.final_price)/price_index.price)*100,0) <= '.$nmaxmumDiscountPercentage)->where( 'ROUND(((price_index.price - price_index.final_price)/price_index.price)*100,0) >= '.$nMinimumDiscountPercentage);
            break;
</code>```

help

I tried to make some filters, join and even get out of the select idea

I found something that could be a close solution but I couldn't put it

```<code>$products->getSelect()->order('(`e`.special_price / `e`.`price`)', 'DESC');
</code>```

Body:
I need to include in the magento 2 filter in the category page, which validates the discounted products in the ASC order.

I managed to do a "where" the problem but it changes the condition of the previous select

should i do some merge?
if so then i also need those with discounts with those in the merge not to be duplicated

Any idea?

<?php
namespace Dizy\Sorting\Plugin\Product\ProductList;

class Toolbar
{
    /**
    * Plugin
    *
    * @param \Magento\Catalog\Block\Product\ProductList\Toolbar $subject
    * @param \Closure $proceed
    * @param \Magento\Framework\Data\Collection $collection
    * @return \Magento\Catalog\Block\Product\ProductList\Toolbar
    */
    public function aroundSetCollection(
        \Magento\Catalog\Block\Product\ProductList\Toolbar $toolbar,
        \Closure $proceed,
        $collection
    ) {
        $this->_collection = $collection;
        $currentOrder = $toolbar->getCurrentOrder();
        $currentDirection = $toolbar->getCurrentDirection();
        $result = $proceed($collection);

        if ($currentOrder) {
            switch ($currentOrder) {
            case 'discount':
                $nmaxmumDiscountPercentage = 100;
                $nMinimumDiscountPercentage = 0;
                $this->_collection->getSelect()->where('ROUND(((price_index.price - price_index.final_price)/price_index.price)*100,0) <= '.$nmaxmumDiscountPercentage)->where( 'ROUND(((price_index.price - price_index.final_price)/price_index.price)*100,0) >= '.$nMinimumDiscountPercentage);
            break;

help

I tried to make some filters, join and even get out of the select idea

I found something that could be a close solution but I couldn't put it

$products->getSelect()->order('(`e`.special_price / `e`.`price`)', 'DESC');


问:
Why is the error produced: `form` must be a single form produced by html_form()?
The following code produces the error: form must be a single form produced by html_form()

Why is this?

```<code>library(rvest)

account <- session("https://www.familytreedna.com/Areas/Main/Apps/SignIn/sign-in.component.html")

login = account %>% html_node("form[name=userInfoForm]") %>% html_form() %>%
  html_form_set(
    kitNumber = "******",
    password  = "******"
  )

account = account %>% html_form_submit(login)

</code>```

I can send the form in the way as shown below, but then the last line produces the error x must be produced by session() and it's not possible to jump to other urls when logged in.

What I am doing wrong?

```<code>login$action="https://www.familytreedna.com/Areas/Main/Apps/SignIn/sign-in.component.html"
logged_in=html_form_submit(login)

logged_in  %>% session_jump_to("https://www.familytreedna.com/groups/germany/activity-feed")

</code>```

I tried this, but the login isn't successful:

```<code>library(rvest)

account = session("https://www.familytreedna.com/sign-in")

login = httr::GET("https://www.familytreedna.com/Areas/Main/Apps/SignIn/sign-in.component.html") %>% read_html() %>% html_node("form[name=userInfoForm]") %>% html_form() %>%
              html_form_set(
                kitNumber = "******",
                password = "******"
              )

            login$action="https://www.familytreedna.com/Areas/Main/Apps/SignIn/sign-in.component.html"

res = session_submit(account, login)
</code>```

Body:
The following code produces the error: form must be a single form produced by html_form()

Why is this?

library(rvest)

account <- session("https://www.familytreedna.com/Areas/Main/Apps/SignIn/sign-in.component.html")

login = account %>% html_node("form[name=userInfoForm]") %>% html_form() %>%
  html_form_set(
    kitNumber = "******",
    password  = "******"
  )

account = account %>% html_form_submit(login)

I can send the form in the way as shown below, but then the last line produces the error x must be produced by session() and it's not possible to jump to other urls when logged in.

What I am doing wrong?

login$action="https://www.familytreedna.com/Areas/Main/Apps/SignIn/sign-in.component.html"
logged_in=html_form_submit(login)

logged_in  %>% session_jump_to("https://www.familytreedna.com/groups/germany/activity-feed")

I tried this, but the login isn't successful:

library(rvest)

account = session("https://www.familytreedna.com/sign-in")

login = httr::GET("https://www.familytreedna.com/Areas/Main/Apps/SignIn/sign-in.component.html") %>% read_html() %>% html_node("form[name=userInfoForm]") %>% html_form() %>%
              html_form_set(
                kitNumber = "******",
                password = "******"
              )

            login$action="https://www.familytreedna.com/Areas/Main/Apps/SignIn/sign-in.component.html"

res = session_submit(account, login)


问:
PencilKit doesnt change
When I try to change color or tool nothing happens and it still drawing with deafult black pen.

class ViewController: UIViewController {

```<code>@IBOutlet weak var canvasView: PKCanvasView!

override func viewDidLoad() {
    super.viewDidLoad()
}

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    setupCanvasView()
}

private func setupCanvasView() {
    canvasView.drawingPolicy = .anyInput
   let toolPicker = PKToolPicker()
        toolPicker.setVisible(true, forFirstResponder: canvasView)
        toolPicker.addObserver(canvasView)
        canvasView.becomeFirstResponder()

}
</code>```

}
Can't fix this problem. What should I do?

Title: PencilKit doesnt change

Body:
When I try to change color or tool nothing happens and it still drawing with deafult black pen.

class ViewController: UIViewController {

@IBOutlet weak var canvasView: PKCanvasView!

override func viewDidLoad() {
    super.viewDidLoad()
}

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    setupCanvasView()
}

private func setupCanvasView() {
    canvasView.drawingPolicy = .anyInput
   let toolPicker = PKToolPicker()
        toolPicker.setVisible(true, forFirstResponder: canvasView)
        toolPicker.addObserver(canvasView)
        canvasView.becomeFirstResponder()

}

}
Can't fix this problem. What should I do?


问:
Gradle Build Failed. Gradle can't see resources
When I try to build the project I get the following error:

```<code>FAILURE: Build failed with an exception.

* What went wrong:

A problem occurred configuring project ':launcher'.

> Could not resolve all artifacts for configuration ':launcher:classpath'.

   > Could not resolve com.android.tools.build:gradle:4.0.1.

     Required by:

         project :launcher

      > Could not resolve com.android.tools.build:gradle:4.0.1.

         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'.

            > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'.

               > dl.google.com

      > Could not resolve com.android.tools.build:gradle:4.0.1.

         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'.

            > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'.

               > jcenter.bintray.com

* Try:

Run with —stacktrace option to get the stack trace. Run with —info or —debug option to get more log output. Run with —scan to get full insights.

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

BUILD FAILED in 2s

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
</code>```

I am using Unity 2021.3.16f1

I have tried different ways to solve the problem. I even resorted to formatting the device, but without result

Body:
When I try to build the project I get the following error:

FAILURE: Build failed with an exception.

* What went wrong:

A problem occurred configuring project ':launcher'.

> Could not resolve all artifacts for configuration ':launcher:classpath'.

   > Could not resolve com.android.tools.build:gradle:4.0.1.

     Required by:

         project :launcher

      > Could not resolve com.android.tools.build:gradle:4.0.1.

         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'.

            > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'.

               > dl.google.com

      > Could not resolve com.android.tools.build:gradle:4.0.1.

         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'.

            > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'.

               > jcenter.bintray.com

* Try:

Run with —stacktrace option to get the stack trace. Run with —info or —debug option to get more log output. Run with —scan to get full insights.

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

BUILD FAILED in 2s

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

I am using Unity 2021.3.16f1

I have tried different ways to solve the problem. I even resorted to formatting the device, but without result


问:
How to solve this multiple nested for loop
EDIT: Big edit from ealier

I have achieved: the ultimate for-loop HELL.

What it does: scans an image and finds a 40 by 40 pixel square that has every pixel within it approximately the same color.

The problem: The code doesn't work as intended. Unsure why, but all my attempts to debug are in vain.

```<code>    jimp.read('jeffrey.png')
          .then(image => {
            console.log(jimp.intToRGBA(image.getPixelColor(0,0)))
            console.log(image.bitmap.width)
            console.log(image.bitmap.height)

                            var breakAll = false;
            var FINALX;
            var FINALY;
var doneCounter = 0;
            //40 by 40 pixels needed for qr code. Thisis barcode, so make it 40 by 80 or smthn, figure out that x thing.
            for(var x = 0; x < image.bitmap.width; x++) {
              var breakThis = false;
              console.log(x + " is x")
              if(breakAll == true) {
                    break;
                  }

              var verticalStart = 0;
              for(var y1 = verticalStart; y1 < image.bitmap.height; y1++) {
                if(breakAll == true) {
                    break;
                  }

                var tempStandardR = jimp.intToRGBA(image.getPixelColor(x,y1)).r;
                var tempStandardG = jimp.intToRGBA(image.getPixelColor(x,y1)).g;
                var tempStandardB = jimp.intToRGBA(image.getPixelColor(x,y1)).b;

                var verticalCounter = 0;

                for(var y2 = y1; y2 < image.bitmap.height; y2++) {
                  if(breakAll == true) {
                    break;
                  }
                  if(verticalCounter >= 40) {

                      //Then do X stuff
                      //horizcountertim

                      for(var y3 = y1; y3 < y1 + 40; y3++) {
                        if(breakAll == true) {
                          break;
                        }
                        breakThis = false;
                        var horizontalCounter = 0;
                        var tempStandardR3 = jimp.intToRGBA(image.getPixelColor(x,y3)).r;
                        var tempStandardG3 = jimp.intToRGBA(image.getPixelColor(x,y3)).g;
                        var tempStandardB3 = jimp.intToRGBA(image.getPixelColor(x,y3)).b;
                        for(var x2 = x; x2 < x + 41; x2++) {

                          if(breakAll == true) {
                            break;
                          }
                          console.log(doneCounter)
                           if(doneCounter >= 40) {
                              //SUCESS!!!!!!
                              //THE SPOT HAS BEEN FOUND AT (x minus 40, y minus 40).
                              //insert other image in this image at above coordinates. Wow I highly doubt this works.
                              console.log('SUCESS!!!!!!!!!')
                              FINALX = x2-40;
                              FINALY = y3-40;
                              breakAll = true;
                              break;
                            }
                           if(breakAll == true) {
                            break;
                          }
                          var tempStandardR4 = jimp.intToRGBA(image.getPixelColor(x2,y3)).r;
                          var tempStandardG4 = jimp.intToRGBA(image.getPixelColor(x2,y3)).g;
                          var tempStandardB4 = jimp.intToRGBA(image.getPixelColor(x2,y3)).b;
                          if((((tempStandardR3 - tempStandardR4) <= 20) && ((tempStandardR3 - tempStandardR4) >= -20)) && (((tempStandardG3 - tempStandardG4) <= 20) && ((tempStandardG3 - tempStandardG4) >= -20)) && (((tempStandardB3 - tempStandardB4) <= 20) && ((tempStandardB3 - tempStandardB4) >= -20))) {
                            horizontalCounter++;
                            if(horizontalCounter == 40) {
                              horizontalCounter = 0;
                              doneCounter++;
                              break;
                            }

                           // if((x2 - x >= 39) && (y3 - y1) >= 39) {

                            if(breakAll == true) {
                              break;
                            }
                          }
                          else {
                            horizontalCounter = 0;
                            verticalCounter = 0;
                            doneCounter = 0;
                            console.log('donecounter reset')
                            verticalStart = y3;
                            //y2 = y3;
                            breakThis = true;
                            break;
                          }
                        }
                        if(breakAll == true) {
                          break;
                        }
                        if(breakThis = true) {
                          break;
                        }

                      }
                    if(breakThis = true) {
                      breakThis = false;
                      break;
                    }
                  }
                  if(breakAll == true) {
                    break;
                  }
                   var tempStandardR2 = jimp.intToRGBA(image.getPixelColor(x,y2)).r;
                  var tempStandardG2 = jimp.intToRGBA(image.getPixelColor(x,y2)).g;
                  var tempStandardB2 = jimp.intToRGBA(image.getPixelColor(x,y2)).b;
                  if((((tempStandardR - tempStandardR2) <= 20) && ((tempStandardR - tempStandardR2) >= -20)) && (((tempStandardG - tempStandardG2) <= 20) && ((tempStandardG - tempStandardG2) >= -20)) && (((tempStandardB - tempStandardB2) <= 20) && ((tempStandardB - tempStandardB2) >= -20))) {
                    verticalCounter++;
                  }
                  else {
                    verticalCounter = 0;
                    verticalStart = y2;
                    console.log('lvl1 reset')
                    doneCounter = 0;
                    break;
                  }

                }
              }
            }
            console.log(' done');
            console.log(FINALX + " = x")
            console.log(FINALY + " = y")
          })
          .catch(err => {
            console.log(err);
          })
</code>```

Each of the tempStandards are the RGB value for that individual pixel.
All of the for loops are to get a 40 by 40 open grid.

The issue I do see is a problem, but am baffled as to why, is doneCounter, that is supposed to ++ every time a horizontal counter has reached 40 and thus finished its horizontal check of one row of the 40 by 40 grid.

The issue when console logging doneCounter is, it console logs the same value twice, which makes no sense since its within the same for loop that has an if else statement that either adds to donecounter or resets it to 0.

EDIT: I scrapped the above code to try and remake it entirely to see if that would let it work, still failed though and not a clue as to why: Below is the updated attempt:

```<code>jimp.read('jeffrey.png')
          .then(image => {

            console.log(jimp.intToRGBA(image.getPixelColor(0,0)))
            console.log(image.bitmap.width)
            console.log(image.bitmap.height)
            var breakAll = false;
            var FINALX;
            var FINALY;
            var doneCounter = 0;
            var veritcalCounter = 0;
            var verticalStart = 0;
            var horizontalCounter = 0;
            var breakAll = false;
            var breakThis = false;
            //40 by 40 pixels needed for qr code. Thisis barcode, so make it 40 by 80 or smthn, figure out that x thing.
            for(var x = 0; x < image.bitmap.width; x++) {
              console.log(x)
              verticalCounter = 0;
              for(var y = 0; y < image.bitmap.height; y++) {
                var tempStandardR = jimp.intToRGBA(image.getPixelColor(x,verticalStart)).r;
                var tempStandardG = jimp.intToRGBA(image.getPixelColor(x,verticalStart)).g;
                var tempStandardB = jimp.intToRGBA(image.getPixelColor(x,verticalStart)).b;
                var tempStandardR2 = jimp.intToRGBA(image.getPixelColor(x,y)).r;
                var tempStandardG2 = jimp.intToRGBA(image.getPixelColor(x,y)).g;
                var tempStandardB2 = jimp.intToRGBA(image.getPixelColor(x,y)).b;
                if((((tempStandardR - tempStandardR2) <= 20) && ((tempStandardR - tempStandardR2) >= -20)) && (((tempStandardG - tempStandardG2) <= 20) && ((tempStandardG - tempStandardG2) >= -20)) && (((tempStandardB - tempStandardB2) <= 20) && ((tempStandardB - tempStandardB2) >= -20))) {
                  verticalCounter++;
                  if(verticalCounter == 40) {
                    verticalCounter = 0;
                    for(var y1 = y-40; y1 < y; y1++) {
                      horizontalCounter = 0;
                      for(var x1 = x; x1 < x+41; x1++) {
                        var tempStandardR3 = jimp.intToRGBA(image.getPixelColor(x,y1)).r;
                        var tempStandardG3 = jimp.intToRGBA(image.getPixelColor(x,y1)).g;
                        var tempStandardB3 = jimp.intToRGBA(image.getPixelColor(x1,y1)).b;
                        var tempStandardR4 = jimp.intToRGBA(image.getPixelColor(x1,y1)).r;
                        var tempStandardG4 = jimp.intToRGBA(image.getPixelColor(x1,y1)).g;
                        var tempStandardB4 = jimp.intToRGBA(image.getPixelColor(x1,y1)).b;
                        if((((tempStandardR3 - tempStandardR4) <= 20) && ((tempStandardR3 - tempStandardR4) >= -20)) && (((tempStandardG3 - tempStandardG4) <= 20) && ((tempStandardG3 - tempStandardG4) >= -20)) && (((tempStandardB3 - tempStandardB4) <= 20) && ((tempStandardB3 - tempStandardB4) >= -20))) {
                          if(x1 == x+40) {
                            doneCounter++;
                            if(doneCounter == 39) {
                              //SUCESS!!!!!!
                              //THE SPOT HAS BEEN FOUND AT (x minus 40, y minus 40).
                              //insert other image in this image at above coordinates. Wow I highly doubt this works.
                              console.log('SUCESS!!!!!!!!!')
                              FINALX = x;
                              FINALY = y1-40;
                              breakAll = true;
                              break;
                            }
                            break;
                          }
                        }
                        else {
                          verticalCounter = 0;
                          horizontalCounter = 0;
                          doneCounter = 0;
                          y = y1;
                          breakThis = true;
                          break;
                        }
                        if(breakAll == true) {
                          break;
                        }
                      }
                      if(breakThis == true) {
                        breakThis = false;
                        break;
                      }
                      if(breakAll == true) {
                        break;
                      }
                    }
                    if(breakAll == true) {
                      break;
                    }
                  }
                  if(breakAll == true) {
                    break;
                  }
                }
                else {
                  verticalCounter = 0;
                  verticalStart = 0;
                }
                if(breakAll == true) {
                  break;
                }
              }
              if(breakAll == true) {
                break;
              }
            }
            console.log(' done');
            console.log(FINALX + " = x")
            console.log(FINALY + " = y")
          })
          .catch(err => {
            console.log(err);
          })
</code>```

Body:
EDIT: Big edit from ealier

I have achieved: the ultimate for-loop HELL.

What it does: scans an image and finds a 40 by 40 pixel square that has every pixel within it approximately the same color.

The problem: The code doesn't work as intended. Unsure why, but all my attempts to debug are in vain.

    jimp.read('jeffrey.png')
          .then(image => {
            console.log(jimp.intToRGBA(image.getPixelColor(0,0)))
            console.log(image.bitmap.width)
            console.log(image.bitmap.height)

                            var breakAll = false;
            var FINALX;
            var FINALY;
var doneCounter = 0;
            //40 by 40 pixels needed for qr code. Thisis barcode, so make it 40 by 80 or smthn, figure out that x thing.
            for(var x = 0; x < image.bitmap.width; x++) {
              var breakThis = false;
              console.log(x + " is x")
              if(breakAll == true) {
                    break;
                  }

              var verticalStart = 0;
              for(var y1 = verticalStart; y1 < image.bitmap.height; y1++) {
                if(breakAll == true) {
                    break;
                  }

                var tempStandardR = jimp.intToRGBA(image.getPixelColor(x,y1)).r;
                var tempStandardG = jimp.intToRGBA(image.getPixelColor(x,y1)).g;
                var tempStandardB = jimp.intToRGBA(image.getPixelColor(x,y1)).b;

                var verticalCounter = 0;

                for(var y2 = y1; y2 < image.bitmap.height; y2++) {
                  if(breakAll == true) {
                    break;
                  }
                  if(verticalCounter >= 40) {

                      //Then do X stuff
                      //horizcountertim

                      for(var y3 = y1; y3 < y1 + 40; y3++) {
                        if(breakAll == true) {
                          break;
                        }
                        breakThis = false;
                        var horizontalCounter = 0;
                        var tempStandardR3 = jimp.intToRGBA(image.getPixelColor(x,y3)).r;
                        var tempStandardG3 = jimp.intToRGBA(image.getPixelColor(x,y3)).g;
                        var tempStandardB3 = jimp.intToRGBA(image.getPixelColor(x,y3)).b;
                        for(var x2 = x; x2 < x + 41; x2++) {

                          if(breakAll == true) {
                            break;
                          }
                          console.log(doneCounter)
                           if(doneCounter >= 40) {
                              //SUCESS!!!!!!
                              //THE SPOT HAS BEEN FOUND AT (x minus 40, y minus 40).
                              //insert other image in this image at above coordinates. Wow I highly doubt this works.
                              console.log('SUCESS!!!!!!!!!')
                              FINALX = x2-40;
                              FINALY = y3-40;
                              breakAll = true;
                              break;
                            }
                           if(breakAll == true) {
                            break;
                          }
                          var tempStandardR4 = jimp.intToRGBA(image.getPixelColor(x2,y3)).r;
                          var tempStandardG4 = jimp.intToRGBA(image.getPixelColor(x2,y3)).g;
                          var tempStandardB4 = jimp.intToRGBA(image.getPixelColor(x2,y3)).b;
                          if((((tempStandardR3 - tempStandardR4) <= 20) && ((tempStandardR3 - tempStandardR4) >= -20)) && (((tempStandardG3 - tempStandardG4) <= 20) && ((tempStandardG3 - tempStandardG4) >= -20)) && (((tempStandardB3 - tempStandardB4) <= 20) && ((tempStandardB3 - tempStandardB4) >= -20))) {
                            horizontalCounter++;
                            if(horizontalCounter == 40) {
                              horizontalCounter = 0;
                              doneCounter++;
                              break;
                            }

                           // if((x2 - x >= 39) && (y3 - y1) >= 39) {

                            if(breakAll == true) {
                              break;
                            }
                          }
                          else {
                            horizontalCounter = 0;
                            verticalCounter = 0;
                            doneCounter = 0;
                            console.log('donecounter reset')
                            verticalStart = y3;
                            //y2 = y3;
                            breakThis = true;
                            break;
                          }
                        }
                        if(breakAll == true) {
                          break;
                        }
                        if(breakThis = true) {
                          break;
                        }

                      }
                    if(breakThis = true) {
                      breakThis = false;
                      break;
                    }
                  }
                  if(breakAll == true) {
                    break;
                  }
                   var tempStandardR2 = jimp.intToRGBA(image.getPixelColor(x,y2)).r;
                  var tempStandardG2 = jimp.intToRGBA(image.getPixelColor(x,y2)).g;
                  var tempStandardB2 = jimp.intToRGBA(image.getPixelColor(x,y2)).b;
                  if((((tempStandardR - tempStandardR2) <= 20) && ((tempStandardR - tempStandardR2) >= -20)) && (((tempStandardG - tempStandardG2) <= 20) && ((tempStandardG - tempStandardG2) >= -20)) && (((tempStandardB - tempStandardB2) <= 20) && ((tempStandardB - tempStandardB2) >= -20))) {
                    verticalCounter++;
                  }
                  else {
                    verticalCounter = 0;
                    verticalStart = y2;
                    console.log('lvl1 reset')
                    doneCounter = 0;
                    break;
                  }

                }
              }
            }
            console.log(' done');
            console.log(FINALX + " = x")
            console.log(FINALY + " = y")
          })
          .catch(err => {
            console.log(err);
          })

Each of the tempStandards are the RGB value for that individual pixel.
All of the for loops are to get a 40 by 40 open grid.

The issue I do see is a problem, but am baffled as to why, is doneCounter, that is supposed to ++ every time a horizontal counter has reached 40 and thus finished its horizontal check of one row of the 40 by 40 grid.

The issue when console logging doneCounter is, it console logs the same value twice, which makes no sense since its within the same for loop that has an if else statement that either adds to donecounter or resets it to 0.

EDIT: I scrapped the above code to try and remake it entirely to see if that would let it work, still failed though and not a clue as to why: Below is the updated attempt:

jimp.read('jeffrey.png')
          .then(image => {

            console.log(jimp.intToRGBA(image.getPixelColor(0,0)))
            console.log(image.bitmap.width)
            console.log(image.bitmap.height)
            var breakAll = false;
            var FINALX;
            var FINALY;
            var doneCounter = 0;
            var veritcalCounter = 0;
            var verticalStart = 0;
            var horizontalCounter = 0;
            var breakAll = false;
            var breakThis = false;
            //40 by 40 pixels needed for qr code. Thisis barcode, so make it 40 by 80 or smthn, figure out that x thing.
            for(var x = 0; x < image.bitmap.width; x++) {
              console.log(x)
              verticalCounter = 0;
              for(var y = 0; y < image.bitmap.height; y++) {
                var tempStandardR = jimp.intToRGBA(image.getPixelColor(x,verticalStart)).r;
                var tempStandardG = jimp.intToRGBA(image.getPixelColor(x,verticalStart)).g;
                var tempStandardB = jimp.intToRGBA(image.getPixelColor(x,verticalStart)).b;
                var tempStandardR2 = jimp.intToRGBA(image.getPixelColor(x,y)).r;
                var tempStandardG2 = jimp.intToRGBA(image.getPixelColor(x,y)).g;
                var tempStandardB2 = jimp.intToRGBA(image.getPixelColor(x,y)).b;
                if((((tempStandardR - tempStandardR2) <= 20) && ((tempStandardR - tempStandardR2) >= -20)) && (((tempStandardG - tempStandardG2) <= 20) && ((tempStandardG - tempStandardG2) >= -20)) && (((tempStandardB - tempStandardB2) <= 20) && ((tempStandardB - tempStandardB2) >= -20))) {
                  verticalCounter++;
                  if(verticalCounter == 40) {
                    verticalCounter = 0;
                    for(var y1 = y-40; y1 < y; y1++) {
                      horizontalCounter = 0;
                      for(var x1 = x; x1 < x+41; x1++) {
                        var tempStandardR3 = jimp.intToRGBA(image.getPixelColor(x,y1)).r;
                        var tempStandardG3 = jimp.intToRGBA(image.getPixelColor(x,y1)).g;
                        var tempStandardB3 = jimp.intToRGBA(image.getPixelColor(x1,y1)).b;
                        var tempStandardR4 = jimp.intToRGBA(image.getPixelColor(x1,y1)).r;
                        var tempStandardG4 = jimp.intToRGBA(image.getPixelColor(x1,y1)).g;
                        var tempStandardB4 = jimp.intToRGBA(image.getPixelColor(x1,y1)).b;
                        if((((tempStandardR3 - tempStandardR4) <= 20) && ((tempStandardR3 - tempStandardR4) >= -20)) && (((tempStandardG3 - tempStandardG4) <= 20) && ((tempStandardG3 - tempStandardG4) >= -20)) && (((tempStandardB3 - tempStandardB4) <= 20) && ((tempStandardB3 - tempStandardB4) >= -20))) {
                          if(x1 == x+40) {
                            doneCounter++;
                            if(doneCounter == 39) {
                              //SUCESS!!!!!!
                              //THE SPOT HAS BEEN FOUND AT (x minus 40, y minus 40).
                              //insert other image in this image at above coordinates. Wow I highly doubt this works.
                              console.log('SUCESS!!!!!!!!!')
                              FINALX = x;
                              FINALY = y1-40;
                              breakAll = true;
                              break;
                            }
                            break;
                          }
                        }
                        else {
                          verticalCounter = 0;
                          horizontalCounter = 0;
                          doneCounter = 0;
                          y = y1;
                          breakThis = true;
                          break;
                        }
                        if(breakAll == true) {
                          break;
                        }
                      }
                      if(breakThis == true) {
                        breakThis = false;
                        break;
                      }
                      if(breakAll == true) {
                        break;
                      }
                    }
                    if(breakAll == true) {
                      break;
                    }
                  }
                  if(breakAll == true) {
                    break;
                  }
                }
                else {
                  verticalCounter = 0;
                  verticalStart = 0;
                }
                if(breakAll == true) {
                  break;
                }
              }
              if(breakAll == true) {
                break;
              }
            }
            console.log(' done');
            console.log(FINALX + " = x")
            console.log(FINALY + " = y")
          })
          .catch(err => {
            console.log(err);
          })


问:
SwiftUI Photo Gallery View Smooth Scrolling
I'm building a photo gallery using SwiftUI, and am trying to ensure that a user can smoothly scroll through thousands of photo thumbnails without performance degradation or visible load times for each photo.

So far, my research has led me to use a lazyvgrid within a ScrollView, which seems to perform better than a lazyvstack or a normal grid when working with a large data set. However, when scrolling through the lazyvgrid, it takes a moment for each new row of thumbnails to load (since lazyvgrid is lazy), and this is especially noticeable when scrolling very quickly.

Ultimately, I'm wondering how other apps with photo galleries get around this issue. Is it impossible to avoid when using SwiftUI, and would I need to use something like UIKit's CollectionView with prefetching?

Here's what I'm doing currently:

```<code>ScrollView {
    LazyVGrid(columns: vGridLayout) {
        ForEach(photoLibraryService.items, id: \.self) { asset in
            PhotoThumbnailView(assetLocalId: asset.localIdentifier, mediaType: asset.mediaType, duration: asset.duration)
        }
    }
}
</code>```

And here's what it looks like when I scroll through it quickly:

Body:
I'm building a photo gallery using SwiftUI, and am trying to ensure that a user can smoothly scroll through thousands of photo thumbnails without performance degradation or visible load times for each photo.

So far, my research has led me to use a lazyvgrid within a ScrollView, which seems to perform better than a lazyvstack or a normal grid when working with a large data set. However, when scrolling through the lazyvgrid, it takes a moment for each new row of thumbnails to load (since lazyvgrid is lazy), and this is especially noticeable when scrolling very quickly.

Ultimately, I'm wondering how other apps with photo galleries get around this issue. Is it impossible to avoid when using SwiftUI, and would I need to use something like UIKit's CollectionView with prefetching?

Here's what I'm doing currently:

ScrollView {
    LazyVGrid(columns: vGridLayout) {
        ForEach(photoLibraryService.items, id: \.self) { asset in
            PhotoThumbnailView(assetLocalId: asset.localIdentifier, mediaType: asset.mediaType, duration: asset.duration)
        }
    }
}

And here's what it looks like when I scroll through it quickly:


问:
List Zip method identifies series as index
I have created tuples before like this:

```<code>list(zip(df['Column1'],df['Column2']))
</code>```

But when I do this, it doesn't work.

```<code>    Lane    Carrier Scac    Cust Linehaul_2022Q2    Cust Linehaul_2022Q3    Cust Linehaul_2022Q4    Load Number_2022Q2  Load Number_2022Q3  Load Number_2022Q4
0   ADELANTO, CA - BLOOMINGTON, CA  RDWY    0.0 105.9   0.0 0   1   0
1   ALACHUA, FL - LITHIA SPRINGS, GA    MGXB    0.0 1603.0  0.0 0   1   0
2   ALACHUA, FL - LITHIA SPRINGS, GA    RDWY    101.3   105.1   0.0 1   1   0

list(zip(df_SO['Cust Linehaul_2022Q2'],df_SO['Cust Linehaul_2022Q3']))

TypeError: 'Index' object is not callable
</code>```

I learnt that way to make a tuple from this thread:
How do I iterate through two lists in parallel?

But not sure why this one is identifying as an index and not a series.

Body:
I have created tuples before like this:

list(zip(df['Column1'],df['Column2']))

But when I do this, it doesn't work.

    Lane    Carrier Scac    Cust Linehaul_2022Q2    Cust Linehaul_2022Q3    Cust Linehaul_2022Q4    Load Number_2022Q2  Load Number_2022Q3  Load Number_2022Q4
0   ADELANTO, CA - BLOOMINGTON, CA  RDWY    0.0 105.9   0.0 0   1   0
1   ALACHUA, FL - LITHIA SPRINGS, GA    MGXB    0.0 1603.0  0.0 0   1   0
2   ALACHUA, FL - LITHIA SPRINGS, GA    RDWY    101.3   105.1   0.0 1   1   0

list(zip(df_SO['Cust Linehaul_2022Q2'],df_SO['Cust Linehaul_2022Q3']))

TypeError: 'Index' object is not callable

I learnt that way to make a tuple from this thread:
How do I iterate through two lists in parallel?

But not sure why this one is identifying as an index and not a series.


问:
How can I correct my tkinter datatype problems?
I am programming a timer and I think I am close to finish but theres a problem with my code.
As you can see below, I try to update the textbox "countdown" by decreasing the input variable with a forloop. The problem is the input is given as a string and I cant subtract the duration by 1 if the variable is a string. Now I do not know where and how I have to convert the variable from string to integral. I tried to convert the variable timer from string to int but it did not work.
I would appreciate help with my little problem and a explanation why my solving idea did not work.
Greetings

Code:

```<code>from tkinter import *
from tkinter import ttk
import tkinter as tk
import time

window = Tk()
window.title("Timer")
window.geometry("150x100")
window.resizable(height=False, width=False)

def get_input():
    activation = False
    timer = entry.get()

    #for test purpose
    print(timer)

    activation = True

    if activation == True:
        for i in timer:
            i = timer - 1
            print(i + " remaining_time")
            time.sleep(1)
            update = True

        countdown = Label(window, text=i)
        countdown.grid()

        if update == True:
            countdown.update
            update = False

headline = Label(window, text = "choose the duration of the timer")
headline.grid()

entry = Entry(window)
entry.grid()

button = Button(window, text = "commit", command=get_input)
button.grid()

window.mainloop()
</code>```

Here is my attempt and Error:

```<code>def get_input():
    activation = False
    timer = entry.get()
    timer_int = int(timer)

    print(timer_int)

    activation = True

    if activation == True:
        for i in timer_int:
            i = timer_int - 1
            print(i + " remaining_time")
            time.sleep(1)
            update = True

        countdown = Label(window, text=i)
        countdown.grid()

        if update == True:
            countdown.update
            update = False
</code>```

Error code for my attempt:

```<code>1
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1921, in __call__
    return self.func(*args)
  File "e:\Wecker\timer.py", line 22, in get_input
    for i in timer_int:
TypeError: 'int' object is not iterable
</code>```

Body:
I am programming a timer and I think I am close to finish but theres a problem with my code.
As you can see below, I try to update the textbox "countdown" by decreasing the input variable with a forloop. The problem is the input is given as a string and I cant subtract the duration by 1 if the variable is a string. Now I do not know where and how I have to convert the variable from string to integral. I tried to convert the variable timer from string to int but it did not work.
I would appreciate help with my little problem and a explanation why my solving idea did not work.
Greetings

Code:

from tkinter import *
from tkinter import ttk
import tkinter as tk
import time

window = Tk()
window.title("Timer")
window.geometry("150x100")
window.resizable(height=False, width=False)

def get_input():
    activation = False
    timer = entry.get()

    #for test purpose
    print(timer)

    activation = True

    if activation == True:
        for i in timer:
            i = timer - 1
            print(i + " remaining_time")
            time.sleep(1)
            update = True

        countdown = Label(window, text=i)
        countdown.grid()

        if update == True:
            countdown.update
            update = False

headline = Label(window, text = "choose the duration of the timer")
headline.grid()

entry = Entry(window)
entry.grid()

button = Button(window, text = "commit", command=get_input)
button.grid()

window.mainloop()

Here is my attempt and Error:

def get_input():
    activation = False
    timer = entry.get()
    timer_int = int(timer)

    print(timer_int)

    activation = True

    if activation == True:
        for i in timer_int:
            i = timer_int - 1
            print(i + " remaining_time")
            time.sleep(1)
            update = True

        countdown = Label(window, text=i)
        countdown.grid()

        if update == True:
            countdown.update
            update = False

Error code for my attempt:

1
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 1921, in __call__
    return self.func(*args)
  File "e:\Wecker\timer.py", line 22, in get_input
    for i in timer_int:
TypeError: 'int' object is not iterable


问:
Python MSS Screenshot monitor sizes different than expected
Using mss, I have taken screenshots of my two monitors: monitor-1 and monitor-2.
When I open up monitor-1, I get the image size of 3840x2160. However, when accessing monitors from mss().monitors[1], I get the size of 1920x1080. They are two completely different sizes!

I also checked this on my second monitor, and the size is correct.

These are my display settings:

Monitor 1
Monitor 2

I got the screenshots with the following code:

import mss
sct = mss.mss()
for x in sct.save(0):
    print(x)
```


问:
Nodejs: is there a way to write a string to the user's terminal input?
I am trying to write a node script with behavior like this:

```<code>$ node derive-command.js
Deriving command...
Finished successfully, took 2.34 seconds...
$ curl https://abcdefghijk.com/api/e/12dce54
</code>```

I am seeking an explanation of how to build a function automaticallyType('curl ...') that will cause the string curl ... to appear after process.exit has occurred, as if the user had typed this string.

I thought this might be impossible but then I found node-copy-paste. It's not exactly what I need but the paste command simulates user input in the same way I am hoping to do. Is there another way of doing this that doesn't require interacting with the user's clipboard?

Body:
I am trying to write a node script with behavior like this:

$ node derive-command.js
Deriving command...
Finished successfully, took 2.34 seconds...
$ curl https://abcdefghijk.com/api/e/12dce54

I am seeking an explanation of how to build a function automaticallyType('curl ...') that will cause the string curl ... to appear after process.exit has occurred, as if the user had typed this string.

I thought this might be impossible but then I found node-copy-paste. It's not exactly what I need but the paste command simulates user input in the same way I am hoping to do. Is there another way of doing this that doesn't require interacting with the user's clipboard?


问:
When I press ⌘ + N I get an error that says "no source actions available" when in a text file
I don't know what happened to my vscode but when I press ⌘ + N I get an error that says no source actions available.

This used to work fine. I'm in a text file when doing this. If I go to the menu and look at what the shortcut for new text file is, it shows ⌘ + N.

Is something misconfigured?


问:
I'm getting a permission error:[winerror 5] and I havent been able to fix it
```<code>import cv2
import numpy as np
import pytesseract
t=0
pytesseract.pytesseract.tesseract_cmd = ("C:\\Program Files\\Tesseract-OCR")
cap = cv2.VideoCapture(0)
while True:
    ret, img = cap.read(0)
    bimg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    circles = cv2.HoughCircles(bimg, cv2.HOUGH_GRADIENT, 1, 20, param1=50, param2=30, minRadius=20, maxRadius=30)

    if circles is not None:

        circles = np.uint16(np.around(circles))
        for i in circles[0, :]:
            circle = bimg[i[1]-30:i[1]+30,i[0]-30:i[0]+30]
        cv2.imshow('sign',circle)
        t+=1
        txt=pytesseract.image_to_string(circle,config='--psm 11')
        sign_number= [int(s) for s in txt.split() if s.isdigit()]
        print(str(sign_number) + "" + str(t))
    cv2.imshow('res',bimg)
    if cv2.waitKey(1) & 0xFF == ord("q"):
        cv2.destroyAllWindows()
        break

</code>```

at line 19 "txt=pytesseract.image_to_string(circle,config='--psm 11')" im getting the error

```<code>Traceback (most recent call last):
  File "C:\Users\danie\Downloads\speedLimit.py", line 19, in <module>
    txt=pytesseract.image_to_string(circle,config='--psm 11')
  File "C:\Users\danie\PycharmProjects\pythonProject\venv\lib\site-packages\pytesseract\pytesseract.py", line 423, in image_to_string
    return {
  File "C:\Users\danie\PycharmProjects\pythonProject\venv\lib\site-packages\pytesseract\pytesseract.py", line 426, in <lambda>
    Output.STRING: lambda: run_and_get_output(*args),
  File "C:\Users\danie\PycharmProjects\pythonProject\venv\lib\site-packages\pytesseract\pytesseract.py", line 288, in run_and_get_output
    run_tesseract(**kwargs)
  File "C:\Users\danie\PycharmProjects\pythonProject\venv\lib\site-packages\pytesseract\pytesseract.py", line 255, in run_tesseract
    proc = subprocess.Popen(cmd_args, **subprocess_args())
  File "C:\Users\danie\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\danie\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Access is denied
</code>```

This code is trying to detect speed limit signs in a video and read the numbers on them (work in progress). While it "worked"(doesn't read the numbers properly) on my old computer, on my new one that I just got I get the error, I'm assuming it has something to do with a setting on my computer but looking it up online just gives me fixes for pip installs in cmd. If someone could tell me how to fix it I would be most grateful.

Body:
import cv2
import numpy as np
import pytesseract
t=0
pytesseract.pytesseract.tesseract_cmd = ("C:\\Program Files\\Tesseract-OCR")
cap = cv2.VideoCapture(0)
while True:
    ret, img = cap.read(0)
    bimg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    circles = cv2.HoughCircles(bimg, cv2.HOUGH_GRADIENT, 1, 20, param1=50, param2=30, minRadius=20, maxRadius=30)

    if circles is not None:

        circles = np.uint16(np.around(circles))
        for i in circles[0, :]:
            circle = bimg[i[1]-30:i[1]+30,i[0]-30:i[0]+30]
        cv2.imshow('sign',circle)
        t+=1
        txt=pytesseract.image_to_string(circle,config='--psm 11')
        sign_number= [int(s) for s in txt.split() if s.isdigit()]
        print(str(sign_number) + "" + str(t))
    cv2.imshow('res',bimg)
    if cv2.waitKey(1) & 0xFF == ord("q"):
        cv2.destroyAllWindows()
        break

at line 19 "txt=pytesseract.image_to_string(circle,config='--psm 11')" im getting the error

Traceback (most recent call last):
  File "C:\Users\danie\Downloads\speedLimit.py", line 19, in <module>
    txt=pytesseract.image_to_string(circle,config='--psm 11')
  File "C:\Users\danie\PycharmProjects\pythonProject\venv\lib\site-packages\pytesseract\pytesseract.py", line 423, in image_to_string
    return {
  File "C:\Users\danie\PycharmProjects\pythonProject\venv\lib\site-packages\pytesseract\pytesseract.py", line 426, in <lambda>
    Output.STRING: lambda: run_and_get_output(*args),
  File "C:\Users\danie\PycharmProjects\pythonProject\venv\lib\site-packages\pytesseract\pytesseract.py", line 288, in run_and_get_output
    run_tesseract(**kwargs)
  File "C:\Users\danie\PycharmProjects\pythonProject\venv\lib\site-packages\pytesseract\pytesseract.py", line 255, in run_tesseract
    proc = subprocess.Popen(cmd_args, **subprocess_args())
  File "C:\Users\danie\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\danie\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
PermissionError: [WinError 5] Access is denied

This code is trying to detect speed limit signs in a video and read the numbers on them (work in progress). While it "worked"(doesn't read the numbers properly) on my old computer, on my new one that I just got I get the error, I'm assuming it has something to do with a setting on my computer but looking it up online just gives me fixes for pip installs in cmd. If someone could tell me how to fix it I would be most grateful.


问:
How to read a RTMP stream and send it to Kinesis Video Stream?
I'm trying to read a RTMP video stream (followed this) and send it to Kinesis Video Stream with the GStreamer plugin dockerized with this command:

```<code>gst-launch-1.0 rtmpsrc location=rtmp://172.17.0.2/live/test \
  ! decodebin ! videoconvert \
  ! video/x-raw,format=I420,width=640,height=480,framerate=30/1 \
  ! x264enc  bframes=0 key-int-max=45 bitrate=500 \
  ! video/x-h264,stream-format=avc,alignment=au,profile=baseline \
  ! kvssink stream-name="STREAM_NAME" storage-size=512 \
      access-key="ACCESS_KEY" \
      secret-key="SECRET_KEY" \
      aws-region="REGION"
</code>```

but I can't and the log says:

```<code>...
2023-01-05 20:08:41 [139732104787520] INFO - getStreamingTokenResultEvent(): Get streaming token result event.
2023-01-05 20:08:41 [139732104787520] DEBUG - stepStateMachine(): State Machine - Current state: 0x0000000000000010, Next state: 0x0000000000000040
2023-01-05 20:08:41 [139732104787520] DEBUG - streamReadyHandler invoked
2023-01-05 20:08:41 [139732104787520] Stream is ready
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstRTMPSrc:rtmpsrc0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstRTMPSrc:rtmpsrc0:
streaming stopped, reason not-linked (-1)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
INFO - Freeing Kinesis Video Stream test
2023-01-05 20:08:43 [139732691388224] INFO - freeKinesisVideoStream(): Freeing Kinesis Video stream.
2023-01-05 20:08:43 [139732691388224] DEBUG - curlApiCallbacksShutdownActiveRequests(): pActiveRequests hashtable is empty
</code>```

what I missing out?

How can I solve?

EDIT:

with this gstreamer command:

```<code>gst-launch-1.0 rtmp2src location="rtmp://172.17.0.2/live/test live=1" \
  ! decodebin3 ! videoconvert \
  ! video/x-raw,format=I420,width=640,height=480,framerate=30/1 \
  ! x264enc  bframes=0 key-int-max=45 bitrate=500 \
  ! video/x-h264,stream-format=avc,alignment=au \
  ! kvssink stream-name="STREAM_NAME" storage-size=512 \
      access-key="ACCESS_KEY" \
      secret-key="SECRET_KEY" \
      aws-region="REGION"
</code>```

I have no errors and the log says:

```<code>...
2023-01-06 05:59:47 [139898318763584] Stream is ready
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
</code>```

But on Kinesis I can't see the stream.

Why?

Body:
I'm trying to read a RTMP video stream (followed this) and send it to Kinesis Video Stream with the GStreamer plugin dockerized with this command:

gst-launch-1.0 rtmpsrc location=rtmp://172.17.0.2/live/test \
  ! decodebin ! videoconvert \
  ! video/x-raw,format=I420,width=640,height=480,framerate=30/1 \
  ! x264enc  bframes=0 key-int-max=45 bitrate=500 \
  ! video/x-h264,stream-format=avc,alignment=au,profile=baseline \
  ! kvssink stream-name="STREAM_NAME" storage-size=512 \
      access-key="ACCESS_KEY" \
      secret-key="SECRET_KEY" \
      aws-region="REGION"

but I can't and the log says:

...
2023-01-05 20:08:41 [139732104787520] INFO - getStreamingTokenResultEvent(): Get streaming token result event.
2023-01-05 20:08:41 [139732104787520] DEBUG - stepStateMachine(): State Machine - Current state: 0x0000000000000010, Next state: 0x0000000000000040
2023-01-05 20:08:41 [139732104787520] DEBUG - streamReadyHandler invoked
2023-01-05 20:08:41 [139732104787520] Stream is ready
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstRTMPSrc:rtmpsrc0: Internal data stream error.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstRTMPSrc:rtmpsrc0:
streaming stopped, reason not-linked (-1)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
INFO - Freeing Kinesis Video Stream test
2023-01-05 20:08:43 [139732691388224] INFO - freeKinesisVideoStream(): Freeing Kinesis Video stream.
2023-01-05 20:08:43 [139732691388224] DEBUG - curlApiCallbacksShutdownActiveRequests(): pActiveRequests hashtable is empty

what I missing out?

How can I solve?

EDIT:

with this gstreamer command:

gst-launch-1.0 rtmp2src location="rtmp://172.17.0.2/live/test live=1" \
  ! decodebin3 ! videoconvert \
  ! video/x-raw,format=I420,width=640,height=480,framerate=30/1 \
  ! x264enc  bframes=0 key-int-max=45 bitrate=500 \
  ! video/x-h264,stream-format=avc,alignment=au \
  ! kvssink stream-name="STREAM_NAME" storage-size=512 \
      access-key="ACCESS_KEY" \
      secret-key="SECRET_KEY" \
      aws-region="REGION"

I have no errors and the log says:

...
2023-01-06 05:59:47 [139898318763584] Stream is ready
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

But on Kinesis I can't see the stream.

Why?


问:
list AWS SCP policies attached to an account
Is there anyway I can get a list of all scp policies that is attached to particular account. I have many account in AWS organization and wanted make list of scp policies attached to each individual account. Below python function is working but only showing default AWS managed scp policy however there are many custom SCP policies (inherited policies) attached that it is not listing. Am I doing something wrong?

```<code>session = boto3.Session(profile_name='saml')
response = session.client('organizations', region_name='us-east-1')

scp = response.list_policies_for_target(TargetId='xxxxxxxxxxxx', Filter='SERVICE_CONTROL_POLICY')
</code>```

With this I am getting only below output.

```<code>$ python test_lambda.py
[{'Arn': 'arn:aws:organizations::aws:policy/service_control_policy/p-FullAWSAccess',
  'AwsManaged': True,
  'Description': 'Allows access to every operation',
  'Id': 'p-FullAWSAccess',
  'Name': 'FullAWSAccess',
  'Type': 'SERVICE_CONTROL_POLICY'}]
</code>```

Body:
Is there anyway I can get a list of all scp policies that is attached to particular account. I have many account in AWS organization and wanted make list of scp policies attached to each individual account. Below python function is working but only showing default AWS managed scp policy however there are many custom SCP policies (inherited policies) attached that it is not listing. Am I doing something wrong?

session = boto3.Session(profile_name='saml')
response = session.client('organizations', region_name='us-east-1')

scp = response.list_policies_for_target(TargetId='xxxxxxxxxxxx', Filter='SERVICE_CONTROL_POLICY')

With this I am getting only below output.

$ python test_lambda.py
[{'Arn': 'arn:aws:organizations::aws:policy/service_control_policy/p-FullAWSAccess',
  'AwsManaged': True,
  'Description': 'Allows access to every operation',
  'Id': 'p-FullAWSAccess',
  'Name': 'FullAWSAccess',
  'Type': 'SERVICE_CONTROL_POLICY'}]


问:
finish ActionMode on Dialog resolution after selected items processed
I'm using my data model to accurately keep track of the selected list items in an adapter.  I reset the selected item flags in onDestroyActionMode which I understand is called from mode.finish().  Unfortunately the DialogFragment is run asynchronously so by the time I get to my business logic in the songViewModel everything is reset already.

How do I propperly finish my actionMode with the selected items remaining selected until I'm done with them?

It seems I have 2 options that I don't really like.

I can implement some handler and try to do some run blocking.

I can move some of the business logic from the viewModel to MainActivity, making a filtered list of the items that I pass to the DialogFragment which then passes them to the viewModel.

I'm leaning toward option 2 but it really confuses me because I'm under the impression that
I should be handling most of my business logic in my viewModel rather than passing it to MainActivity then to a DialogFragment just to come back to the viewModel again.

```<code>override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
            return when (item.itemId) {
                R.id.action_make_set_list -> {
                    //make a list
                    showSetListDialog(currentArtist)
                    Toast.makeText(this@MainActivity, "Make Set List Selected", Toast.LENGTH_SHORT)
                        .show()
                    mode.finish()
                    true
                }
                R.id.action_delete_songs -> {
                    songViewModel.deleteSelectedSongs()
                    Toast.makeText(this@MainActivity, "Delete Songs selected", Toast.LENGTH_SHORT)
                        .show()
                    mode.finish()
                    true
                }
                else -> false
            }
        }

        override fun onDestroyActionMode(mode: ActionMode?) {
            mActionMode = null
            isInActionMode = false
            selectionCounter = 0
            actionAdapter?.notifyDataSetChanged()
            //reset the isSelected field for the current list, is there a more efficient way???
            actionAdapter?.currentList?.forEach { it.isSelected = false }

        }
</code>```

I placed mode.finish() AFTER the showSetListDialog expecting it would execute after the Dialog was finished because I didn't know the Dialog was asynchronous.  What happened is all the items were deselected by the time I got to my function in the viewModel.

Body:
I'm using my data model to accurately keep track of the selected list items in an adapter.  I reset the selected item flags in onDestroyActionMode which I understand is called from mode.finish().  Unfortunately the DialogFragment is run asynchronously so by the time I get to my business logic in the songViewModel everything is reset already.

How do I propperly finish my actionMode with the selected items remaining selected until I'm done with them?

It seems I have 2 options that I don't really like.

I can implement some handler and try to do some run blocking.

I can move some of the business logic from the viewModel to MainActivity, making a filtered list of the items that I pass to the DialogFragment which then passes them to the viewModel.

I'm leaning toward option 2 but it really confuses me because I'm under the impression that
I should be handling most of my business logic in my viewModel rather than passing it to MainActivity then to a DialogFragment just to come back to the viewModel again.

override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
            return when (item.itemId) {
                R.id.action_make_set_list -> {
                    //make a list
                    showSetListDialog(currentArtist)
                    Toast.makeText(this@MainActivity, "Make Set List Selected", Toast.LENGTH_SHORT)
                        .show()
                    mode.finish()
                    true
                }
                R.id.action_delete_songs -> {
                    songViewModel.deleteSelectedSongs()
                    Toast.makeText(this@MainActivity, "Delete Songs selected", Toast.LENGTH_SHORT)
                        .show()
                    mode.finish()
                    true
                }
                else -> false
            }
        }

        override fun onDestroyActionMode(mode: ActionMode?) {
            mActionMode = null
            isInActionMode = false
            selectionCounter = 0
            actionAdapter?.notifyDataSetChanged()
            //reset the isSelected field for the current list, is there a more efficient way???
            actionAdapter?.currentList?.forEach { it.isSelected = false }

        }

I placed mode.finish() AFTER the showSetListDialog expecting it would execute after the Dialog was finished because I didn't know the Dialog was asynchronous.  What happened is all the items were deselected by the time I got to my function in the viewModel.


问:
io unsupported operation for python
I have a problem in python where i type the code below and gives me the io.UnsupportedOperation: not writable error.
here's the code:

 string = "set style vintage"
 new_style = line_4.replace("set style","")
 with open("style.txt","w") as set_style:
     set_style.write(str(new_style))
```

I converted to string and nothing was fixed

Title: io unsupported operation for python

Body:
I have a problem in python where i type the code below and gives me the io.UnsupportedOperation: not writable error.
here's the code:

 string = "set style vintage"
 new_style = line_4.replace("set style","")
 with open("style.txt","w") as set_style:
     set_style.write(str(new_style))

I converted to string and nothing was fixed


问:
Failed to parse model JSON of response from Firebase
I am trying to load a custom model from Firebase (The custom model is a .json file with three bin files).

The following code saves my custom model (Jupyter notebook, Python):

```<code>tfjs.converters.save_keras_model(model2, "model2")
</code>```

Structure of the saved model:

The following code is using the loadLayersModel (ReactJS):

```<code>const link = {
    model:
             "https://firebasestorage.googleapis.com/v0/b/xxxxxxx.appspot.com/o/model2%2Fmodel.json?alt=media&token=f4b6be76-b760-496e-8983-7beda892f5a5",

};

const model = await loadLayersModel(link.model);
</code>```

This is the following error (Chrome):

```<code>Uncaught (in promise) Error: Failed to parse model JSON of response from https://firebasestorage.googleapis.com/v0/b/xxxxxxxx.appspot.com/o/model2%2Fmodel.json?alt=media&token=f4b6be76-b760-496e-8983-7beda892f5a5. Please make sure the server is serving valid JSON for this request.
    at HTTPRequest.load (http.ts:168:1)
    at async loadLayersModelFromIOHandler (models.ts:293:1)
    at async predictionModel (App.js:74:1)
</code>```

These are my rules in firebase storage (Firebase storage):

I already tried to load a tflite model, but it gave me the same predictions over and over again. So I am trying to understand how to load in a json model from firebase.

Body:
I am trying to load a custom model from Firebase (The custom model is a .json file with three bin files).

The following code saves my custom model (Jupyter notebook, Python):

tfjs.converters.save_keras_model(model2, "model2")

Structure of the saved model:

The following code is using the loadLayersModel (ReactJS):

const link = {
    model:
             "https://firebasestorage.googleapis.com/v0/b/xxxxxxx.appspot.com/o/model2%2Fmodel.json?alt=media&token=f4b6be76-b760-496e-8983-7beda892f5a5",

};

const model = await loadLayersModel(link.model);

This is the following error (Chrome):

Uncaught (in promise) Error: Failed to parse model JSON of response from https://firebasestorage.googleapis.com/v0/b/xxxxxxxx.appspot.com/o/model2%2Fmodel.json?alt=media&token=f4b6be76-b760-496e-8983-7beda892f5a5. Please make sure the server is serving valid JSON for this request.
    at HTTPRequest.load (http.ts:168:1)
    at async loadLayersModelFromIOHandler (models.ts:293:1)
    at async predictionModel (App.js:74:1)

These are my rules in firebase storage (Firebase storage):

I already tried to load a tflite model, but it gave me the same predictions over and over again. So I am trying to understand how to load in a json model from firebase.


问:
How to evaluate clusters' quality using a distance matrix in python?
I am trying to customize a hierarchical cluster procedure using a correlation distance between variables, and I need to evaluate the cluster quality. But, all the methods of cluster quality evaluation I found in python are observation-oriented and don't use distance matrix as input.

For example, the cluster evaluation scores available in sci-kit learn, SciPy or clusteval do not provide a how-to-use the distance matrix as input to compute any of the following quality metrics that are based on distances:

Davies–Bouldin index

calinski_harabasz

Silhouette

Do you have any solution for accessing cluster quality using custom distance metrics in hierarchical clustering?

Distance-Matrix-based Hierarchical Clustering

```<code>DistanceMatrix = 1-abs(pipe6.Stats())
N = DistanceMatrix.shape[0]
score = []
for K in range(2, N-1):
    hclus = skclus.FeatureAgglomeration(n_clusters=K,
                                        linkage="complete",
                                        metric="precomputed")
    hclus.fit(DistanceMatrix)
    clusters = hclus.labels_
    Quality = metrics.davies_bouldin_score(X=DistanceMatrix,
                                           labels=clusters)
    score.append(Quality)
</code>```

Body:
I am trying to customize a hierarchical cluster procedure using a correlation distance between variables, and I need to evaluate the cluster quality. But, all the methods of cluster quality evaluation I found in python are observation-oriented and don't use distance matrix as input.

For example, the cluster evaluation scores available in sci-kit learn, SciPy or clusteval do not provide a how-to-use the distance matrix as input to compute any of the following quality metrics that are based on distances:

Davies–Bouldin index

calinski_harabasz

Silhouette

Do you have any solution for accessing cluster quality using custom distance metrics in hierarchical clustering?

Distance-Matrix-based Hierarchical Clustering

DistanceMatrix = 1-abs(pipe6.Stats())
N = DistanceMatrix.shape[0]
score = []
for K in range(2, N-1):
    hclus = skclus.FeatureAgglomeration(n_clusters=K,
                                        linkage="complete",
                                        metric="precomputed")
    hclus.fit(DistanceMatrix)
    clusters = hclus.labels_
    Quality = metrics.davies_bouldin_score(X=DistanceMatrix,
                                           labels=clusters)
    score.append(Quality)


问:
@font-face works with all fonts, except one
I have a Shopify store that has personalized text box inputs.  When a customer enters text, the text font changes depending on which "Font" they select.

All fonts work except "Freestyle Script".  I can't get that font to work on my iPhone, but it does work on PC browsers like Edge and Chrome.  What could be causing this?

Product page: https://www.palmettowoodshop.com/products/kershaw-scallion-1620ol-personalized-pocket-knife

All of my fonts are setup exactly as shown in the code below and they all work on my iPhone except Freestyle Script.  It is loaded in the "Assets" folder in Shopify, is named Freestyle_Script.ttf and is installable, so I'm not sure what the problem is.

```<code>   @font-face{
   font-family: 'Freestyle Script';
   src: url( {{ 'Freestyle_Script.ttf' | asset_url }} ) ;
   src: local('☺'), url( {{ 'Freestyle_Script.ttf' | asset_url }} ) ;
   font-display: swap;
 }
</code>```

Body:
I have a Shopify store that has personalized text box inputs.  When a customer enters text, the text font changes depending on which "Font" they select.

All fonts work except "Freestyle Script".  I can't get that font to work on my iPhone, but it does work on PC browsers like Edge and Chrome.  What could be causing this?

Product page: https://www.palmettowoodshop.com/products/kershaw-scallion-1620ol-personalized-pocket-knife

All of my fonts are setup exactly as shown in the code below and they all work on my iPhone except Freestyle Script.  It is loaded in the "Assets" folder in Shopify, is named Freestyle_Script.ttf and is installable, so I'm not sure what the problem is.

   @font-face{
   font-family: 'Freestyle Script';
   src: url( {{ 'Freestyle_Script.ttf' | asset_url }} ) ;
   src: local('☺'), url( {{ 'Freestyle_Script.ttf' | asset_url }} ) ;
   font-display: swap;
 }


问:
Installing apport for virtualenv
While I know that it isn't the intended way of using apport, I'm formatting errors using apport_python_hook.apport_excepthook. Unsurprisingly the apport_python_hook is inaccessible from a venv (but it is in the global scope). The issue is that apport isn't a real python/pip package (it is apt package, but when installed it inserts some python modules so site-packages)

Currently I'm just copying the file to my project directory but the downside of this approach is that I can't update it automatically. Maybe building it from source would work, but I haven't tested it yet.

Title: Installing apport for virtualenv


问:
install plugin for wordpress website hosted on aws ec2
i have a wordpress website hosted on an aws ec2 and im not able to install wordpress plugins, i get an error Failed to connect to FTP Server 18.119.110.172:21

to host a wordpress website on an ec2 i used this video https://youtu.be/8Uofkq718n8, in the security rules for the ec2 i opened port 21 and i know im using the right username and password, i dont know what else to do


问:
Can I edit Finder context menu items with Hammerspoon?
With Automator I can create Quick Actions in Finder. Is it possible to do the same thing with Hammerspoon?</p>