问:
How to make code that adds row work in filtered table
I have a code that adds rows on my table, it works like this.

Copy entire row based on current cell location (Red row).

Then paste it below the current cell location by adding rows, not just copying the data

Error im getting: Error 1004 - Cannot move cells in a table or filtered range

The problem is, I can't get this code to work when my table has filters, how do I do this without breaking my current code?

My code:

```<code>Sub INSERT_ROWS()

Application.ScreenUpdating = False

    Dim MyTable As Object
    Dim RowsToAdd As Long
    RowsToAdd = Worksheets("CC").Range("B18") 'Where i get the number of rows to be added

    Set MyTable = ActiveSheet.ListObjects(1)

    If RowsToAdd > 0 Then
            If Not Intersect(Selection, MyTable.DataBodyRange) Is Nothing Then

            Dim SelectedRow As Long
            SelectedRow = Intersect(Selection, MyTable.DataBodyRange).Row - MyTable.HeaderRowRange.Row

            Dim RowCounter As Long
            For RowCounter = SelectedRow To SelectedRow + RowsToAdd - 2 'To place rows bellow current cell location
                MyTable.ListRows.Add Position:=RowCounter + 1
                MyTable.ListRows(RowCounter).Range.Copy Destination:=MyTable.ListRows(RowCounter + 1).Range
            Next RowCounter
        End If
    End If

Application.ScreenUpdating = True

End Sub
</code>```

Body:
I have a code that adds rows on my table, it works like this.

Copy entire row based on current cell location (Red row).

Then paste it below the current cell location by adding rows, not just copying the data

Error im getting: Error 1004 - Cannot move cells in a table or filtered range

The problem is, I can't get this code to work when my table has filters, how do I do this without breaking my current code?

My code:

Sub INSERT_ROWS()

Application.ScreenUpdating = False

    Dim MyTable As Object
    Dim RowsToAdd As Long
    RowsToAdd = Worksheets("CC").Range("B18") 'Where i get the number of rows to be added

    Set MyTable = ActiveSheet.ListObjects(1)

    If RowsToAdd > 0 Then
            If Not Intersect(Selection, MyTable.DataBodyRange) Is Nothing Then

            Dim SelectedRow As Long
            SelectedRow = Intersect(Selection, MyTable.DataBodyRange).Row - MyTable.HeaderRowRange.Row

            Dim RowCounter As Long
            For RowCounter = SelectedRow To SelectedRow + RowsToAdd - 2 'To place rows bellow current cell location
                MyTable.ListRows.Add Position:=RowCounter + 1
                MyTable.ListRows(RowCounter).Range.Copy Destination:=MyTable.ListRows(RowCounter + 1).Range
            Next RowCounter
        End If
    End If

Application.ScreenUpdating = True

End Sub


来源: stackexchange

问:
Positive Covariance but why not fit in OLS?
Could you help explain me why please? I have tested a pair of data for their covariance and I got a positive result but why I input them together in linear regression, the p value is not significant?

Thank you very much

I am trying to test linear regression in excel and the output summary is not significant but when I pair the data, the covariance is positive

ContentLicense: CC BY-SA 4.0


问:
No libraries found for 'org.springframework.data.repository.CrudRepository' error when trying to import CrudRepository
Am trying to import CrudRepository into my interface, but i keep getting the error "No libraries found for 'org.springframework.data.repository.CrudRepository'"

Its a gradle project and am doing it on Intellij 2022.1 Ultimate

The repository is:

```<code>package co2103.hw2.repo;
import co2103.hw2.model.Reimbursement;
import org.springframework.data.repository.CrudRepository;

@Repository
public interface ReimbursementRepository extends CrudRepository <Reimbursement, Long> {

}

</code>```

and the Java class is

```<code>package co2103.hw2.model;

import javax.persistence.*;
@Entity
public class Reimbursement{
    @Id
    @GeneratedValue
    private int id;
    private int amount;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    @Override
    public String toString() {
        return "Reimbursement{" +
                "id=" + id +
                ", amount=" + amount +
                '}';
    }
}

</code>```

Worth noting that in the the import statement

```<code>import org.springframework.data.repository.CrudRepository;
</code>```

the data component is highlighted as an error with the hovertext "Cannot resolve symbol 'data'"

I tried solutions in this link but it seems not to work

I have also noticed that most of the soutions onlie are for mavel projects

Body:
Am trying to import CrudRepository into my interface, but i keep getting the error "No libraries found for 'org.springframework.data.repository.CrudRepository'"

Its a gradle project and am doing it on Intellij 2022.1 Ultimate

The repository is:

package co2103.hw2.repo;
import co2103.hw2.model.Reimbursement;
import org.springframework.data.repository.CrudRepository;

@Repository
public interface ReimbursementRepository extends CrudRepository <Reimbursement, Long> {

}

and the Java class is

package co2103.hw2.model;

import javax.persistence.*;
@Entity
public class Reimbursement{
    @Id
    @GeneratedValue
    private int id;
    private int amount;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    @Override
    public String toString() {
        return "Reimbursement{" +
                "id=" + id +
                ", amount=" + amount +
                '}';
    }
}

Worth noting that in the the import statement

import org.springframework.data.repository.CrudRepository;

the data component is highlighted as an error with the hovertext "Cannot resolve symbol 'data'"

I tried solutions in this link but it seems not to work

I have also noticed that most of the soutions onlie are for mavel projects


问:
How can I solve svm predict model problem
Im having problem by svm predict model

from sklearn.svm import SVC

svm_model = SVC(kernel='rbf', C=8, gamma=0.1)

svm_model.fit(X_train_std, y_train)

y_pred = svm_model.predict(X_test_std)

```<code>/usr/local/lib/python3.8/dist-packages/sklearn/utils/validation.py:993: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
  y = column_or_1d(y, warn=True)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-53-398f1caaa8e8> in <module>
      3 svm_model = SVC(kernel='rbf', C=8, gamma=0.1)
      4
----> 5 svm_model.fit(X_train_std, y_train)
      6
      7 y_pred = svm_model.predict(X_test_std)

2 frames
/usr/local/lib/python3.8/dist-packages/sklearn/utils/multiclass.py in check_classification_targets(y)
    195         "multilabel-sequences",
    196     ]:
--> 197         raise ValueError("Unknown label type: %r" % y_type)
    198
    199

ValueError: Unknown label type: 'continuous'
</code>```

I thought y type problem

```<code>train = pd.get_dummies(train, columns=['LSTAT'], drop_first=True)
</code>```

So I use that but problem was disappeared

Somebody help me

Body:
Im having problem by svm predict model

from sklearn.svm import SVC

svm_model = SVC(kernel='rbf', C=8, gamma=0.1)

svm_model.fit(X_train_std, y_train)

y_pred = svm_model.predict(X_test_std)

/usr/local/lib/python3.8/dist-packages/sklearn/utils/validation.py:993: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
  y = column_or_1d(y, warn=True)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-53-398f1caaa8e8> in <module>
      3 svm_model = SVC(kernel='rbf', C=8, gamma=0.1)
      4
----> 5 svm_model.fit(X_train_std, y_train)
      6
      7 y_pred = svm_model.predict(X_test_std)

2 frames
/usr/local/lib/python3.8/dist-packages/sklearn/utils/multiclass.py in check_classification_targets(y)
    195         "multilabel-sequences",
    196     ]:
--> 197         raise ValueError("Unknown label type: %r" % y_type)
    198
    199

ValueError: Unknown label type: 'continuous'

I thought y type problem

train = pd.get_dummies(train, columns=['LSTAT'], drop_first=True)

So I use that but problem was disappeared

Somebody help me


问:
Algolia retrieve "geoDistance"
I'm have this Eloquent query using Algolia with 'getRankingInfo'.

```<code>$shop = Shops::search('')->with([
                'aroundLatLng' => $db->latitudine . "," . $db->longitudine,
                'aroundRadius' => 2000,
                'getRankingInfo' => true
            ])->query(function ($query) {
                $query->with('shops_branches');
            })->get();

dd($shops);
</code>```

With a dump I can see 'geoDistance'

```<code>#scoutMetadata: array:2 [▼
        "_highlightResult" => array:3 [▶
        "_rankingInfo" => array:10 [▶
          "nbTypos" => 0
          "firstMatchedWord" => 0
          "proximityDistance" => 0
          "userScore" => 1316
          "geoDistance" => 719
          "geoPrecision" => 1
          "nbExactWords" => 0
          "words" => 0
          "filters" => 0
          "matchedGeoLocation" => array:3 [▶
            "lat" => 40.9734
            "lng" => 14.2114
            "distance" => 719
          ]
        ]
      ]
</code>```

How can I retrieve 'geoDistance' in my collection?

Thanks

Title: Algolia retrieve "geoDistance"

Body:
I'm have this Eloquent query using Algolia with 'getRankingInfo'.

$shop = Shops::search('')->with([
                'aroundLatLng' => $db->latitudine . "," . $db->longitudine,
                'aroundRadius' => 2000,
                'getRankingInfo' => true
            ])->query(function ($query) {
                $query->with('shops_branches');
            })->get();

dd($shops);

With a dump I can see 'geoDistance'

#scoutMetadata: array:2 [▼
        "_highlightResult" => array:3 [▶
        "_rankingInfo" => array:10 [▶
          "nbTypos" => 0
          "firstMatchedWord" => 0
          "proximityDistance" => 0
          "userScore" => 1316
          "geoDistance" => 719
          "geoPrecision" => 1
          "nbExactWords" => 0
          "words" => 0
          "filters" => 0
          "matchedGeoLocation" => array:3 [▶
            "lat" => 40.9734
            "lng" => 14.2114
            "distance" => 719
          ]
        ]
      ]

How can I retrieve 'geoDistance' in my collection?

Thanks


问:
Not able to set background color of Tk Entry widget in Go
I am trying to use atk package in Go (version go1.19.3 linux/amd64 on Debian Stable) to create a simple GUI application. I am using following code to add a Label and an Entry field:

```<code>package main
import (
    "github.com/visualfc/atk/tk"
    "fmt"
)
func MainWindow() {
    var mainWin = tk.RootWindow()

    var lbl = tk.NewLabel(mainWin, "Enter Name:")
    var err = lbl.SetBackground("blue")  // working;
    if err != nil {fmt.Println(err.Error())}

    err = lbl.SetForground("red")  // working;
    if err != nil {fmt.Println(err.Error())}

    var ent = tk.NewEntry(mainWin)
    err = ent.SetBackground("blue")  // not working;
    if err != nil {fmt.Println(err.Error())}

    err = ent.SetForeground("red")  // working;
    if err != nil {fmt.Println(err.Error())}

    tk.NewHPackLayout(mainWin).AddWidgets( lbl, ent)
    mainWin.Center(nil)
    mainWin.ShowNormal()
}
func main() {
    tk.MainLoop(MainWindow)
}
</code>```

The program builds and runs without any error. However, although both the label colors and foreground entry filed color are correctly set, the background color for entry widget is not set:

I have checked the documentation here.

Where is the problem and how can it be solved?

Body:
I am trying to use atk package in Go (version go1.19.3 linux/amd64 on Debian Stable) to create a simple GUI application. I am using following code to add a Label and an Entry field:

package main
import (
    "github.com/visualfc/atk/tk"
    "fmt"
)
func MainWindow() {
    var mainWin = tk.RootWindow()

    var lbl = tk.NewLabel(mainWin, "Enter Name:")
    var err = lbl.SetBackground("blue")  // working;
    if err != nil {fmt.Println(err.Error())}

    err = lbl.SetForground("red")  // working;
    if err != nil {fmt.Println(err.Error())}

    var ent = tk.NewEntry(mainWin)
    err = ent.SetBackground("blue")  // not working;
    if err != nil {fmt.Println(err.Error())}

    err = ent.SetForeground("red")  // working;
    if err != nil {fmt.Println(err.Error())}

    tk.NewHPackLayout(mainWin).AddWidgets( lbl, ent)
    mainWin.Center(nil)
    mainWin.ShowNormal()
}
func main() {
    tk.MainLoop(MainWindow)
}

The program builds and runs without any error. However, although both the label colors and foreground entry filed color are correctly set, the background color for entry widget is not set:

I have checked the documentation here.

Where is the problem and how can it be solved?


问:
Role Base Authorization with UseJwtBearerAuthentication on Net 4.7.2 WebApi
My desktop app call a Net WebApi using access token coming from keycloak. The Authorization attribute on my webapi running well but my WebApi it can't work with authorization. I tried to inject role claims but the api keep on error 401. Here is my Startup.cs

```<code>[assembly: OwinStartup(typeof(Demo.Startup))]

namespace Demo
{
    public class CustomOAuthBearerProvider : OAuthBearerAuthenticationProvider
    {
        public override Task ValidateIdentity(OAuthValidateIdentityContext context)
        {
            var claims = context.Ticket.Identity.Claims;
            context.Ticket.Identity.AddClaim(new Claim(ClaimTypes.Role, "Admin")); // injected claims here
            base.ValidateIdentity(context);
            return Task.FromResult<object>(null);
        }
    }

    public partial class Startup
    {
        static string _realm = "myrealm";
        static string _authority = "http://localhost:8080/realms/myrealm";

        public void Configuration(IAppBuilder app)
        {
            IdentityModelEventSource.ShowPII = true;

            var domain = _authority;
            var apiIdentifier = "account";
            var keyResolver = new OpenIdConnectSigningKeyResolver(domain);
            app.UseJwtBearerAuthentication(
                new JwtBearerAuthenticationOptions
                {
                    AuthenticationMode = AuthenticationMode.Active,
                    TokenValidationParameters = new TokenValidationParameters()
                    {
                        ValidAudience = apiIdentifier,
                        ValidIssuer = domain.TrimEnd('/'),
                        IssuerSigningKeyResolver = (token, securityToken, kid, parameters) => keyResolver.GetSigningKey(kid),
                    },
                    Provider = new CustomOAuthBearerProvider()
                });

            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
        }
}
</code>```

My controller:

```<code>[Route("test")]
[Authorize(Roles = "Admin")]
public Strig Test()
{
   return "Hello";
}
</code>```

test method always returning 401 eventhough I inject an Admin role from ValidateIdentity. The method working properly if i take out Roles decoration.

Body:
My desktop app call a Net WebApi using access token coming from keycloak. The Authorization attribute on my webapi running well but my WebApi it can't work with authorization. I tried to inject role claims but the api keep on error 401. Here is my Startup.cs

[assembly: OwinStartup(typeof(Demo.Startup))]

namespace Demo
{
    public class CustomOAuthBearerProvider : OAuthBearerAuthenticationProvider
    {
        public override Task ValidateIdentity(OAuthValidateIdentityContext context)
        {
            var claims = context.Ticket.Identity.Claims;
            context.Ticket.Identity.AddClaim(new Claim(ClaimTypes.Role, "Admin")); // injected claims here
            base.ValidateIdentity(context);
            return Task.FromResult<object>(null);
        }
    }

    public partial class Startup
    {
        static string _realm = "myrealm";
        static string _authority = "http://localhost:8080/realms/myrealm";

        public void Configuration(IAppBuilder app)
        {
            IdentityModelEventSource.ShowPII = true;

            var domain = _authority;
            var apiIdentifier = "account";
            var keyResolver = new OpenIdConnectSigningKeyResolver(domain);
            app.UseJwtBearerAuthentication(
                new JwtBearerAuthenticationOptions
                {
                    AuthenticationMode = AuthenticationMode.Active,
                    TokenValidationParameters = new TokenValidationParameters()
                    {
                        ValidAudience = apiIdentifier,
                        ValidIssuer = domain.TrimEnd('/'),
                        IssuerSigningKeyResolver = (token, securityToken, kid, parameters) => keyResolver.GetSigningKey(kid),
                    },
                    Provider = new CustomOAuthBearerProvider()
                });

            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
        }
}

My controller:

[Route("test")]
[Authorize(Roles = "Admin")]
public Strig Test()
{
   return "Hello";
}

test method always returning 401 eventhough I inject an Admin role from ValidateIdentity. The method working properly if i take out Roles decoration.


问:
Counting presence or absence of tallies by rows
Hi I am not sure how to explain what I need but I'll try. I need a query (if there is one) for counting if a tally was present in a point (column). So all species with more than one tally in a point will count only as one.

This is how the data looks:
Sp  Site  Pnt1   Pnt2   Pnt3   Total
A      1   1       1      1      3
A      2           1      1      2
A      3   1                     1
B      1   1       1      1      3
B      2   1                     1
C      1           1      1      2
C      2                         0

I want to count if the sites have tally or not and if they are repeated by points (for the same species) I want to count them as one. I would like the resulting table to look like this.

Sp   Pnt1   Pnt2   Pnt3   Total
A      1      1      1      3
B      1      1      1      3
C      0      1      1      2

Thanks for all the help you can provide.


问:
How to Implement Feature-Flags in Java/Spring with Kubernetes Replica Set?
I implemented some feature-flag logic following Baeldungs guide, and it works great as long as the service is isolated (local, or 1 pod in the cloud) when I update the feature-flag via the controller endpoint.

The issue is, I deploy 2 pods for the microservice since it's heavy on usage. How can I make sure both pods are updated when I update the feature-flag programmatically?

Am I supposed to use Kubernetes feature gates? I've tried researching it, but have been hitting dead ends.

TIA!


问:
Is it possible to change the playback rate value of a Spotify track playing on my website?
The thing is... Spotify doesn't seem to create an audio or video element to play these tracks so I can change the playback rate from the element reference, it creates an  element instead:

```<code><iframe src="https://sdk.scdn.co/embedded/index.html" alt="Audio Playback Container" allow="encrypted-media; autoplay">
 <html>
  <head>
   <meta charset="UTF-8">
   <title>Spotify Embedded Player</title>
  </head>
  <body>
   <script src="index.js"></script>
  </body>
 </html>
</iframe>
</code>```

The script source is: https://sdk.scdn.co/embedded/index.js

Is the 'allow="encrypted-media"' telling me something?

I know this is possible on the official Spotify website, because a video or audio element is created, but since I'm using the Spotify Web Playback SDK, I can't do that.

Body:
The thing is... Spotify doesn't seem to create an audio or video element to play these tracks so I can change the playback rate from the element reference, it creates an  element instead:

   <meta charset="UTF-8">
   <title>Spotify Embedded Player</title>

The script source is: https://sdk.scdn.co/embedded/index.js

Is the 'allow="encrypted-media"' telling me something?

I know this is possible on the official Spotify website, because a video or audio element is created, but since I'm using the Spotify Web Playback SDK, I can't do that.


问:
AttributeError: '_tkinter.tkapp' object has no attribute 'cur'
this is the tkinter app code

import sqlite3
from tkinter import *
from db import db

class root(Tk):
        def __init__(self):
            super().__init__()
            self.title("book info")
            self.minsize(500, 400)
            self.configure(background="gray")
            self.create_data()
            self.populate_list()

        def create_data(self):

            #make title input

            self.title = StringVar()

            self.titleEntry = Label(self, text="title")
            self.titleEntry.place(x=41, y=10)

            entry = Entry(self, textvariable=self.title)
            entry.place(x=66, y=10)

            # make years input

            self.years = StringVar()

            self.yearsEntry = Label(self, text="years")
            self.yearsEntry.place(x=269, y=10)

            entry2 = Entry(self, textvariable=self.years)
            entry2.place(x=300.5, y=10.2)

            # make author input

            self.author = StringVar()

            self.authorEntry = Label(self, text="author")
            self.authorEntry.place(x=40, y=51)

            entry3 = Entry(self, textvariable=self.author)
            entry3.place(x=80, y=51)

            # make isbn input

            self.isbn = StringVar()

            self.isbnEntry = Label(self, text="isbn")
            self.isbnEntry.place(x=270, y=52)

            entry_iv = Entry(self, textvariable=self.isbn)
            entry_iv.place(x=297, y=52)

            # listbox

            self.list_box = Listbox(self, height=10, width=50)
            self.list_box.place(x=85, y=200)

            # buttons

            save_button = Button(self,text= "save")
            save_button.place(x=66, y=150)

            delete_button = Button(self, text="delete")
            delete_button.place(x=215, y=150)

            search_button = Button(self, text="search")
            search_button.place(x=360, y=150)

        def populate_list(self):
            #clear list
            self.list_box.delete(0,END)

            rows = db.fetch(self)
            for row in rows:
                self.list_box.insert(END,row)

    win = root()
    win.mainloop()
```
<p>and this is the databace code</p>
```import sqlite3

class db():

    def __init__(self):
        self.cur = conn.cursor("wikibook.db")
        self.cur.execute("CREATE TABELE IF NOT EXISTS book (id INTEGER PRIMARY KEY,title TEXT,yearTEXT,author TEXT,isbn INTEGER)")
        self.conn.commit()

    def fetch(self):
        self.cur.execute("SELECT FROM * book")
        rows = self.cur.fetchall
        return rows

    def insert(self, title, year, author, isbn):
        self.cur.execute("INSERT INTO book VALUES (id ,? ,?, ?, ?)",(text, year ,author, isbn, id))
        self.conn.commit()

    def delete(self,id):
        self.cur.execute("DELETE FROM books WHERE id=?",(id,))
        self.conn.commit()

    def update(self ,title, year, author, isbn):
        self.cur.execute("UPDATE FROM book (?, ?, ?, ?)",(title ,year ,author ,isbn))
        self.conn.commit()

    def search(self):
        self.cur.execute("SELECT* FROM book WHERE title = ? and author = ? and year = ? and isbn = ?",    (title ,year ,author ,isbn))
        rows = self.cur.fetchall()
        return rows

    def __del__(self):
        self.conn.close()
```

I hope this helps to solve the problem

Body:
this is the tkinter app code

import sqlite3
from tkinter import *
from db import db

class root(Tk):
        def __init__(self):
            super().__init__()
            self.title("book info")
            self.minsize(500, 400)
            self.configure(background="gray")
            self.create_data()
            self.populate_list()

        def create_data(self):

            #make title input

            self.title = StringVar()

            self.titleEntry = Label(self, text="title")
            self.titleEntry.place(x=41, y=10)

            entry = Entry(self, textvariable=self.title)
            entry.place(x=66, y=10)

            # make years input

            self.years = StringVar()

            self.yearsEntry = Label(self, text="years")
            self.yearsEntry.place(x=269, y=10)

            entry2 = Entry(self, textvariable=self.years)
            entry2.place(x=300.5, y=10.2)

            # make author input

            self.author = StringVar()

            self.authorEntry = Label(self, text="author")
            self.authorEntry.place(x=40, y=51)

            entry3 = Entry(self, textvariable=self.author)
            entry3.place(x=80, y=51)

            # make isbn input

            self.isbn = StringVar()

            self.isbnEntry = Label(self, text="isbn")
            self.isbnEntry.place(x=270, y=52)

            entry_iv = Entry(self, textvariable=self.isbn)
            entry_iv.place(x=297, y=52)

            # listbox

            self.list_box = Listbox(self, height=10, width=50)
            self.list_box.place(x=85, y=200)

            # buttons

            save_button = Button(self,text= "save")
            save_button.place(x=66, y=150)

            delete_button = Button(self, text="delete")
            delete_button.place(x=215, y=150)

            search_button = Button(self, text="search")
            search_button.place(x=360, y=150)

        def populate_list(self):
            #clear list
            self.list_box.delete(0,END)

            rows = db.fetch(self)
            for row in rows:
                self.list_box.insert(END,row)

    win = root()
    win.mainloop()

and this is the databace code

import sqlite3

class db():

    def __init__(self):
        self.cur = conn.cursor("wikibook.db")
        self.cur.execute("CREATE TABELE IF NOT EXISTS book (id INTEGER PRIMARY KEY,title TEXT,yearTEXT,author TEXT,isbn INTEGER)")
        self.conn.commit()

    def fetch(self):
        self.cur.execute("SELECT FROM * book")
        rows = self.cur.fetchall
        return rows

    def insert(self, title, year, author, isbn):
        self.cur.execute("INSERT INTO book VALUES (id ,? ,?, ?, ?)",(text, year ,author, isbn, id))
        self.conn.commit()

    def delete(self,id):
        self.cur.execute("DELETE FROM books WHERE id=?",(id,))
        self.conn.commit()

    def update(self ,title, year, author, isbn):
        self.cur.execute("UPDATE FROM book (?, ?, ?, ?)",(title ,year ,author ,isbn))
        self.conn.commit()

    def search(self):
        self.cur.execute("SELECT* FROM book WHERE title = ? and author = ? and year = ? and isbn = ?",    (title ,year ,author ,isbn))
        rows = self.cur.fetchall()
        return rows

    def __del__(self):
        self.conn.close()

I hope this helps to solve the problem


问:
Calling smart contract function went to "execution reverted" error
There is Avax contract:

```<code>avax_contract_address = '0xe4b679400f0f267212d5d812b95f58c83243ee71'
</code>```

by requesting list of available functions through standard ABI set, we can find a function "symbol" as well as "name" in the list.

```<code>    addr = w3.toChecksumAddress(address)
    cont = w3.eth.contract(address=addr, abi=abi)
    symbol_f = cont.get_function_by_name('symbol')
    name_f = cont.get_function_by_name('name')
</code>```

symbol_f and name_f are not empty and has the object to call.
but when I am trying to call:

```<code>symbol = symbol_f().call()
</code>```

it goes to the error:

```<code>  File "cytoolz/functoolz.pyx", line 666, in cytoolz.functoolz.pipe
  File "cytoolz/functoolz.pyx", line 641, in cytoolz.functoolz.c_pipe
  File "....", line 580, in raise_solidity_error_on_revert
    raise ContractLogicError('execution reverted')
web3.exceptions.ContractLogicError: execution reverted
</code>```

I was pointed to the address details which says that original contract is a proxy, meaning that the function should be called from implementation one.

from the contract source code, I got IMPLEMENTATION_SLOT address and found original contract:

```<code>avax_admin_ctr_slot = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103'
impl_contr = w3.toChecksumAddress(f"0x{w3.toHex(w3.eth.get_storage_at(addr, avax_admin_ctr_slot))[-40:]}")
</code>```

the address back is valid and also returns the list of functions with "symbol" and "name" in. But unfortunately, they can't be called as well - same error.

As newer in that, can you navigate me how I can:

check if the function is really implemented

and call the function if it is in the list of supported by whatever it is proxy or admin contract?

Body:
There is Avax contract:

avax_contract_address = '0xe4b679400f0f267212d5d812b95f58c83243ee71'

by requesting list of available functions through standard ABI set, we can find a function "symbol" as well as "name" in the list.

    addr = w3.toChecksumAddress(address)
    cont = w3.eth.contract(address=addr, abi=abi)
    symbol_f = cont.get_function_by_name('symbol')
    name_f = cont.get_function_by_name('name')

symbol_f and name_f are not empty and has the object to call.
but when I am trying to call:

symbol = symbol_f().call()

it goes to the error:

  File "cytoolz/functoolz.pyx", line 666, in cytoolz.functoolz.pipe
  File "cytoolz/functoolz.pyx", line 641, in cytoolz.functoolz.c_pipe
  File "....", line 580, in raise_solidity_error_on_revert
    raise ContractLogicError('execution reverted')
web3.exceptions.ContractLogicError: execution reverted

I was pointed to the address details which says that original contract is a proxy, meaning that the function should be called from implementation one.

from the contract source code, I got IMPLEMENTATION_SLOT address and found original contract:

avax_admin_ctr_slot = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103'
impl_contr = w3.toChecksumAddress(f"0x{w3.toHex(w3.eth.get_storage_at(addr, avax_admin_ctr_slot))[-40:]}")

the address back is valid and also returns the list of functions with "symbol" and "name" in. But unfortunately, they can't be called as well - same error.

As newer in that, can you navigate me how I can:

check if the function is really implemented

and call the function if it is in the list of supported by whatever it is proxy or admin contract?


问:
Particle.js Radial Gradient background to particles
i would like to use gradient backgrounds in particles, that is to say, I want the particles to each have a gradient of different colours with some shadows for depth and if at all its possible, i would like to animate the gradeients as well.

I am new to this library and am not sure if this is possible, Thanks!

i have made a simple canvas with circles bouncing around, thats all i have been able to achieve

```<code>
{
  "autoPlay": true,
  "background": {
    "color": {
      "value": "#000"
    },
    "image": "",
    "position": "",
    "repeat": "",
    "size": "",
    "opacity": 1
  },
  "backgroundMask": {
    "composite": "destination-out",
    "cover": {
      "color": {
        "value": "#fff"
      },
      "opacity": 1
    },
    "enable": false
  },
  "defaultThemes": {},
  "delay": 0,
  "fullScreen": {
    "enable": true,
    "zIndex": -1
  },
  "detectRetina": true,
  "duration": 0,
  "fpsLimit": 120,
  "interactivity": {
    "detectsOn": "window",
    "events": {
      "onClick": {
        "enable": false,
        "mode": []
      },
      "onDiv": {
        "selectors": [],
        "enable": false,
        "mode": [],
        "type": "circle"
      },
      "onHover": {
        "enable": false,
        "mode": [],
        "parallax": {
          "enable": false,
          "force": 2,
          "smooth": 10
        }
      },
      "resize": {
        "delay": 0.5,
        "enable": true
      }
    },
    "modes": {
      "attract": {
        "distance": 200,
        "duration": 0.4,
        "easing": "ease-out-quad",
        "factor": 1,
        "maxSpeed": 50,
        "speed": 1
      },
      "bounce": {
        "distance": 200
      },
      "bubble": {
        "distance": 200,
        "duration": 0.4,
        "mix": false,
        "divs": {
          "distance": 200,
          "duration": 0.4,
          "mix": false,
          "selectors": []
        }
      },
      "connect": {
        "distance": 80,
        "links": {
          "opacity": 0.5
        },
        "radius": 60
      },
      "grab": {
        "distance": 100,
        "links": {
          "blink": false,
          "consent": false,
          "opacity": 1
        }
      },
      "push": {
        "default": true,
        "groups": [],
        "quantity": 4
      },
      "remove": {
        "quantity": 2
      },
      "repulse": {
        "distance": 200,
        "duration": 0.4,
        "factor": 100,
        "speed": 1,
        "maxSpeed": 50,
        "easing": "ease-out-quad",
        "divs": {
          "distance": 200,
          "duration": 0.4,
          "factor": 100,
          "speed": 1,
          "maxSpeed": 50,
          "easing": "ease-out-quad",
          "selectors": []
        }
      },
      "slow": {
        "factor": 3,
        "radius": 200
      },
      "trail": {
        "delay": 1,
        "pauseOnStop": false,
        "quantity": 1
      },
      "light": {
        "area": {
          "gradient": {
            "start": {
              "value": "#ffffff"
            },
            "stop": {
              "value": "#000000"
            }
          },
          "radius": 1000
        },
        "shadow": {
          "color": {
            "value": "#000000"
          },
          "length": 2000
        }
      }
    }
  },
  "manualParticles": [],
  "particles": {
    "bounce": {
      "horizontal": {
        "random": {
          "enable": false,
          "minimumValue": 0.1
        },
        "value": 1
      },
      "vertical": {
        "random": {
          "enable": false,
          "minimumValue": 0.1
        },
        "value": 1
      }
    },
    "collisions": {
      "absorb": {
        "speed": 2
      },
      "bounce": {
        "horizontal": {
          "random": {
            "enable": false,
            "minimumValue": 1
          },
          "value": {
            "min": 0.1,
            "max": 10
          }
        },
        "vertical": {
          "random": {
            "enable": false,
            "minimumValue": 0.1
          },
          "value": {
            "min": 0.1,
            "max": 10
          }
        }
      },
      "enable": true,
      "mode": "bounce",
      "overlap": {
        "enable": false,
        "retries": 0
      }
    },
    "color": {
      "value": "#ff0000",
      "animation": {
        "h": {
          "count": 0,
          "enable": false,
          "offset": 0,
          "speed": 1,
          "decay": 0,
          "sync": true
        },
        "s": {
          "count": 0,
          "enable": false,
          "offset": 0,
          "speed": 1,
          "decay": 0,
          "sync": true
        },
        "l": {
          "count": 0,
          "enable": false,
          "offset": 0,
          "speed": 1,
          "decay": 0,
          "sync": true
        }
      }
    },
    "groups": {},
    "move": {
      "angle": {
        "offset": 0,
        "value": 90
      },
      "attract": {
        "distance": 200,
        "enable": false,
        "rotate": {
          "x": 3000,
          "y": 3000
        }
      },
      "center": {
        "x": 50,
        "y": 50,
        "mode": "percent",
        "radius": 0
      },
      "decay": 0,
      "distance": {},
      "direction": "none",
      "drift": 0,
      "enable": true,
      "gravity": {
        "acceleration": 9.81,
        "enable": false,
        "inverse": false,
        "maxSpeed": 50
      },
      "path": {
        "clamp": true,
        "delay": {
          "random": {
            "enable": false,
            "minimumValue": 0
          },
          "value": 0
        },
        "enable": false,
        "options": {}
      },
      "outModes": {
        "default": "bounce",
        "bottom": "bounce",
        "left": "bounce",
        "right": "bounce",
        "top": "bounce"
      },
      "random": true,
      "size": true,
      "speed": 8,
      "spin": {
        "acceleration": 0,
        "enable": false
      },
      "straight": false,
      "trail": {
        "enable": true,
        "length": 3,
        "fillColor": {
          "value": "#000000"
        }
      },
      "vibrate": false,
      "warp": false
    },
    "number": {
      "density": {
        "enable": false,
        "area": 800,
        "factor": 1000
      },
      "limit": 0,
      "value": 14
    },
    "opacity": {
      "random": {
        "enable": false,
        "minimumValue": 0.1
      },
      "value": 1,
      "animation": {
        "count": 0,
        "enable": false,
        "speed": 0.25,
        "decay": 0,
        "sync": false,
        "destroy": "none",
        "startValue": "random"
      }
    },
    "reduceDuplicates": false,
    "shadow": {
      "blur": 4,
      "color": {
        "value": "#000"
      },
      "enable": true,
      "offset": {
        "x": 0,
        "y": 0
      }
    },
    "shape": {
      "options": {},
      "type": "circle"
    },
    "size": {
      "random": {
        "enable": false,
        "minimumValue": 1
      },
      "value": 41,
      "animation": {
        "count": 0,
        "enable": false,
        "speed": 5,
        "decay": 0,
        "sync": false,
        "destroy": "none",
        "startValue": "random"
      }
    },
    "stroke": {
      "width": 0,
      "color": {
        "value": "#004cff",
        "animation": {
          "h": {
            "count": 0,
            "enable": false,
            "offset": 0,
            "speed": 1,
            "decay": 0,
            "sync": true
          },
          "s": {
            "count": 0,
            "enable": false,
            "offset": 0,
            "speed": 1,
            "decay": 0,
            "sync": true
          },
          "l": {
            "count": 0,
            "enable": false,
            "offset": 0,
            "speed": 1,
            "decay": 0,
            "sync": true
          }
        }
      }
    },
    "zIndex": {
      "random": {
        "enable": false,
        "minimumValue": 0
      },
      "value": 0,
      "opacityRate": 1,
      "sizeRate": 1,
      "velocityRate": 1
    },
    "life": {
      "count": 0,
      "delay": {
        "random": {
          "enable": false,
          "minimumValue": 0
        },
        "value": 0,
        "sync": false
      },
      "duration": {
        "random": {
          "enable": false,
          "minimumValue": 0.0001
        },
        "value": 0,
        "sync": false
      }
    },
    "rotate": {
      "random": {
        "enable": false,
        "minimumValue": 0
      },
      "value": 0,
      "animation": {
        "enable": false,
        "speed": 0,
        "decay": 0,
        "sync": false
      },
      "direction": "clockwise",
      "path": false
    },
    "destroy": {
      "bounds": {},
      "mode": "none",
      "split": {
        "count": 1,
        "factor": {
          "random": {
            "enable": false,
            "minimumValue": 0
          },
          "value": 3
        },
        "rate": {
          "random": {
            "enable": false,
            "minimumValue": 0
          },
          "value": {
            "min": 4,
            "max": 9
          }
        },
        "sizeOffset": true,
        "particles": {}
      }
    },
    "roll": {
      "darken": {
        "enable": false,
        "value": 0
      },
      "enable": false,
      "enlighten": {
        "enable": false,
        "value": 0
      },
      "mode": "vertical",
      "speed": 25
    },
    "tilt": {
      "random": {
        "enable": false,
        "minimumValue": 0
      },
      "value": 0,
      "animation": {
        "enable": false,
        "speed": 0,
        "decay": 0,
        "sync": false
      },
      "direction": "clockwise",
      "enable": false
    },
    "twinkle": {
      "lines": {
        "enable": false,
        "frequency": 0.05,
        "opacity": 1
      },
      "particles": {
        "enable": false,
        "frequency": 0.05,
        "opacity": 1
      }
    },
    "wobble": {
      "distance": 5,
      "enable": false,
      "speed": {
        "angle": 50,
        "move": 10
      }
    },
    "orbit": {
      "animation": {
        "count": 0,
        "enable": false,
        "speed": 1,
        "decay": 0,
        "sync": false
      },
      "enable": false,
      "opacity": 1,
      "rotation": {
        "random": {
          "enable": false,
          "minimumValue": 0
        },
        "value": 45
      },
      "width": 1
    },
    "links": {
      "blink": false,
      "color": {
        "value": "#fff"
      },
      "consent": false,
      "distance": 100,
      "enable": false,
      "frequency": 1,
      "opacity": 1,
      "shadow": {
        "blur": 5,
        "color": {
          "value": "#000"
        },
        "enable": false
      },
      "triangles": {
        "enable": false,
        "frequency": 1
      },
      "width": 1,
      "warp": false
    },
    "repulse": {
      "random": {
        "enable": false,
        "minimumValue": 0
      },
      "value": 0,
      "enabled": false,
      "distance": 1,
      "duration": 1,
      "factor": 1,
      "speed": 1
    }
  },
  "pauseOnBlur": true,
  "pauseOnOutsideViewport": true,
  "responsive": [],
  "smooth": false,
  "style": {},
  "themes": [],
  "zLayers": 100,
  "emitters": []
}
</code>```

Body:
i would like to use gradient backgrounds in particles, that is to say, I want the particles to each have a gradient of different colours with some shadows for depth and if at all its possible, i would like to animate the gradeients as well.

I am new to this library and am not sure if this is possible, Thanks!

i have made a simple canvas with circles bouncing around, thats all i have been able to achieve

{
  "autoPlay": true,
  "background": {
    "color": {
      "value": "#000"
    },
    "image": "",
    "position": "",
    "repeat": "",
    "size": "",
    "opacity": 1
  },
  "backgroundMask": {
    "composite": "destination-out",
    "cover": {
      "color": {
        "value": "#fff"
      },
      "opacity": 1
    },
    "enable": false
  },
  "defaultThemes": {},
  "delay": 0,
  "fullScreen": {
    "enable": true,
    "zIndex": -1
  },
  "detectRetina": true,
  "duration": 0,
  "fpsLimit": 120,
  "interactivity": {
    "detectsOn": "window",
    "events": {
      "onClick": {
        "enable": false,
        "mode": []
      },
      "onDiv": {
        "selectors": [],
        "enable": false,
        "mode": [],
        "type": "circle"
      },
      "onHover": {
        "enable": false,
        "mode": [],
        "parallax": {
          "enable": false,
          "force": 2,
          "smooth": 10
        }
      },
      "resize": {
        "delay": 0.5,
        "enable": true
      }
    },
    "modes": {
      "attract": {
        "distance": 200,
        "duration": 0.4,
        "easing": "ease-out-quad",
        "factor": 1,
        "maxSpeed": 50,
        "speed": 1
      },
      "bounce": {
        "distance": 200
      },
      "bubble": {
        "distance": 200,
        "duration": 0.4,
        "mix": false,
        "divs": {
          "distance": 200,
          "duration": 0.4,
          "mix": false,
          "selectors": []
        }
      },
      "connect": {
        "distance": 80,
        "links": {
          "opacity": 0.5
        },
        "radius": 60
      },
      "grab": {
        "distance": 100,
        "links": {
          "blink": false,
          "consent": false,
          "opacity": 1
        }
      },
      "push": {
        "default": true,
        "groups": [],
        "quantity": 4
      },
      "remove": {
        "quantity": 2
      },
      "repulse": {
        "distance": 200,
        "duration": 0.4,
        "factor": 100,
        "speed": 1,
        "maxSpeed": 50,
        "easing": "ease-out-quad",
        "divs": {
          "distance": 200,
          "duration": 0.4,
          "factor": 100,
          "speed": 1,
          "maxSpeed": 50,
          "easing": "ease-out-quad",
          "selectors": []
        }
      },
      "slow": {
        "factor": 3,
        "radius": 200
      },
      "trail": {
        "delay": 1,
        "pauseOnStop": false,
        "quantity": 1
      },
      "light": {
        "area": {
          "gradient": {
            "start": {
              "value": "#ffffff"
            },
            "stop": {
              "value": "#000000"
            }
          },
          "radius": 1000
        },
        "shadow": {
          "color": {
            "value": "#000000"
          },
          "length": 2000
        }
      }
    }
  },
  "manualParticles": [],
  "particles": {
    "bounce": {
      "horizontal": {
        "random": {
          "enable": false,
          "minimumValue": 0.1
        },
        "value": 1
      },
      "vertical": {
        "random": {
          "enable": false,
          "minimumValue": 0.1
        },
        "value": 1
      }
    },
    "collisions": {
      "absorb": {
        "speed": 2
      },
      "bounce": {
        "horizontal": {
          "random": {
            "enable": false,
            "minimumValue": 1
          },
          "value": {
            "min": 0.1,
            "max": 10
          }
        },
        "vertical": {
          "random": {
            "enable": false,
            "minimumValue": 0.1
          },
          "value": {
            "min": 0.1,
            "max": 10
          }
        }
      },
      "enable": true,
      "mode": "bounce",
      "overlap": {
        "enable": false,
        "retries": 0
      }
    },
    "color": {
      "value": "#ff0000",
      "animation": {
        "h": {
          "count": 0,
          "enable": false,
          "offset": 0,
          "speed": 1,
          "decay": 0,
          "sync": true
        },
        "s": {
          "count": 0,
          "enable": false,
          "offset": 0,
          "speed": 1,
          "decay": 0,
          "sync": true
        },
        "l": {
          "count": 0,
          "enable": false,
          "offset": 0,
          "speed": 1,
          "decay": 0,
          "sync": true
        }
      }
    },
    "groups": {},
    "move": {
      "angle": {
        "offset": 0,
        "value": 90
      },
      "attract": {
        "distance": 200,
        "enable": false,
        "rotate": {
          "x": 3000,
          "y": 3000
        }
      },
      "center": {
        "x": 50,
        "y": 50,
        "mode": "percent",
        "radius": 0
      },
      "decay": 0,
      "distance": {},
      "direction": "none",
      "drift": 0,
      "enable": true,
      "gravity": {
        "acceleration": 9.81,
        "enable": false,
        "inverse": false,
        "maxSpeed": 50
      },
      "path": {
        "clamp": true,
        "delay": {
          "random": {
            "enable": false,
            "minimumValue": 0
          },
          "value": 0
        },
        "enable": false,
        "options": {}
      },
      "outModes": {
        "default": "bounce",
        "bottom": "bounce",
        "left": "bounce",
        "right": "bounce",
        "top": "bounce"
      },
      "random": true,
      "size": true,
      "speed": 8,
      "spin": {
        "acceleration": 0,
        "enable": false
      },
      "straight": false,
      "trail": {
        "enable": true,
        "length": 3,
        "fillColor": {
          "value": "#000000"
        }
      },
      "vibrate": false,
      "warp": false
    },
    "number": {
      "density": {
        "enable": false,
        "area": 800,
        "factor": 1000
      },
      "limit": 0,
      "value": 14
    },
    "opacity": {
      "random": {
        "enable": false,
        "minimumValue": 0.1
      },
      "value": 1,
      "animation": {
        "count": 0,
        "enable": false,
        "speed": 0.25,
        "decay": 0,
        "sync": false,
        "destroy": "none",
        "startValue": "random"
      }
    },
    "reduceDuplicates": false,
    "shadow": {
      "blur": 4,
      "color": {
        "value": "#000"
      },
      "enable": true,
      "offset": {
        "x": 0,
        "y": 0
      }
    },
    "shape": {
      "options": {},
      "type": "circle"
    },
    "size": {
      "random": {
        "enable": false,
        "minimumValue": 1
      },
      "value": 41,
      "animation": {
        "count": 0,
        "enable": false,
        "speed": 5,
        "decay": 0,
        "sync": false,
        "destroy": "none",
        "startValue": "random"
      }
    },
    "stroke": {
      "width": 0,
      "color": {
        "value": "#004cff",
        "animation": {
          "h": {
            "count": 0,
            "enable": false,
            "offset": 0,
            "speed": 1,
            "decay": 0,
            "sync": true
          },
          "s": {
            "count": 0,
            "enable": false,
            "offset": 0,
            "speed": 1,
            "decay": 0,
            "sync": true
          },
          "l": {
            "count": 0,
            "enable": false,
            "offset": 0,
            "speed": 1,
            "decay": 0,
            "sync": true
          }
        }
      }
    },
    "zIndex": {
      "random": {
        "enable": false,
        "minimumValue": 0
      },
      "value": 0,
      "opacityRate": 1,
      "sizeRate": 1,
      "velocityRate": 1
    },
    "life": {
      "count": 0,
      "delay": {
        "random": {
          "enable": false,
          "minimumValue": 0
        },
        "value": 0,
        "sync": false
      },
      "duration": {
        "random": {
          "enable": false,
          "minimumValue": 0.0001
        },
        "value": 0,
        "sync": false
      }
    },
    "rotate": {
      "random": {
        "enable": false,
        "minimumValue": 0
      },
      "value": 0,
      "animation": {
        "enable": false,
        "speed": 0,
        "decay": 0,
        "sync": false
      },
      "direction": "clockwise",
      "path": false
    },
    "destroy": {
      "bounds": {},
      "mode": "none",
      "split": {
        "count": 1,
        "factor": {
          "random": {
            "enable": false,
            "minimumValue": 0
          },
          "value": 3
        },
        "rate": {
          "random": {
            "enable": false,
            "minimumValue": 0
          },
          "value": {
            "min": 4,
            "max": 9
          }
        },
        "sizeOffset": true,
        "particles": {}
      }
    },
    "roll": {
      "darken": {
        "enable": false,
        "value": 0
      },
      "enable": false,
      "enlighten": {
        "enable": false,
        "value": 0
      },
      "mode": "vertical",
      "speed": 25
    },
    "tilt": {
      "random": {
        "enable": false,
        "minimumValue": 0
      },
      "value": 0,
      "animation": {
        "enable": false,
        "speed": 0,
        "decay": 0,
        "sync": false
      },
      "direction": "clockwise",
      "enable": false
    },
    "twinkle": {
      "lines": {
        "enable": false,
        "frequency": 0.05,
        "opacity": 1
      },
      "particles": {
        "enable": false,
        "frequency": 0.05,
        "opacity": 1
      }
    },
    "wobble": {
      "distance": 5,
      "enable": false,
      "speed": {
        "angle": 50,
        "move": 10
      }
    },
    "orbit": {
      "animation": {
        "count": 0,
        "enable": false,
        "speed": 1,
        "decay": 0,
        "sync": false
      },
      "enable": false,
      "opacity": 1,
      "rotation": {
        "random": {
          "enable": false,
          "minimumValue": 0
        },
        "value": 45
      },
      "width": 1
    },
    "links": {
      "blink": false,
      "color": {
        "value": "#fff"
      },
      "consent": false,
      "distance": 100,
      "enable": false,
      "frequency": 1,
      "opacity": 1,
      "shadow": {
        "blur": 5,
        "color": {
          "value": "#000"
        },
        "enable": false
      },
      "triangles": {
        "enable": false,
        "frequency": 1
      },
      "width": 1,
      "warp": false
    },
    "repulse": {
      "random": {
        "enable": false,
        "minimumValue": 0
      },
      "value": 0,
      "enabled": false,
      "distance": 1,
      "duration": 1,
      "factor": 1,
      "speed": 1
    }
  },
  "pauseOnBlur": true,
  "pauseOnOutsideViewport": true,
  "responsive": [],
  "smooth": false,
  "style": {},
  "themes": [],
  "zLayers": 100,
  "emitters": []
}


问:
Find three sets of Top 5 non-zero column names in descending order
I am relatively new to python and struggling with a problem
I am trying to find the top keywords based on description to optimize the keyword search algorithm.

I have created a TF-IDF matrix and I need to do the following

a) Find the top n column names row-wise (which will correspond to keywords because the column names are tokens of my corpus)

b) Divide the top n columns into three sets in descending order (Set1 - Top 10 TFIDF, Set2- 11-20 , Set3 - 21-30) (if there are 15 items, the top 10 go in the first column, the next 5 go in second column, 3rd column stays empty)

I have a code snippet which creates a column per keyword (top 3) . I want to extend it to save buckets of 10 items each. The cur

Following is the code

```<code>dfScore = pd.DataFrame(score.toarray(), columns=tfidf.get_feature_names())
    pd.concat([df,pd.DataFrame(dfScore.apply(lambda x:list(dfScore.columns[np.array(x).argsort()[::-1][:3]]), axis=1).values.tolist(),  columns=['One', 'Two', 'Three'])], axis=1)
</code>```

Body:
I am relatively new to python and struggling with a problem
I am trying to find the top keywords based on description to optimize the keyword search algorithm.

I have created a TF-IDF matrix and I need to do the following

a) Find the top n column names row-wise (which will correspond to keywords because the column names are tokens of my corpus)

b) Divide the top n columns into three sets in descending order (Set1 - Top 10 TFIDF, Set2- 11-20 , Set3 - 21-30) (if there are 15 items, the top 10 go in the first column, the next 5 go in second column, 3rd column stays empty)

I have a code snippet which creates a column per keyword (top 3) . I want to extend it to save buckets of 10 items each. The cur

Following is the code

dfScore = pd.DataFrame(score.toarray(), columns=tfidf.get_feature_names())
    pd.concat([df,pd.DataFrame(dfScore.apply(lambda x:list(dfScore.columns[np.array(x).argsort()[::-1][:3]]), axis=1).values.tolist(),  columns=['One', 'Two', 'Three'])], axis=1)


问:
EF Core - many-to-many: how to add middle entity when one entity does not yet exist?
I am curios if I can make this easier/better.

The user is able to create new tickets and with each ticket can be several files associated, one file can be related to multiple tickets.

Now, when the user creates a ticket, he can already add files. Meaning I have no Id for the ticket and thus no way to build a relation. How should I solve this?

```<code>public class FilesPerTicket
{
    public int TickedId;
    public Ticket Ticket;

    public int FileId;
    public File File;
}

public class File
{
    public ICollection<FilesPerTicket> FilesperTicket;
}

public class Ticket
{
    public ICollection<FilesPerTicket> FilesperTicket;
}
</code>```

Now the user creates the ticket and adds several files to it.

```<code>public IActionResult Create(MyModel model)
{
    // .....
    var filesPerTicket = model.Files.Select(x => new FilesPerTicket() { FileId = x.Value }).ToList();
    var newTicket = new Ticket() { //...... };
    newTicket.FilesPerTicket = filesPerTicket;

    // ....
    context.Add(newTicket);
    context.SaveChanges();
}
</code>```

This doesn't work because we haven't provided a Ticketid and therefore every TicketId in FilesPerTicket is 0.

I know that I just can save the ticket and afterwards it will have the primary key in it. Which I then can use to fill the FilesPerTicket and save that one.

But then I would have those in separate transactions (because SaveChanges was called) and use another try/catch.

Is there an way to tell EF Core to fill this TicketId automatically when this entity gets saved at the same time as a ticket? Or some other way to save that entity?

Body:
I am curios if I can make this easier/better.

The user is able to create new tickets and with each ticket can be several files associated, one file can be related to multiple tickets.

Now, when the user creates a ticket, he can already add files. Meaning I have no Id for the ticket and thus no way to build a relation. How should I solve this?

public class FilesPerTicket
{
    public int TickedId;
    public Ticket Ticket;

    public int FileId;
    public File File;
}

public class File
{
    public ICollection<FilesPerTicket> FilesperTicket;
}

public class Ticket
{
    public ICollection<FilesPerTicket> FilesperTicket;
}

Now the user creates the ticket and adds several files to it.

public IActionResult Create(MyModel model)
{
    // .....
    var filesPerTicket = model.Files.Select(x => new FilesPerTicket() { FileId = x.Value }).ToList();
    var newTicket = new Ticket() { //...... };
    newTicket.FilesPerTicket = filesPerTicket;

    // ....
    context.Add(newTicket);
    context.SaveChanges();
}

This doesn't work because we haven't provided a Ticketid and therefore every TicketId in FilesPerTicket is 0.

I know that I just can save the ticket and afterwards it will have the primary key in it. Which I then can use to fill the FilesPerTicket and save that one.

But then I would have those in separate transactions (because SaveChanges was called) and use another try/catch.

Is there an way to tell EF Core to fill this TicketId automatically when this entity gets saved at the same time as a ticket? Or some other way to save that entity?


问:
Unity Android : unable to resolve class okhttp3.OkHttpClient
I'm trying to deploy an App on Android.

The problem

I first got the following error : can't resolve symbol okhttp and now I keep getting unable to resolve class okhttp3.OkHttpClient because of the importing line.

What I've tried

According to this similar post I added a custom Main Gradle Template

and I added the two following lines :

```<code>implementation 'com.squareup.okhttp3:okhttp:3.0.1'
import okhttp3.OkHttpClient;
</code>```

Here is the complete Gradle file :

```<code>buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
// Must be Android Gradle Plugin 3.6.0 or later. For a list of
// compatible Gradle versions refer to:
// https://developer.android.com/studio/releases/gradle-plugin
classpath 'com.android.tools.build:gradle:3.6.0'
}
}

allprojects {
repositories {
google()
mavenCentral()
flatDir {
dirs 'libs'
}
}
}

apply plugin: 'com.android.library'
**APPLY_PLUGINS**

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.squareup.okhttp3:okhttp:3.0.1'
**DEPS**}
import okhttp3.OkHttpClient;

android {
    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdkVersion **MINSDKVERSION**
        targetSdkVersion **TARGETSDKVERSION**
        ndk {
            abiFilters **ABIFILTERS**
        }
        versionCode **VERSIONCODE**
        versionName '**VERSIONNAME**'
        consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
    }

    lintOptions {
        abortOnError false
    }

    aaptOptions {
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
        noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
    }**PACKAGING_OPTIONS**
}**REPOSITORIES****SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
</code>```

Body:
I'm trying to deploy an App on Android.

The problem

I first got the following error : can't resolve symbol okhttp and now I keep getting unable to resolve class okhttp3.OkHttpClient because of the importing line.

What I've tried

According to this similar post I added a custom Main Gradle Template

and I added the two following lines :

implementation 'com.squareup.okhttp3:okhttp:3.0.1'
import okhttp3.OkHttpClient;

Here is the complete Gradle file :

buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
// Must be Android Gradle Plugin 3.6.0 or later. For a list of
// compatible Gradle versions refer to:
// https://developer.android.com/studio/releases/gradle-plugin
classpath 'com.android.tools.build:gradle:3.6.0'
}
}

allprojects {
repositories {
google()
mavenCentral()
flatDir {
dirs 'libs'
}
}
}

apply plugin: 'com.android.library'
**APPLY_PLUGINS**

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.squareup.okhttp3:okhttp:3.0.1'
**DEPS**}
import okhttp3.OkHttpClient;

android {
    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdkVersion **MINSDKVERSION**
        targetSdkVersion **TARGETSDKVERSION**
        ndk {
            abiFilters **ABIFILTERS**
        }
        versionCode **VERSIONCODE**
        versionName '**VERSIONNAME**'
        consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
    }

    lintOptions {
        abortOnError false
    }

    aaptOptions {
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
        noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
    }**PACKAGING_OPTIONS**
}**REPOSITORIES****SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**


问:
TS `export declare namespace` shadows already exported variable
I have a tool (which I am not able to modify) generating TS typings for me based on some unrelated code. It has generated some typings which I don't know how to process.

Basically, it exports a declared namespace and an interface with the same name. When I import them in my file, the type I get is being ambiguous.

File A.ts:

export declare namespace foo {
  interface goo {
    blah: number;
  }
}

export interface foo {
  goo: number;
}
```
<p>File <code>B.ts</code>:</p>
<pre class="lang-js prettyprint-override"><code>import type { foo } from './A'

let goo: foo;
</code>```

and when I hover over foo it shows:

(alias) interface foo
(alias) namespace foo
```

The foo type is aliasing both namespace foo and interface foo. Is it possible to differentiate between them? I only need the interface foo, but I am not able to modify the file generated (A.ts).

Body:
I have a tool (which I am not able to modify) generating TS typings for me based on some unrelated code. It has generated some typings which I don't know how to process.

Basically, it exports a declared namespace and an interface with the same name. When I import them in my file, the type I get is being ambiguous.

File A.ts:

export declare namespace foo {
  interface goo {
    blah: number;
  }
}

export interface foo {
  goo: number;
}

File B.ts:

import type { foo } from './A'

let goo: foo;

and when I hover over foo it shows:

(alias) interface foo
(alias) namespace foo

The foo type is aliasing both namespace foo and interface foo. Is it possible to differentiate between them? I only need the interface foo, but I am not able to modify the file generated (A.ts).