问:
ClassCastException with CoordinatorLayout in AndroidX project
My project uses AndroidX, and has a CoordinatorLayout, AppbarLayout... I have the dependencies listed in the gradle file but the layout editor is throwing error and keeps saying classes couldn't be found. This causing a render problem but the project compiles and the app is working well.

Gradle (app):

```<code>    dependencies {
//...
//...
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.android.material:material:1.1.0-alpha06'
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
    implementation 'com.google.android.material:material:1.1.0-alpha06'
    implementation 'androidx.core:core:1.2.0-alpha01'
    implementation 'androidx.media:media:1.1.0-beta01'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.1.0-alpha06'
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0-alpha01'
    implementation group: 'androidx.coordinatorlayout', name: 'coordinatorlayout', version: '1.0.0'
}
</code>```

XML layout file:

```<code>    <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl_parent_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorBackgroundGrey"
        ads:layout_constraintEnd_toEndOf="parent"
        ads:layout_constraintStart_toStartOf="parent"
        ads:layout_constraintTop_toTopOf="parent">

        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBarlayout"
            android:layout_width="match_parent"
            android:layout_height="280dp"
            android:fitsSystemWindows="true"
            android:theme="@style/ThemeOverlay.AppCompat.ActionBar">

            <com.google.android.material.appbar.CollapsingToolbarLayout
                android:id="@+id/collapsingToolbarLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true"
                ads:contentScrim="?attr/colorPrimary"
                ads:layout_scrollFlags="scroll|exitUntilCollapsed">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    ads:layout_collapseMode="parallax">

                    <com.balysv.materialripple.MaterialRippleLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        ads:mrl_rippleAlpha="0.2"
                        ads:mrl_rippleColor="@color/colorRipple"
                        ads:mrl_rippleHover="true"
                        ads:mrl_rippleOverlay="true">

                        <ImageView
                            android:id="@+id/imv_image"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:contentDescription="@string/text_image_view_descrip"
                            android:scaleType="centerCrop"
                            ads:layout_collapseMode="none"
                            ads:srcCompat="@drawable/ic_launcher_foreground" />

                    </com.balysv.materialripple.MaterialRippleLayout>

                </RelativeLayout>

                <androidx.appcompat.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="@color/demo_dark_transparent"
                    ads:layout_collapseMode="pin"
                    ads:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

            </com.google.android.material.appbar.CollapsingToolbarLayout>

        </com.google.android.material.appbar.AppBarLayout>

        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:foreground="?android:attr/selectableItemBackground"
            ads:behavior_overlapTop="64dp"
            ads:cardCornerRadius="3dp"
            ads:cardElevation="3sp"
            ads:cardPreventCornerOverlap="false"
            ads:cardUseCompatPadding="true"
            app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">

            <androidx.core.widget.NestedScrollView
                android:id="@+id/nestedScrollView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clipToPadding="false">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <include
                        android:id="@+id/lyt_main_content"
                        layout="@layout/include_news_content"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentStart="true"
                        android:layout_alignParentTop="true"
                        android:visibility="visible" />

                    <ViewFlipper
                        android:id="@+id/view_flipper2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:background="#F44336">

                    </ViewFlipper>

                </RelativeLayout>

            </androidx.core.widget.NestedScrollView>

        </androidx.cardview.widget.CardView>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>

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

Tried almost everything I could without success.

EDIT:

Java class (import):

```<code>import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import androidx.core.widget.NestedScrollView;
</code>```

答:
add the following lines in gradle.properties

```<code># Enable configure on demand.
org.gradle.configureondemand=true
android.useAndroidX=true
android.enableJetifier=true
</code>```

Make sure the following dependencies are listed correctly

```<code>dependencies {
  implementation fileTree(include: ['*.jar'], dir: 'libs')
  implementation 'androidx.appcompat:appcompat:1.0.2'
  implementation 'com.google.android.material:material:1.1.0-alpha06'
  implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
  implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
</code>```

The Clean Project and Rebuild Project.
If the problem still persists try Invalidate Caches/Restart

Body:
My project uses AndroidX, and has a CoordinatorLayout, AppbarLayout... I have the dependencies listed in the gradle file but the layout editor is throwing error and keeps saying classes couldn't be found. This causing a render problem but the project compiles and the app is working well.

Gradle (app):

    dependencies {
//...
//...
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.android.material:material:1.1.0-alpha06'
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
    implementation 'com.google.android.material:material:1.1.0-alpha06'
    implementation 'androidx.core:core:1.2.0-alpha01'
    implementation 'androidx.media:media:1.1.0-beta01'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.1.0-alpha06'
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0-alpha01'
    implementation group: 'androidx.coordinatorlayout', name: 'coordinatorlayout', version: '1.0.0'
}

XML layout file:

    <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl_parent_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorBackgroundGrey"
        ads:layout_constraintEnd_toEndOf="parent"
        ads:layout_constraintStart_toStartOf="parent"
        ads:layout_constraintTop_toTopOf="parent">

        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBarlayout"
            android:layout_width="match_parent"
            android:layout_height="280dp"
            android:fitsSystemWindows="true"
            android:theme="@style/ThemeOverlay.AppCompat.ActionBar">

            <com.google.android.material.appbar.CollapsingToolbarLayout
                android:id="@+id/collapsingToolbarLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true"
                ads:contentScrim="?attr/colorPrimary"
                ads:layout_scrollFlags="scroll|exitUntilCollapsed">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    ads:layout_collapseMode="parallax">

                    <com.balysv.materialripple.MaterialRippleLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        ads:mrl_rippleAlpha="0.2"
                        ads:mrl_rippleColor="@color/colorRipple"
                        ads:mrl_rippleHover="true"
                        ads:mrl_rippleOverlay="true">

                        <ImageView
                            android:id="@+id/imv_image"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:contentDescription="@string/text_image_view_descrip"
                            android:scaleType="centerCrop"
                            ads:layout_collapseMode="none"
                            ads:srcCompat="@drawable/ic_launcher_foreground" />

                    </com.balysv.materialripple.MaterialRippleLayout>

                </RelativeLayout>

                <androidx.appcompat.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="@color/demo_dark_transparent"
                    ads:layout_collapseMode="pin"
                    ads:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

            </com.google.android.material.appbar.CollapsingToolbarLayout>

        </com.google.android.material.appbar.AppBarLayout>

        <androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:foreground="?android:attr/selectableItemBackground"
            ads:behavior_overlapTop="64dp"
            ads:cardCornerRadius="3dp"
            ads:cardElevation="3sp"
            ads:cardPreventCornerOverlap="false"
            ads:cardUseCompatPadding="true"
            app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">

            <androidx.core.widget.NestedScrollView
                android:id="@+id/nestedScrollView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clipToPadding="false">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <include
                        android:id="@+id/lyt_main_content"
                        layout="@layout/include_news_content"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentStart="true"
                        android:layout_alignParentTop="true"
                        android:visibility="visible" />

                    <ViewFlipper
                        android:id="@+id/view_flipper2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:background="#F44336">

                    </ViewFlipper>

                </RelativeLayout>

            </androidx.core.widget.NestedScrollView>

        </androidx.cardview.widget.CardView>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

Tried almost everything I could without success.

EDIT:

Java class (import):

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewFlipper;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import androidx.core.widget.NestedScrollView;

Body:
add the following lines in gradle.properties

# Enable configure on demand.
org.gradle.configureondemand=true
android.useAndroidX=true
android.enableJetifier=true

Make sure the following dependencies are listed correctly

dependencies {
  implementation fileTree(include: ['*.jar'], dir: 'libs')
  implementation 'androidx.appcompat:appcompat:1.0.2'
  implementation 'com.google.android.material:material:1.1.0-alpha06'
  implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
  implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}

The Clean Project and Rebuild Project.
If the problem still persists try Invalidate Caches/Restart


来源: stackexchange

问:
javascript search array of arrays
Let's say we have the following js array

```<code>var ar = [
   [2,6,89,45],
   [3,566,23,79],
   [434,677,9,23]
];

var val = [3,566,23,79];
</code>```

Is there a js builtin function or jQuery one with which you can search the array ar for val?

Thanks

***UPDATE*************

Taking fusion's response I created this prototype

```<code>Array.prototype.containsArray = function(val) {
    var hash = {};
    for(var i=0; i<this.length; i++) {
        hash[this[i]] = i;
    }
    return hash.hasOwnProperty(val);
}
</code>```

答:
You can use toString convertion to compare elements</p>

```<code>var ar = [
   [2,6,89,45],
   [3,566,23,79],
   [434,677,9,23]
];

var val = [3,566,23,79];

s = !ar.every(a => (a.toString() != val.toString()));
console.log(s) // true
</code>```

ContentLicense: CC BY-SA 3.0

Title: javascript search array of arrays

Body:
Let's say we have the following js array

var ar = [
   [2,6,89,45],
   [3,566,23,79],
   [434,677,9,23]
];

var val = [3,566,23,79];

Is there a js builtin function or jQuery one with which you can search the array ar for val?

Thanks

***UPDATE*************

Taking fusion's response I created this prototype

Array.prototype.containsArray = function(val) {
    var hash = {};
    for(var i=0; i<this.length; i++) {
        hash[this[i]] = i;
    }
    return hash.hasOwnProperty(val);
}

Body:
You can use toString convertion to compare elements

var ar = [
   [2,6,89,45],
   [3,566,23,79],
   [434,677,9,23]
];

var val = [3,566,23,79];

s = !ar.every(a => (a.toString() != val.toString()));
console.log(s) // true

ContentLicense: CC BY-SA 4.0


问:
Problem with NSMutableAttributedString with link attribute
I run this code in Swift 5, iOS 12.1:

```
let linkText = NSMutableAttributedString(string: "this is link", attributes: [.link: NSString(string: "http://example.com")])
textView.attributedText = linkText
textView.linkTextAttributes = [.foregroundColor: UIColor.blue, .underlineColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single]
```

I get error:

```[__SwiftValue integerValue]: unrecognized selector sent to instance 0x600002ba3b10
```

I don't know what is wrong.

答:
Use this NSUnderlineStyle.single.rawValue

instead of NSUnderlineStyle.single

```<code>textView?.linkTextAttributes = [.foregroundColor: UIColor.blue, .underlineColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single.rawValue]
</code>```

Body:
I run this code in Swift 5, iOS 12.1:

let linkText = NSMutableAttributedString(string: "this is link", attributes: [.link: NSString(string: "http://example.com")])
textView.attributedText = linkText
textView.linkTextAttributes = [.foregroundColor: UIColor.blue, .underlineColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single]

I get error:

[__SwiftValue integerValue]: unrecognized selector sent to instance 0x600002ba3b10

I don't know what is wrong.

Body:
Use this NSUnderlineStyle.single.rawValue

instead of NSUnderlineStyle.single

textView?.linkTextAttributes = [.foregroundColor: UIColor.blue, .underlineColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single.rawValue]


问:
Assigning values in a predicate
Is there a way to assing 2 times a different value in a variable inside a predicate?For example can we somehow make

```<code>X is 10,
X is 3.
</code>```

produce true?

答:
Please don't do it like this. is/2 is for evaluating arithmetic expressions.

Without any context whatsoever it is <s>difficult</s> impossible to suggest what is the right way to do it. The traditional way is to have a predicate that looks like this:

```<code>ten_or_three(10).
ten_or_three(3).
</code>```

You can do all kinds of Prolog-y things with a predicate like that.

```<code>?- ten_or_three(10).
true.

?- ten_or_three(4).
false.

?- length(L, 3), maplist(ten_or_three, L), sumlist(L, Sum).
L = [10, 10, 10],
Sum = 30 ;
L = [10, 10, 3],
Sum = 23 ;
L = [10, 3, 10],
Sum = 23 ;
L = [10, 3, 3],
Sum = 16 ;
L = [3, 10, 10],
Sum = 23 ;
L = [3, 10, 3],
Sum = 16 ;
L = [3, 3, 10],
Sum = 16 ;
L = [3, 3, 3],
Sum = 9.
</code>```

Title: Assigning values in a predicate

Body:
Is there a way to assing 2 times a different value in a variable inside a predicate?For example can we somehow make

X is 10,
X is 3.

produce true?

Body:
Please don't do it like this. is/2 is for evaluating arithmetic expressions.

Without any context whatsoever it is <s>difficult</s> impossible to suggest what is the right way to do it. The traditional way is to have a predicate that looks like this:

ten_or_three(10).
ten_or_three(3).

You can do all kinds of Prolog-y things with a predicate like that.

?- ten_or_three(10).
true.

?- ten_or_three(4).
false.

?- length(L, 3), maplist(ten_or_three, L), sumlist(L, Sum).
L = [10, 10, 10],
Sum = 30 ;
L = [10, 10, 3],
Sum = 23 ;
L = [10, 3, 10],
Sum = 23 ;
L = [10, 3, 3],
Sum = 16 ;
L = [3, 10, 10],
Sum = 23 ;
L = [3, 10, 3],
Sum = 16 ;
L = [3, 3, 10],
Sum = 16 ;
L = [3, 3, 3],
Sum = 9.


问:
How to Transfer Token via Contact Address
My Solidity Code transfer ETH is working, But ERC20 Token Not Transfer.

pragma solidity ^0.5.1;

contract Token {
  function transfer(address to, uint256 value) public returns (bool success);
  function approve(address _spender, uint256 _value) public returns (bool success);
  function transferFrom(address from, address to, uint256 value) public returns (bool success);
}

contract General {

```<code> mapping(uint256 => address) public userOf;

address admin;

event SetTokenInfoEvent(uint16 tokenCode, string symbol, address tokenAddr, uint256 totaltokens);

constructor() public{
admin = 0xc8e3b905E7d462BD6368240BEC9C482b215D4147;
}

function deposit() public payable {
    require(msg.value > 0);
}

 function withdraw(uint256 amount,uint256 _cusid) public {
    require(userOf[_cusid]==msg.sender);
    require(amount > 0);
    msg.sender.transfer(amount);
}

function storecustomer(address user,uint256 _cusid) public returns(bool)
{
   require(admin == msg.sender);
  userOf[_cusid]=user;
   return true;
}

function tokenDeposit(address tokenaddr,uint256 tokenAmount) public payable
{
     Token(tokenaddr).transferFrom(msg.sender,address(this), tokenAmount);
}

//token withdraw

function tokenWithdraw(uint256 _cusid,uint16 tokenAddr,address withdrawAddr, uint256 tokenAmount) public payable
{
     require(userOf[_cusid]==msg.sender);
     Token(tokenAddr).transfer(withdrawAddr, tokenAmount);

}
</code>```

}

答:
In tokenwithdraw function you used uint for tokenaddr that is wrong change uint to address </p>

```<code>function tokenWithdraw(uint256 _cusid,address tokenAddr,address withdrawAddr, uint256 tokenAmount) public payable
 {
 require(userOf[_cusid]==msg.sender);
 Token(tokenAddr).transfer(withdrawAddr, tokenAmount);

}
</code>```

Body:
My Solidity Code transfer ETH is working, But ERC20 Token Not Transfer.

pragma solidity ^0.5.1;

contract Token {
  function transfer(address to, uint256 value) public returns (bool success);
  function approve(address _spender, uint256 _value) public returns (bool success);
  function transferFrom(address from, address to, uint256 value) public returns (bool success);
}

contract General {

 mapping(uint256 => address) public userOf;

address admin;

event SetTokenInfoEvent(uint16 tokenCode, string symbol, address tokenAddr, uint256 totaltokens);

constructor() public{
admin = 0xc8e3b905E7d462BD6368240BEC9C482b215D4147;
}

function deposit() public payable {
    require(msg.value > 0);
}

 function withdraw(uint256 amount,uint256 _cusid) public {
    require(userOf[_cusid]==msg.sender);
    require(amount > 0);
    msg.sender.transfer(amount);
}

function storecustomer(address user,uint256 _cusid) public returns(bool)
{
   require(admin == msg.sender);
  userOf[_cusid]=user;
   return true;
}

function tokenDeposit(address tokenaddr,uint256 tokenAmount) public payable
{
     Token(tokenaddr).transferFrom(msg.sender,address(this), tokenAmount);
}

//token withdraw

function tokenWithdraw(uint256 _cusid,uint16 tokenAddr,address withdrawAddr, uint256 tokenAmount) public payable
{
     require(userOf[_cusid]==msg.sender);
     Token(tokenAddr).transfer(withdrawAddr, tokenAmount);

}

}

Body:
In tokenwithdraw function you used uint for tokenaddr that is wrong change uint to address

function tokenWithdraw(uint256 _cusid,address tokenAddr,address withdrawAddr, uint256 tokenAmount) public payable
 {
 require(userOf[_cusid]==msg.sender);
 Token(tokenAddr).transfer(withdrawAddr, tokenAmount);

}


问:
VBA Debug - Run-time 1004: R1C1 Formula Not Calculating
I'm trying to write some VBA scripting that embodies an Excel formula, but keep getting an error and can't seem to find a solution anywhere.

I think that what might be causing the problem is that I have an R1C1 formula that includes a +1. I can't tell for sure, but it seems possible that it could be construed as bad syntax. Perhaps making it think I'm referring to the current column + 1 column. Total stretch though.

```<code>Range("A4").Select
ActiveCell.FormulaR1C1 = _
    "=IF(R[-1]C+1>R2C15,"",R[-1]C+1)"
</code>```

The end result should be that if the previous row's value +1 is greater than the value in R2C15 (O2), it will produce a blank, otherwise the previous row's value +1. However, I keep getting the 1004 error.

Any thoughts?

答:
You haven't escaped your quotation marks.

If you are new to VBA it takes some getting used to but you need to use

```<code>Range("A4").Select
ActiveCell.FormulaR1C1 = _
    "=IF(R[-1]C+1>R2C15,"""",R[-1]C+1)"
</code>```

Body:
I'm trying to write some VBA scripting that embodies an Excel formula, but keep getting an error and can't seem to find a solution anywhere.

I think that what might be causing the problem is that I have an R1C1 formula that includes a +1. I can't tell for sure, but it seems possible that it could be construed as bad syntax. Perhaps making it think I'm referring to the current column + 1 column. Total stretch though.

Range("A4").Select
ActiveCell.FormulaR1C1 = _
    "=IF(R[-1]C+1>R2C15,"",R[-1]C+1)"

The end result should be that if the previous row's value +1 is greater than the value in R2C15 (O2), it will produce a blank, otherwise the previous row's value +1. However, I keep getting the 1004 error.

Any thoughts?

Body:
You haven't escaped your quotation marks.

If you are new to VBA it takes some getting used to but you need to use

Range("A4").Select
ActiveCell.FormulaR1C1 = _
    "=IF(R[-1]C+1>R2C15,"""",R[-1]C+1)"


问:
MSI creates invalid registry entry names when run in the Windows docker container
I have the old MSI package which during installation creates some of registry entries.

The root of the registry entries is named TEST·ING (please notice the dot, which is CHR(183)).

The setup creates these entries either via regular MSI Registry table or VBS custom action.

The ones created via VBS custom action ends up named like 'TEST�ING'.

It works fine when the installation is made on regular machine.

Looks like not a Docker problem but rather something related to language settings but the default language for non-Unicode programs is set to the English.

答: Replacing Chr(183) with ChrW(183) in VBScript code did the job.</p>


问:
why list is not work properly in this code?
My Code:

```<code>b=list(input("entr"))

print(b)
for a in b :

    if a>5:
        print(a)
</code>```

I got this error :

TypeError: '>' not supported between instances of 'str' and 'int'

答:
Try this,

```<code>b=list(map(int,input("Enter: ").split()))
</code>```

It will take int as inputs and convert into list.

Ex:

```<code>>>> b=list(map(int,input("Enter").split()))
Enter: 3 4 5 6 7
>>> for a in b :
        if a>5:
            print(a)
6
7
</code>```

Body:
My Code:

b=list(input("entr"))

print(b)
for a in b :

    if a>5:
        print(a)

I got this error :

TypeError: '>' not supported between instances of 'str' and 'int'

Body:
Try this,

b=list(map(int,input("Enter: ").split()))

It will take int as inputs and convert into list.

Ex:

>>> b=list(map(int,input("Enter").split()))
Enter: 3 4 5 6 7
>>> for a in b :
        if a>5:
            print(a)
6
7


问:
Encountering _jspService is exceeding the 65535 bytes limit issue in JBOSS EAP7
I was encountering JBWEB004061: An error occurred at line: 129 in the generated java file
The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit.

I have tried several solution around the web and issue still persists.

I am using JBOSS EAP 7 as the server.
Included apache tomcat in the runtime of the project

Note: I am migrating servers from Websphere to JBOSS. No problem in Websphere at all.

Any light and output would be appreciated.

Here are the stacktrace of the error:

```<code>2019-05-30 12:10:12,893 ERROR [io.undertow.request] (default task-25) UT005023: Exception handling request to /%Path%/template.jsp: org.apache.jasper.JasperException: JBWEB004062: Unable to compile class for JSP:

JBWEB004061: An error occurred at line: 129 in the generated java file
The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit

Stacktrace:
        at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:95)
        at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:198)
        at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:449)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:359)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:652)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:402)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:346)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        at io.undertow.jsp.JspFileHandler.handleRequest(JspFileHandler.java:32)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:266)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToServlet(ServletInitialHandler.java:211)
        at io.undertow.servlet.spec.RequestDispatcherImpl.includeImpl(RequestDispatcherImpl.java:352)
        at io.undertow.servlet.spec.RequestDispatcherImpl.include(RequestDispatcherImpl.java:265)
        at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:907)
        at org.apache.jsp.jsp.common.template_jsp._jspx_meth_c_005fwhen_005f4(template_jsp.java:882)
        at org.apache.jsp.jsp.common.template_jsp._jspx_meth_c_005fchoose_005f3(template_jsp.java:838)
        at org.apache.jsp.jsp.common.template_jsp._jspx_meth_c_005fotherwise_005f2(template_jsp.java:806)
        at org.apache.jsp.jsp.common.template_jsp._jspx_meth_c_005fchoose_005f2(template_jsp.java:741)
        at org.apache.jsp.jsp.common.template_jsp._jspService(template_jsp.java:198)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:402)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:346)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        at io.undertow.jsp.JspFileHandler.handleRequest(JspFileHandler.java:32)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:266)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToPath(ServletInitialHandler.java:201)
        at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImpl(RequestDispatcherImpl.java:202)
        at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:109)
        at ph.com.common.servlet.CommonServlet.performTask(CommonServlet.java:364)
        at ph.com.common.servlet.CommonServlet.doPost(CommonServlet.java:78)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:285)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:264)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:175)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:792)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

</code>```

答:
Already solved it by adding:

```<code>   <jsp-config generate-strings-as-char-arrays="true" mapped-file="false" tag-pooling="false" trim-spaces="true"/>
</code>```

in %JBoss_path%/domain/configuration/domain.xml

my fault is I just added the same code in the standalone.xml

Thanks all!

Body:
I was encountering JBWEB004061: An error occurred at line: 129 in the generated java file
The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit.

I have tried several solution around the web and issue still persists.

I am using JBOSS EAP 7 as the server.
Included apache tomcat in the runtime of the project

Note: I am migrating servers from Websphere to JBOSS. No problem in Websphere at all.

Any light and output would be appreciated.

Here are the stacktrace of the error:

2019-05-30 12:10:12,893 ERROR [io.undertow.request] (default task-25) UT005023: Exception handling request to /%Path%/template.jsp: org.apache.jasper.JasperException: JBWEB004062: Unable to compile class for JSP:

JBWEB004061: An error occurred at line: 129 in the generated java file
The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit

Stacktrace:
        at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:95)
        at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:198)
        at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:449)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:359)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:652)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:402)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:346)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        at io.undertow.jsp.JspFileHandler.handleRequest(JspFileHandler.java:32)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:266)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToServlet(ServletInitialHandler.java:211)
        at io.undertow.servlet.spec.RequestDispatcherImpl.includeImpl(RequestDispatcherImpl.java:352)
        at io.undertow.servlet.spec.RequestDispatcherImpl.include(RequestDispatcherImpl.java:265)
        at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:907)
        at org.apache.jsp.jsp.common.template_jsp._jspx_meth_c_005fwhen_005f4(template_jsp.java:882)
        at org.apache.jsp.jsp.common.template_jsp._jspx_meth_c_005fchoose_005f3(template_jsp.java:838)
        at org.apache.jsp.jsp.common.template_jsp._jspx_meth_c_005fotherwise_005f2(template_jsp.java:806)
        at org.apache.jsp.jsp.common.template_jsp._jspx_meth_c_005fchoose_005f2(template_jsp.java:741)
        at org.apache.jsp.jsp.common.template_jsp._jspService(template_jsp.java:198)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:402)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:346)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        at io.undertow.jsp.JspFileHandler.handleRequest(JspFileHandler.java:32)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:266)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToPath(ServletInitialHandler.java:201)
        at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImpl(RequestDispatcherImpl.java:202)
        at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:109)
        at ph.com.common.servlet.CommonServlet.performTask(CommonServlet.java:364)
        at ph.com.common.servlet.CommonServlet.doPost(CommonServlet.java:78)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:285)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:264)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:175)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:792)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

Body:
Already solved it by adding:

   <jsp-config generate-strings-as-char-arrays="true" mapped-file="false" tag-pooling="false" trim-spaces="true"/>

in %JBoss_path%/domain/configuration/domain.xml

my fault is I just added the same code in the standalone.xml

Thanks all!


问:
How to save a queryset?
I would like to know how I can save my queryset in the database:

```<code>def data_min(self):
        qs1 = Csr.objects.values_list('value_base')
        qs2 = Modelb.objects.filter(Q(limit_a__gte=qs1) & (Q(limit_b__lte=qs1))).distinct().values_list('limit_b')
        qs3 = qs2[0]
        return qs3
</code>```

This function returns me:

```<code><QuerySet [(Decimal('133.22'),)]>
</code>```

Now my question is how I keep it in my Model in the field "bdata_superior":

```<code>class Csr(models.Model):
tarifa_cobro = models.ForeignKey(Tarifa_Sem, on_delete=models.CASCADE, null=True, blank=True)
value_base = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)
bdata_superior = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)
data_inferior = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)

class Modelb(models.Model):
    limit_a = models.DecimalField(max_digits=10, decimal_places=2)
    limit_b = models.DecimalField(max_digits=10, decimal_places=2)
</code>```

The problem is that when I save it, I get the following error:

```<code>conversion from method to Decimal is not supported

def save(self, *args, **kwargs):
        self.bdata_superior = self.data_min
        super (Crs, self).save(*args, **kwargs)
</code>```

答:
call the data_min function and then save, the return value to self.bdata_superior, you're presently assigning the function to self.bdata_superior

```<code>def save(self, *args, **kwargs):
        self.bdata_superior = self.data_min()
        super (Crs, self).save(*args, **kwargs)
</code>```

Title: How to save a queryset?

Body:
I would like to know how I can save my queryset in the database:

def data_min(self):
        qs1 = Csr.objects.values_list('value_base')
        qs2 = Modelb.objects.filter(Q(limit_a__gte=qs1) & (Q(limit_b__lte=qs1))).distinct().values_list('limit_b')
        qs3 = qs2[0]
        return qs3

This function returns me:

<QuerySet [(Decimal('133.22'),)]>

Now my question is how I keep it in my Model in the field "bdata_superior":

class Csr(models.Model):
tarifa_cobro = models.ForeignKey(Tarifa_Sem, on_delete=models.CASCADE, null=True, blank=True)
value_base = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)
bdata_superior = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)
data_inferior = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)

class Modelb(models.Model):
    limit_a = models.DecimalField(max_digits=10, decimal_places=2)
    limit_b = models.DecimalField(max_digits=10, decimal_places=2)

The problem is that when I save it, I get the following error:

conversion from method to Decimal is not supported

def save(self, *args, **kwargs):
        self.bdata_superior = self.data_min
        super (Crs, self).save(*args, **kwargs)

Body:
call the data_min function and then save, the return value to self.bdata_superior, you're presently assigning the function to self.bdata_superior

def save(self, *args, **kwargs):
        self.bdata_superior = self.data_min()
        super (Crs, self).save(*args, **kwargs)


问:
What can cause an error in InitializeComponent method?
I have an app, which can execute another app by the path to *.exe file. Both work well on my computer, but on the other one I get an error:
"Setting property System.Windows.Controls.ContentControl.Content has thrown an exception at string 33, position 6."

I've tried to track it, so I exactly know, that it happens in InitializeComponent method of the second app. Then I catched the error from this method and the message was: "
An exception was thrown when calling a constructor of the type 'UPR.FeedBack.App.MainWindow' that matches the specified binding constraints (string 9, position 23)" But I can't even imagine, why does it happen.

Also I thought, that the problem is in missing some *.dll files on the second machine, but I have set all the references of the project to be copied locally.

And I've tried to execute it without assigning Datacontext and configuring window, it didn't solve this.

Executing the process:

```<code>        process = new Process
        {
            StartInfo =
            {
                FileName = fileName,
                Verb = "Open",
                WindowStyle = ProcessWindowStyle.Normal,
                Arguments = string.Join(" ", userName),
                WorkingDirectory = processPath
            }
        };

        process.Start();
</code>```

MAINWINDOW.xaml.cs(second app):

```<code>namespace UPR.FeedBack.App
{
    /// <summary>
    /// Логика взаимодействия для MainWindow.xaml
    /// </summary>
    public partial class MainWindow : MetroWindow
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = Bootstrapper.Container.Resolve<MainViewModel>();
            ConfigureWindow();
        }
     }
}
</code>```

MAINWINDOW.xaml(second app):

```<code><Controls:MetroWindow xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls" x:Class="UPR.FeedBack.App.MainWindow"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                  xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
                  xmlns:local="clr-namespace:InfrastructureLight.Common.Helpers;assembly=InfrastructureLight.Common"
                  mc:Ignorable="d"
                  xmlns:vm="clr-namespace:UPR.FeedBack.App"
                  Title="Title"
                  d:DataContext="{d:DesignInstance vm:MainWindow}">
</code>```

So as I see, the error is in ' xmlns:vm="clr-namespace:UPR.FeedBack.App" '. But the namespace is right. And again: the apps work on my computer without any errors, but on others I get such problems.

答:
Could you provide detailed sub inner exception ?

Also could look this post it might be useful in your case.

"The invocation of the constructor on type 'TestWPF.MainWindow' that matches the specified binding constraints threw an exception."- how to fix this?

Body:
I have an app, which can execute another app by the path to *.exe file. Both work well on my computer, but on the other one I get an error:
"Setting property System.Windows.Controls.ContentControl.Content has thrown an exception at string 33, position 6."

I've tried to track it, so I exactly know, that it happens in InitializeComponent method of the second app. Then I catched the error from this method and the message was: "
An exception was thrown when calling a constructor of the type 'UPR.FeedBack.App.MainWindow' that matches the specified binding constraints (string 9, position 23)" But I can't even imagine, why does it happen.

Also I thought, that the problem is in missing some *.dll files on the second machine, but I have set all the references of the project to be copied locally.

And I've tried to execute it without assigning Datacontext and configuring window, it didn't solve this.

Executing the process:

        process = new Process
        {
            StartInfo =
            {
                FileName = fileName,
                Verb = "Open",
                WindowStyle = ProcessWindowStyle.Normal,
                Arguments = string.Join(" ", userName),
                WorkingDirectory = processPath
            }
        };

        process.Start();

MAINWINDOW.xaml.cs(second app):

namespace UPR.FeedBack.App
{
    ///
    /// Логика взаимодействия для MainWindow.xaml
    ///
    public partial class MainWindow : MetroWindow
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = Bootstrapper.Container.Resolve<MainViewModel>();
            ConfigureWindow();
        }
     }
}

MAINWINDOW.xaml(second app):

<Controls:MetroWindow xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls" x:Class="UPR.FeedBack.App.MainWindow"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                  xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
                  xmlns:local="clr-namespace:InfrastructureLight.Common.Helpers;assembly=InfrastructureLight.Common"
                  mc:Ignorable="d"
                  xmlns:vm="clr-namespace:UPR.FeedBack.App"
                  Title="Title"
                  d:DataContext="{d:DesignInstance vm:MainWindow}">

So as I see, the error is in ' xmlns:vm="clr-namespace:UPR.FeedBack.App" '. But the namespace is right. And again: the apps work on my computer without any errors, but on others I get such problems.


问:
Receive any Keyboard input and use with Switch statement on Unity
I don't want to use if statement. For simplicity and performance I want to use switch case and execute that method. I want all the keyboard Input to get detected. But is there any method that will pass any key press information?
My current approach is :

```<code>// Update is called once per frame
void Update()
{
    char a = Input.GetKey();//anything like this method?
    switch (a)
    {
        case 'a':
                //print'';
                break;
        case 'b':
                //print'';
                break;
        default:
            break;
    }

}
</code>```

How can I achieve this any key press information detection without if statement?

答:
```<code>foreach(KeyCode kcode in Enum.GetValues(typeof(KeyCode)))
{
    if (Input.GetKey(kcode))
    Debug.Log("KeyCode down: " + kcode);
}
</code>```

Also you can cache the value of Enum.GetValues(typeof(KeyCode)) for optimization.

Body:
I don't want to use if statement. For simplicity and performance I want to use switch case and execute that method. I want all the keyboard Input to get detected. But is there any method that will pass any key press information?
My current approach is :

// Update is called once per frame
void Update()
{
    char a = Input.GetKey();//anything like this method?
    switch (a)
    {
        case 'a':
                //print'';
                break;
        case 'b':
                //print'';
                break;
        default:
            break;
    }

}

How can I achieve this any key press information detection without if statement?

Body:
foreach(KeyCode kcode in Enum.GetValues(typeof(KeyCode)))
{
    if (Input.GetKey(kcode))
    Debug.Log("KeyCode down: " + kcode);
}

Also you can cache the value of Enum.GetValues(typeof(KeyCode)) for optimization.


问:
PHP: exceptions vs errors?
Maybe I'm missing it somewhere in the PHP manual, but what exactly is the difference between an error and an exception?  The only difference that I can see is that errors and exceptions are handled differently.  But what causes an exception and what causes an error?</p>

答:
From PHP: Exceptions - Manual:

As of PHP 7.1.0, a catch block may specify multiple exceptions using the pipe (|) character. This is useful for when different exceptions from different class hierarchies are handled the same.

```<code>try {
  // do something
} catch (Error | Exception $e) {
  echo $e->getMessage();
}
</code>```

ContentLicense: CC BY-SA 2.5

Title: PHP: exceptions vs errors?

Body:
From PHP: Exceptions - Manual:

As of PHP 7.1.0, a catch block may specify multiple exceptions using the pipe (|) character. This is useful for when different exceptions from different class hierarchies are handled the same.

try {
  // do something
} catch (Error | Exception $e) {
  echo $e->getMessage();
}


问:
Can you inherit RBAC blob storage roles from Azure AD Security Groups?
I'm having trouble with the authentication using Azure Blob Storage, we're using ADAL in an Angular app to connect with Azure Blob storage.

I have set up the Azure App Registration with Storage impersonate and can acquire a token for the user to the https://storage.azure.com/ resource.

The Storage Account has Access Controls configured for Storage Blob Data Contributor for users, now this is where I start to have problems.

If I assign the user directly to Storage Blob Data Contributor - everything works as expected and we can query and upload blobs.

However, if we assign Storage Blob Data Contributor to an AD Security Group, members of said AD Group cannot access the storage and receive 403 errors with the x-ms-error-code: AuthorizationPermissionMismatch header.

Are there any restrictions on assigning permissions via groups? Do we need Premium AD? Any help would be much appreciated.

Update

Confirmed not an issue with Premium AD as that's still not working after trying a tenancy that has P2.

The documentation here states;

When an RBAC role is assigned to an Azure AD security principal, Azure grants access to those resources for that security principal. Access can be scoped to the level of the subscription, the resource group, the storage account, or an individual container or queue. An Azure AD security principal may be a user, a group, an application service principal, or a managed identity for Azure resources.

Surely that means that you can assign roles either per person or inherit from a group???

Full context;

App Registration configured with Azure Storage -> user_impersonation

User has the Storage Blob Data Contributor role assigned via
GROUP ASSIGNMENT

Angular App can authorize against https://storage.azure.com/ and acquire a token

403 error on the PUT request with the error code AuthorizationPermissionMismatch

Update role assignments to include a direct assignment

Acquire a new token...

PUT now works and the image is stored successfully

Now this works - it's proved the Groups is the cause. Why do group assignments not give users access?

Again any help would be appreciated!

Update 2

As requested in the answer below;

"Check Access" option from the "IAM Access" blade shows I have the Storage Blob Data Contributor role assignment from three groups (QA - Technician, QA - Site Admin w/o customer data and QA - Site Admin w/ customer data)

I haven't changed these the users associated with the roles since they were created several months ago, and as the image above shows, I must be a member of the role to be included here.

The Group is not dynamically assigned, all users are assigned to the Roles by the Membership section. Does it matter that these are via another group?
i.e.

答:
Could you please use "Check Access" option from the "IAM Access" blade on the affected storage account in azure portal and see if the user who is part of the group shows the role assignment via inheritance? Also I would request you to check if the user is part of the group at the point we attempted access . Is the group having dynamic membership user assignment ?

storage account > IAM > Add role and add the special permission for this type of request, STORAGE BLOB DATA CONTRIBUTOR, I would recommend you to please look into these article

For now, you can test the identity based access using the PowerShell
https://learn.microsoft.com/en-us/azure/storage/common/storage-auth-aad-rbac-powershell

Let me know the status


问:
Firefox: CSS: change style when button focused
It is possible to remove the extra Firefox-specific spacing from <button> tags. The only drawback is that the outline will be missing when you focus to the button on your keyboard.

I would very much like to make my buttons consistent across Chrome, IE8, Firefox. If I could use a CSS :hover, I could easily show the button as focused using the same style that removes that Firefox spacing and outline.

Is there any way to do this without JavaScript? I do not care if other browsers ignore the rule. In fact I would prefer a :-moz-focused if there is such a thing so I can be sure that it won't happen in the other browsers.

Also, if a Chrome style outer glow could be accomplished in Firefox, that would be twice as good.

答:
There is, in fact, a :focus selector.  Is that not what you need?

```<code>a:hover, a:active, a:focus {
   border: 1px dotted #f00;
}
</code>```

I've done this with pretty decent results, although it is possible with the right combination of clicks and tabs to wind up with more than one element highlighted (one active and another focused).  Not likely to be an issue in normal use, though you might consider a visual distinction between hover/active and focus.

Also note that :focus is supported in IE8 and 9 but not earlier versions.  (The chart on quirksmode.org seems to indicate that it doesn't work in 8, but testing shows otherwise.)

Body:
There is, in fact, a :focus selector.  Is that not what you need?

a:hover, a:active, a:focus {
   border: 1px dotted #f00;
}

I've done this with pretty decent results, although it is possible with the right combination of clicks and tabs to wind up with more than one element highlighted (one active and another focused).  Not likely to be an issue in normal use, though you might consider a visual distinction between hover/active and focus.

Also note that :focus is supported in IE8 and 9 but not earlier versions.  (The chart on quirksmode.org seems to indicate that it doesn't work in 8, but testing shows otherwise.)


问:
How to open Navigation Drawer when click on navigation drawer icon
How to open Navigation Drawer when click on navigation drawer icon.

I want open Navigation Drawer like this

![Navigation Drawer][1]

I added a menu but still not showing

```<code>toggle = new ActionBarDrawerToggle(
            DashBordActivity.this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }

@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawerLayout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement

    return super.onOptionsItemSelected(item);
}

@SuppressWarnings("StatementWithEmptyBody")
//@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawerLayout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

public void setupToolbar(String title) {
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(title);
    toolbar.setTitleTextColor(Color.BLACK);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

private void setupDrawerContent(NavigationView navigationView) {
    //revision: this don't works, use setOnChildClickListener() and setOnGroupClickListener() above instead
    navigationView.setNavigationItemSelectedListener(
            new NavigationView.OnNavigationItemSelectedListener() {
                @Override
                public boolean onNavigationItemSelected(MenuItem menuItem) {
                    menuItem.setChecked(true);
                    drawer.closeDrawers();
                    return true;
                }
            });
}
</code>```

navigation drawer is not open when i click on the drawer how to solve this problem

is there any code is missing in my code.

答:
```<code>  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
       toolbar.setNavigationIcon(R.drawable.menu);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                drawer.openDrawer(START);
            }
        });
</code>```

Body:
How to open Navigation Drawer when click on navigation drawer icon.

I want open Navigation Drawer like this

![Navigation Drawer][1]

I added a menu but still not showing

toggle = new ActionBarDrawerToggle(
            DashBordActivity.this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }

@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawerLayout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement

    return super.onOptionsItemSelected(item);
}

@SuppressWarnings("StatementWithEmptyBody")
//@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawerLayout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

public void setupToolbar(String title) {
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(title);
    toolbar.setTitleTextColor(Color.BLACK);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

private void setupDrawerContent(NavigationView navigationView) {
    //revision: this don't works, use setOnChildClickListener() and setOnGroupClickListener() above instead
    navigationView.setNavigationItemSelectedListener(
            new NavigationView.OnNavigationItemSelectedListener() {
                @Override
                public boolean onNavigationItemSelected(MenuItem menuItem) {
                    menuItem.setChecked(true);
                    drawer.closeDrawers();
                    return true;
                }
            });
}

navigation drawer is not open when i click on the drawer how to solve this problem

is there any code is missing in my code.


问:
How can I count how many horizontal brush strokes are required to draw an array of buildings?
By given an array of integers, each element represents a building. For example: int buildings[] = {1, 4, 3, 2, 3, 1}.

If I drew the buildings horizontally with a brush, how many brush strike I would use?

I should write a function that returns the number of these brush strokes.  For example 5.

I can do it easily on run time O(n^2), by using 2 loops.

The external loop running on the levels of each building (according to the highest building).

The inner loop is running on the array from 0 to n, and compares the difference of the height (0 or 1) between two near elements.

How can I do this in the O(n) time and O(n) space?

答:
A brush stroke starts whenever the height increases going from left to right, and ends when it decreases. You only need to look at when it increases, because if you just count the starting points of each stroke you will have the stroke count. Instead of looping over the height levels in an inner loop, just subtract one height level from the previous to get the difference.

In pseudo-code:

```<code>int BrushCount(int[] buildings)
{
    int brushCount = 0;
    int prevHeight = 0;
    for(int i = 0; i < buildings.length; i++)
    {
        if(buildings[i] > prevHeight)
             brushCount = brushCount + (buildings[i] - prevHeight);
        prevHeight = buildings[i];
    }
    return brushCount;
}
</code>```

Runs in O(n).

Body:
A brush stroke starts whenever the height increases going from left to right, and ends when it decreases. You only need to look at when it increases, because if you just count the starting points of each stroke you will have the stroke count. Instead of looping over the height levels in an inner loop, just subtract one height level from the previous to get the difference.

In pseudo-code:

int BrushCount(int[] buildings)
{
    int brushCount = 0;
    int prevHeight = 0;
    for(int i = 0; i < buildings.length; i++)
    {
        if(buildings[i] > prevHeight)
             brushCount = brushCount + (buildings[i] - prevHeight);
        prevHeight = buildings[i];
    }
    return brushCount;
}

Runs in O(n).


问:
I want to use non-consumable and auto renewable So,Is it possible to use 2 IAP products in one App?
In My App I have used non-consumable IAP while Login.
and I want to use Auto-renewable subscription for Remove Ad feature.

So, Will it be any chance of rejection from Apple or Is this a valid to use multiple product in one App?

答: Yes, It is possible but for that you have to create two group in your developer portal. For same group you can't purchase two IAP.</p>


问:
Add related ForeignKey fields with serializer in Django REST Framework
I'm using Django 2.2 and Django REST Framework

I have three models like

```<code>class Plan(models.Model):
    name = models.CharField(_('Plan Name'), max_length=100)
    default = models.NullBooleanField(default=None, unique=True)
    created = models.DateTimeField(_('created'), db_index=True)
    quotas = models.ManyToManyField('Quota', through='PlanQuota')

class Quota(models.Model):
    codename = models.CharField(max_length=50, unique=True)
    name = models.CharFieldmax_length=100)
    unit = models.CharField(max_length=100, blank=True)

class PlanQuota(models.Model):
    plan = models.ForeignKey('Plan', on_delete=models.CASCADE)
    quota = models.ForeignKey('Quota', on_delete=models.CASCADE)
    value = models.IntegerField(default=1, null=True, blank=True)
</code>```

I have to get all quota and their value from PlanQuota in the plan serializer while getting a list of plans.

I have the following serializer

```<code>class PlanQuotaSerialier(serializers.ModelSerializer):
    class Meta:
        model = PlanQuota
        depth = 1
        fields = ['quota', 'value']

class PlanListSerializer(serializers.ModelSerializer):
    plan_quota = PlanQuotaSerialier(read_only=True, many=True)

    class Meta:
        model = Plan
        depth = 1
        fields = ['name', 'default', 'created', 'plan_quota']
</code>```

But there is no plan_quota in the response.

How can I add all Quota and their value for each plan in a single query (SQL JOIN)?

Edit 2:

Adding source to the serializer field worked

```<code>plan_quota = PlanQuotaSerialier(source='planquota_set', many=True)
</code>```

And the result is like

```<code>"results": [
        {
            "name": "Test Plan 1",
            "default": true,
            "plan_quotas": [
                {
                    "quota": {
                        "id": 1,
                        "order": 0,
                        "codename": "TEST",
                        "name": "Test Domain",
                        "unit": "count",
                        "description": "",
                        "is_boolean": false,
                        "url": ""
                    },
                    "value": 10
                },
             ]
       }
]
</code>```

Can I club all fields from quota with value field in the plan_quotas list?

答:
```<code>class PlanQuota(models.Model):
    plan = models.ForeignKey('Plan', on_delete=models.CASCADE, related_name='plan_quotas')
    quota = models.ForeignKey('Quota', on_delete=models.CASCADE)
    value = models.IntegerField(default=1, null=True, blank=True)

class PlanListSerializer(serializers.ModelSerializer):
    class Meta:
        model = Plan
        depth = 1
        fields = ['name', 'default', 'created', 'plan_quotas']
</code>```

Body:
I'm using Django 2.2 and Django REST Framework

I have three models like

class Plan(models.Model):
    name = models.CharField(_('Plan Name'), max_length=100)
    default = models.NullBooleanField(default=None, unique=True)
    created = models.DateTimeField(_('created'), db_index=True)
    quotas = models.ManyToManyField('Quota', through='PlanQuota')

class Quota(models.Model):
    codename = models.CharField(max_length=50, unique=True)
    name = models.CharFieldmax_length=100)
    unit = models.CharField(max_length=100, blank=True)

class PlanQuota(models.Model):
    plan = models.ForeignKey('Plan', on_delete=models.CASCADE)
    quota = models.ForeignKey('Quota', on_delete=models.CASCADE)
    value = models.IntegerField(default=1, null=True, blank=True)

I have to get all quota and their value from PlanQuota in the plan serializer while getting a list of plans.

I have the following serializer

class PlanQuotaSerialier(serializers.ModelSerializer):
    class Meta:
        model = PlanQuota
        depth = 1
        fields = ['quota', 'value']

class PlanListSerializer(serializers.ModelSerializer):
    plan_quota = PlanQuotaSerialier(read_only=True, many=True)

    class Meta:
        model = Plan
        depth = 1
        fields = ['name', 'default', 'created', 'plan_quota']

But there is no plan_quota in the response.

How can I add all Quota and their value for each plan in a single query (SQL JOIN)?

Edit 2:

Adding source to the serializer field worked

plan_quota = PlanQuotaSerialier(source='planquota_set', many=True)

And the result is like

"results": [
        {
            "name": "Test Plan 1",
            "default": true,
            "plan_quotas": [
                {
                    "quota": {
                        "id": 1,
                        "order": 0,
                        "codename": "TEST",
                        "name": "Test Domain",
                        "unit": "count",
                        "description": "",
                        "is_boolean": false,
                        "url": ""
                    },
                    "value": 10
                },
             ]
       }
]

Can I club all fields from quota with value field in the plan_quotas list?


问:
Angular 5 StaticInjectorError:[Http]
hello i am getting such an error what is the reason for this?

StaticInjectorError[Http]: StaticInjectorError[Http]: NullInjectorError: No provider for Http! at NullInjector.get (core.js:923) at resolveToken (core.js:1211) at tryResolveToken (core.js:1153)enter code here at StaticInjector.get (core.js:1024) at resolveToken (core.js:1211) at tryResolveToken (core.js:1153) at StaticInjector.get (core.js:1024) at resolveNgModuleDep (core.js:10585) at NgModuleRef.get (core.js:11806) at resolveDep (core.js:12302)

```<code>import { Injectable } from '@angular/core' import {Todo} from './Todo'

import {Http, Response,Headers,RequestOptions} from '@angular/Http' import {Observable} from 'rxjs/Observable' import 'rxjs/add/operator/do' import 'rxjs/add/operator/catch' import 'rxjs/add/operator/map'

@Injectable() export class TodoService{

constructor(private http: Http){}

todoUrl = "https://jsonplaceholder.typicode.com/todos";

getTodos():Observable{ return this.http.get("https://jsonplaceholder.typicode.com/todos") .map((res:Response)=>res.json()) .do(data=>console.log("TODOS LIST")) } }
</code>```

答:
Import the HttpClientModule in the app.module.ts as mentioned in the example.
Thanks World! :)

```<code> import { HttpClientModule } from '@angular/http';

        @NgModule({
            imports: [ BrowserModule, HttpClientModule ],
            providers: [],
            declarations: [ AppComponent ],
            bootstrap: [ AppComponent ]
        })
        export default class AppModule { }

        platformBrowserDynamic().bootstrapModule(AppModule);
</code>```

Title: Angular 5 StaticInjectorError:[Http]

Body:
hello i am getting such an error what is the reason for this?

StaticInjectorError[Http]: StaticInjectorError[Http]: NullInjectorError: No provider for Http! at NullInjector.get (core.js:923) at resolveToken (core.js:1211) at tryResolveToken (core.js:1153)enter code here at StaticInjector.get (core.js:1024) at resolveToken (core.js:1211) at tryResolveToken (core.js:1153) at StaticInjector.get (core.js:1024) at resolveNgModuleDep (core.js:10585) at NgModuleRef.get (core.js:11806) at resolveDep (core.js:12302)

import { Injectable } from '@angular/core' import {Todo} from './Todo'

import {Http, Response,Headers,RequestOptions} from '@angular/Http' import {Observable} from 'rxjs/Observable' import 'rxjs/add/operator/do' import 'rxjs/add/operator/catch' import 'rxjs/add/operator/map'

@Injectable() export class TodoService{

constructor(private http: Http){}

todoUrl = "https://jsonplaceholder.typicode.com/todos";

getTodos():Observable{ return this.http.get("https://jsonplaceholder.typicode.com/todos") .map((res:Response)=>res.json()) .do(data=>console.log("TODOS LIST")) } }

Body:
Import the HttpClientModule in the app.module.ts as mentioned in the example.
Thanks World! :)

 import { HttpClientModule } from '@angular/http';

        @NgModule({
            imports: [ BrowserModule, HttpClientModule ],
            providers: [],
            declarations: [ AppComponent ],
            bootstrap: [ AppComponent ]
        })
        export default class AppModule { }

        platformBrowserDynamic().bootstrapModule(AppModule);


问:
Excel - conditionally transpose rows to columns
I've got an extract of an online spreadsheet where it's laid out :

```<code>1   date   author   modified   comment
1   date   author   modified   comment2
1   date   author   modified   comment3
1   date   author   modified   commentn
2   date   author   modified   comment
2   date   author   modified   comment2
2   date   author   modified   comment3
2   date   author   modified   commentn
3   date   author   modified   comment
3   date   author   modified   comment2
3   date   author   modified   comment3
3   date   author   modified   commentn
....
3000 date   author modified   comment60
</code>```

The number of comments associated with each index varies, and we have a few thousand lines.
For the life of me, I can't work out how to transpose these with a formula

Any thoughts on how I can achieve this in Excel?

I'd like to get it laid out as:

```<code>1 author concat(date, comment)  concat(date, comment)  concat(date, comment)
2 author concat(date, comment)  concat(date, comment)  concat(date, comment)
</code>```

...

答:
Here is one way using some formulas:

Formula in A2:

```<code>=IFERROR(INDEX(Sheet1!$A$1:$A$12,MATCH(0,COUNTIF($A$1:A1,Sheet1!$A$1:$A$12),0)),"")
</code>```

Enter through CtrlShiftEnter

Drag down...

Formula in B2:

```<code>=INDEX(Sheet!$C$1:$C$12,MATCH(A2,Sheet1!$A$1:$A$12,0))
</code>```

Drag down...

Formula in C2:

```<code>=IFERROR(INDEX(Sheet1!$B$1:$B$12,SMALL((Sheet1!$A$1:$A$12=$A2)*ROW(Sheet1!$A$1:$A$12),COUNTIF(Sheet1!$A$1:$A$12,"<>"&$A2)+(COLUMN()-2)))&", "&INDEX(Sheet1!$E$1:$E$12,SMALL((Sheet1!$A$1:$A$12=$A2)*ROW(Sheet1!$A$1:$A$12),COUNTIF(Sheet1!$A$1:$A$12,"<>"&$A2)+(COLUMN()-2))),"")
</code>```

Enter through CtrlShiftEnter

Drag right and down...

And if that would return numbers instead of dates for you, than swap this part: INDEX(Sheet1!$B$1:$B$12 with: INDEX(TEXT(Sheet1!$B$1:$B$12,"DD-MM-YYYY") or whatever dateformat you might want to use.

Your first step could also just to copy the first columns of ID's on sheet1, paste them on sheet2 and remove duplicates. In that case you will have to adjust ranges on the other formulas to start with A1 instead of A2.

Body:
I've got an extract of an online spreadsheet where it's laid out :

1   date   author   modified   comment
1   date   author   modified   comment2
1   date   author   modified   comment3
1   date   author   modified   commentn
2   date   author   modified   comment
2   date   author   modified   comment2
2   date   author   modified   comment3
2   date   author   modified   commentn
3   date   author   modified   comment
3   date   author   modified   comment2
3   date   author   modified   comment3
3   date   author   modified   commentn
....
3000 date   author modified   comment60

The number of comments associated with each index varies, and we have a few thousand lines.
For the life of me, I can't work out how to transpose these with a formula

Any thoughts on how I can achieve this in Excel?

I'd like to get it laid out as:

1 author concat(date, comment)  concat(date, comment)  concat(date, comment)
2 author concat(date, comment)  concat(date, comment)  concat(date, comment)

...

Body:
Here is one way using some formulas:

Formula in A2:

=IFERROR(INDEX(Sheet1!$A$1:$A$12,MATCH(0,COUNTIF($A$1:A1,Sheet1!$A$1:$A$12),0)),"")

Enter through CtrlShiftEnter

Drag down...

Formula in B2:

=INDEX(Sheet!$C$1:$C$12,MATCH(A2,Sheet1!$A$1:$A$12,0))

Drag down...

Formula in C2:

=IFERROR(INDEX(Sheet1!$B$1:$B$12,SMALL((Sheet1!$A$1:$A$12=$A2)*ROW(Sheet1!$A$1:$A$12),COUNTIF(Sheet1!$A$1:$A$12,"<>"&$A2)+(COLUMN()-2)))&", "&INDEX(Sheet1!$E$1:$E$12,SMALL((Sheet1!$A$1:$A$12=$A2)*ROW(Sheet1!$A$1:$A$12),COUNTIF(Sheet1!$A$1:$A$12,"<>"&$A2)+(COLUMN()-2))),"")

Enter through CtrlShiftEnter

Drag right and down...

And if that would return numbers instead of dates for you, than swap this part: INDEX(Sheet1!$B$1:$B$12 with: INDEX(TEXT(Sheet1!$B$1:$B$12,"DD-MM-YYYY") or whatever dateformat you might want to use.

Your first step could also just to copy the first columns of ID's on sheet1, paste them on sheet2 and remove duplicates. In that case you will have to adjust ranges on the other formulas to start with A1 instead of A2.


问:
How to display two 1-m related CoreData entities in two NSTableViews using NSArray bindings
I have an entity 'person' and a 1-m related entity 'visit' defined in CoreData. Now I want to display and modify their values in related tables using NSArray controllers with COCOA bindings on MacOS

My project is for MacOS and I'm using Xcode with Swift.
I have defined the data structure and Viewcontroller objects using the Xcode builder. The table for the 'person' is already working and I can add or delete persons. However I'm not able to find a way to bind the 'visit' table to the selected person. I tried several options, like connecting the content of the 'visit' array controller as recommended in Master-detail using bindings with TWO NSTableViews, but all ended up in compile time errors.

As I'm working with the visual Xcode builders, the is not much code for the moment. Here is what I did so far:

I have defined the two entity classes with the Xcode data model builder, then the two tables and array controllers with the storyboard interface builder. Then I bound the table views content to the respective array controllers and the columns to their own table view with the respective entity attribute. I also added + and - buttons to add some rows. So far everything worked fine. But the details ('visit') had no connection to any 'person'. Hence I deleted all entries in the 'visit' table and tried to bind the content of its array controller to the selected person.  That is where I get stuck.
Maybe I missed some initialization of the CoreData entities, but I have no clue how to proceed

答:
I'm looking at my working macOS project which has two NSTableViews in Master-Detail.

The .xib has two array controllers, one for the master and detail entities.  Let's call them MasterAC and DetailAC.  The Master and Detail table columns are bound to these array controllers.

In the bindings for the DetailAC, the Content Array binding is bound to: MasterAC.selection.details, where details is the name of the master-to-detail relationship.

In the bindings for both MasterAC and DetailAC, the Managed Object Context binding in both are bound to the same managed object context.

In the array controllers, only these two bindings (Content Array and Managed Object Context) are bound.

If that does not fix it, I can poke around some more.  Cocoa Bindings with Core Data in macOS are beautiful once you get them working :))

Appendix.  If you've got an-ordered set

If the master-to-detail to-many relationship is an unordered set, and you are using the old school method of defining an index attribute on your Detail entity, you can define a detailsOrdered attribute in your Master class like this:

```<code>func detailsOrdered() -> [Any]? {
    return details().arraySorted(byKeyPath: "index")
}
</code>```

and then bind to MasterAC.selection.detailsOrdered instead of MasterAC.selection.details.

The above implementation requires the following extension of Set:

```<code>extension Set<AnyHashable> {
    func arraySorted(byKeyPath keyPath: String?) -> [Any]? {
        let unorderedArray = Array(self)
        let sortDescriptor = NSSortDescriptor(key: keyPath, ascending: true)
        let orderedArray = (unorderedArray as NSArray).sortedArray(using: [sortDescriptor])
        return orderedArray
    }
}
</code>```

Body:
I'm looking at my working macOS project which has two NSTableViews in Master-Detail.

The .xib has two array controllers, one for the master and detail entities.  Let's call them MasterAC and DetailAC.  The Master and Detail table columns are bound to these array controllers.

In the bindings for the DetailAC, the Content Array binding is bound to: MasterAC.selection.details, where details is the name of the master-to-detail relationship.

In the bindings for both MasterAC and DetailAC, the Managed Object Context binding in both are bound to the same managed object context.

In the array controllers, only these two bindings (Content Array and Managed Object Context) are bound.

If that does not fix it, I can poke around some more.  Cocoa Bindings with Core Data in macOS are beautiful once you get them working :))

Appendix.  If you've got an-ordered set

If the master-to-detail to-many relationship is an unordered set, and you are using the old school method of defining an index attribute on your Detail entity, you can define a detailsOrdered attribute in your Master class like this:

func detailsOrdered() -> [Any]? {
    return details().arraySorted(byKeyPath: "index")
}

and then bind to MasterAC.selection.detailsOrdered instead of MasterAC.selection.details.

The above implementation requires the following extension of Set:

extension Set<AnyHashable> {
    func arraySorted(byKeyPath keyPath: String?) -> [Any]? {
        let unorderedArray = Array(self)
        let sortDescriptor = NSSortDescriptor(key: keyPath, ascending: true)
        let orderedArray = (unorderedArray as NSArray).sortedArray(using: [sortDescriptor])
        return orderedArray
    }
}


问:
Postgres interval in total months
I have a Postgres table with interval data, such as:

0 month

1 month

1.5 months

9 months

1 year

I would like to create a view which displays the values, but in total months (so the correct values in my case would be: 0, 1, 1.5, 9, 12). I have tried using:

```<code>EXTRACT(MONTHS FROM "MyTable"."Interval"::INTERVAL)
</code>```

However, this yielded incorrect results (0, 1, 1, 9, 0).

Is there another function, which would display the expected values?

答:
Well, the extract function retrieves subfields such as year or hour from date/time values, not the total time you want,but we can construct the result by ourself, as below:

```<code>postgres=# select * from month_table ;
   month
------------
 0 month
 1 month
 1.5 months
 9 months
 1 year
 2 years
 1.5 years
(7 rows)

postgres=# select
    case when month ~ 'month' then regexp_replace(month,' month.*','')::numeric
         when month ~ 'year' then regexp_replace(month,' year.*','')::numeric * 12 end as months
from
    month_table;
 months
--------
      0
      1
    1.5
      9
     12
     24
   18.0
(7 rows)
</code>```

Title: Postgres interval in total months

Body:
I have a Postgres table with interval data, such as:

0 month

1 month

1.5 months

9 months

1 year

I would like to create a view which displays the values, but in total months (so the correct values in my case would be: 0, 1, 1.5, 9, 12). I have tried using:

EXTRACT(MONTHS FROM "MyTable"."Interval"::INTERVAL)

However, this yielded incorrect results (0, 1, 1, 9, 0).

Is there another function, which would display the expected values?

Body:
Well, the extract function retrieves subfields such as year or hour from date/time values, not the total time you want,but we can construct the result by ourself, as below:

postgres=# select * from month_table ;
   month
------------
 0 month
 1 month
 1.5 months
 9 months
 1 year
 2 years
 1.5 years
(7 rows)

postgres=# select
    case when month ~ 'month' then regexp_replace(month,' month.*','')::numeric
         when month ~ 'year' then regexp_replace(month,' year.*','')::numeric * 12 end as months
from
    month_table;
 months
--------
      0
      1
    1.5
      9
     12
     24
   18.0
(7 rows)


问:
Getting an "Internal Service Exception" when trying to run an extremely basic AWS-glue crawler with a large number of columns
I'm trying to do some POC-testing by getting S3 parquet files to be queryable through Athena.

I'm starting with something pretty basic: a single parquet file, with around 400 rows and about 800 columns (this is an unusual storage system I know; but for business logic reasons there aren't a ton of other options)

This seems to fail when I try to run a glue crawler across it, with a generic Internal Service Exception error.

I tried the same thing with a smaller number of columns (everything else the same) and low and behold, it worked. Is this some sort of limitation I'm unaware of?

Any help would be appreciated.

答:
This is not glue limitation but athena limitation. Since data catalog is internally using Athena for queries, it should follow Athena standards.

Athena table, view, database, and column names allow only underscore special characters

Athena table, view, database, and column names
cannot contain special characters, other than underscore (_).

More details: https://docs.aws.amazon.com/athena/latest/ug/tables-databases-columns-names.html