问:
Git push results in "Authentication Failed"
I have been using GitHub for a little while, and I have been fine with git add, git commit, and git push, so far without any problems. Suddenly I am having an error that says:

fatal: Authentication Failed

In the terminal I cloned a repository, worked on a file and then I used git add to add the file to the commit log and when I did git commit, it worked fine. Finally, git push asks for username and password. I put those in correctly and every time I do this, it says the same error.

What is the cause of this problem and how can I fix it?

The contents of .git/config are:

```<code>[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = http://www.github.com/######/Random-Python-Tests
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[user]
        name = #####
        email = ############
</code>```

答: This happened to us after forcing "Two Factor Authentication" before login from Gitlab. We had to paste the text inside id_rsa.pub to Gitlab, and then reintroduce the repository in VS code using the terminal.</p>

Body:
I have been using GitHub for a little while, and I have been fine with git add, git commit, and git push, so far without any problems. Suddenly I am having an error that says:

fatal: Authentication Failed

In the terminal I cloned a repository, worked on a file and then I used git add to add the file to the commit log and when I did git commit, it worked fine. Finally, git push asks for username and password. I put those in correctly and every time I do this, it says the same error.

What is the cause of this problem and how can I fix it?

The contents of .git/config are:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = http://www.github.com/######/Random-Python-Tests
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[user]
        name = #####
        email = ############


来源: stackexchange

问:
arrange number with 5 digits from the biggest to lowest in c only with 'if'
I have a question.
I working in c and I need to take a number from the user with 5 digits and sort it from the biggest number to the lowest  only with 'if'
I tried to do with 5 variables but the code getting huge.
there some easy way to do it only with 'ifs'???

for example, I get the number: 87953
the output should be : 98753.

(in the pic it only one situation).
enter image description here

答:
Here is a recursive approach where number of ifs are fixed irrespective size of array or number of digits,

```<code>#include <iostream>

int fun(char _arr[],int _size,int _index =0)
{
    if (_index+1 < _size)
    {
        bool flag = false;
        if (_arr[_index] < _arr[_index + 1])
        {
            std::swap(_arr[_index], _arr[_index + 1]);
            flag = true;
        }
        if (fun(_arr,  _size, _index + 1))
        {
            fun(_arr, _size, _index);
            return true;
        }
        else {
            return flag;
        }
    } else
    {
        return false;
    }
}

int main()
{
    char a[] = { 1,2,3,4,5};

    for (auto _a : a)
    {
        std::cout << (int)_a << " ";
    }
    std::cout<<std::endl;
    fun(a,sizeof(a),0);
    for (auto _a : a)
    {
        std::cout << (int)_a << " ";
    }
}
</code>```

output:

1 2 3 4 5

  5 4 3 2 1

ContentLicense: CC BY-SA 4.0

Body:
Here is a recursive approach where number of ifs are fixed irrespective size of array or number of digits,

#include <iostream>

int fun(char _arr[],int _size,int _index =0)
{
    if (_index+1 < _size)
    {
        bool flag = false;
        if (_arr[_index] < _arr[_index + 1])
        {
            std::swap(_arr[_index], _arr[_index + 1]);
            flag = true;
        }
        if (fun(_arr,  _size, _index + 1))
        {
            fun(_arr, _size, _index);
            return true;
        }
        else {
            return flag;
        }
    } else
    {
        return false;
    }
}

int main()
{
    char a[] = { 1,2,3,4,5};

    for (auto _a : a)
    {
        std::cout << (int)_a << " ";
    }
    std::cout<<std::endl;
    fun(a,sizeof(a),0);
    for (auto _a : a)
    {
        std::cout << (int)_a << " ";
    }
}

output:

1 2 3 4 5

  5 4 3 2 1


问:
Google AdWords API - AdGroupAdError CANNOT_CREATE_DEPRECATED_ADS
I'm using Google AdWords Python SDK to create ResponsiveDisplayAds. My code is like below.

```<code>adgroup_ad_service = adwords_client.GetService(
    service_name = "AdGroupAdService",
    version = "v201809"
)

operations = [{
    'operator': 'ADD',
    'operand': {
        'xsi_type': 'AdGroupAd',
        'adGroupId': '<AD_GROUP_ID>',
        'ad': {
            'xsi_type': 'ResponsiveDisplayAd',
            'marketingImage': {
                'mediaId': '<MEDIA_ID>'
            },
            'shortHeadline': 'Short Headline',
            'longHeadline': 'This is a very long headline',
            'description': 'This is a description',
            'businessName': 'Test Business Name',
            'finalUrls': ['https://www.google.com'],
            'squareMarketingImage': {
                'mediaId': '<MEDIA_ID>'
            }
        },
        'status': 'PAUSED'
    }
}]

ads_response = adgroup_ad_service.mutate(operations)

print("AD RESPONSE : {}".format(ads_response))
</code>```

But It's giving me, AdGroupAdError.CANNOT_CREATE_DEPRECATED_ADS.

According to the documentation it describe this error as An ad of this type is deprecated and cannot be created. Only deletions are permitted..

But in documentation of the AdGroupAd ResponsiveDisplayAd, is one of the accepted Ad types.

So it would be great if someone can point me a direction to resolve this issue.

答:
Use AddMultiAssetResponsiveDisplayAd  instead.
Same result in a different way.
Hope you can make it like i did.

Body:
I'm using Google AdWords Python SDK to create ResponsiveDisplayAds. My code is like below.

adgroup_ad_service = adwords_client.GetService(
    service_name = "AdGroupAdService",
    version = "v201809"
)

operations = [{
    'operator': 'ADD',
    'operand': {
        'xsi_type': 'AdGroupAd',
        'adGroupId': '<AD_GROUP_ID>',
        'ad': {
            'xsi_type': 'ResponsiveDisplayAd',
            'marketingImage': {
                'mediaId': '<MEDIA_ID>'
            },
            'shortHeadline': 'Short Headline',
            'longHeadline': 'This is a very long headline',
            'description': 'This is a description',
            'businessName': 'Test Business Name',
            'finalUrls': ['https://www.google.com'],
            'squareMarketingImage': {
                'mediaId': '<MEDIA_ID>'
            }
        },
        'status': 'PAUSED'
    }
}]

ads_response = adgroup_ad_service.mutate(operations)

print("AD RESPONSE : {}".format(ads_response))

But It's giving me, AdGroupAdError.CANNOT_CREATE_DEPRECATED_ADS.

According to the documentation it describe this error as An ad of this type is deprecated and cannot be created. Only deletions are permitted..

But in documentation of the AdGroupAd ResponsiveDisplayAd, is one of the accepted Ad types.

So it would be great if someone can point me a direction to resolve this issue.


问:
ionic 4 make ion-item transparent depending upon selected value
If selected value using <select> is greater than the value in the database, I want to make that particular ion-item transparent or blur. For that, I have a property called disabled. But I can't dynamically make ion-item transparent.
Thank you in advance

```<code>  onChange(new_quantity,object, stock  ) {
    let stocks = stock

     for(let i=0; i<stocks.length; i++) {
            if(new_quantity > stocks[i].RemainingQuantity){

              console.log(new_quantity)
              console.log(object.quantity)
              console.log(stocks[i].RemainingQuantity)

              object.disabled = true
              console.log("quantity not available")

              this.presentAlert()
            }
    }
}
</code>```

html

```<code><ion-list>
    <ion-item *ngFor="let p of cart ;  let i=index" class="ion-text-wrap">

            <ion-grid>

              <div class="ion-text-end" *ngIf="p.disabled">
                <ion-label color="tertiary">Out of stock</ion-label>
              </div>

     <select style="max-width:50%;" (change)="onChange($event.target.value, p, p.product.stocks) " [value]=p.quantity  >

      <option  [ngValue] = "q" *ngFor ="let q of quantity" >{{q}}</option>
      </select>
      </ion-grid>

        </ion-item>
</ion-list>
</code>```

答:
You can simplify your code by just passing the index of the cart to check the products stock. If you get the value of the ion-select with ngModel, you can access that value directly in the function without passing it in.

There we loop your selected products stock. If the remainingQuantity is less than your productQuantity, the cart is disabled. This will add a new css class item-disabled to your item, which sets the background to transparent.

Html

<ion-list>
  <ion-item *ngFor="let c of cart; let i=index" class="ion-text-wrap" [ngClass]="{ 'item-transparent': c.disabled  }">
    <ion-grid>

        <ion-label color="tertiary">Out of stock</ion-label>

      <ion-select style="max-width:50%;" [(ngModel)]="productQuantity" (ionChange)="checkIfProductIsOutOfStock(i)" value="c.quantity">
        <ion-select-option value="quantity" *ngFor="let quantity of c.quantity">{{ quantity }}</ion-select-option>
      </ion-select>
    </ion-grid>
  </ion-item>
</ion-list>
```

<h3>Ts</h3>

<pre class="lang-js prettyprint-override"><code>productQuantity: number;

checkIfProductIsOutOfStock(index: number) {
  const stocks = this.cart[index].products.stocks;

  stocks.forEach((stock: object) => {
    if (this.productQuantity > stock['RemainingQuantity'] {
      this.cart[index].disabled = true;
    }
  });
}
</code>```

Css

.item-transparent {
  --background: transparent;
}
```

Body:
If selected value using <select> is greater than the value in the database, I want to make that particular ion-item transparent or blur. For that, I have a property called disabled. But I can't dynamically make ion-item transparent.
Thank you in advance

  onChange(new_quantity,object, stock  ) {
    let stocks = stock

     for(let i=0; i<stocks.length; i++) {
            if(new_quantity > stocks[i].RemainingQuantity){

              console.log(new_quantity)
              console.log(object.quantity)
              console.log(stocks[i].RemainingQuantity)

              object.disabled = true
              console.log("quantity not available")

              this.presentAlert()
            }
    }
}

html

<ion-list>
    <ion-item *ngFor="let p of cart ;  let i=index" class="ion-text-wrap">

            <ion-grid>

                <ion-label color="tertiary">Out of stock</ion-label>

     <select style="max-width:50%;" (change)="onChange($event.target.value, p, p.product.stocks) " [value]=p.quantity  >

      <option  [ngValue] = "q" *ngFor ="let q of quantity" >{{q}}</option>
      </select>
      </ion-grid>

        </ion-item>
</ion-list>

Body:
You can simplify your code by just passing the index of the cart to check the products stock. If you get the value of the ion-select with ngModel, you can access that value directly in the function without passing it in.

There we loop your selected products stock. If the remainingQuantity is less than your productQuantity, the cart is disabled. This will add a new css class item-disabled to your item, which sets the background to transparent.

Html

<ion-list>
  <ion-item *ngFor="let c of cart; let i=index" class="ion-text-wrap" [ngClass]="{ 'item-transparent': c.disabled  }">
    <ion-grid>
      <div class="ion-text-end" *ngIf="c.disabled">
        <ion-label color="tertiary">Out of stock</ion-label>
      </div>
      <ion-select style="max-width:50%;" [(ngModel)]="productQuantity" (ionChange)="checkIfProductIsOutOfStock(i)" value="c.quantity">
        <ion-select-option value="quantity" *ngFor="let quantity of c.quantity">{{ quantity }}</ion-select-option>
      </ion-select>
    </ion-grid>
  </ion-item>
</ion-list>

Ts

productQuantity: number;

checkIfProductIsOutOfStock(index: number) {
  const stocks = this.cart[index].products.stocks;

  stocks.forEach((stock: object) => {
    if (this.productQuantity > stock['RemainingQuantity'] {
      this.cart[index].disabled = true;
    }
  });
}

Css

.item-transparent {
  --background: transparent;
}


问:
Why does included layouts suggestions are not coming while working with Databinding? [Not solved]
Only activity_main binding suggestions coming, but not content_main. can anybody please help what's going wrong? can anyone give me why it's not happening? I tried with binding.included..... not coming

Code

activity_main:

```<code><?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
            name="UserViewModel"
            type="com.lifetrenz.lifetrenz_gcc_doctorapp.viewmodel.UserViewModel" />
    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <include
            android:id="@+id/included"
            layout="@layout/content_main"
            tools:layout_editor_absoluteX="0dp"
            tools:layout_editor_absoluteY="0dp" />

        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="683dp"
            android:text="Button"
            app:layout_constraintBottom_toTopOf="@+id/included"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.554"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.0" />

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>
</code>```

content_main:

```<code><?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".view.MainActivity"
    tools:showIn="@layout/activity_main"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <RelativeLayout
        android:id="@+id/relative_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@+id/textView"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.719"
        tools:layout_editor_absoluteX="31dp">

    </RelativeLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
</code>```

MainActivity

```<code> binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
    binding.setLifecycleOwner(this);
    binding.setUserViewModel(userViewModel);
</code>```

relative_layout and textview binding suggestion not coming in MainActivity.

Already tried Invalidate cache/restart!

NOTE: If I'll move code from content_main to main_activity and remove include and all suggestions are coming.

答:
As @FahadAlotaibi said it will show surely.

```<code>    <androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/wholeLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include
        android:id="@+id/included"
        layout="@layout/content_main"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="0dp" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="683dp"
        android:text="Button"
        app:layout_constraintBottom_toTopOf="@+id/included"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.554"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0" />

</androidx.constraintlayout.widget.ConstraintLayout>
</code>```

In Java:

```<code>binding = DataBindingUtil.setContentView(this, R.layout.activity_main);

binding.wholeLayout.textView.setText("");
</code>```

Body:
Only activity_main binding suggestions coming, but not content_main. can anybody please help what's going wrong? can anyone give me why it's not happening? I tried with binding.included..... not coming

Code

activity_main:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
            name="UserViewModel"
            type="com.lifetrenz.lifetrenz_gcc_doctorapp.viewmodel.UserViewModel" />
    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <include
            android:id="@+id/included"
            layout="@layout/content_main"
            tools:layout_editor_absoluteX="0dp"
            tools:layout_editor_absoluteY="0dp" />

        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="683dp"
            android:text="Button"
            app:layout_constraintBottom_toTopOf="@+id/included"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.554"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.0" />

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

content_main:

<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".view.MainActivity"
    tools:showIn="@layout/activity_main"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <RelativeLayout
        android:id="@+id/relative_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@+id/textView"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.719"
        tools:layout_editor_absoluteX="31dp">

    </RelativeLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity

 binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
    binding.setLifecycleOwner(this);
    binding.setUserViewModel(userViewModel);

relative_layout and textview binding suggestion not coming in MainActivity.

Already tried Invalidate cache/restart!

NOTE: If I'll move code from content_main to main_activity and remove include and all suggestions are coming.

Body:
As @FahadAlotaibi said it will show surely.

    <androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/wholeLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include
        android:id="@+id/included"
        layout="@layout/content_main"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="0dp" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="683dp"
        android:text="Button"
        app:layout_constraintBottom_toTopOf="@+id/included"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.554"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0" />

</androidx.constraintlayout.widget.ConstraintLayout>

In Java:

binding = DataBindingUtil.setContentView(this, R.layout.activity_main);

binding.wholeLayout.textView.setText("");


问:
destructor/callback in C for getting shared_ptr behavour
I'm writing a socket listener in C. Whenever it accepts, it creates a new thread (detached) recv the data and process.

But everytime, I need to manually call close(socket_descriptor). Had it been C++, I could have in someway choose to close it inside a destructor.

I was trying to find out something that provides me same behaviour.

Basically, I want to create something like shared_ptr in C.

Is there anyway in C where one can get a signal or a notification when an object is going out of scope?

答:
There is no such thing as an automatic destructor in plain old C. Have you considered doing that through a garbage collector?

For example, you could use the Boehm-Demers-Weiser conservative garbage collector to allocate your objects and then call GC_REGISTER_FINALIZER to close the socket descriptor whenever the object becomes inaccessible.

Another solution could be to wrap the client's callback function into another function which simply calls the callback and then closes the socket. This way you wouldn't have to close it explicitly in every callback function.

ContentLicense: CC BY-SA 3.0


问:
Laravel : create hierarchical route for category
I'm implementing category structure , some products would have one level category but other may have two or more level :

```<code>/posts/cat2/post-sulg

/posts/cat-1/sub-1/post-slug

/posts/cat-3/sub../../../post-slug
</code>```

as i dont know how depth it would be and using category slugs is only for seo (i find post only by its slug) what is the best way to create a route to handle this structure?

答:
I did something similar, this in PostController.php using

```<code>public function slug($slug) { return $this->show(Post::where('slug', @end(explode('/', $slug)))->firstOrFail()); }
</code>```

In routes/web.php

```<code>Route::get ('posts/{slug}', 'PostController@slug')->name('post.slug')->where(['slug' => '^(?!((.*/edit$)|(create$))).*\D+.*$']);
Route::resource('posts', 'PostController');
</code>```

If you want to use the full category list as the slug, just change the slug function:

```<code>public function slug($slug) { return $this->show(Post::where('slug', $slug)->firstOrFail()); }
</code>```

Body:
I'm implementing category structure , some products would have one level category but other may have two or more level :

/posts/cat2/post-sulg

/posts/cat-1/sub-1/post-slug

/posts/cat-3/sub../../../post-slug

as i dont know how depth it would be and using category slugs is only for seo (i find post only by its slug) what is the best way to create a route to handle this structure?

Body:
I did something similar, this in PostController.php using

public function slug($slug) { return $this->show(Post::where('slug', @end(explode('/', $slug)))->firstOrFail()); }

In routes/web.php

Route::get ('posts/{slug}', 'PostController@slug')->name('post.slug')->where(['slug' => '^(?!((.*/edit$)|(create$))).*\D+.*$']);
Route::resource('posts', 'PostController');

If you want to use the full category list as the slug, just change the slug function:

public function slug($slug) { return $this->show(Post::where('slug', $slug)->firstOrFail()); }


问:
How to indent a long ternary condition in Php?
I have a long ternary condition in Php that exceeds the 120 hard rule.

What would be the right indentation according to PSR standard?

This is my ternary condition. The condition is a bit long, so the function call exceeds the 120 rule.

```<code>$variable = (condition) ? function() : $variable
</code>```

Is this a valid indendation?

```<code>$variable = (condition)
    ? function()
    : $variable
</code>```

答:
One option is to put each part on new line so it is clearly visible what you do in the "if" part and "else" part:</p>

```<code>$variable = (condition)
    ? function()
    : $variable;
</code>```

Body:
I have a long ternary condition in Php that exceeds the 120 hard rule.

What would be the right indentation according to PSR standard?

This is my ternary condition. The condition is a bit long, so the function call exceeds the 120 rule.

$variable = (condition) ? function() : $variable

Is this a valid indendation?

$variable = (condition)
    ? function()
    : $variable

Body:
One option is to put each part on new line so it is clearly visible what you do in the "if" part and "else" part:

$variable = (condition)
    ? function()
    : $variable;


问:
Query Run in different DB after returning to check remotely
Please help me on this.

I am running a query remotely on A.db, because it's a big data and maybe something is wrong on A.db that day so it took a long time. I don't spending time as long as I would get my result.

After hours of running(16 HOURS to be exact), the result is executing fail with some error. I went through the query and couldn't find any mistakes. But after a few read, I realize that the query has been executing in B.db instead of A.db that I was originally executing.

Is there any reason for the query to change to different db by itself? I read through the query and even let my colleague went through it, nothing is asking the query to run in different db.

Please help me on this, is has been bugged me for more than a week, I can't focus on others due to this problem.

Thank you

答:
Hey this can't be run on different DB if you ran it on some DB.
There might be chances that if you accidentally hit object explorer and selected different DB.

Better way you can do is just add

```<code>Use DB_name
</code>```

at top of your query this will say engine to run query in that db which you said.

```<code>Use a.DB
SELECT distinct A.* from (
</code>```

Body:
Hey this can't be run on different DB if you ran it on some DB.
There might be chances that if you accidentally hit object explorer and selected different DB.

Better way you can do is just add

Use DB_name

at top of your query this will say engine to run query in that db which you said.

Use a.DB
SELECT distinct A.* from (


问:
Get the first element from the file path
I have the vector in a data frame

```<code>c("E:\\\\My Network Places.old.dat", "E:\\\\pagefile.sys", "E:\\\\Press_Dly_Diff_G_91.rbc",
"E:\\\\TV_Press_Dly_Diff_A\\Retrospect\\Dantz", "E:\\\\TV_Press_Dly_Diff_A\\Retrospect\\TV_Press_Dly_Diff_A\\1-TV_Press_Dly_Diff_A\\AA000083.rdb",
"E:\\\\TV_Press_Dly_Diff_A\\Retrospect\\TV_Press_Dly_Diff_A\\1-TV_Press_Dly_Diff_A\\AA000561.rdb"
)
</code>```

In the above the length of file paths vary from just 1 to 5.  I am trying to get each level of the file path into a column in the data frame.  I tried with the first part using the following:

```<code>library(stringr)
df1$PF <- strsplit(df1$File.Name, "\\\\"))
df1$PFolder <- df1$PF[[1]][3]
</code>```

But I am getting only the first My Network Places.old.dat for all the rows in the data frame.  How do I split the path into multiple columns based on \\ separator and save it into separate columns within the data frame.  The desired output looks like this:

```<code>File.Name         FilePath1         FilePath2       FilePath3
</code>```

The above character vector is in File.Name in the data frame.

答:
Here is a base R solution using strsplit, i.e.,

```<code>res <- data.frame(do.call(rbind,lapply(s <- strsplit(v,split = "\\\\+"),`length<-`,max(lengths(s)))))
</code>```

such that

```<code>> res
  X1                        X2         X3                  X4                    X5           X6
1 E: My Network Places.old.dat       <NA>                <NA>                  <NA>         <NA>
2 E:              pagefile.sys       <NA>                <NA>                  <NA>         <NA>
3 E:   Press_Dly_Diff_G_91.rbc       <NA>                <NA>                  <NA>         <NA>
4 E:       TV_Press_Dly_Diff_A Retrospect               Dantz                  <NA>         <NA>
5 E:       TV_Press_Dly_Diff_A Retrospect TV_Press_Dly_Diff_A 1-TV_Press_Dly_Diff_A AA000083.rdb
6 E:       TV_Press_Dly_Diff_A Retrospect TV_Press_Dly_Diff_A 1-TV_Press_Dly_Diff_A AA000561.rdb
</code>```

DATA

```<code>v <- c("E:\\\\My Network Places.old.dat", "E:\\\\pagefile.sys", "E:\\\\Press_Dly_Diff_G_91.rbc",
       "E:\\\\TV_Press_Dly_Diff_A\\Retrospect\\Dantz", "E:\\\\TV_Press_Dly_Diff_A\\Retrospect\\TV_Press_Dly_Diff_A\\1-TV_Press_Dly_Diff_A\\AA000083.rdb",
       "E:\\\\TV_Press_Dly_Diff_A\\Retrospect\\TV_Press_Dly_Diff_A\\1-TV_Press_Dly_Diff_A\\AA000561.rdb"
)
</code>```

Body:
I have the vector in a data frame

c("E:\\\\My Network Places.old.dat", "E:\\\\pagefile.sys", "E:\\\\Press_Dly_Diff_G_91.rbc",
"E:\\\\TV_Press_Dly_Diff_A\\Retrospect\\Dantz", "E:\\\\TV_Press_Dly_Diff_A\\Retrospect\\TV_Press_Dly_Diff_A\\1-TV_Press_Dly_Diff_A\\AA000083.rdb",
"E:\\\\TV_Press_Dly_Diff_A\\Retrospect\\TV_Press_Dly_Diff_A\\1-TV_Press_Dly_Diff_A\\AA000561.rdb"
)

In the above the length of file paths vary from just 1 to 5.  I am trying to get each level of the file path into a column in the data frame.  I tried with the first part using the following:

library(stringr)
df1$PF <- strsplit(df1$File.Name, "\\\\"))
df1$PFolder <- df1$PF[[1]][3]

But I am getting only the first My Network Places.old.dat for all the rows in the data frame.  How do I split the path into multiple columns based on \\ separator and save it into separate columns within the data frame.  The desired output looks like this:

File.Name         FilePath1         FilePath2       FilePath3

The above character vector is in File.Name in the data frame.

Body:
Here is a base R solution using strsplit, i.e.,

res <- data.frame(do.call(rbind,lapply(s <- strsplit(v,split = "\\\\+"),`length<-`,max(lengths(s)))))

such that

> res
  X1                        X2         X3                  X4                    X5           X6
1 E: My Network Places.old.dat       <NA>                <NA>                  <NA>         <NA>
2 E:              pagefile.sys       <NA>                <NA>                  <NA>         <NA>
3 E:   Press_Dly_Diff_G_91.rbc       <NA>                <NA>                  <NA>         <NA>
4 E:       TV_Press_Dly_Diff_A Retrospect               Dantz                  <NA>         <NA>
5 E:       TV_Press_Dly_Diff_A Retrospect TV_Press_Dly_Diff_A 1-TV_Press_Dly_Diff_A AA000083.rdb
6 E:       TV_Press_Dly_Diff_A Retrospect TV_Press_Dly_Diff_A 1-TV_Press_Dly_Diff_A AA000561.rdb

DATA

v <- c("E:\\\\My Network Places.old.dat", "E:\\\\pagefile.sys", "E:\\\\Press_Dly_Diff_G_91.rbc",
       "E:\\\\TV_Press_Dly_Diff_A\\Retrospect\\Dantz", "E:\\\\TV_Press_Dly_Diff_A\\Retrospect\\TV_Press_Dly_Diff_A\\1-TV_Press_Dly_Diff_A\\AA000083.rdb",
       "E:\\\\TV_Press_Dly_Diff_A\\Retrospect\\TV_Press_Dly_Diff_A\\1-TV_Press_Dly_Diff_A\\AA000561.rdb"
)


问:
Installation failed due to: 'null' - Android Studio 3.5
I have updated Android studio to 3.5, ever since I am running into an APK installation problem. This is the only log it shows:

```<code>Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION
Installation failed due to: 'null'
Retry
</code>```

This happens when trying to install APK on a real device. If I uninstall the app from the device and then rerun the build, it installs only one time and then it keeps throwing this error on the next installation. It runs fine on an emulator but I can not use an emulator for everything.

What I have tried:

Deleted Android Studio configuration file.

Deleted Gradle files from the project.

Invalidated and reset caches.

Cleaned/rebuilt the project.

Looked for similar problems Stackoverflow(nothing matches my problem)

Clean installed(Removed all files including SDKs) Android Studio 3.5

Update

I installed Linux Mint on my machine and tested the AS 3.5 there, for some reason everything is working fine even for Android 7 and below devices.

Previous OS: Windows 10 1903

Current OS: Linux Mint 19.2

I reckon this problem may be originating from Windows machines.

答:
I also faced the same issue , i followed the following steps
1) Clean Project
2) Rebuilt Project

This solved my problem

Body:
I have updated Android studio to 3.5, ever since I am running into an APK installation problem. This is the only log it shows:

Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION
Installation failed due to: 'null'
Retry

This happens when trying to install APK on a real device. If I uninstall the app from the device and then rerun the build, it installs only one time and then it keeps throwing this error on the next installation. It runs fine on an emulator but I can not use an emulator for everything.

What I have tried:

Deleted Android Studio configuration file.

Deleted Gradle files from the project.

Invalidated and reset caches.

Cleaned/rebuilt the project.

Looked for similar problems Stackoverflow(nothing matches my problem)

Clean installed(Removed all files including SDKs) Android Studio 3.5

Update

I installed Linux Mint on my machine and tested the AS 3.5 there, for some reason everything is working fine even for Android 7 and below devices.

Previous OS: Windows 10 1903

Current OS: Linux Mint 19.2

I reckon this problem may be originating from Windows machines.


问:
Python-magic installation error - ImportError: failed to find libmagic
I am trying to install python-magic for Windows and I have followed all the instructions in https://github.com/ahupp/python-magic and repeated the process several times but I am still getting this error:

```<code>ImportError: failed to find libmagic. Check your installation
</code>```

I have magic1.dll (along with the two other files the docs specified) in C:\Windows\System32 so I am not sure what the issue is. I would appreciate any help or workarounds.

答:
I know this is a Windows question, but i wanted to share a Debian solution:

```<code>apt-get install libmagic-dev
</code>```

Kind regards.

Body:
I am trying to install python-magic for Windows and I have followed all the instructions in https://github.com/ahupp/python-magic and repeated the process several times but I am still getting this error:

ImportError: failed to find libmagic. Check your installation

I have magic1.dll (along with the two other files the docs specified) in C:\Windows\System32 so I am not sure what the issue is. I would appreciate any help or workarounds.

Body:
I know this is a Windows question, but i wanted to share a Debian solution:

apt-get install libmagic-dev

Kind regards.


问:
The executable was signed with invalid entitlements using App store
The entitlements specified in your application’s Code Signing Entitlements file do not match those specified in your provisioning profile.

(0xE8008016).

I have tried all the possibilities but still facing issue.

答: Check whether the Code Signing Identity values under Project  > Build Settings and Targets > Build Settings are correct.</p>

ContentLicense: CC BY-SA 2.5


问:
Ktor application not running on my computer
I am trying to learn to use ktor and I'm trying to display the text "Hello Ktor" at the root path but all I keep getting is this site can't be reached.
This is my code:

```<code>import io.ktor.application.*
import io.ktor.http.ContentType
import io.ktor.response.respondText
import io.ktor.routing.get
import io.ktor.routing.routing

fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)

private val userData = "{\"users\": [\"Timi\", \"Tomi\", \"Temi\"]}"

@Suppress("unused") // Referenced in application.conf
@kotlin.jvm.JvmOverloads
fun Application.module(testing: Boolean = false) {

    routing {
        get("/") {
            call.respondText("Hello Ktor", ContentType.Text.Plain)
        }

    }
}

</code>```

What am I doing wrong?

答:
Your code is fine.
I think you just need to access it correctly from browser.
Try

127.0.0.1:8080

or

localhost:8080

or simply follow nice tutorial from official website.

Body:
I am trying to learn to use ktor and I'm trying to display the text "Hello Ktor" at the root path but all I keep getting is this site can't be reached.
This is my code:

import io.ktor.application.*
import io.ktor.http.ContentType
import io.ktor.response.respondText
import io.ktor.routing.get
import io.ktor.routing.routing

fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)

private val userData = "{\"users\": [\"Timi\", \"Tomi\", \"Temi\"]}"

@Suppress("unused") // Referenced in application.conf
@kotlin.jvm.JvmOverloads
fun Application.module(testing: Boolean = false) {

    routing {
        get("/") {
            call.respondText("Hello Ktor", ContentType.Text.Plain)
        }

    }
}

What am I doing wrong?


问:
How to retain the type of list elements after stored in a dictionary?
I have a nested dictionary, which is of following form.

```<code>import pickle

db = {'obj 1':
        {
        'a' : 1, 'b' : 2, 'c' : 3,
        'foo': [0, a, a+b, 2*a, 2*(b+c)],
        'bar': [c, c+a, c-b, 2*c, 2*a]
        },
    'obj 2':
        {
        'a' : 4, 'b' : 5, 'c' : 6,
        'foo': [0, a, a+b, 2*a, 2*(b+c), 0, 0],
        'bar': [c, c+a, c-b, 2*c, 2*a, 0, 0]
        },
}

with open("db.pkl", "wb") as pkl:
    pickle.dump(db, pkl)

print(db)
</code>```

It's throwing this error:

```<code>Traceback (most recent call last):
  File "dmy.py", line 8, in <module>
    'foo': [0, a, a+b, 2*a, 2*(b+c)],
NameError: name 'a' is not defined
</code>```

Is there anything I can do such that I'll get the output for dmy = db['obj 1']['foo'] to be [0, a, a+b, 2*a, 2*(b+c)] which is a list.
I understand what I am doing may not be the right approach, but I need the contents together like this.

Note: I already tried converting the list elements individually into strings, but while parsing, I couldn't get the content in this specified form i.e [0, a, a+b, 2*a, 2*(b+c)].

Closest I could find was this link Python - is there a way to store an operation(+ - * /) in a list or as a variable?

答:
You could replace your list comprehensions with lambda functions and pickle them using dill (https://pypi.org/project/dill/) instead of pickle:</p>

```<code>import dill

db = {'obj 1':
        {
        'a' : 1, 'b' : 2, 'c' : 3,
        'foo': lambda a, b, c : [0, a, a+b, 2*a, 2*(b+c)],
        'bar': lambda a, b, c : [c, c+a, c-b, 2*c, 2*a]
        },
    'obj 2':
        {
        'a' : 4, 'b' : 5, 'c' : 6,
        'foo': lambda a, b, c : [0, a, a+b, 2*a, 2*(b+c), 0, 0],
        'bar': lambda a, b, c : [c, c+a, c-b, 2*c, 2*a, 0, 0]
        },
}

print(db)

pickled_db = dill.dumps(db)
unpickled_db = dill.loads(pickled_db)

print(unpickled_db)
</code>```

Body:
I have a nested dictionary, which is of following form.

import pickle

db = {'obj 1':
        {
        'a' : 1, 'b' : 2, 'c' : 3,
        'foo': [0, a, a+b, 2*a, 2*(b+c)],
        'bar': [c, c+a, c-b, 2*c, 2*a]
        },
    'obj 2':
        {
        'a' : 4, 'b' : 5, 'c' : 6,
        'foo': [0, a, a+b, 2*a, 2*(b+c), 0, 0],
        'bar': [c, c+a, c-b, 2*c, 2*a, 0, 0]
        },
}

with open("db.pkl", "wb") as pkl:
    pickle.dump(db, pkl)

print(db)

It's throwing this error:

Traceback (most recent call last):
  File "dmy.py", line 8, in <module>
    'foo': [0, a, a+b, 2*a, 2*(b+c)],
NameError: name 'a' is not defined

Is there anything I can do such that I'll get the output for dmy = db['obj 1']['foo'] to be [0, a, a+b, 2*a, 2*(b+c)] which is a list.
I understand what I am doing may not be the right approach, but I need the contents together like this.

Note: I already tried converting the list elements individually into strings, but while parsing, I couldn't get the content in this specified form i.e [0, a, a+b, 2*a, 2*(b+c)].

Closest I could find was this link Python - is there a way to store an operation(+ - * /) in a list or as a variable?

Body:
You could replace your list comprehensions with lambda functions and pickle them using dill (https://pypi.org/project/dill/) instead of pickle:

import dill

db = {'obj 1':
        {
        'a' : 1, 'b' : 2, 'c' : 3,
        'foo': lambda a, b, c : [0, a, a+b, 2*a, 2*(b+c)],
        'bar': lambda a, b, c : [c, c+a, c-b, 2*c, 2*a]
        },
    'obj 2':
        {
        'a' : 4, 'b' : 5, 'c' : 6,
        'foo': lambda a, b, c : [0, a, a+b, 2*a, 2*(b+c), 0, 0],
        'bar': lambda a, b, c : [c, c+a, c-b, 2*c, 2*a, 0, 0]
        },
}

print(db)

pickled_db = dill.dumps(db)
unpickled_db = dill.loads(pickled_db)

print(unpickled_db)


问:
Update query with aggregate self-join
I am using a self-join to get year-to-date totals. This works:

```<code>SELECT tc.EmployeeID, tc.TimeCardNum, tc.Tax, SUM(inr.Tax) AS YTDTax
FROM TimeCards tc
JOIN (
        SELECT EmployeeID, TimeCardNum, Tax
        FROM TimeCards
) AS inr
ON inr.EmployeeID = tc.EmployeeID
AND inr.TimeCardNum <= tc.TimeCardNum
GROUP BY tc.EmployeeID, tc.TimeCardNum, tc.Tax
ORDER BY tc.EmployeeID, tc.TimeCardNum
</code>```

which gives me a running total column that resets for each employee.

Now I want to turn it into an UPDATE query to put that data into a new column. How is this done?

答:
Have you tried:

```<code>UPDATE a
SET a.YTDTax=b.YTDTax
FROM TimeCards a
INNER JOIN (
    SELECT tc.EmployeeID, tc.TimeCardNum, tc.Tax, SUM(inr.Tax) AS YTDTax
    FROM TimeCards tc
    JOIN (
            SELECT EmployeeID, TimeCardNum, Tax
            FROM TimeCards
    ) AS inr
    ON inr.EmployeeID = tc.EmployeeID
    AND inr.TimeCardNum <= tc.TimeCardNum
    GROUP BY tc.EmployeeID, tc.TimeCardNum, tc.Tax
) b on a.EmployeeID=b.EmployeeID
AND a.TimeCardNum = b.TimeCardNum
</code>```

Run in a transaction to ensure it produces the desired output.

Title: Update query with aggregate self-join

Body:
I am using a self-join to get year-to-date totals. This works:

SELECT tc.EmployeeID, tc.TimeCardNum, tc.Tax, SUM(inr.Tax) AS YTDTax
FROM TimeCards tc
JOIN (
        SELECT EmployeeID, TimeCardNum, Tax
        FROM TimeCards
) AS inr
ON inr.EmployeeID = tc.EmployeeID
AND inr.TimeCardNum <= tc.TimeCardNum
GROUP BY tc.EmployeeID, tc.TimeCardNum, tc.Tax
ORDER BY tc.EmployeeID, tc.TimeCardNum

which gives me a running total column that resets for each employee.

Now I want to turn it into an UPDATE query to put that data into a new column. How is this done?

Body:
Have you tried:

UPDATE a
SET a.YTDTax=b.YTDTax
FROM TimeCards a
INNER JOIN (
    SELECT tc.EmployeeID, tc.TimeCardNum, tc.Tax, SUM(inr.Tax) AS YTDTax
    FROM TimeCards tc
    JOIN (
            SELECT EmployeeID, TimeCardNum, Tax
            FROM TimeCards
    ) AS inr
    ON inr.EmployeeID = tc.EmployeeID
    AND inr.TimeCardNum <= tc.TimeCardNum
    GROUP BY tc.EmployeeID, tc.TimeCardNum, tc.Tax
) b on a.EmployeeID=b.EmployeeID
AND a.TimeCardNum = b.TimeCardNum

Run in a transaction to ensure it produces the desired output.


问:
Vuetify multiple rows align and set the same width
How to align multiple rows with col="auto" in Vuetify?

I want to make cols="auto" the same width between multiple rows.

```<code><div id="problem_list" class="text-center">
  <v-row>
    <v-col cols="auto">
      ID
    </v-col>
    <v-divider vertical></v-divider>
    <v-col class="text-left">
      Title
    </v-col>
    <v-divider vertical></v-divider>
    <v-col cols="auto">
      Ratio
    </v-col>
  </v-row>
  <v-row>
    <v-col cols="auto">
      1
    </v-col>
    <v-divider vertical></v-divider>
    <v-col class="text-left">
      fdkj
    </v-col>
    <v-divider vertical></v-divider>
    <v-col cols="auto">
      8
    </v-col>
  </v-row>
</div>
</code>```

答:
Try to override some Vuetify CSS rules in order to have the same width whatever the number of columns :

```<code>.row{
display: grid;
    grid-template-columns: repeat(auto-fit,minmax(64px,auto));
}
</code>```

please check this codepen sample

Body:
How to align multiple rows with col="auto" in Vuetify?

I want to make cols="auto" the same width between multiple rows.

  <v-row>
    <v-col cols="auto">
      ID
    </v-col>
    <v-divider vertical></v-divider>
    <v-col class="text-left">
      Title
    </v-col>
    <v-divider vertical></v-divider>
    <v-col cols="auto">
      Ratio
    </v-col>
  </v-row>
  <v-row>
    <v-col cols="auto">
      1
    </v-col>
    <v-divider vertical></v-divider>
    <v-col class="text-left">
      fdkj
    </v-col>
    <v-divider vertical></v-divider>
    <v-col cols="auto">
      8
    </v-col>
  </v-row>

Body:
Try to override some Vuetify CSS rules in order to have the same width whatever the number of columns :

.row{
display: grid;
    grid-template-columns: repeat(auto-fit,minmax(64px,auto));
}

please check this codepen sample


问:
Visual Studio extension could not find a required assembly
I wrote an extension for Visual Studio 2013. Because of bloody ComboBox bug, I had to include System.Windows.Interactivity to my project. To add more details:

<Project> uses additional solution assembly, say <Project>.Editor, which contains the physical editor.

<Project>.Editor references System.Windows.Interactivity

<Project> references System.Windows.Interactivity as well. In fact, I'm using nuget to load Expression.Blend.Sdk package (it's compatible with WPF 4.5)

Effect: When part of editor, which contains mentioned ComboBox displays, I immediately get an exception:

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: Could not load file or assembly 'System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I'm running the extension in the experimental instance and the folder:

```<code>C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0
</code>```

contains System.Windows.Interactivity.dll, but for some reason it seems not to be seen by the IDE.

What's even more weird, I'm using other additional packages, like IronPython and they never caused me such trouble.

How can I fix that?

Edit: In response to comments

Actually, the InnerException contains field called FusionLog, which contains the following:

```<code>=== Pre-bind state information ===
LOG: DisplayName = System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35 | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\<user>\AppData\Local\Temp\devE4FC.tmp
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
</code>```

But there's more. I used ProcMon to check, where Visual Studio looks for that DLL and noticed in the end:

```<code>08:46:46,7508050    devenv.exe  7544    CreateFile  C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\Lib\System.Windows.Interactivity  NAME NOT FOUND  Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
08:46:46,7509231    devenv.exe  7544    CreateFile  C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\Lib\System.Windows.Interactivity.EXE  NAME NOT FOUND  Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
08:46:46,7510379    devenv.exe  7544    CreateFile  C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\Lib\System.Windows.Interactivity.DLL  NAME NOT FOUND  Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
</code>```

The Lib folder contains a few Python modules I'm using (for scripting purposes, as I'm using IronPython). And, ironically, the assembly is in the

```<code>C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\
</code>```

folder (without Lib). But Visual Studio omits it in its search despite fact, that it's the most natural place to search (as requesting assembly resides there as well)

答:
Using Microsoft.Xaml.Behaviors.Wpf instead of System.Windows.Interactivity the problem goes away.

Here's how to migrate: https://devblogs.microsoft.com/dotnet/open-sourcing-xaml-behaviors-for-wpf/
(Basically: install nuget, replace xmlns namespaces in xaml files.)

Body:
I wrote an extension for Visual Studio 2013. Because of bloody ComboBox bug, I had to include System.Windows.Interactivity to my project. To add more details:

<Project> uses additional solution assembly, say <Project>.Editor, which contains the physical editor.

<Project>.Editor references System.Windows.Interactivity

<Project> references System.Windows.Interactivity as well. In fact, I'm using nuget to load Expression.Blend.Sdk package (it's compatible with WPF 4.5)

Effect: When part of editor, which contains mentioned ComboBox displays, I immediately get an exception:

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: Could not load file or assembly 'System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I'm running the extension in the experimental instance and the folder:

C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0

contains System.Windows.Interactivity.dll, but for some reason it seems not to be seen by the IDE.

What's even more weird, I'm using other additional packages, like IronPython and they never caused me such trouble.

How can I fix that?

Edit: In response to comments

Actually, the InnerException contains field called FusionLog, which contains the following:

=== Pre-bind state information ===
LOG: DisplayName = System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35 | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\<user>\AppData\Local\Temp\devE4FC.tmp
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity/System.Windows.Interactivity.EXE.

But there's more. I used ProcMon to check, where Visual Studio looks for that DLL and noticed in the end:

08:46:46,7508050    devenv.exe  7544    CreateFile  C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\Lib\System.Windows.Interactivity  NAME NOT FOUND  Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
08:46:46,7509231    devenv.exe  7544    CreateFile  C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\Lib\System.Windows.Interactivity.EXE  NAME NOT FOUND  Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
08:46:46,7510379    devenv.exe  7544    CreateFile  C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\Lib\System.Windows.Interactivity.DLL  NAME NOT FOUND  Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

The Lib folder contains a few Python modules I'm using (for scripting purposes, as I'm using IronPython). And, ironically, the assembly is in the

C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\

folder (without Lib). But Visual Studio omits it in its search despite fact, that it's the most natural place to search (as requesting assembly resides there as well)


答:
Remove the v-divider and cols="auto". Removing cols will make the col auto by default. If you want the dividers, use CSS instead.

Template:

```<code><v-row>
    <v-col class="test">
        ID
    </v-col>
    <v-col class="test">
        Title
    </v-col>
    <v-col class="test">
        Ratio
    </v-col>
</v-row>
<v-row>
    <v-col class="test">
        1
    </v-col>
    <v-col class="text-left test">
        fdkj
    </v-col>
    <v-col class="test">
        8
    </v-col>
</v-row>
</code>```

CSS:

```<code>.test {
   border-left: 1px solid lightgray;
}
</code>```

Codepen

But Judging for what you are trying to do, isn't it just better to just use v-simple-table or v-data-table instead?

Title: Vuetify multiple rows align and set the same width

Body:
Remove the v-divider and cols="auto". Removing cols will make the col auto by default. If you want the dividers, use CSS instead.

Template:

<v-row>
    <v-col class="test">
        ID
    </v-col>
    <v-col class="test">
        Title
    </v-col>
    <v-col class="test">
        Ratio
    </v-col>
</v-row>
<v-row>
    <v-col class="test">
        1
    </v-col>
    <v-col class="text-left test">
        fdkj
    </v-col>
    <v-col class="test">
        8
    </v-col>
</v-row>

CSS:

.test {
   border-left: 1px solid lightgray;
}

Codepen

But Judging for what you are trying to do, isn't it just better to just use v-simple-table or v-data-table instead?


问:
continuous log file processing and extract required data using python
I have to analyze a log file which will generate continuously 24*7. So, the data will be huge. I will have credentials to where log file is generating. But how can I get that streaming data ( I mean like any free tools or processes) so that I can use it in my python code to extract some required information from that log stream and will have to prepare a real time dashboard with that data. please tell some possibilities to achieve above task.</p>

答:
It looks like pygtail will do what you want:
https://pypi.org/project/pygtail/</p>

```<code>from pygtail import Pygtail

for line in Pygtail("some.log"):
    sys.stdout.write(line)
</code>```

Body:
It looks like pygtail will do what you want:
https://pypi.org/project/pygtail/

from pygtail import Pygtail

for line in Pygtail("some.log"):
    sys.stdout.write(line)


问:
How to feed the output of a finetuned bert model as inpunt to another finetuned bert model?
I finetuned two separate bert model (bert-base-uncased) on sentiment analysis and pos tagging tasks. Now, I want to feed the output of the pos tagger (batch, seqlength, hiddensize) as input to the sentiment model.The original bert-base-uncased model is in 'bertModel/' folder which contains 'model.bin' and 'config.json'. Here is my code:

```<code>class DeepSequentialModel(nn.Module):
def __init__(self, sentiment_model_file, postag_model_file, device):
    super(DeepSequentialModel, self).__init__()

    self.sentiment_model = SentimentModel().to(device)
    self.sentiment_model.load_state_dict(torch.load(sentiment_model_file, map_location=device))
    self.postag_model = PosTagModel().to(device)
    self.postag_model.load_state_dict(torch.load(postag_model_file, map_location=device))

    self.classificationLayer = nn.Linear(768, 1)

def forward(self, seq, attn_masks):
    postag_context = self.postag_model(seq, attn_masks)
    sent_context = self.sentiment_model(postag_context, attn_masks)
    logits = self.classificationLayer(sent_context)
    return logits

class PosTagModel(nn.Module):
def __init__(self,):
    super(PosTagModel, self).__init__()
    self.bert_layer = BertModel.from_pretrained('bertModel/')
    self.classificationLayer = nn.Linear(768, 43)

def forward(self, seq, attn_masks):
    cont_reps, _ = self.bert_layer(seq, attention_mask=attn_masks)
    return cont_reps

class SentimentModel(nn.Module):
def __init__(self,):
    super(SentimentModel, self).__init__()
    self.bert_layer = BertModel.from_pretrained('bertModel/')
    self.cls_layer = nn.Linear(768, 1)

def forward(self, input, attn_masks):
    cont_reps, _ = self.bert_layer(encoder_hidden_states=input, encoder_attention_mask=attn_masks)
    cls_rep = cont_reps[:, 0]
    return cls_rep
</code>```

But I get the below error. I appreciate it if someone could help me. Thanks!

```<code>    cont_reps, _ = self.bert_layer(encoder_hidden_states=input, encoder_attention_mask=attn_masks)
    result = self.forward(*input, **kwargs)
    TypeError: forward() got an unexpected keyword argument 'encoder_hidden_states'
</code>```

答:
To formulate this as an answer, too, and keep it properly visible for future visitors, the forward() call of transformers does not support these arguments in version 2.1.1, or any earlier version, for that matter. note that the link in my comment is in fact pointing to a different forward function, but otherwise the point still holds.

Passing encoder_hidden_states to forward() was first possible in version 2.2.0.

Body:
I finetuned two separate bert model (bert-base-uncased) on sentiment analysis and pos tagging tasks. Now, I want to feed the output of the pos tagger (batch, seqlength, hiddensize) as input to the sentiment model.The original bert-base-uncased model is in 'bertModel/' folder which contains 'model.bin' and 'config.json'. Here is my code:

class DeepSequentialModel(nn.Module):
def __init__(self, sentiment_model_file, postag_model_file, device):
    super(DeepSequentialModel, self).__init__()

    self.sentiment_model = SentimentModel().to(device)
    self.sentiment_model.load_state_dict(torch.load(sentiment_model_file, map_location=device))
    self.postag_model = PosTagModel().to(device)
    self.postag_model.load_state_dict(torch.load(postag_model_file, map_location=device))

    self.classificationLayer = nn.Linear(768, 1)

def forward(self, seq, attn_masks):
    postag_context = self.postag_model(seq, attn_masks)
    sent_context = self.sentiment_model(postag_context, attn_masks)
    logits = self.classificationLayer(sent_context)
    return logits

class PosTagModel(nn.Module):
def __init__(self,):
    super(PosTagModel, self).__init__()
    self.bert_layer = BertModel.from_pretrained('bertModel/')
    self.classificationLayer = nn.Linear(768, 43)

def forward(self, seq, attn_masks):
    cont_reps, _ = self.bert_layer(seq, attention_mask=attn_masks)
    return cont_reps

class SentimentModel(nn.Module):
def __init__(self,):
    super(SentimentModel, self).__init__()
    self.bert_layer = BertModel.from_pretrained('bertModel/')
    self.cls_layer = nn.Linear(768, 1)

def forward(self, input, attn_masks):
    cont_reps, _ = self.bert_layer(encoder_hidden_states=input, encoder_attention_mask=attn_masks)
    cls_rep = cont_reps[:, 0]
    return cls_rep

But I get the below error. I appreciate it if someone could help me. Thanks!

    cont_reps, _ = self.bert_layer(encoder_hidden_states=input, encoder_attention_mask=attn_masks)
    result = self.forward(*input, **kwargs)
    TypeError: forward() got an unexpected keyword argument 'encoder_hidden_states'


问:
Java regex split on whitespace /not preceded
I would like to split  a string:"x=   2-3   y=3 z=   this,   that"
I would split this up on one or more whitespaces, that are not preceded by a '=' or a ','
meaning group one: "x=   2-3"
              two: "y=3"
              three: "z=   this,   that"
I have an expression that kinda does it but its only good if = or , has only one whitespace after it.

```<code>(?<![,=])\\s+
</code>```

答:
Thinking the other way around (looking forward instead of backwards), would the following do the job for you?

```<code>\\s+(?=\\S*=)
</code>```

\\s+ - one or more whitespace characters

(?=\\S*=) - positive lookahead to make sure it's followed by as many non-whitespace characters and a literal equal sign.

Body:
I would like to split  a string:"x=   2-3   y=3 z=   this,   that"
I would split this up on one or more whitespaces, that are not preceded by a '=' or a ','
meaning group one: "x=   2-3"
              two: "y=3"
              three: "z=   this,   that"
I have an expression that kinda does it but its only good if = or , has only one whitespace after it.

(?<![,=])\\s+

Body:
Thinking the other way around (looking forward instead of backwards), would the following do the job for you?

\\s+(?=\\S*=)

\\s+ - one or more whitespace characters

(?=\\S*=) - positive lookahead to make sure it's followed by as many non-whitespace characters and a literal equal sign.


问:
Error:expected expression before '=' token
I am getting an error as expected expression before '=' token.</p>

```<code>#define RMH_MAX_UNENCODED_LENGTH= (RMH_MESSAGE_MAX_SIZE - RMH_ENCODED_MSG_OVERHEAD); // RMH_MAX_UNENCODED_LENGTH =4064

#define RMH_MAX_ENCODED_LENGTH = (3*sizeof(RMH_MAX_UNENCODED_LENGTH) / 4);//RMH_MAX_ENCODED_LENGTH =4;

int k = RMH_MAX_UNENCODED_LENGTH; //Error:expected expression before '=' token
NSLog(@"f:%d",k);
</code>```

答:
Your syntax is wrong. Use:

```<code>#define RMH_MAX_UNENCODED_LENGTH (RMH_MESSAGE_MAX_SIZE - RMH_ENCODED_MSG_OVERHEAD)
</code>```

Note: no =, no ;, no comment after it.

defines are "simply" pure text substitutions.

Body:
I am getting an error as expected expression before '=' token.

#define RMH_MAX_UNENCODED_LENGTH= (RMH_MESSAGE_MAX_SIZE - RMH_ENCODED_MSG_OVERHEAD); // RMH_MAX_UNENCODED_LENGTH =4064

#define RMH_MAX_ENCODED_LENGTH = (3*sizeof(RMH_MAX_UNENCODED_LENGTH) / 4);//RMH_MAX_ENCODED_LENGTH =4;

int k = RMH_MAX_UNENCODED_LENGTH; //Error:expected expression before '=' token
NSLog(@"f:%d",k);

Body:
Your syntax is wrong. Use:

#define RMH_MAX_UNENCODED_LENGTH (RMH_MESSAGE_MAX_SIZE - RMH_ENCODED_MSG_OVERHEAD)

Note: no =, no ;, no comment after it.

defines are "simply" pure text substitutions.


答:
For now I managed to solve it usingeval. Code I used is given below.

```<code>import pickle

db = {'obj 1':
        {
        'a' : 1,
        'b' : 2,
        'c' : 3,
        'foo': ['0', 'a', 'a+b', '2*a', '2*(b+c)'],
        'bar': ['c', 'c+a', 'c-b', '2*c', '2*a']
        },
    'obj 2':
        {
        'a' : 4,
        'b' : 5,
        'c' : 6,
        'foo': ['0', 'a', 'a+b', '2*a', '2*(b+c)', '0', '0'],
        'bar': ['c', 'c+a', 'c-b', '2*c', '2*a', '0', '0']
        },
}

with open("db.pkl", "wb") as pkl:
    pickle.dump(db, pkl)
print(db)
with open("db.pkl", "rb") as pkl:
    db_pkl = pickle.loads(pkl.read())

a = db_pkl['obj 1']['a']
b = db_pkl['obj 1']['b']
c = db_pkl['obj 1']['c']
arr = db_pkl['obj 1']['foo']

arr_foo = []
for i in range(0, len(arr)):
    foo = eval(arr[i])
    arr_foo.append(foo)
print("\n", arr_foo)
</code>```

Output:

```<code>{'obj 1': {'a': 1, 'b': 2, 'c': 3, 'foo': ['0', 'a', 'a+b', '2*a', '2*(b+c)'], 'bar': ['c', 'c+a', 'c-b', '2*c', '2*a']}, 'obj 2': {'a': 4, 'b': 5, 'c': 6, 'foo': ['0', 'a', 'a+b', '2*a', '2*(b+c)', '0', '0'], 'bar': ['c', 'c+a', 'c-b', '2*c', '2*a', '0', '0']}}

 [0, 1, 3, 2, 10]
</code>```

It doesn't retain the variable names but rather computes it.
If anybody have a cleaner, better or alternate way to do this please feel free to edit or post answer.

Title: How to retain the type of list elements after stored in a dictionary?

Body:
For now I managed to solve it usingeval. Code I used is given below.

import pickle

db = {'obj 1':
        {
        'a' : 1,
        'b' : 2,
        'c' : 3,
        'foo': ['0', 'a', 'a+b', '2*a', '2*(b+c)'],
        'bar': ['c', 'c+a', 'c-b', '2*c', '2*a']
        },
    'obj 2':
        {
        'a' : 4,
        'b' : 5,
        'c' : 6,
        'foo': ['0', 'a', 'a+b', '2*a', '2*(b+c)', '0', '0'],
        'bar': ['c', 'c+a', 'c-b', '2*c', '2*a', '0', '0']
        },
}

with open("db.pkl", "wb") as pkl:
    pickle.dump(db, pkl)
print(db)
with open("db.pkl", "rb") as pkl:
    db_pkl = pickle.loads(pkl.read())

a = db_pkl['obj 1']['a']
b = db_pkl['obj 1']['b']
c = db_pkl['obj 1']['c']
arr = db_pkl['obj 1']['foo']

arr_foo = []
for i in range(0, len(arr)):
    foo = eval(arr[i])
    arr_foo.append(foo)
print("\n", arr_foo)

Output:

{'obj 1': {'a': 1, 'b': 2, 'c': 3, 'foo': ['0', 'a', 'a+b', '2*a', '2*(b+c)'], 'bar': ['c', 'c+a', 'c-b', '2*c', '2*a']}, 'obj 2': {'a': 4, 'b': 5, 'c': 6, 'foo': ['0', 'a', 'a+b', '2*a', '2*(b+c)', '0', '0'], 'bar': ['c', 'c+a', 'c-b', '2*c', '2*a', '0', '0']}}

 [0, 1, 3, 2, 10]

It doesn't retain the variable names but rather computes it.
If anybody have a cleaner, better or alternate way to do this please feel free to edit or post answer.


问:
Define context variables in behave python
Sometimes, you need to define values dynamically, (like datetime now, random strings, random integers, file contents, etc.) and use them across different steps without being explicit or hard-coding the value.

So, my question is how could I define variables inside of steps (the correct way to do it) to use these variables in the following steps.

Some example

```<code>Given A random string of length "100" as "my_text"
And I log in to my platform
And I ask to add the following post:
 | title                    | description |
 | Some example of title    | {{my_text}} |
When I submit the post form
Then The posts table shows these posts:
 | title                    | description |
 | Some example of title    | {{my_text}} |
And I delete any post containing in the description "{{my_text}}"
</code>```

This is a basic example trying to explain why I would like to define variables in steps and save them in the context to use it in the following steps.

My idea was to modify before_step and after_step methods... to set a variable in context to store my custom variables like this:

```<code>def before_step(context):
    if not hasattr(context, 'vars'):
       context.vars = {}

    if hasattr(context, table) and context.table:
       parse_table(context)

def parse_table(context):
    # Here use a regex to check each cell and look for `"{{<identifier>}}"` and if match, replace the cell value by context.vars[identifier] so the step "the posts table shows these posts will never know what is `{{my_text}}` it will be abstract seeing the random string.
</code>```

Scenarios Outline, use something like this defining variables like "<some_identifier>" and then for each example replace the value in the step.

It's basically to reproduce the behaviour but for any kind of step, simple or using tables.

Is it the right way to do something like this?

答:
From Behave docs on the context:

When behave launches into a new feature or scenario it adds a new layer to the context, allowing the new activity level to add new values, or overwrite ones previously defined, for the duration of that activity. These can be thought of as scopes:

```<code>@given('I request a new widget for an account via SOAP')
def step_impl(context):
    client = Client("http://127.0.0.1:8000/soap/")
    // method client.Allocate(...) returns a dict
    context.response = client.Allocate(customer_first='Firstname',
        customer_last='Lastname', colour='red')
    // context vars can be set more directly
    context.new_var = "My new variable!"

@then('I should receive an OK SOAP response')
def step_impl(context):
    eq_(context.response['ok'], 1)
    cnv = str(context.new_var)
    print (f"This is my new variable:'{cnv}'"
</code>```

So, the value can be set using dot notation and retrieved the same.

Body:
Sometimes, you need to define values dynamically, (like datetime now, random strings, random integers, file contents, etc.) and use them across different steps without being explicit or hard-coding the value.

So, my question is how could I define variables inside of steps (the correct way to do it) to use these variables in the following steps.

Some example

Given A random string of length "100" as "my_text"
And I log in to my platform
And I ask to add the following post:
 | title                    | description |
 | Some example of title    | {{my_text}} |
When I submit the post form
Then The posts table shows these posts:
 | title                    | description |
 | Some example of title    | {{my_text}} |
And I delete any post containing in the description "{{my_text}}"

This is a basic example trying to explain why I would like to define variables in steps and save them in the context to use it in the following steps.

My idea was to modify before_step and after_step methods... to set a variable in context to store my custom variables like this:

def before_step(context):
    if not hasattr(context, 'vars'):
       context.vars = {}

    if hasattr(context, table) and context.table:
       parse_table(context)

def parse_table(context):
    # Here use a regex to check each cell and look for `"{{<identifier>}}"` and if match, replace the cell value by context.vars[identifier] so the step "the posts table shows these posts will never know what is `{{my_text}}` it will be abstract seeing the random string.

Scenarios Outline, use something like this defining variables like "<some_identifier>" and then for each example replace the value in the step.

It's basically to reproduce the behaviour but for any kind of step, simple or using tables.

Is it the right way to do something like this?

Body:
From Behave docs on the context:

When behave launches into a new feature or scenario it adds a new layer to the context, allowing the new activity level to add new values, or overwrite ones previously defined, for the duration of that activity. These can be thought of as scopes:

@given('I request a new widget for an account via SOAP')
def step_impl(context):
    client = Client("http://127.0.0.1:8000/soap/")
    // method client.Allocate(...) returns a dict
    context.response = client.Allocate(customer_first='Firstname',
        customer_last='Lastname', colour='red')
    // context vars can be set more directly
    context.new_var = "My new variable!"

@then('I should receive an OK SOAP response')
def step_impl(context):
    eq_(context.response['ok'], 1)
    cnv = str(context.new_var)
    print (f"This is my new variable:'{cnv}'"

So, the value can be set using dot notation and retrieved the same.


问:
Python - Count Numbers of Different Digits in String
I'm very new to Python, please help.

I can only use if else statements, no loops or anything special like that.

This program asks the user for one string.
It counts the number of different digits in the string.  for
example a11111a1a1 contains a single digit, while a1s2d1d2d1d2d1
contains 2 digits.

Examples:

```<code>% python3 countNumbers.py
enter string: qwerty
there are no digits in string: "qwerty"

% python3 countNumbers.py
enter string: asdf1sdfg
there is one digit in string: "asdf1sdfg"

% python3 countNumbers.py
enter string: as1as2as333333
there are 3 different digits in string: "as1as2as333333"

% python3 countNumbers.py
enter string: a0123456789x
there are 10 different digits in string: "a0123456789x"
</code>```

```<code>num = input("enter string: ")
count = 0

if "0" in num:
    count = count + 1
if "1" in num:
    count = count + 1
if "2" in num:
    count = count + 1
if "3" in num:
    count = count + 1
if "4" in num:
    count = count + 1
if "5" in num:
    count = count + 1
if "6" in num:
    count = count + 1
if "7" in num:
    count = count + 1
if "8" in num:
    count = count + 1
if "9" in num:
    count = count + 1

if count >= 1:
    print("there is one digit in string: ", num)
elif count >= 2:
    print("there are two digits in string: ", num)
else:
    print("there are no digits in string: ", num)

</code>```

答:
Well if you knew loop it would have been much much easier and would have looked pythonic. However, I have modified your code here and here is the solution using 'if-else' statement and 'sets'

```<code>s = set()
if "0" in num:
    s.add(0)
if "1" in num:
    s.add(1)
if "2" in num:
    s.add(2)
if "3" in num:
    s.add(3)
if "4" in num:
    s.add(4)
if "5" in num:
    s.add(5)
if "6" in num:
    s.add(6)
if "7" in num:
    s.add(7)
if "8" in num:
    s.add(8)
if "9" in num:
    s.add(9)
print(len(s))
</code>```

Body:
I'm very new to Python, please help.

I can only use if else statements, no loops or anything special like that.

This program asks the user for one string.
It counts the number of different digits in the string.  for
example a11111a1a1 contains a single digit, while a1s2d1d2d1d2d1
contains 2 digits.

Examples:

% python3 countNumbers.py
enter string: qwerty
there are no digits in string: "qwerty"

% python3 countNumbers.py
enter string: asdf1sdfg
there is one digit in string: "asdf1sdfg"

% python3 countNumbers.py
enter string: as1as2as333333
there are 3 different digits in string: "as1as2as333333"

% python3 countNumbers.py
enter string: a0123456789x
there are 10 different digits in string: "a0123456789x"

num = input("enter string: ")
count = 0

if "0" in num:
    count = count + 1
if "1" in num:
    count = count + 1
if "2" in num:
    count = count + 1
if "3" in num:
    count = count + 1
if "4" in num:
    count = count + 1
if "5" in num:
    count = count + 1
if "6" in num:
    count = count + 1
if "7" in num:
    count = count + 1
if "8" in num:
    count = count + 1
if "9" in num:
    count = count + 1

if count >= 1:
    print("there is one digit in string: ", num)
elif count >= 2:
    print("there are two digits in string: ", num)
else:
    print("there are no digits in string: ", num)

Body:
Well if you knew loop it would have been much much easier and would have looked pythonic. However, I have modified your code here and here is the solution using 'if-else' statement and 'sets'

s = set()
if "0" in num:
    s.add(0)
if "1" in num:
    s.add(1)
if "2" in num:
    s.add(2)
if "3" in num:
    s.add(3)
if "4" in num:
    s.add(4)
if "5" in num:
    s.add(5)
if "6" in num:
    s.add(6)
if "7" in num:
    s.add(7)
if "8" in num:
    s.add(8)
if "9" in num:
    s.add(9)
print(len(s))


问:
Unable to use Intellij with a generated sources folder
Related question
How to configure IntelliJ IDEA and/or Maven to automatically add directories with Java source code generated using jaxb2-maven-plugin?

I have a custom plugin that generates sources under target/generated-sources (Note no toolname here). So I get sources like target/generated-sources/com/mycompany...etc.

This format cannot be changed at all, so will I be able to configure Intellij into adding it as a source folder. As of now, I can see that Intellij has added target/generated-sources/com as the source folder.

Please note that I do not have the option of configuring the plugin !

UPDATE 1: I do not agree with the fact that I MUST put my generated sources under a tool name folder. It may be a good convention, but if I have only one generator there is no need for me to put it there? Again, in my pom.xml I have a resources section which clearly indicates that target/generated-sources should be treated as a source folder. This works perfectly fine in Eclipse so I have no idea why Intellij would not respect my settings.

TL;DR -> When I put target/generated-sources in the resource section of pom.xml why is Intellij overzealous to add target/generated-sources/com to the classpath?

答: Solved it by removing the "Excluded" in the module setting (right click on project, "Open module settings").


问:
How to make MySQL server in XAMPP work well after a crash?
The MySQL server in XAMPP does not start well anymore.

I tried changing the port as recommended here, and the server still does not start, although it attempts to do this: a new PID is shown for a fraction of second next to MySQL in the context of the screenshot below when clicking on Start.

I also tried to run netstat -ano|find "3306" (I tried with 3307 too) but it does not show anything, the same when running it in the Command Prompt as admin. I also restarted the computer and removed the new PHP code I wrote today. Yesterday everything worked fine.

Note: the day before yesterday I had my working computer instantly turned off by mistake.

A screenshot:

The log file is here and a part of it says that it is a bug, but a bug of MariaDB which I do not use.

I am a beginner, I use MySQL just for WordPress.

Thank you.

Update 1

Running netstat -ab results in this.

Now I am checking if there are updates to XAMPP.

Update 2

It seems that there are no updates to XAMPP.

答:
First of all check your port and check if your firewall is not blocking that port, try different ports 3306, 3307, 3308.

This is your error :

```<code>2020-02-20  9:40:14 0 [Note] InnoDB: Loading buffer pool(s) from C:\xampp\mysql\data\ib_buffer_pool
2020-02-20  9:40:14 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-02-20  9:40:14 0 [Note] Server socket created on IP: '::'.
</code>```

I would re-install xampp instead of spending tons of time on trying to find error.

There are some explanition here : https://forums.mysql.com/read.php?10,652134,652135#msg-652135

Open shell from from control panel and start mysql with this command:

```<code>mysqld –-console –-skip-grant-tables –-skip-external-locking
</code>```

Open another shell from control panel and repair database with this command:

```<code>mysqlcheck -r --databases mysql --use-frm
</code>```

Stop mysql, close shells and restart mysql normally.

Also see InnoDB Corruption and Recovery https://chepri.com/mysql-innodb-corruption-and-recovery/

Body:
First of all check your port and check if your firewall is not blocking that port, try different ports 3306, 3307, 3308.

This is your error :

2020-02-20  9:40:14 0 [Note] InnoDB: Loading buffer pool(s) from C:\xampp\mysql\data\ib_buffer_pool
2020-02-20  9:40:14 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-02-20  9:40:14 0 [Note] Server socket created on IP: '::'.

I would re-install xampp instead of spending tons of time on trying to find error.

There are some explanition here : https://forums.mysql.com/read.php?10,652134,652135#msg-652135

Open shell from from control panel and start mysql with this command:

mysqld –-console –-skip-grant-tables –-skip-external-locking

Open another shell from control panel and repair database with this command:

mysqlcheck -r --databases mysql --use-frm

Stop mysql, close shells and restart mysql normally.

Also see InnoDB Corruption and Recovery https://chepri.com/mysql-innodb-corruption-and-recovery/


问:
How to override WordPress Plugin class method
I have a plugin which class is something like that:

```<code><?php

namespace myPro\EventCalendarPro;

use WP_Widget;

/**
 * Adds ECP_Widget widget.
 */

class ECP_Widget extends WP_Widget {

    public function widget () {

    }
}

?>
</code>```

Now, how can I override the widget method from my theme functions.php file?

答:
The simple answer to this question is "You cannot do this".

Because in PHP you cannot redefine classes, methods, and functions. But you can use PHP Runkit extension to redefine your methods

Runkit function to redefine method is runkit_method_redefine

Code Example

<?php
class Example {
    function foo() {
        return "foo!\n";
    }
}

// create an Example object
$e = new Example();

// output Example::foo() (before redefine)
echo "Before: " . $e->foo();

// Redefine the 'foo' method
runkit_method_redefine(
    'Example',
    'foo',
    '',
    'return "bar!\n";',
    RUNKIT_ACC_PUBLIC
);

// output Example::foo() (after redefine)
echo "After: " . $e->foo();
?>
```

But for first you should install the php-runkit extension on your server.

How to install Runkit

Body:
I have a plugin which class is something like that:

<?php

namespace myPro\EventCalendarPro;

use WP_Widget;

/**
 * Adds ECP_Widget widget.
 */

class ECP_Widget extends WP_Widget {

    public function widget () {

    }
}

?>

Now, how can I override the widget method from my theme functions.php file?

Body:
The simple answer to this question is "You cannot do this".

Because in PHP you cannot redefine classes, methods, and functions. But you can use PHP Runkit extension to redefine your methods

Runkit function to redefine method is runkit_method_redefine

Code Example

<?php
class Example {
    function foo() {
        return "foo!\n";
    }
}

// create an Example object
$e = new Example();

// output Example::foo() (before redefine)
echo "Before: " . $e->foo();

// Redefine the 'foo' method
runkit_method_redefine(
    'Example',
    'foo',
    '',
    'return "bar!\n";',
    RUNKIT_ACC_PUBLIC
);

// output Example::foo() (after redefine)
echo "After: " . $e->foo();
?>

But for first you should install the php-runkit extension on your server.

How to install Runkit