问:
Is there a way to call extension methods from debug console?
Debugging with extension methods seems to be a bit problematic currently.

Consider the following code:

import 'dart:developer';

void main() {
  final a = A();
  workaround = a.extMethod;
  debugger();
  a.normalMethod();
  a.extMethod();
}

class A {
  String normalMethod() => 'hello from class';
}

extension AX on A {
  String extMethod() => 'hello from extension';
}
```
<p>When debugging this, stepping into both methods (<code>normalMethod()</code> and <code>extMethod()</code>) will work fine, the only difference is that <code>this</code> isn't available for <code>extMethod()</code> for some reason (there is <code>#this</code> instead, but it can't be used anyhow).</p>
<p>The extension method (<code>extMethod()</code>) is impossible to use for evaluations in the debug console, though.</p>
```a.normalMethod()
"hello from class"

a.extMethod()
Unhandled exception:
NoSuchMethodError: Class 'A' has no instance method 'extMethod'.
Receiver: Instance of 'A'
Tried calling: extMethod()
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
#1      Eval ()

workaround()
"hello from extension"
```

I have found kind of a workaround as you can see, but it has to be in place before running the program so I'd definitely prefer a better method that can be used on fly without any preparation.

I have found two very old issues describing this exact problem but both are closed and from what I understand, unresolved.

https://github.com/dart-lang/sdk/issues/44801

https://github.com/dart-lang/sdk/issues/44472

I'm using Dart 2.18.6 (latest stable).

Body:
Debugging with extension methods seems to be a bit problematic currently.

Consider the following code:

import 'dart:developer';

void main() {
  final a = A();
  workaround = a.extMethod;
  debugger();
  a.normalMethod();
  a.extMethod();
}

class A {
  String normalMethod() => 'hello from class';
}

extension AX on A {
  String extMethod() => 'hello from extension';
}

When debugging this, stepping into both methods (normalMethod() and extMethod()) will work fine, the only difference is that this isn't available for extMethod() for some reason (there is #this instead, but it can't be used anyhow).

The extension method (extMethod()) is impossible to use for evaluations in the debug console, though.

a.normalMethod()
"hello from class"

a.extMethod()
Unhandled exception:
NoSuchMethodError: Class 'A' has no instance method 'extMethod'.
Receiver: Instance of 'A'
Tried calling: extMethod()
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
#1      Eval ()

workaround()
"hello from extension"

I have found kind of a workaround as you can see, but it has to be in place before running the program so I'd definitely prefer a better method that can be used on fly without any preparation.

I have found two very old issues describing this exact problem but both are closed and from what I understand, unresolved.

https://github.com/dart-lang/sdk/issues/44801

https://github.com/dart-lang/sdk/issues/44472

I'm using Dart 2.18.6 (latest stable).


来源: stackexchange

问:
(PySpark) Update a delta table based on conditional expression while iterating over a lookup df and extract values to insert from a nested dict?
I have a mapping/lookup table/DF according to which I have to extract values from a highly nested json/dictionary. These values have to be inserted as column values to a delta table. How do I do this leveraging pyspark's parallelism?

I know I can collect() the mapping dataframe, open the json file and update each column of a row of a temp df and append to delta table but that will not run in parrallel.

Alternatively, I broadcast the dict/JSON, iterate over mapping dataframe using foreach() and according to when condition I upsert my delta table. But column.when() does not allow me to update a delta table nor does the delta.tables.merge() allow me to compare a dataframe and a dict.

ContentLicense: CC BY-SA 4.0


问:
Data mismatch between a Source Server and a destination server
I am trying to load data from a table in Oracle server to SQL server and data that gets loaded has mismathc rows. I am using Openquery to load the data. The data gets loaded perfectly fine in SQL Server 2013 but rows mismatch in SQL Server 2019. Anyone has ever come across this?

Source Server data

State
City

NY
Syracuse

Florida
Orlando

Texas
Austin

Data loaded in destination server

State
City

NY
Austin

Florida
Syracuse

Texas
Orlando

Below is the Openquery i am using

```<code>INSERT INTO table321
SELECT \* FROM OPENQUERY(hjgg, ''
select \*
FROM table1'')
</code>```

Body:
I am trying to load data from a table in Oracle server to SQL server and data that gets loaded has mismathc rows. I am using Openquery to load the data. The data gets loaded perfectly fine in SQL Server 2013 but rows mismatch in SQL Server 2019. Anyone has ever come across this?

Source Server data

State
City

NY
Syracuse

Florida
Orlando

Texas
Austin

Data loaded in destination server

State
City

NY
Austin

Florida
Syracuse

Texas
Orlando

Below is the Openquery i am using

INSERT INTO table321
SELECT \* FROM OPENQUERY(hjgg, ''
select \*
FROM table1'')


问:
How to scrape data from product catalogue?
What would be a good way to go about scraping all the product information from a website catalogue?

For example, https://shop.donaldson.com/store/en-za/product/1KDFF0005/prod1360010 - I want all the gather all the information displayed for products starting with 1KDF

Nothing yet as still new to this and looking for assistance on how to go about this


问:
How does browsers get WebPush protocol endpoint?
when we allow web push permission, how does the Browser get the endpoint for push notifications?

When we run this code, we sometimes get a null response (data) in the console. I want to know which endpoint Browser calls to get the WebPush endpoint. Is there any way to trace the problem?

```<code>navigator.serviceWorker
.getRegistration('YOUR SERVICE WORKER SCOPE')
.then(function (serviceWorkerRegistration) {
            const subscribeOptions = {
                  userVisibleOnly: true,
                  applicationServerKey: 'YOUR VAPID KEY',
          };

          return serviceWorkerRegistration.pushManager.subscribe(subscribeOptions);
    }).then((data) => {
          console.log( JSON.parse(JSON.stringify(data)));
})
</code>```

Body:
when we allow web push permission, how does the Browser get the endpoint for push notifications?

When we run this code, we sometimes get a null response (data) in the console. I want to know which endpoint Browser calls to get the WebPush endpoint. Is there any way to trace the problem?

navigator.serviceWorker
.getRegistration('YOUR SERVICE WORKER SCOPE')
.then(function (serviceWorkerRegistration) {
            const subscribeOptions = {
                  userVisibleOnly: true,
                  applicationServerKey: 'YOUR VAPID KEY',
          };

          return serviceWorkerRegistration.pushManager.subscribe(subscribeOptions);
    }).then((data) => {
          console.log( JSON.parse(JSON.stringify(data)));
})


问:
Golang unexpected behaviour while implementing concurrency using channel and select statement
Below is my implementation of the Pub/Sub model in golang using concurrency. The code executes as expected sometimes but sometimes it gives output like this:

Output

```<code>message received on channel 2: Hello World
message received on channel 3: Hello World
message received on channel 1: Hello World
message received on channel 1:
subscriber 1's context cancelled
message received on channel 3: Only channels 2 and 3 should print this
message received on channel 2: Only channels 2 and 3 should print this
</code>```

Key thing to note here is that subscriber 1 printed message received on channel 1:   even after there is a call in the main function to remove it as a subscriber. Subscriber 1 should only receive one message. What seems to be happening is that subscriber receives a message from subscriber.out before the dctx is cancelled. How can I fix this. The subscriber's goroutine is launched in the AddSubscriber method.

Expected execution:
Channel 1 should only print once and then it's context should be cancelled and it's goroutine should exit.

main.go

```<code>package main

import (
    "fmt"
    "net/http"
)

func main() {
  var err error

    publisher := NewPublisher()

  publisher.AddSubscriber()
  publisher.AddSubscriber()
  publisher.AddSubscriber()

  publisher.Start()

  err = publisher.Publish("Hello World")
  if err != nil {
    fmt.Printf("could not publish: %v\n", err)
  }

  err = publisher.RemoveSubscriber(1)
  if err != nil {
    fmt.Printf("could not remove subscriber: %v\n", err)
  }

  err = publisher.Publish("Only channels 2 and 3 should print this")
  if err != nil {
    fmt.Printf("could not publish: %v\n", err)
  }

  // this is merely to keep the server running
  http.ListenAndServe(":8080", nil)
}
</code>```

publisher.go

```<code>package main

import (
    "context"
    "errors"
    "fmt"
    "sync"
)

// Publisher sends messages received in its in channel
// to all the Subscribers listening to it.
type Publisher struct {
    sequence    uint
    in          chan string
    subscribers map[uint]*Subscriber
    sync.RWMutex
    ctx         context.Context
    cancel      *context.CancelFunc
}

// NewPublisher returns a new Publisher with zero subscribers.
// A Publishers needs to be started with the Publisher.Start()
// method before it can start publishing incoming messages.
func NewPublisher() *Publisher {
    ctx, cancel := context.WithCancel(context.Background())
    return &Publisher{subscribers: map[uint]*Subscriber{}, ctx: ctx, cancel: &cancel}
}

// AddSubscriber creates a new Subscriber that starts
// listening to the messages sent by this Publisher.
func (p *Publisher) AddSubscriber() {
    dctx, cancel := context.WithCancel(p.ctx)
    p.Lock()
    nextId := p.sequence + 1
    subscriber := NewSubscriber(nextId, dctx, &cancel)
    p.subscribers[nextId] = subscriber
    p.sequence = p.sequence + 1
    p.Unlock()

    go func() {
        for {
            select {
            case <-p.ctx.Done():
                fmt.Printf("parent context cancelled\n")
                (*subscriber.cancel)()
                return
            case <-dctx.Done():
                fmt.Printf("subscriber %d's context cancelled\n", subscriber.id)
                return
            case msg := <-subscriber.out:
                fmt.Printf("message received on channel %d: %s\n", subscriber.id, msg)
            }
        }
    }()
}

// Publish sends the msg to all the subscribers subscribed to it.
func (p *Publisher) Publish(msg string) error {
    // publish only if Publisher has been started
    if p.in == nil {
        return errors.New("publisher not started yet")
    }
    // publish only if subscriber count > 0
    p.RLock()
    if len(p.subscribers) == 0 {
        return errors.New("no subscribers to receive the message")
    }
    p.RUnlock()

    // send message to in channel
    // establish lock to ensure no modifications take place
    // while the message is being sent
    p.Lock()
    p.in <- msg
    p.Unlock()

    return nil
}

// Start initializes the the publishers in channel
// and makes it ready to start publishing incoming messages.
func (p *Publisher) Start() {
    in := make(chan string)
    p.in = in

    go func() {
        for {
            select {
            case <-p.ctx.Done():
                // using break here only breaks out of select statement
                // instead of breaking out of the loop
                fmt.Printf("done called on publisher\n")
                return
            case msg := <-p.in:
                p.RLock()
                for _, subscriber := range p.subscribers {
                    subscriber.out <- msg
                }
                p.RUnlock()
            }
        }
    }()
}

// Stop prevents the Publisher from listening to any
// incoming messages by closing the in channel.
func (p *Publisher) Stop() {
    // should I also remove all subscribers to prevent it from panicking?
    (*p.cancel)()
}

// RemoveSubscriber removes the subscriber specified by the given id.
// It returns an error "could not find subscriber"
// if Subscriber with the given id is not subscribed to the Publisher.
func (p *Publisher) RemoveSubscriber(id uint) error {
    p.Lock()
    defer p.Unlock()
    subscriber, ok := p.subscribers[id]

    if !ok {
        return errors.New("could not find subscriber")
    }

    (*subscriber.cancel)()
    delete(p.subscribers, id)
    close(subscriber.out)

    return nil
}
</code>```

Body:
Below is my implementation of the Pub/Sub model in golang using concurrency. The code executes as expected sometimes but sometimes it gives output like this:

Output

message received on channel 2: Hello World
message received on channel 3: Hello World
message received on channel 1: Hello World
message received on channel 1:
subscriber 1's context cancelled
message received on channel 3: Only channels 2 and 3 should print this
message received on channel 2: Only channels 2 and 3 should print this

Key thing to note here is that subscriber 1 printed message received on channel 1:   even after there is a call in the main function to remove it as a subscriber. Subscriber 1 should only receive one message. What seems to be happening is that subscriber receives a message from subscriber.out before the dctx is cancelled. How can I fix this. The subscriber's goroutine is launched in the AddSubscriber method.

Expected execution:
Channel 1 should only print once and then it's context should be cancelled and it's goroutine should exit.

main.go

package main

import (
    "fmt"
    "net/http"
)

func main() {
  var err error

    publisher := NewPublisher()

  publisher.AddSubscriber()
  publisher.AddSubscriber()
  publisher.AddSubscriber()

  publisher.Start()

  err = publisher.Publish("Hello World")
  if err != nil {
    fmt.Printf("could not publish: %v\n", err)
  }

  err = publisher.RemoveSubscriber(1)
  if err != nil {
    fmt.Printf("could not remove subscriber: %v\n", err)
  }

  err = publisher.Publish("Only channels 2 and 3 should print this")
  if err != nil {
    fmt.Printf("could not publish: %v\n", err)
  }

  // this is merely to keep the server running
  http.ListenAndServe(":8080", nil)
}

publisher.go

package main

import (
    "context"
    "errors"
    "fmt"
    "sync"
)

// Publisher sends messages received in its in channel
// to all the Subscribers listening to it.
type Publisher struct {
    sequence    uint
    in          chan string
    subscribers map[uint]*Subscriber
    sync.RWMutex
    ctx         context.Context
    cancel      *context.CancelFunc
}

// NewPublisher returns a new Publisher with zero subscribers.
// A Publishers needs to be started with the Publisher.Start()
// method before it can start publishing incoming messages.
func NewPublisher() *Publisher {
    ctx, cancel := context.WithCancel(context.Background())
    return &Publisher{subscribers: map[uint]*Subscriber{}, ctx: ctx, cancel: &cancel}
}

// AddSubscriber creates a new Subscriber that starts
// listening to the messages sent by this Publisher.
func (p *Publisher) AddSubscriber() {
    dctx, cancel := context.WithCancel(p.ctx)
    p.Lock()
    nextId := p.sequence + 1
    subscriber := NewSubscriber(nextId, dctx, &cancel)
    p.subscribers[nextId] = subscriber
    p.sequence = p.sequence + 1
    p.Unlock()

    go func() {
        for {
            select {
            case <-p.ctx.Done():
                fmt.Printf("parent context cancelled\n")
                (*subscriber.cancel)()
                return
            case <-dctx.Done():
                fmt.Printf("subscriber %d's context cancelled\n", subscriber.id)
                return
            case msg := <-subscriber.out:
                fmt.Printf("message received on channel %d: %s\n", subscriber.id, msg)
            }
        }
    }()
}

// Publish sends the msg to all the subscribers subscribed to it.
func (p *Publisher) Publish(msg string) error {
    // publish only if Publisher has been started
    if p.in == nil {
        return errors.New("publisher not started yet")
    }
    // publish only if subscriber count > 0
    p.RLock()
    if len(p.subscribers) == 0 {
        return errors.New("no subscribers to receive the message")
    }
    p.RUnlock()

    // send message to in channel
    // establish lock to ensure no modifications take place
    // while the message is being sent
    p.Lock()
    p.in <- msg
    p.Unlock()

    return nil
}

// Start initializes the the publishers in channel
// and makes it ready to start publishing incoming messages.
func (p *Publisher) Start() {
    in := make(chan string)
    p.in = in

    go func() {
        for {
            select {
            case <-p.ctx.Done():
                // using break here only breaks out of select statement
                // instead of breaking out of the loop
                fmt.Printf("done called on publisher\n")
                return
            case msg := <-p.in:
                p.RLock()
                for _, subscriber := range p.subscribers {
                    subscriber.out <- msg
                }
                p.RUnlock()
            }
        }
    }()
}

// Stop prevents the Publisher from listening to any
// incoming messages by closing the in channel.
func (p *Publisher) Stop() {
    // should I also remove all subscribers to prevent it from panicking?
    (*p.cancel)()
}

// RemoveSubscriber removes the subscriber specified by the given id.
// It returns an error "could not find subscriber"
// if Subscriber with the given id is not subscribed to the Publisher.
func (p *Publisher) RemoveSubscriber(id uint) error {
    p.Lock()
    defer p.Unlock()
    subscriber, ok := p.subscribers[id]

    if !ok {
        return errors.New("could not find subscriber")
    }

    (*subscriber.cancel)()
    delete(p.subscribers, id)
    close(subscriber.out)

    return nil
}


问:
ASP.NET MVC 5: is there a way to set default culture under a specific Area? such as the admin area?
I have a multilingual site with two cultures ar and en where the arabic is the default one.

Yet under I'm having a date format issue under Areas/Admin which is why I need the culture under Admin Only to be set to en.

Is there a way to achieve this?

Thanks in advance.

I tried to set the culture under _ViewStart.cshtml

```<code>System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en");
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");`
</code>```

But when I submit the form, the Datetime field is still showing in "ar" format

Body:
I have a multilingual site with two cultures ar and en where the arabic is the default one.

Yet under I'm having a date format issue under Areas/Admin which is why I need the culture under Admin Only to be set to en.

Is there a way to achieve this?

Thanks in advance.

I tried to set the culture under _ViewStart.cshtml

System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en");
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");`

But when I submit the form, the Datetime field is still showing in "ar" format


问:
Spring Boot PostMapping should use @RequestParam or @RequestBody
I'm trying to create CRUD endpoints for a model and i feel little confused about the type of request I should use.

Let's say that this is my Entity:

```<code>@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Language {

    @Id
    @JsonProperty("language_id")
    private UUID languageId;

    @JsonProperty("language_name")
    private String languageName;

    @JsonProperty("abbreviation")
    private String abbreviation;

    @JsonProperty("created_at")
    private LocalDateTime createdAt;

    @JsonProperty("modified_at")
    private LocalDateTime modifiedAt;

}

</code>```

and i want to develop an endpoint in the Controller to create new language. The user should provide only the language name and the language abbreviation.

I've tried with this one :

```<code>
@Operation(
        summary = "Create a new language",
        description = "This endpoint is used to create a new language.\n" +
                "\n" +
                "| Parameter | Type | Description\n" +
                "| - | - | -\n" +
                "| language_name | String | The name of the language (arabic, french ...)\n" +
                "| languageAbbrev  | String | The abbreviation of the language (AR, FR...)\n",
        responses = {
                @ApiResponse(
                        description = "| Parameter | Type | Description\n" +
                                "| - | - | -\n" +
                                "|language_id| UUID | The unique identifier for the language\n" +
                                "| language_name | String | The name of the language (French, English ...)\n" +
                                "| languageAbbrev  | String | The abbreviation of the language (FR, EN...)\n" +
                                "| created_at | LocalDateTime | The first time the language was created\n" +
                                "| modified_at | LocalDateTime | The Last time the language was modified. If it's never modified it will return the created_at value\n",
                        responseCode = "200",
                        content = { @Content(mediaType = "application/json",
                                schema = @Schema(implementation = CreatedSKillDTO.class)) }),
                @ApiResponse(description = "language already exists", responseCode = "403", content = @Content),
                @ApiResponse(description = "Internal server error", responseCode = "500", content = @Content)
        }
)
@PostMapping("/")
public ResponseEntity<Language> addNewLanguage(@RequestParam("languageName") String languageName,
                                               @RequestParam("languageAbbrev") String languageAbbrv){
    return new ResponseEntity<>(languageService.addNewLanguage(languageName, languageAbbrv), HttpStatus.OK);
}

</code>```

The first question is: should i use languageName and languageAbbrv as RequestParams , or should i create a new object containing these two parameter and pass it as RequestBody?

The second question: I'm letting the database generate the Id of the language, is it a good practice or not !

Body:
I'm trying to create CRUD endpoints for a model and i feel little confused about the type of request I should use.

Let's say that this is my Entity:

@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Language {

    @Id
    @JsonProperty("language_id")
    private UUID languageId;

    @JsonProperty("language_name")
    private String languageName;

    @JsonProperty("abbreviation")
    private String abbreviation;

    @JsonProperty("created_at")
    private LocalDateTime createdAt;

    @JsonProperty("modified_at")
    private LocalDateTime modifiedAt;

}

and i want to develop an endpoint in the Controller to create new language. The user should provide only the language name and the language abbreviation.

I've tried with this one :

@Operation(
        summary = "Create a new language",
        description = "This endpoint is used to create a new language.\n" +
                "\n" +
                "| Parameter | Type | Description\n" +
                "| - | - | -\n" +
                "| language_name | String | The name of the language (arabic, french ...)\n" +
                "| languageAbbrev  | String | The abbreviation of the language (AR, FR...)\n",
        responses = {
                @ApiResponse(
                        description = "| Parameter | Type | Description\n" +
                                "| - | - | -\n" +
                                "|language_id| UUID | The unique identifier for the language\n" +
                                "| language_name | String | The name of the language (French, English ...)\n" +
                                "| languageAbbrev  | String | The abbreviation of the language (FR, EN...)\n" +
                                "| created_at | LocalDateTime | The first time the language was created\n" +
                                "| modified_at | LocalDateTime | The Last time the language was modified. If it's never modified it will return the created_at value\n",
                        responseCode = "200",
                        content = { @Content(mediaType = "application/json",
                                schema = @Schema(implementation = CreatedSKillDTO.class)) }),
                @ApiResponse(description = "language already exists", responseCode = "403", content = @Content),
                @ApiResponse(description = "Internal server error", responseCode = "500", content = @Content)
        }
)
@PostMapping("/")
public ResponseEntity<Language> addNewLanguage(@RequestParam("languageName") String languageName,
                                               @RequestParam("languageAbbrev") String languageAbbrv){
    return new ResponseEntity<>(languageService.addNewLanguage(languageName, languageAbbrv), HttpStatus.OK);
}

The first question is: should i use languageName and languageAbbrv as RequestParams , or should i create a new object containing these two parameter and pass it as RequestBody?

The second question: I'm letting the database generate the Id of the language, is it a good practice or not !


问:
Sparklyr problem with tidy() function in context of ml_generalized_linear_regression() compared to ml_logistic_regression()
I am trying to build a model through sparklyr.

I started with exploratory analysis and then data cleaning (one hot encoding mostly).

I then built a logistic regression model with a binary outcome variable (0,1) using ml_logistic_regression which worked well and I was able to use the tidy() function to get a tibble of coefficients.

However, I wished to obtain the standard deviations for the model so I went on to use ml_generalized_linear_regression(). This model also worked but it will not let me create the tibble due to an error:

```<code>Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  :
  arguments imply differing number of rows: 38, 0
</code>```

Clearly there is a difference in the number of rows in my arguments for the model but I'm not sure why that is the case.

One hot encoding method

```<code>dataset = mutate(dataset, var_1 = ifelse(var == 'x', 1,0), var_2 = ifelse(var == 'y', 1,0)```

model building method

```model <-dataset %>%  ml_logistic_regression(binaryoutcome ~ var1 + continuousvar, family = 'binomial')
summary(model)
tidy(model)
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  :
  arguments imply differing number of rows: 38, 0```

```

Body:
I am trying to build a model through sparklyr.

I started with exploratory analysis and then data cleaning (one hot encoding mostly).

I then built a logistic regression model with a binary outcome variable (0,1) using ml_logistic_regression which worked well and I was able to use the tidy() function to get a tibble of coefficients.

However, I wished to obtain the standard deviations for the model so I went on to use ml_generalized_linear_regression(). This model also worked but it will not let me create the tibble due to an error:

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  :
  arguments imply differing number of rows: 38, 0

Clearly there is a difference in the number of rows in my arguments for the model but I'm not sure why that is the case.

One hot encoding method

dataset = mutate(dataset, var_1 = ifelse(var == 'x', 1,0), var_2 = ifelse(var == 'y', 1,0)```

model building method

```model <-dataset %>%  ml_logistic_regression(binaryoutcome ~ var1 + continuousvar, family = 'binomial')
summary(model)
tidy(model)
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  :
  arguments imply differing number of rows: 38, 0```


问:
Ajax Progress bar interrupts page reloading(and flash-messages)(Ajax,Yii2,PHP)
The task was to create file uploading progres bar. (I'm a beginner,so please consider it). I found some good way how to make it with Ajax and JQuery. Everything seems to work good, percentege is running accordingly to file loading. But my backend(Yii2) response was Flash-message with the number of rewrited and created answers. But instead I've got nothing. I realized that the page is not reloading.
Below is my progress bar code:

```<code><?php
$loader = <<<JS
    $(document).ready(function(){
        // File upload via Ajax
        $(".formUpload").on('submit', function(e){
            e.preventDefault();
            $.ajax({
                xhr: function() {
                    var xhr = new window.XMLHttpRequest();
                    xhr.upload.addEventListener("progress", function(evt) {
                        if (evt.lengthComputable) {
                            var percentComplete = Math.floor(((evt.loaded / evt.total) * 100));
                            $(".progress-bar").width(percentComplete + '%');
                            $(".progress-bar").html(percentComplete+ '%');
                        }
                    }, false);
                    return xhr;
                },
                type: 'POST',
                url: "$url",
                data: new FormData(this),
                contentType: false,
                cache: false,
                processData:false,
                    beforeSend: function(){
                        $(".progress-bar").width('0%');
                    },
                    error:function(){
                         $('#uploadStatus').html('<p style="color:#EA4335;">Импорт не удался.</p>');
                    },
                    success: function(){
                        setTimeout(function (){
                            $('.formUpload')[0].reset();
                           // location.reload();
                            $('#uploadStatus').html(`<p style="color:#28A74B;">`+resp+`</p>`);
                        },500);

                    }
            });
        });
    });
JS;
$this->registerJs($loader);

?>
</code>```
```<code><div class="progress">
    <div class="progress-bar" role="progressbar" aria-label="Example with label" style="width: 0%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">0%</div>
</div>
</code>```

First I tried to use - location.reload(); but it didn't help.
So I tried to get response from the controller using success function and it works. But the problem , that first time we load files and php handle it and give response how many created and rewrited answers. In the end success function response shows this value and immediately numbers are changing to new.
Like this - Created:2,rewrited:3,Total imported:5 -> become - Created:0,rewrited:5,Total imported:5

The problem comes from multiple Ajax requests and all of them contain form, so php tries to handle again,but new answers already created, so it shows only rewrited.
Is there any option how to avoid it?Or to make working progress bar in another way ?

Body:
The task was to create file uploading progres bar. (I'm a beginner,so please consider it). I found some good way how to make it with Ajax and JQuery. Everything seems to work good, percentege is running accordingly to file loading. But my backend(Yii2) response was Flash-message with the number of rewrited and created answers. But instead I've got nothing. I realized that the page is not reloading.
Below is my progress bar code:

<?php
$loader = <<<JS
    $(document).ready(function(){
        // File upload via Ajax
        $(".formUpload").on('submit', function(e){
            e.preventDefault();
            $.ajax({
                xhr: function() {
                    var xhr = new window.XMLHttpRequest();
                    xhr.upload.addEventListener("progress", function(evt) {
                        if (evt.lengthComputable) {
                            var percentComplete = Math.floor(((evt.loaded / evt.total) * 100));
                            $(".progress-bar").width(percentComplete + '%');
                            $(".progress-bar").html(percentComplete+ '%');
                        }
                    }, false);
                    return xhr;
                },
                type: 'POST',
                url: "$url",
                data: new FormData(this),
                contentType: false,
                cache: false,
                processData:false,
                    beforeSend: function(){
                        $(".progress-bar").width('0%');
                    },
                    error:function(){
                         $('#uploadStatus').html('
Импорт не удался.
');
                    },
                    success: function(){
                        setTimeout(function (){
                            $('.formUpload')[0].reset();
                           // location.reload();
                            $('#uploadStatus').html(`<p style="color:#28A74B;">`+resp+`</p>`);
                        },500);

                    }
            });
        });
    });
JS;
$this->registerJs($loader);

?>

0%

First I tried to use - location.reload(); but it didn't help.
So I tried to get response from the controller using success function and it works. But the problem , that first time we load files and php handle it and give response how many created and rewrited answers. In the end success function response shows this value and immediately numbers are changing to new.
Like this - Created:2,rewrited:3,Total imported:5 -> become - Created:0,rewrited:5,Total imported:5

The problem comes from multiple Ajax requests and all of them contain form, so php tries to handle again,but new answers already created, so it shows only rewrited.
Is there any option how to avoid it?Or to make working progress bar in another way ?


问:
Is there a way to close the menu on a mobile browser when navigating back or forward to a web page that was previously viewed?
I'm new to building websites and am in the process of building a simple website that I'd like to use as a blog. I'd like to be able to have the menu closed (on a mobile browser) when navigating back or forward to a page that has been previously viewed. To achieve this I've been using Javascript to reload a page when navigating back or forward to it.

```<code>if(performance.getEntriesByType("navigation")[0].type == "back_forward"){
    location.reload();

debugger;

}
</code>```

This Javascript works well. However, I'm finding that there is now a flash of unstyled content that appears on the screen for about a second or so when navigating back or forward to a previously viewed page on my website.

As a workaround for getting the menu to close upon the navigation of a page on a mobile browser, I've been using a re-trigger of the javascript that I have set to the menu bar. I have it set up so that the background isn't scrollable when navigating and use the code below to ensure that it stays as such on a previously viewed page on my website. If I cannot close my menu upon navigation, I'd at least like it to function how I have it coded (have it so that the background freezes and isn't scrollable) when returning to a page. The Javascript no longer runs properly upon navigation to a previously viewed web page so I've been using this code to combat it. It doesn't seem to be working properly. The background is scrollable (which it shouldn't be) and I still find a flash of unstyled content appearing between pages.

```<code>if (performance.getEntriesByType("navigation")[0].type == "back_forward") {
  document.getElementById('cp_toggle03').dispatchEvent(
    new Event('change')
  );
}

</code>```

Below is all the code on my website. Is there a way I can set it so that the menu is closed when navigating back and forth between previously viewed web pages? Is setting Javascript to reload the page upon navigation my only option? Any knowledge that you could share with me would be very much appreciated. Thank you.

```<code><!DOCTYPE html>
<html lang="en">

<head>

<meta name="viewport" content="width=device-width, initial-scale=1.0;" charset="utf-8">

<title>MORIKOBOSHI・</title>

</head>

<body>

<div class="page-wrap">

<div class="cp_cont">
<input id="cp_toggle03" type="checkbox">
<div class="cp_mobilebar">
<label for="cp_toggle03" class="cp_menuicon">
<span></span>
</label>
</div>
<label id="h-menu_black" class="cp_toggle03" for="cp_menuicon"></label>
<div id="body" class="noscroll"></div>

<header class="cp_offcm03">

<nav>
<ul style="text-align: center; margin-left: 210px; overflow: hidden;">

<li style="border-bottom: 1px solid lightgray;"><a href="#">Home</a></li>
<li style="border-bottom: 1px solid lightgray;"><a href="#">Blog</a></li>
<li style="border-bottom: 1px solid lightgray;"><a href="#">About This Website</a></li>
<li style="border-bottom: 1px solid lightgray;"><a href="#">Bibliography</a></li>

<div class="searchbar">

<form id="frmSearch" class="search2" method="get" action="default.html" style=" padding-right: 10px; padding-top: 20px; text-align: center; position: inline;">
<input class="search2" id="txtSearch" type="text" placeholder="Custom Google Search" name="serach_bar" size="31" maxlength="255" value="" style="top: 185px; width: 180px; height: 26px;">
<input class="search1" type="submit" name="submition" value="Search" style="padding-left: 5px; top: 153px; height: 25px; width: 50.5px; display: inline-flex; justify-content: center; font-size: 10.5px;">
<input class="search2" type="hidden" name="sitesearch" value="default.html">

</form>
</div>

<script type="text/javascript">
 document.getElementById('frmSearch').onsubmit = function() {
 window.location = 'http://www.google.com/search?q=site:morikoboshi.com' + document.getElementById('txtSearch').value;
        return false;
    }

</script>

<script>
 document.getElementById('cp_toggle03').onchange = function() {
 if (document.getElementById('cp_toggle03').checked) {
 document.body.style.overflow = "hidden";
  } else {
 document.body.style.overflow = "";
  }
}

</script>

</ul>
</nav>
</header>

<div class="setsumei">

 <br><br><h1 style="text-align: center; font-size: 40px;">◯◯◯◯</h1>
    <br><p style="text-align: justify; font-size: 16px;"></p>

 <p style="text-align: center; font-size: 13px;">Author: ◯◯◯◯</p>
 <p style="text-align: center; font-size: 13px;">Photos/Videos Taken：◯◯◯◯/◯◯/◯◯</p>

 <br><br><p style="text-align: justify; font-size: 16px;">

    #
 </p>

</div>

<br><br><div class="image">

  <a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

</div>

<br><br><footer class="site-footer" style="font-size: 12px;">MORIKOBOSHI© | <a href="#">日本語</a></footer>

</div>
</div>

<style>

.body{background-color: white;
      font-family: sans-serif;}

 .searchbar{float: right;}

 .image{text-align: center;}

 .setsumei{margin-left: 20px;
           margin-right: 20px;}

 .footer{width: 100%;
           height: 40px;
           text-align: center;
           border-top: 1px solid black;
           position: absolute;
           bottom: 0;
           padding: 10px;}

 .page-wrap {
  min-height: 100%;
  /* equal to footer height */
  margin-bottom: -40px;
}

 .page-wrap:after {
  content: "";
  display: block;
  }

 .site-footer, .page-wrap:after {
  /* .push must be the same height as footer */
  height: 20px;
}

 .site-footer {
  text-align: center;
  border-top: 1px solid black;
  padding: 10px;
}

 *, *:before, *:after {
    padding-left: 0;
    margin: 0;
    box-sizing: border-box;

}

 ol, ul {
    list-style: none;
}

 a {
    text-decoration: none;
    color: black;
}

 .cp_cont {
    height: auto;
}

/* menu */
 .cp_offcm03 {
    position: relative;
    z-index: 5000;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: auto;
    width: 100%;
    height: auto;
    padding-top: 0;
    -webkit-transition: transform 0.3s ease-in;
            transition: transform 0.3s ease-in;
    text-align: center;
    color: black;
    background-color: white;
}
 .cp_offcm03 nav,
 .cp_offcm03 ul {
    height: 100%;
}

 .cp_offcm03 li {
    display: inline-block;
    margin-right: -6px;
}

 .cp_offcm03 a {
    display: block;
    padding: 15px 45px;
    margin-bottom: -5px;
    -webkit-transition: background-color .3s ease-in;
            transition: background-color .3s ease-in;
}

 .cp_offcm03 a:hover {
    background-color: lightgray;
}

/* menu toggle */
 #cp_toggle03 {
    display: none;
}

 #cp_toggle03:checked ~ .cp_offcm03 {
    -webkit-transform: translateX(0);
                    transform: translateX(0);
}

 #cp_toggle03:checked ~ .cp_container {
    -webkit-transform: translateX(0);
                    transform: translateX(0);
}

 .cp_mobilebar {
    display: none;

}

/* content */
 .cp_container {
    position: relative;
    top: 0;
    padding: 35px auto;
    -webkit-transition: transform .3s ease-in;
            transition: transform .3s ease-in;
}

 .cp_content {
    margin: 0 auto;
    padding: 20px;
    height: 65vh;
    text-align: center;

}

@media (max-width: 1130px)and (min-width: 280px) {
/* menu */
 .cp_offcm03 {
        position: fixed;
        left: -250px;
        overflow-y: hidden;
        width: 250px;
        height: 100%;
        padding-top: 40px;
        color: black;
        background-color: white;
        z-index: 1000;
    }

 .cp_offcm03 nav {
        background: white;
        border-right: 0.5px solid lightgray;
        margin-left: -210px;
    }

 .cp_offcm03 li {
        display: block;
        margin-right: 0;}

 .cp_offcm03 a {
        padding: 20px;

    }

/* menu toggle */
 .cp_mobilebar {
        display: block;
        z-index: 2000;
        position: relative;
        top: 0;
        left: 0;
        padding: 0 25px;
        width: 100%;
        height: 40px;
        background-color: white;
        border-bottom: .05px solid lightgray;

    }

 .cp_menuicon {
        display: block;
        position: relative;
        width: 25px;
        height: 100%;
        cursor: pointer;
        -webkit-transition: transform .3s ease-in;
                transition: transform .3s ease-in;
    }
 .cp_menuicon > span {
        display: block;
        position: absolute;
        top: 55%;
        margin-top: -0.3em;
        width: 100%;
        height: 0.2em;
        border-radius: 1px;
        background-color: black;
        -webkit-transition: transform .3s ease;
                transition: transform .3s ease;
    }
 .cp_menuicon > span:before,
 .cp_menuicon > span:after {
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        border-radius: 1px;
        background-color: black;
        -webkit-transition: transform .3s ease-in;
                transition: transform .3s ease-in;
    }

 .cp_menuicon > span:before {
        -webkit-transform: translateY(-0.6em);
                transform: translateY(-0.6em);
    }

 .cp_menuicon > span:after {
        -webkit-transform: translateY(0.6em);
                transform: translateY(0.6em);
    }

 #cp_toggle03:checked + .cp_mobilebar .cp_menuicon {
        -webkit-transform: rotate(45deg);
                transform: rotate(45deg);
    }

 #cp_toggle03:checked + .cp_mobilebar span:before,
 #cp_toggle03:checked + .cp_mobilebar span:after {
        -webkit-transform: rotate(90deg);
                transform: rotate(90deg);
    }

 #cp_toggle03:checked ~ .cp_offcm03 {
        -webkit-transform: translateX(100%);
                transform: translateX(100%);
    }

 #cp_toggle03:checked ~ .cp_container {
        -webkit-transform: translateX(250px);
                transform: translateX(250px);
    }

 input:checked ~ #h-menu_black {
    display: block;/*カバーを表示*/
    opacity: .6;
}

 #h-menu_black {
    display: none;
    position: fixed;
    z-index: 999;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    opacity: 0;
    transition: .7s ease-in-out;
}

/* content */
 .cp_container {
        top: 60px;
        height: 92vh;
        text-align: center;
    }

 .noscroll{
        overflow: hidden;
        position: fixed;
    }

</style>

</body>
</html>

</code>```

Body:
I'm new to building websites and am in the process of building a simple website that I'd like to use as a blog. I'd like to be able to have the menu closed (on a mobile browser) when navigating back or forward to a page that has been previously viewed. To achieve this I've been using Javascript to reload a page when navigating back or forward to it.

if(performance.getEntriesByType("navigation")[0].type == "back_forward"){
    location.reload();

debugger;

}

This Javascript works well. However, I'm finding that there is now a flash of unstyled content that appears on the screen for about a second or so when navigating back or forward to a previously viewed page on my website.

As a workaround for getting the menu to close upon the navigation of a page on a mobile browser, I've been using a re-trigger of the javascript that I have set to the menu bar. I have it set up so that the background isn't scrollable when navigating and use the code below to ensure that it stays as such on a previously viewed page on my website. If I cannot close my menu upon navigation, I'd at least like it to function how I have it coded (have it so that the background freezes and isn't scrollable) when returning to a page. The Javascript no longer runs properly upon navigation to a previously viewed web page so I've been using this code to combat it. It doesn't seem to be working properly. The background is scrollable (which it shouldn't be) and I still find a flash of unstyled content appearing between pages.

if (performance.getEntriesByType("navigation")[0].type == "back_forward") {
  document.getElementById('cp_toggle03').dispatchEvent(
    new Event('change')
  );
}

Below is all the code on my website. Is there a way I can set it so that the menu is closed when navigating back and forth between previously viewed web pages? Is setting Javascript to reload the page upon navigation my only option? Any knowledge that you could share with me would be very much appreciated. Thank you.

<!DOCTYPE html>

<meta name="viewport" content="width=device-width, initial-scale=1.0;" charset="utf-8">

<title>MORIKOBOSHI・</title>

<input id="cp_toggle03" type="checkbox">

Home

Blog

About This Website

Bibliography

<form id="frmSearch" class="search2" method="get" action="default.html" style=" padding-right: 10px; padding-top: 20px; text-align: center; position: inline;">
<input class="search2" id="txtSearch" type="text" placeholder="Custom Google Search" name="serach_bar" size="31" maxlength="255" value="" style="top: 185px; width: 180px; height: 26px;">
<input class="search1" type="submit" name="submition" value="Search" style="padding-left: 5px; top: 153px; height: 25px; width: 50.5px; display: inline-flex; justify-content: center; font-size: 10.5px;">
<input class="search2" type="hidden" name="sitesearch" value="default.html">

</form>

◯◯◯◯

Author: ◯◯◯◯

Photos/Videos Taken：◯◯◯◯/◯◯/◯◯

    #

MORIKOBOSHI© | 日本語


问:
Instagram API Doesn't Show The Alteration
When i send a get request to this api, it returns the user's profile information but if user follows a new account and if i send a get request again it doesn't return the alteration.

https://i.instagram.com/api/v1/users/web_profile_info/?username=


问:
Magento 2 & Cybersource payment invalid field for duplicated product categories
I'm using Cybersource Payment gateway for my Magento 2 install, the gateway require some Merchant Data fields to be populated with the oeder, one of the fields is the Product category, currently i'm using the below method

```<code>   $name = $categories = [];
            foreach ($order->getAllVisibleItems() as $_item) {
                array_push($name, $_item->getName());
                $product = $this->productModel->load($_item->getProductId());
                $cats = $product->getCategoryIds();
                foreach($cats as $cat){
                    $category = $this->categoryModel->load($cat);
                    array_push($categories, $category->getName());
                }

            }
</code>```

Then i'm calling the category using

```<code>                'product_category' => implode(',', $categories),

</code>```

but the issue is, when i'm creating an order with more than one product from the same category lets say 3 products from the same category, it show in the response the categories 3 times, and in this way i receive an error in cybersource that the product category fields has an invalid value.

how to show only the product category only one time?

Body:
I'm using Cybersource Payment gateway for my Magento 2 install, the gateway require some Merchant Data fields to be populated with the oeder, one of the fields is the Product category, currently i'm using the below method

   $name = $categories = [];
            foreach ($order->getAllVisibleItems() as $_item) {
                array_push($name, $_item->getName());
                $product = $this->productModel->load($_item->getProductId());
                $cats = $product->getCategoryIds();
                foreach($cats as $cat){
                    $category = $this->categoryModel->load($cat);
                    array_push($categories, $category->getName());
                }

            }

Then i'm calling the category using

                'product_category' => implode(',', $categories),

but the issue is, when i'm creating an order with more than one product from the same category lets say 3 products from the same category, it show in the response the categories 3 times, and in this way i receive an error in cybersource that the product category fields has an invalid value.

how to show only the product category only one time?


问:
error when deploying nextjs on netlify/ anyone could help me fix this error thank you]
[error when deploying nextjs on netlify/ anyone could help me fix this error thank you]
(https://i.stack.imgur.com/FaOHC.png)

Followed the instruction on the error but still not working


问:
Here sdk Flutter error plugins add, how to fix it?
i allready for add here sdk add sdk in dep
Initialize the HERE SDK androidmanifest n xmlns:tools="http://schemas.android.com/tools"
enter image description here

in the tutorial if add SDK in dependencies the error in plugins/here_sdk auto correct, but in my code is error


问:
Rails db:drop issue | no implicit conversion of nil into String | ' TypeError: no implicit conversion of nil into String
Let me tell you first that I have the user model containing the password_digest

```<code>class CreateUsers < ActiveRecord::Migration[6.1]
  def change
    create_table :users do |t|
      t.string :first_name
      t.string :last_name
      t.string :thumbnail
      t.string :email
      t.string :password_digest
      t.string :uid
      t.string :provider

      t.timestamps
    end
  end
end
</code>```

But I decided to install the Devise with the same User model as below:

```<code>class AddDeviseToUsers < ActiveRecord::Migration[7.0]
  def self.up
    change_table :users do |t|
      ## Database authenticatable
      #t.string :email,              null: false, default: ""
      t.string :encrypted_password, null: false, default: ""
    end
    add_index :users, :email,                unique: true
    add_index :users, :reset_password_token, unique: true
  end

  def self.down
    # By default, we don't want to make any assumption about how to roll back a migration when your
    # model already existed. Please edit below which fields you would like to remove in this migration.
    raise ActiveRecord::IrreversibleMigration
  end
end
</code>```

And I generate new migration to remove such password_digest as follows:

```<code>class RemovePasswordDigestFromUsers < ActiveRecord::Migration[7.0]
  def change
    remove_column :users, :password_digest, :string
  end
end
</code>```

But what happen is I cannot do rails db:seed

```<code>rails aborted!
NoMethodError: undefined method `password_digest=' for #<User id: nil, first_name: "Clifford", last_name: "Marshall", thumbnail: nil, email: "owner1@example.com", uid: nil, provider: nil, created_at: nil, updated_at: nil>
Did you mean?  password_digest
/xxx/xxx/xxx/xxx/db/seeds.rb:18:in `<main>'
</code>```

While my code db/seeds.rb:18:in is as follows:

```<code>owners = User.create([
                       {
                         first_name: 'Clifford',
                         last_name: 'Marshall',
                         email: 'owner1@example.com',
                         password: '12345678',
                         thumbnail: 'https://randomuser.me/api/portraits/thumb/men/50.jpg',
                       },
</code>```

So now I'm trying to to the rails db:reset but seems like rails db:drop cannot proceed with the following error

```<code>no implicit conversion of nil into String
Couldn't drop database ''
rails aborted!
TypeError: no implicit conversion of nil into String

Tasks: TOP => db:drop:_unsafe
(See full trace by running task with --trace)
</code>```

And when I roll back once (only for the migration that used for removing password_digest) I can't do it more with the following error:

```<code>rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

ActiveRecord::IrreversibleMigration
/xxx/xxx/xxx/xxx/db/migrate/20221211120417_add_devise_to_users.rb:49:in `down'

Caused by:
ActiveRecord::IrreversibleMigration: ActiveRecord::IrreversibleMigration
/xxx/xxx/xxx/xxx/db/migrate/20221211120417_add_devise_to_users.rb:49:in `down'
</code>```

Appreciate your help sir.

Body:
Let me tell you first that I have the user model containing the password_digest

class CreateUsers < ActiveRecord::Migration[6.1]
  def change
    create_table :users do |t|
      t.string :first_name
      t.string :last_name
      t.string :thumbnail
      t.string :email
      t.string :password_digest
      t.string :uid
      t.string :provider

      t.timestamps
    end
  end
end

But I decided to install the Devise with the same User model as below:

class AddDeviseToUsers < ActiveRecord::Migration[7.0]
  def self.up
    change_table :users do |t|
      ## Database authenticatable
      #t.string :email,              null: false, default: ""
      t.string :encrypted_password, null: false, default: ""
    end
    add_index :users, :email,                unique: true
    add_index :users, :reset_password_token, unique: true
  end

  def self.down
    # By default, we don't want to make any assumption about how to roll back a migration when your
    # model already existed. Please edit below which fields you would like to remove in this migration.
    raise ActiveRecord::IrreversibleMigration
  end
end

And I generate new migration to remove such password_digest as follows:

class RemovePasswordDigestFromUsers < ActiveRecord::Migration[7.0]
  def change
    remove_column :users, :password_digest, :string
  end
end

But what happen is I cannot do rails db:seed

rails aborted!
NoMethodError: undefined method `password_digest=' for #<User id: nil, first_name: "Clifford", last_name: "Marshall", thumbnail: nil, email: "owner1@example.com", uid: nil, provider: nil, created_at: nil, updated_at: nil>
Did you mean?  password_digest
/xxx/xxx/xxx/xxx/db/seeds.rb:18:in `'

While my code db/seeds.rb:18:in is as follows:

owners = User.create([
                       {
                         first_name: 'Clifford',
                         last_name: 'Marshall',
                         email: 'owner1@example.com',
                         password: '12345678',
                         thumbnail: 'https://randomuser.me/api/portraits/thumb/men/50.jpg',
                       },

So now I'm trying to to the rails db:reset but seems like rails db:drop cannot proceed with the following error

no implicit conversion of nil into String
Couldn't drop database ''
rails aborted!
TypeError: no implicit conversion of nil into String

Tasks: TOP => db:drop:_unsafe
(See full trace by running task with --trace)

And when I roll back once (only for the migration that used for removing password_digest) I can't do it more with the following error:

rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

ActiveRecord::IrreversibleMigration
/xxx/xxx/xxx/xxx/db/migrate/20221211120417_add_devise_to_users.rb:49:in `down'

Caused by:
ActiveRecord::IrreversibleMigration: ActiveRecord::IrreversibleMigration
/xxx/xxx/xxx/xxx/db/migrate/20221211120417_add_devise_to_users.rb:49:in `down'

Appreciate your help sir.


问:
! object 'long' not found while plotting shp using ggplot2
I have this simple code to read shp file and plot in 3D.

```<code>library(sf)
library(ggplot2)
library(ggmap)    # for fortifying shapefiles
nc <- st_read("shp/polygons.shp")
#plot(st_zm(nc), max.plot = 1)
shapefile_df <- fortify(nc)
map <- ggplot() +
  geom_path(data = shapefile_df,
            aes(x=long, y=lat, group = group),
            color = 'gray', fill = 'white', size = .2)

print(map)
</code>```

but I am getting an error

```<code>    Error in `geom_path()`:
! Problem while computing aesthetics.
ℹ Error occurred in the 1st layer.
Caused by error in `FUN()`:
! object 'long' not found
Run `rlang::last_error()` to see where the error occurred.
</code>```

Here is the nc object

Body:
I have this simple code to read shp file and plot in 3D.

library(sf)
library(ggplot2)
library(ggmap)    # for fortifying shapefiles
nc <- st_read("shp/polygons.shp")
#plot(st_zm(nc), max.plot = 1)
shapefile_df <- fortify(nc)
map <- ggplot() +
  geom_path(data = shapefile_df,
            aes(x=long, y=lat, group = group),
            color = 'gray', fill = 'white', size = .2)

print(map)

but I am getting an error

    Error in `geom_path()`:
! Problem while computing aesthetics.
ℹ Error occurred in the 1st layer.
Caused by error in `FUN()`:
! object 'long' not found
Run `rlang::last_error()` to see where the error occurred.

Here is the nc object


问:
Angular Material stepper animation on step change
Angular Material horizontal stepper has a nice animated feature on step change. On each step the new content is scrolled on enter. But it is missing the leave animation!

How it could be implemented?

For reference the demo

Demo: https://stackblitz.com/run?file=src%2Fapp%2Fstepper-overview-example.ts

HTML:

```<code><button mat-raised-button (click)="isLinear = !isLinear" id="toggle-linear">
  {{!isLinear ? 'Enable linear mode' : 'Disable linear mode'}}
</button>
<mat-stepper [linear]="isLinear" #stepper>
  <mat-step [stepControl]="firstFormGroup">
    <form [formGroup]="firstFormGroup">
      <ng-template matStepLabel>Fill out your name</ng-template>
      <mat-form-field appearance="fill">
        <mat-label>Name</mat-label>
        <input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
      </mat-form-field>
      <div>
        <button mat-button matStepperNext>Next</button>
      </div>
    </form>
  </mat-step>
  <!-- #docregion label -->
  <mat-step [stepControl]="secondFormGroup" label="Fill out your address">
  <!-- #enddocregion label -->
    <form [formGroup]="secondFormGroup">
      <mat-form-field appearance="fill">
        <mat-label>Address</mat-label>
        <input matInput formControlName="secondCtrl" placeholder="Ex. 1 Main St, New York, NY"
               required>
      </mat-form-field>
      <div>
        <button mat-button matStepperPrevious>Back</button>
        <button mat-button matStepperNext>Next</button>
      </div>
    </form>
  </mat-step>
  <mat-step>
    <ng-template matStepLabel>Done</ng-template>
    <p>You are now done.</p>
    <div>
      <button mat-button matStepperPrevious>Back</button>
      <button mat-button (click)="stepper.reset()">Reset</button>
    </div>
  </mat-step>
</mat-stepper>

import {Component} from '@angular/core';
import {FormBuilder, Validators} from '@angular/forms';

@Component({
  selector: 'stepper-overview-example',
  templateUrl: 'stepper-overview-example.html',
  styleUrls: ['stepper-overview-example.css'],
})
export class StepperOverviewExample {
  firstFormGroup = this._formBuilder.group({
    firstCtrl: ['', Validators.required],
  });
  secondFormGroup = this._formBuilder.group({
    secondCtrl: ['', Validators.required],
  });
  isLinear = false;

  constructor(private _formBuilder: FormBuilder) {}
}
</code>```

Body:
Angular Material horizontal stepper has a nice animated feature on step change. On each step the new content is scrolled on enter. But it is missing the leave animation!

How it could be implemented?

For reference the demo

Demo: https://stackblitz.com/run?file=src%2Fapp%2Fstepper-overview-example.ts

HTML:

<button mat-raised-button (click)="isLinear = !isLinear" id="toggle-linear">
  {{!isLinear ? 'Enable linear mode' : 'Disable linear mode'}}
</button>
<mat-stepper [linear]="isLinear" #stepper>
  <mat-step [stepControl]="firstFormGroup">
    <form [formGroup]="firstFormGroup">
      <ng-template matStepLabel>Fill out your name</ng-template>
      <mat-form-field appearance="fill">
        <mat-label>Name</mat-label>
        <input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
      </mat-form-field>

        <button mat-button matStepperNext>Next</button>

    </form>
  </mat-step>

  <mat-step [stepControl]="secondFormGroup" label="Fill out your address">

    <form [formGroup]="secondFormGroup">
      <mat-form-field appearance="fill">
        <mat-label>Address</mat-label>
        <input matInput formControlName="secondCtrl" placeholder="Ex. 1 Main St, New York, NY"
               required>
      </mat-form-field>

        <button mat-button matStepperPrevious>Back</button>
        <button mat-button matStepperNext>Next</button>

    </form>
  </mat-step>
  <mat-step>
    <ng-template matStepLabel>Done</ng-template>

You are now done.

      <button mat-button matStepperPrevious>Back</button>
      <button mat-button (click)="stepper.reset()">Reset</button>

  </mat-step>
</mat-stepper>

import {Component} from '@angular/core';
import {FormBuilder, Validators} from '@angular/forms';

@Component({
  selector: 'stepper-overview-example',
  templateUrl: 'stepper-overview-example.html',
  styleUrls: ['stepper-overview-example.css'],
})
export class StepperOverviewExample {
  firstFormGroup = this._formBuilder.group({
    firstCtrl: ['', Validators.required],
  });
  secondFormGroup = this._formBuilder.group({
    secondCtrl: ['', Validators.required],
  });
  isLinear = false;

  constructor(private _formBuilder: FormBuilder) {}
}


问:
OSError: [Errno 22] Invalid argument for taking input from user for a csv file
I am trying to convert a csv file data into a sql table and to do that i am taking input of the file from the user.

```<code>fileinput = input("Which file do you want:")
            data=pd.read_csv(fileinput)
            df=pd.DataFrame(data)
            for row in df.itertuples():
                cursor.execute('''INSERT INTO xiib(Rollno,Name,Physics,Chemistry,Maths,Computer_Sci,English,Physical_edu)
                VALUES (?,?,?,?,?,?,?,?)
                ''',
                row.Rollno,
                row.Name,
                row.Physics,
                row.Chemistry,
                row.Maths,
                row.Computer_Sci,
                row.English,
                row.Physical_edu
                )
            mycon.commit()
</code>```

the error:
OSError: [Errno 22] Invalid argument:

the output is showing invalid argument and i have tried using r: for string but isn't helping either
the other error is AttributeError: 'Pandas' object has no attribute 'Physics', I don't understand thsi one either as the values before this don't raise any error

Body:
I am trying to convert a csv file data into a sql table and to do that i am taking input of the file from the user.

fileinput = input("Which file do you want:")
            data=pd.read_csv(fileinput)
            df=pd.DataFrame(data)
            for row in df.itertuples():
                cursor.execute('''INSERT INTO xiib(Rollno,Name,Physics,Chemistry,Maths,Computer_Sci,English,Physical_edu)
                VALUES (?,?,?,?,?,?,?,?)
                ''',
                row.Rollno,
                row.Name,
                row.Physics,
                row.Chemistry,
                row.Maths,
                row.Computer_Sci,
                row.English,
                row.Physical_edu
                )
            mycon.commit()

the error:
OSError: [Errno 22] Invalid argument:

the output is showing invalid argument and i have tried using r: for string but isn't helping either
the other error is AttributeError: 'Pandas' object has no attribute 'Physics', I don't understand thsi one either as the values before this don't raise any error


问:
Why my mongodb is not connecting with nodejs? MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One c
Why my mongo dB is not connecting with nodejs? its showing thi error in console
MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/ its also not consoling Database connected! and in Atlas its showing Current IP Address not added. You will not be able to connect to databases from this address. i tried to add  ADD IP ADDRESS but when ever i am refreshing it than its showing IP Address not added again and again

```<code>const mongoose = require("mongoose");
require('dotenv').config();

mongoose.connect(process.env.MONGO_URL).then(
    () => {
        console.log("Database connected!")
    }
).catch((err) => {
    console.log(err)
})
</code>```

env:

```<code>MONGO_URL = 'mongodb+srv://app123:app123@cluster0.w6xczff.mongodb.net/?retryWrites=true&w=majority'
JWT_SECERT = 'app'
</code>```

Body:
Why my mongo dB is not connecting with nodejs? its showing thi error in console
MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/ its also not consoling Database connected! and in Atlas its showing Current IP Address not added. You will not be able to connect to databases from this address. i tried to add  ADD IP ADDRESS but when ever i am refreshing it than its showing IP Address not added again and again

const mongoose = require("mongoose");
require('dotenv').config();

mongoose.connect(process.env.MONGO_URL).then(
    () => {
        console.log("Database connected!")
    }
).catch((err) => {
    console.log(err)
})

env:

MONGO_URL = 'mongodb+srv://app123:app123@cluster0.w6xczff.mongodb.net/?retryWrites=true&w=majority'
JWT_SECERT = 'app'


问:
MUI DataGrid height transition
```<code>        const [pageSize, setPageSize] = useState<number>(10);

        <DataGrid
          pageSize={pageSize}
          autoHeight
          ...
        />
</code>```

The DataGrid is autoHeight. The default pageSize is set to 10. After invoke the `setPageSize`, the pageSize will changed, and the DataGrid conent and height will change dynamically.

Is there any way to make the transition effect in height in DataGrid after the pageSize value is changed. Thanks.

Title: MUI DataGrid height transition

Body:
        const [pageSize, setPageSize] = useState<number>(10);

        <DataGrid
          pageSize={pageSize}
          autoHeight
          ...
        />

The DataGrid is autoHeight. The default pageSize is set to 10. After invoke the `setPageSize`, the pageSize will changed, and the DataGrid conent and height will change dynamically.

Is there any way to make the transition effect in height in DataGrid after the pageSize value is changed. Thanks.


问:
Changing page number of interactive table in order to scrape data from website
I have been scraping certain data from https://stats.oecd.org/Index.aspx?DataSetCode=REVDEU

Having successfully scraped the data on the first page, I am struggling to scrape the data on the next page. As changing the page of the table doesn't change the URL, it must use javascript instead and therefore will I have to use selenium?
How do I go about setting the PageNumber parameter to page 2?

```<code>from bs4 import BeautifulSoup
import requests
import pandas as pd

url = "https://stats.oecd.org/Index.aspx?DataSetCode=REVDEU"
page = requests.get(url)
soup = BeautifulSoup(page.text, 'lxml')

table = soup.find("table", {'class': 'DataTable'})

for row in table.find_all('tr', {'id': 'row1'}):
    data = row.find_all('td')
    row_data = [td.text.strip() for td in data]

</code>```

Relevant website element:

```<code><select class="PageNumber" name="PAGE" id="PAGE" onchange="ChgPageNumberSel(this.selectedIndex+1)">
<option value="1">1</option>
<option value="2" selected="selected">2</option>
<option value="3">3</option>
<option value="4">4</option></select>
</code>```

Body:
I have been scraping certain data from https://stats.oecd.org/Index.aspx?DataSetCode=REVDEU

Having successfully scraped the data on the first page, I am struggling to scrape the data on the next page. As changing the page of the table doesn't change the URL, it must use javascript instead and therefore will I have to use selenium?
How do I go about setting the PageNumber parameter to page 2?

from bs4 import BeautifulSoup
import requests
import pandas as pd

url = "https://stats.oecd.org/Index.aspx?DataSetCode=REVDEU"
page = requests.get(url)
soup = BeautifulSoup(page.text, 'lxml')

table = soup.find("table", {'class': 'DataTable'})

for row in table.find_all('tr', {'id': 'row1'}):
    data = row.find_all('td')
    row_data = [td.text.strip() for td in data]

Relevant website element:

<select class="PageNumber" name="PAGE" id="PAGE" onchange="ChgPageNumberSel(this.selectedIndex+1)">
<option value="1">1</option>
<option value="2" selected="selected">2</option>
<option value="3">3</option>
<option value="4">4</option></select>


问:
Which method is best to select a particular value from a PHP array and use as a new array?
Here is a PHP array example

```<code>Array
(
    [A1345] => Array
        (
            [name] => Choco Chip Cookies
            [code] => A1345
            [price] => 180
            [quantity] => 1
            [mrp] => 220
        )

    [A1344] => Array
        (
            [name] => Handmade Soap
            [code] => A1344
            [price] => 210
            [quantity] => 1
            [mrp] => 258
        )

)
</code>```

I would Like to use the [code] A1345 and A1344 as a different array, how can I do that. This is just an example. The array can be smaller or larger.

The intention is to save these product code in database when user submits the date via a shopping cart.

Which of the following is better ?

```<code>$names = array_column($array, 'code');
print_r($names);
</code>```

#result Array ( [0] => A1345 [1] => A1344 )

or

```<code>    $result = array_map(
    function($x) {
        return $x['code'];
    }, $array);

print_r($result);
</code>```

#Result Array ( [A1345] => A1345 [A1344] => A1344 )

Body:
Here is a PHP array example

Array
(
    [A1345] => Array
        (
            [name] => Choco Chip Cookies
            [code] => A1345
            [price] => 180
            [quantity] => 1
            [mrp] => 220
        )

    [A1344] => Array
        (
            [name] => Handmade Soap
            [code] => A1344
            [price] => 210
            [quantity] => 1
            [mrp] => 258
        )

)

I would Like to use the [code] A1345 and A1344 as a different array, how can I do that. This is just an example. The array can be smaller or larger.

The intention is to save these product code in database when user submits the date via a shopping cart.

Which of the following is better ?

$names = array_column($array, 'code');
print_r($names);

#result Array ( [0] => A1345 [1] => A1344 )

or

    $result = array_map(
    function($x) {
        return $x['code'];
    }, $array);

print_r($result);

#Result Array ( [A1345] => A1345 [A1344] => A1344 )


问:
Spider not Crawling in scrapyd But Works Using scrapy crawl
I was tasked for work to pull a ton of inventory for a company that was acquired by the company I work for. I thought scrapy would be a great tool for this and so far I'm having fun. However, I am trying to utilize scrapyd and am running into a problem that might be an easy fix. I am using a virtual environment (env) and I am running the following:

Ubuntu 20.04

Python 3.8

Scrapy 2.7.1

scrapyd 1.3.0 (twistd 22.10.0)

scrapyd-client 1.2.2

I just cloned a scrapy project with a spider that looked interesting from github and started playing around. I am able to run the spider using the command:

```<code>scrapy crawl examplespider
</code>```

It works great and I love it. I followed some tutorials to use scrapyd and deploy my scrapy projects to it and schedule them. This is where I run into the problem I am having. I can confirm that the daemon is running:

```<code>(scrape) ubuntu@ip-172-26-13-235:~/env$ curl http://localhost:6800/daemonstatus.json
{"node_name": "ip-172-26-13-235", "status": "ok", "pending": 0, "running": 0, "finished": 11}
</code>```

Verified that the project was deployed:

```<code>(scrape) ubuntu@ip-172-26-13-235:~/env$ curl http://localhost:6800/listprojects.json
{"node_name": "ip-172-26-13-235", "status": "ok", "projects": ["NebulaEmailScraper"]}
</code>```

Checked the versions (There are a lot because I was troubleshooting trying to make it work)

```<code>(scrape) ubuntu@ip-172-26-13-235:~/env$ curl http://localhost:6800/listversions.json?project=NebulaEmailScraper
{"node_name": "ip-172-26-13-235", "status": "ok", "versions": ["1671003419", "1671086362", "1671182432", "1671183695", "1671183711", "1671183723", "1671183824", "1671184333", "1671184826", "1671184854", "1671186281", "1671187105", "1671260058", "1671260865", "1671261377", "1671261947"]}
</code>```

Checked the spider:

```<code>(scrape) ubuntu@ip-172-26-13-235:~/env$ curl http://localhost:6800/listspiders.json?project=NebulaEmailScraper
{"node_name": "ip-172-26-13-235", "status": "ok", "spiders": ["googleemailspider"]}
</code>```

Checked the jobs that I scheduled and ran:

```<code>    (scrape) ubuntu@ip-172-26-13-235:~/env$ curl http://localhost:6800/listjobs.json?project=NebulaEmailScraper | python -m json.tool
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2228  100  2228    0     0   120k      0 --:--:-- --:--:-- --:--:--  120k
{    "node_name": "ip-172-26-13-235",
     "status": "ok",    "pending": [],
     "running": [],    "finished": [
    {
             "project": "NebulaEmailScraper",
             "spider": "googleemailspider",
             "id": "1ccfce2e7ddc11edbfc8f1be5e75662a",
             "start_time": "2022-12-17 07:26:25.477894",
             "end_time": "2022-12-17 07:26:26.445959"
    },
    ... I won't list all of them
</code>```

Here are what the log files look like:

```<code>scrapy.spidermiddlewares.depth.DepthMiddleware']
2022-12-17 06:57:41 [scrapy.middleware] INFO: Enabled item pipelines:
['nebulaemailscraper.pipelines.EmailsDetailsPipeline']
2022-12-17 06:57:41 [scrapy.core.engine] INFO: Spider opened
2022-12-17 06:57:41 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2022-12-17 06:57:41 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023
2022-12-17 06:57:41 [scrapy.core.engine] INFO: Closing spider (finished)
2022-12-17 06:57:41 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'elapsed_time_seconds': 0.002463,
 'finish_reason': 'finished',
 'finish_time': datetime.datetime(2022, 12, 17, 6, 57, 41, 386908),
 'log_count/DEBUG': 1,
 'log_count/INFO': 10,
 'log_count/WARNING': 1,
 'memusage/max': 63549440,
 'memusage/startup': 63549440,
 'start_time': datetime.datetime(2022, 12, 17, 6, 57, 41, 384445)}
2022-12-17 06:57:41 [scrapy.core.engine] INFO: Spider closed (finished)
</code>```

Like I said, when I run scrapy crawl [spidername] it works great and says it crawled 100s of pages.

Here is my scrapy.cfg

```<code># Automatically created by: scrapy startproject
#
# For more information about the [deploy] section see:
# https://scrapyd.readthedocs.io/en/latest/deploy.html

[settings]
default = nebulaemailscraper.settings

[deploy]
url = http://localhost:6800/
project = nebulaemailscraper
</code>```

Here is my settings.py

```<code>BOT_NAME = "nebulaemailscraper"
SPIDER_MODULES = ["nebulaemailscraper.spiders"]
NEWSPIDER_MODULE = "nebulaemailscraper.spiders"

# Crawl responsibly by identifying yourself (and your website) on the user-agent
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36"

# Obey robots.txt rules
ROBOTSTXT_OBEY = False
DOWNLOAD_DELAY = 0.1

# Enable or disable spider middlewares
# See https://docs.scrapy.org/en/latest/topics/spider-middleware.html
SPIDER_MIDDLEWARES = {
    "nebulaemailscraper.middlewares.NebulaemailscraperSpiderMiddleware": 543,
}

# Enable or disable downloader middlewares
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
    'nebulaemailscraper.middlewares.NebulaemailscraperDownloaderMiddleware': 543,
}

# Enable or disable extensions
# See https://docs.scrapy.org/en/latest/topics/extensions.html
EXTENSIONS = {
    'scrapy.extensions.telnet.TelnetConsole': None,
}

# Configure item pipelines
# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
    "nebulaemailscraper.pipelines.EmailsDetailsPipeline": 300,
}

# Enable or disable spider middlewares
# See https://docs.scrapy.org/en/latest/topics/spider-middleware.html
SPIDER_MIDDLEWARES = {
    "nebulaemailscraper.middlewares.NebulaemailscraperSpiderMiddleware": 543,
}

# Enable or disable downloader middlewares
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
    'nebulaemailscraper.middlewares.NebulaemailscraperDownloaderMiddleware': 543,
}

# Enable or disable extensions
# See https://docs.scrapy.org/en/latest/topics/extensions.html
EXTENSIONS = {
    'scrapy.extensions.telnet.TelnetConsole': None,
}

# Configure item pipelines
# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
    "nebulaemailscraper.pipelines.EmailsDetailsPipeline": 300,
}
</code>```

I have tried deleting the project and creating a new one and it did not work. I am so tired at the moment that I need to lay down. I will update this question some more after I get a few hours of rest. Thanks everyone for the help. I'm sure it's a config file preventing this from working the way its supposed to.

Body:
I was tasked for work to pull a ton of inventory for a company that was acquired by the company I work for. I thought scrapy would be a great tool for this and so far I'm having fun. However, I am trying to utilize scrapyd and am running into a problem that might be an easy fix. I am using a virtual environment (env) and I am running the following:

Ubuntu 20.04

Python 3.8

Scrapy 2.7.1

scrapyd 1.3.0 (twistd 22.10.0)

scrapyd-client 1.2.2

I just cloned a scrapy project with a spider that looked interesting from github and started playing around. I am able to run the spider using the command:

scrapy crawl examplespider

It works great and I love it. I followed some tutorials to use scrapyd and deploy my scrapy projects to it and schedule them. This is where I run into the problem I am having. I can confirm that the daemon is running:

(scrape) ubuntu@ip-172-26-13-235:~/env$ curl http://localhost:6800/daemonstatus.json
{"node_name": "ip-172-26-13-235", "status": "ok", "pending": 0, "running": 0, "finished": 11}

Verified that the project was deployed:

(scrape) ubuntu@ip-172-26-13-235:~/env$ curl http://localhost:6800/listprojects.json
{"node_name": "ip-172-26-13-235", "status": "ok", "projects": ["NebulaEmailScraper"]}

Checked the versions (There are a lot because I was troubleshooting trying to make it work)

(scrape) ubuntu@ip-172-26-13-235:~/env$ curl http://localhost:6800/listversions.json?project=NebulaEmailScraper
{"node_name": "ip-172-26-13-235", "status": "ok", "versions": ["1671003419", "1671086362", "1671182432", "1671183695", "1671183711", "1671183723", "1671183824", "1671184333", "1671184826", "1671184854", "1671186281", "1671187105", "1671260058", "1671260865", "1671261377", "1671261947"]}

Checked the spider:

(scrape) ubuntu@ip-172-26-13-235:~/env$ curl http://localhost:6800/listspiders.json?project=NebulaEmailScraper
{"node_name": "ip-172-26-13-235", "status": "ok", "spiders": ["googleemailspider"]}

Checked the jobs that I scheduled and ran:

    (scrape) ubuntu@ip-172-26-13-235:~/env$ curl http://localhost:6800/listjobs.json?project=NebulaEmailScraper | python -m json.tool
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2228  100  2228    0     0   120k      0 --:--:-- --:--:-- --:--:--  120k
{    "node_name": "ip-172-26-13-235",
     "status": "ok",    "pending": [],
     "running": [],    "finished": [
    {
             "project": "NebulaEmailScraper",
             "spider": "googleemailspider",
             "id": "1ccfce2e7ddc11edbfc8f1be5e75662a",
             "start_time": "2022-12-17 07:26:25.477894",
             "end_time": "2022-12-17 07:26:26.445959"
    },
    ... I won't list all of them

Here are what the log files look like:

scrapy.spidermiddlewares.depth.DepthMiddleware']
2022-12-17 06:57:41 [scrapy.middleware] INFO: Enabled item pipelines:
['nebulaemailscraper.pipelines.EmailsDetailsPipeline']
2022-12-17 06:57:41 [scrapy.core.engine] INFO: Spider opened
2022-12-17 06:57:41 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2022-12-17 06:57:41 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023
2022-12-17 06:57:41 [scrapy.core.engine] INFO: Closing spider (finished)
2022-12-17 06:57:41 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'elapsed_time_seconds': 0.002463,
 'finish_reason': 'finished',
 'finish_time': datetime.datetime(2022, 12, 17, 6, 57, 41, 386908),
 'log_count/DEBUG': 1,
 'log_count/INFO': 10,
 'log_count/WARNING': 1,
 'memusage/max': 63549440,
 'memusage/startup': 63549440,
 'start_time': datetime.datetime(2022, 12, 17, 6, 57, 41, 384445)}
2022-12-17 06:57:41 [scrapy.core.engine] INFO: Spider closed (finished)

Like I said, when I run scrapy crawl [spidername] it works great and says it crawled 100s of pages.

Here is my scrapy.cfg

# Automatically created by: scrapy startproject
#
# For more information about the [deploy] section see:
# https://scrapyd.readthedocs.io/en/latest/deploy.html

[settings]
default = nebulaemailscraper.settings

[deploy]
url = http://localhost:6800/
project = nebulaemailscraper

Here is my settings.py

BOT_NAME = "nebulaemailscraper"
SPIDER_MODULES = ["nebulaemailscraper.spiders"]
NEWSPIDER_MODULE = "nebulaemailscraper.spiders"

# Crawl responsibly by identifying yourself (and your website) on the user-agent
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36"

# Obey robots.txt rules
ROBOTSTXT_OBEY = False
DOWNLOAD_DELAY = 0.1

# Enable or disable spider middlewares
# See https://docs.scrapy.org/en/latest/topics/spider-middleware.html
SPIDER_MIDDLEWARES = {
    "nebulaemailscraper.middlewares.NebulaemailscraperSpiderMiddleware": 543,
}

# Enable or disable downloader middlewares
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
    'nebulaemailscraper.middlewares.NebulaemailscraperDownloaderMiddleware': 543,
}

# Enable or disable extensions
# See https://docs.scrapy.org/en/latest/topics/extensions.html
EXTENSIONS = {
    'scrapy.extensions.telnet.TelnetConsole': None,
}

# Configure item pipelines
# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
    "nebulaemailscraper.pipelines.EmailsDetailsPipeline": 300,
}

# Enable or disable spider middlewares
# See https://docs.scrapy.org/en/latest/topics/spider-middleware.html
SPIDER_MIDDLEWARES = {
    "nebulaemailscraper.middlewares.NebulaemailscraperSpiderMiddleware": 543,
}

# Enable or disable downloader middlewares
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
DOWNLOADER_MIDDLEWARES = {
    'nebulaemailscraper.middlewares.NebulaemailscraperDownloaderMiddleware': 543,
}

# Enable or disable extensions
# See https://docs.scrapy.org/en/latest/topics/extensions.html
EXTENSIONS = {
    'scrapy.extensions.telnet.TelnetConsole': None,
}

# Configure item pipelines
# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
ITEM_PIPELINES = {
    "nebulaemailscraper.pipelines.EmailsDetailsPipeline": 300,
}

I have tried deleting the project and creating a new one and it did not work. I am so tired at the moment that I need to lay down. I will update this question some more after I get a few hours of rest. Thanks everyone for the help. I'm sure it's a config file preventing this from working the way its supposed to.


问:
Magento 2 - How complete my payment gateway - redirect user to external website
I'm trying to make a payment gateway, this gateway is like all others with one exception.

in this gateway, after the user does the following:

add items to cart

got to cart

start checkout

select MyCustomPayment (can be selected)

click pay (currently just directing to the success page)

after clicking pay, i would like to redirect the user to another url, of a payment gateway

I have Vodapay\Gateway\Command\Authorize.php

<?php

namespace Dischem\Vodapay\Gateway\Command;

use Magento\Payment\Gateway\CommandInterface;

class Authorize implements CommandInterface
{
    public function __construct()
    {
        // TODO: Implement contsturutor as needed.
    }

    public function execute(array $commandSubject)
    {
        // TODO: Get order here
        // TODO: generate redirection link here for example link could be https://example.com/orderid=1234
        // TODO: return redirection link to user
    }

}
```
<h3>and the following <code>di.xml</code></h3>
<pre class="lang-xml prettyprint-override"><code><config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Dischem\Vodapay\Api\VodapayInterface" type="Dischem\Vodapay\Model\Api\Vodapay"/>
    <!-- Payment Gateway Facade -->
    <virtualType name="VodapayFacade" type="Magento\Payment\Model\Method\Adapter">
        <arguments>
            <argument name="code" xsi:type="const">Dischem\Vodapay\Model\Payment\Vodapay::METHOD_CODE</argument>
            <argument name="formBlockType" xsi:type="string">Magento\Payment\Block\Form</argument>
            <argument name="infoBlockType" xsi:type="string">Magento\Payment\Block\Info</argument>
            <argument name="valueHandlerPool" xsi:type="object">VodapayValueHandlerPool</argument>
            <argument name="validatorPool" xsi:type="object">VodapayValidatorPool</argument>
            <argument name="commandPool" xsi:type="object">VodapayCommandPool</argument>
        </arguments>
    </virtualType>
    <!-- Value Handler Pool entries -->
    <virtualType name="VodapayValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
        <arguments>
            <argument name="handlers" xsi:type="array">
                <item name="default" xsi:type="string">VodapayConfigValueHandler</item>
            </argument>
        </arguments>
    </virtualType>
    <virtualType name="VodapayConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler">
        <arguments>
            <argument name="configInterface" xsi:type="object">VodapayConfig</argument>
        </arguments>
    </virtualType>
    <!-- Validator Pool -->
    <virtualType name="VodapayValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
        <arguments>
            <argument name="validators" xsi:type="array">
                <item name="country" xsi:type="string">VodapayCountryValidator</item>
                <item name="availability" xsi:type="string">Dischem\Vodapay\Gateway\Validator\SessionValidator</item>
            </argument>
        </arguments>
    </virtualType>
    <virtualType name="VodapayCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
        <arguments>
            <argument name="config" xsi:type="object">VodapayConfig</argument>
        </arguments>
    </virtualType>
    <!-- Command Pool entries -->
    <virtualType name="VodapayCommandPool" type="Magento\Payment\Gateway\Command\CommandPool">
        <arguments>
            <argument name="commands" xsi:type="array">
                <item name="authorize" xsi:type="string">Dischem\Vodapay\Gateway\Command\Authorize</item>
            </argument>
        </arguments>
    </virtualType>
    <!-- Multiple use entries -->
    <virtualType name="VodapayConfig" type="Magento\Payment\Gateway\Config\Config">
        <arguments>
            <argument name="methodCode" xsi:type="const">Dischem\Vodapay\Model\Payment\Vodapay::METHOD_CODE</argument>
        </arguments>
    </virtualType>
</config>
</code>```

Body:
I'm trying to make a payment gateway, this gateway is like all others with one exception.

in this gateway, after the user does the following:

add items to cart

got to cart

start checkout

select MyCustomPayment (can be selected)

click pay (currently just directing to the success page)

after clicking pay, i would like to redirect the user to another url, of a payment gateway

I have Vodapay\Gateway\Command\Authorize.php

<?php

namespace Dischem\Vodapay\Gateway\Command;

use Magento\Payment\Gateway\CommandInterface;

class Authorize implements CommandInterface
{
    public function __construct()
    {
        // TODO: Implement contsturutor as needed.
    }

    public function execute(array $commandSubject)
    {
        // TODO: Get order here
        // TODO: generate redirection link here for example link could be https://example.com/orderid=1234
        // TODO: return redirection link to user
    }

}

and the following di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Dischem\Vodapay\Api\VodapayInterface" type="Dischem\Vodapay\Model\Api\Vodapay"/>

    <virtualType name="VodapayFacade" type="Magento\Payment\Model\Method\Adapter">
        <arguments>
            <argument name="code" xsi:type="const">Dischem\Vodapay\Model\Payment\Vodapay::METHOD_CODE</argument>
            <argument name="formBlockType" xsi:type="string">Magento\Payment\Block\Form</argument>
            <argument name="infoBlockType" xsi:type="string">Magento\Payment\Block\Info</argument>
            <argument name="valueHandlerPool" xsi:type="object">VodapayValueHandlerPool</argument>
            <argument name="validatorPool" xsi:type="object">VodapayValidatorPool</argument>
            <argument name="commandPool" xsi:type="object">VodapayCommandPool</argument>
        </arguments>
    </virtualType>

    <virtualType name="VodapayValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
        <arguments>
            <argument name="handlers" xsi:type="array">
                <item name="default" xsi:type="string">VodapayConfigValueHandler</item>
            </argument>
        </arguments>
    </virtualType>
    <virtualType name="VodapayConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler">
        <arguments>
            <argument name="configInterface" xsi:type="object">VodapayConfig</argument>
        </arguments>
    </virtualType>

    <virtualType name="VodapayValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
        <arguments>
            <argument name="validators" xsi:type="array">
                <item name="country" xsi:type="string">VodapayCountryValidator</item>
                <item name="availability" xsi:type="string">Dischem\Vodapay\Gateway\Validator\SessionValidator</item>
            </argument>
        </arguments>
    </virtualType>
    <virtualType name="VodapayCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
        <arguments>
            <argument name="config" xsi:type="object">VodapayConfig</argument>
        </arguments>
    </virtualType>

    <virtualType name="VodapayCommandPool" type="Magento\Payment\Gateway\Command\CommandPool">
        <arguments>
            <argument name="commands" xsi:type="array">
                <item name="authorize" xsi:type="string">Dischem\Vodapay\Gateway\Command\Authorize</item>
            </argument>
        </arguments>
    </virtualType>

    <virtualType name="VodapayConfig" type="Magento\Payment\Gateway\Config\Config">
        <arguments>
            <argument name="methodCode" xsi:type="const">Dischem\Vodapay\Model\Payment\Vodapay::METHOD_CODE</argument>
        </arguments>
    </virtualType>
</config>


问:
String.format("%f", value) - Rounding off end digits
My value is 0.10565

When this value get divided by 100 and formatted to string it gets converted to 0.001057.

But my expected value is  0.0010565 , there should be no rounding off happening at the end.

Is there any way to do it?

```<code>chargeAmount = Double.parseDouble(chargeInCents)/(double)100;
chargeInDollar = String.format("%f", chargeAmount);
</code>```

It tried using this to convert my double value to string after dividing it by 100

Body:
My value is 0.10565

When this value get divided by 100 and formatted to string it gets converted to 0.001057.

But my expected value is  0.0010565 , there should be no rounding off happening at the end.

Is there any way to do it?

chargeAmount = Double.parseDouble(chargeInCents)/(double)100;
chargeInDollar = String.format("%f", chargeAmount);

It tried using this to convert my double value to string after dividing it by 100


问:
How do I import data from file as element?
I am using Blockly and I need to get a toolbar I've defined as an xml file into the document as an element. I want to do this because there is a part were you need an xml element but mine is very long so I made it an external file.

I have tried writing the file path in a variable.

```<code>const toolbox = "toolbox.xml";

function demo() {
    console.log('hi')
    const jsCode = Blockly.JavaScript.workspaceToCode(workspace);
    console.log(jsCode)
}

const workspace = Blockly.inject('blocklyDiv', { toolbox: toolbox });
</code>```

This is how its done in the documentation:

```<code><xml id="toolbox" style="display: none">
  <block type="controls_if"></block>
  <block type="controls_whileUntil"></block>
</xml>
<script>
var workspace = Blockly.inject('blocklyDiv',
      {toolbox: document.getElementById('toolbox')});
</script>
</code>```

This is not how I want to do it because it will take up room in my html.

Body:
I am using Blockly and I need to get a toolbar I've defined as an xml file into the document as an element. I want to do this because there is a part were you need an xml element but mine is very long so I made it an external file.

I have tried writing the file path in a variable.

const toolbox = "toolbox.xml";

function demo() {
    console.log('hi')
    const jsCode = Blockly.JavaScript.workspaceToCode(workspace);
    console.log(jsCode)
}

const workspace = Blockly.inject('blocklyDiv', { toolbox: toolbox });

This is how its done in the documentation:

<xml id="toolbox" style="display: none">
  <block type="controls_if"></block>
  <block type="controls_whileUntil"></block>
</xml>

This is not how I want to do it because it will take up room in my html.


问:
how to drop indexes that have duplicate values in specific columns
I have a question that need your helps to solve it.
I have a data frame like this :

index
Column A
Column B
column c
column D

1
a
Cell 1
b
5

2
a
Cell 1
b
5

3
b
Cell 1
c
4

4
b
Cell 1
t
9

5
b
Cell 1
t
8

6
g
Cell 1
k
4

7
g
Cell 1
h
3

8
g
Cell 1
h
1

in that dataframe i need to remove indexes that have same value** only in column A and column C.**
for example i need to drop index 2 , 5 , 8.
please help me.
thanks.

I tried to use

```<code>duplicated()
</code>```

function but it couldn't answer properly my question.

Body:
I have a question that need your helps to solve it.
I have a data frame like this :

index
Column A
Column B
column c
column D

1
a
Cell 1
b
5

2
a
Cell 1
b
5

3
b
Cell 1
c
4

4
b
Cell 1
t
9

5
b
Cell 1
t
8

6
g
Cell 1
k
4

7
g
Cell 1
h
3

8
g
Cell 1
h
1

in that dataframe i need to remove indexes that have same value** only in column A and column C.**
for example i need to drop index 2 , 5 , 8.
please help me.
thanks.

I tried to use

duplicated()

function but it couldn't answer properly my question.