问:
Pop up blocker in Selenium
I'm facing the pop up blocker issue while open the popup window from parent button Click.

Error Reference

I tried the following things but I'm facing the same Error.

1.In internet option->privacy tab I unchecked "Turn On block pop up" option.
2.under security tab I tried with uncheck the Enable protected mode.
3.added my website in the popup allowing site also under "turn on block popup"

Note :

1.I'm able to open the popup by manually without any interruption.
2.I'm using IE and C# .

答:
You should set the capabilities for IE Like below.</p>

```<code>caps.setCapability("browserstack.ie.enablePopups", "true");
</code>```

Title: Pop up blocker in Selenium

Body:
You should set the capabilities for IE Like below.

caps.setCapability("browserstack.ie.enablePopups", "true");


来源: stackexchange

问:
Merge two mongo collections with query condition in pentaho
I have a problem querying two collections and combining the results to form another collection.

Collection1:

```<code>{
    "ResourceCost" : 0.0032258065,
    "ResourceId" : "i-08c35f123eea43f30",
    "Unit" : "USD",
    "billdate" : ISODate("2017-12-01T16:30:00.000Z")
}
</code>```

Collection 2:

```<code>{
    "resource_id" : "i-08c35f123eea43f30",
    "Timestamp" : ISODate("2017-12-01T18:30:00.000Z"),
    "Avg" : 0.0,
    "total" : 0.0,
    "sample_cnt" : 1440.0,
    "max" : 0.0,
    "min" : 0.0
}
</code>```

I need to update the collection 1 with collection 2 data. So finally I am expecting collection 1 data as below

Check with same time for both fields and resource id. Update the data

collection 1:

```<code>{
   "ResourceCost" : 0.0032258065,
   "ResourceId" : "i-08c35f123eea43f30",
   "Unit" : "USD",
   "billdate" : ISODate("2017-12-01T16:30:00.000Z")
   "Avg" : 0.0,
   "total" : 0.0,
   "sample_cnt" : 1440.0,
   "max" : 0.0,
   "min" : 0.0
}
</code>```

答:
In mongodb 3.4 you can use this</p>

```<code>    db.col1.aggregate([
    {
        $lookup:{
                from:"col2",
                localField:"ResourceId",
                foreignField:"resource_id",
                as:"result"
            }
    },   {
      $replaceRoot: {
         newRoot: {
           $mergeObjects: [ { $arrayElemAt: [ "$result", 0 ] }, "$$ROOT" ]
         }
     }
   },{
     $project: { result: 0 }
     }])
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a problem querying two collections and combining the results to form another collection.

Collection1:

{
    "ResourceCost" : 0.0032258065,
    "ResourceId" : "i-08c35f123eea43f30",
    "Unit" : "USD",
    "billdate" : ISODate("2017-12-01T16:30:00.000Z")
}

Collection 2:

{
    "resource_id" : "i-08c35f123eea43f30",
    "Timestamp" : ISODate("2017-12-01T18:30:00.000Z"),
    "Avg" : 0.0,
    "total" : 0.0,
    "sample_cnt" : 1440.0,
    "max" : 0.0,
    "min" : 0.0
}

I need to update the collection 1 with collection 2 data. So finally I am expecting collection 1 data as below

Check with same time for both fields and resource id. Update the data

collection 1:

{
   "ResourceCost" : 0.0032258065,
   "ResourceId" : "i-08c35f123eea43f30",
   "Unit" : "USD",
   "billdate" : ISODate("2017-12-01T16:30:00.000Z")
   "Avg" : 0.0,
   "total" : 0.0,
   "sample_cnt" : 1440.0,
   "max" : 0.0,
   "min" : 0.0
}

Body:
In mongodb 3.4 you can use this

    db.col1.aggregate([
    {
        $lookup:{
                from:"col2",
                localField:"ResourceId",
                foreignField:"resource_id",
                as:"result"
            }
    },   {
      $replaceRoot: {
         newRoot: {
           $mergeObjects: [ { $arrayElemAt: [ "$result", 0 ] }, "$$ROOT" ]
         }
     }
   },{
     $project: { result: 0 }
     }])


问:
What is a spring service annotation?
I understand that @Service is used to mark a class as a business logic class. Why is it useful for spring? I can already use @Component to mark a class as a bean. I understand that @Service is more specific than @Component, but how?

答: The @Service annotation is a specialization of the component annotation. It doesn’t currently provide any additional behavior over the @Component annotation, but it’s a good idea to use @Service over @Component in service-layer classes because it specifies intent better. Additionally, tool support and additional behavior might rely on it in the future.</p>

Title: What is a spring service annotation?


问:
Programmatically deduce the size of an enum independently of the value of its elements?
Is there any way, possibly requiring C++11/14, to deduce the number of elements in an enum regardless of the values of the enum elements themselves?

Consider an enum like

enum { Val1 = 1, Val2 = 2, Val3 = 4 }

for which the answer would be 3. I know there's that wrinkle, where I could have e.g. Val3 = Val1, but this can be ignored for my use case.

I've seen quite a few similar questions, both here on SO and elsewhere, but I've yet to find a proper answer for this. If there is any at all.

Usually, the proposed solution is to introduce a LAST element, but this would only give me the next higher enum value (using the example above, that would be 5), which would be of no use to me.

答:
If there is any at all.

There is not.

Even with the new C++17, there is not a proposal that I am aware of that would allow you to achieve this.

Usually, the proposed solution is to introduce a LAST element, but this would only give me the next higher enum value (using the example above, that would be 5), which would be of no use to me.

Then you will have to re-aproach your problem.


问:
Check boxes bottom border is not visible in internet explorer

Check boxes are working fine in chrome but not in internet explorer.

Here is my HTML code:

```<code><div class="patient-div-w" style="width: 9.5vw;">
  <input type="checkbox" id="edema" class="input-checkbox-l">
  <label class="label-n" for="edema" style="line-height: 8vh;">Edema</label>
  <br>
</div>
</code>```

Here is my CSS code:

```<code>input[type="checkbox"] {
    opacity: 0;
    margin: 0px 3px 0px 0px;
}

.input-checkbox-l[type="checkbox"] + label {
    background-image: url(../images/unchk.png);
    background-size: 1.2vw;
    background-repeat: no-repeat;
    padding-left: 1.7vw;
    background-position: 0vh 0vw;
    width: 8vw;
    margin: 0vw;
    position: relative;
    top: -.1vh;
    left: -1.6vw;
    white-space: nowrap;
    font-family: "Roboto Regular";
}

.label-n {
    font-size: 1vw;
    color: #000;
}
</code>```

The same is the problem with radio buttons.
Any kind of help is highly appreciated.

答:
Try this:

Lets assume the parent of .patient-div-w is .parent-div. So we need to do the following:

```<code>.parent-div{
  overflow: auto;
  zoom: 1;
}
</code>```

This is a very common issue. You can read more about it here

Body:
Check boxes are working fine in chrome but not in internet explorer.

Here is my HTML code:

  <input type="checkbox" id="edema" class="input-checkbox-l">
  Edema

Here is my CSS code:

input[type="checkbox"] {
    opacity: 0;
    margin: 0px 3px 0px 0px;
}

.input-checkbox-l[type="checkbox"] + label {
    background-image: url(../images/unchk.png);
    background-size: 1.2vw;
    background-repeat: no-repeat;
    padding-left: 1.7vw;
    background-position: 0vh 0vw;
    width: 8vw;
    margin: 0vw;
    position: relative;
    top: -.1vh;
    left: -1.6vw;
    white-space: nowrap;
    font-family: "Roboto Regular";
}

.label-n {
    font-size: 1vw;
    color: #000;
}

The same is the problem with radio buttons.
Any kind of help is highly appreciated.

Body:
Try this:

Lets assume the parent of .patient-div-w is .parent-div. So we need to do the following:

.parent-div{
  overflow: auto;
  zoom: 1;
}

This is a very common issue. You can read more about it here


问:
Android gradle sync issue
This app was running perfectly OK without any issue. Suddenly i saw this gradle sync problems.I'm really stuck and need help. What to do now? I've uninstalled and reinstalled android support repository from SDK manager.

```<code>C:\Users\DELL\AndroidStudioProjects\Prokriti\app\build.gradle
    Error:Error:Failed to resolve: com.android.support:support-annotations:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:appcompat-v7:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:customtabs:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:cardview-v7:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:support-v4:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:support-core-utils:27.0.1
Install Repository and sync project
</code>```

build.gradle  (app)

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.avtro.prokriti.prokriti"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:support-core-utils:25.3.1'
    compile 'com.android.support:support-annotations:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-auth:11.0.4'
    compile 'com.google.firebase:firebase-core:11.0.2'
    compile 'com.google.firebase:firebase-messaging:11.0.2'
    compile 'com.google.firebase:firebase-database:11.0.2'
    compile 'com.google.firebase:firebase-auth:11.0.2'
    compile 'com.google.firebase:firebase-ads:11.0.2'
    compile 'com.afollestad.material-dialogs:core:0.9.4.5'
    compile 'com.wang.avi:library:2.1.3'
    compile 'com.google.android.gms:play-services-ads:11.0.4'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.survivingwithandroid:weatherlib:1.6.0'
    compile 'com.amitshekhar.android:android-networking:1.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.google.firebase:firebase-storage:11.0.2'
    androidTestCompile 'junit:junit:4.12'
    compile 'javax.inject:javax.inject:1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.github.bumptech.glide:glide:3.8.0'
}
apply plugin: 'com.google.gms.google-services'
</code>```

build.gradle  (project)

```<code>buildscript {
    repositories {
        jcenter()
    }
dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
</code>```

i didnt update android studio or gradle. Android support repository is installed.

答:
I solve the problem by removing

```<code> compile 'com.facebook.android:facebook-android-sdk:[4,5)'
</code>```

And adding

```<code>compile 'com.facebook.android:facebook-android-sdk:4.26.0'
</code>```

Title: Android gradle sync issue

Body:
This app was running perfectly OK without any issue. Suddenly i saw this gradle sync problems.I'm really stuck and need help. What to do now? I've uninstalled and reinstalled android support repository from SDK manager.

C:\Users\DELL\AndroidStudioProjects\Prokriti\app\build.gradle
    Error:Error:Failed to resolve: com.android.support:support-annotations:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:appcompat-v7:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:customtabs:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:cardview-v7:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:support-v4:27.0.1
Install Repository and sync project
    Error:Error:Failed to resolve: com.android.support:support-core-utils:27.0.1
Install Repository and sync project

build.gradle  (app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.avtro.prokriti.prokriti"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:support-core-utils:25.3.1'
    compile 'com.android.support:support-annotations:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-auth:11.0.4'
    compile 'com.google.firebase:firebase-core:11.0.2'
    compile 'com.google.firebase:firebase-messaging:11.0.2'
    compile 'com.google.firebase:firebase-database:11.0.2'
    compile 'com.google.firebase:firebase-auth:11.0.2'
    compile 'com.google.firebase:firebase-ads:11.0.2'
    compile 'com.afollestad.material-dialogs:core:0.9.4.5'
    compile 'com.wang.avi:library:2.1.3'
    compile 'com.google.android.gms:play-services-ads:11.0.4'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.survivingwithandroid:weatherlib:1.6.0'
    compile 'com.amitshekhar.android:android-networking:1.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.google.firebase:firebase-storage:11.0.2'
    androidTestCompile 'junit:junit:4.12'
    compile 'javax.inject:javax.inject:1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.github.bumptech.glide:glide:3.8.0'
}
apply plugin: 'com.google.gms.google-services'

build.gradle  (project)

buildscript {
    repositories {
        jcenter()
    }
dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

i didnt update android studio or gradle. Android support repository is installed.

Body:
I solve the problem by removing

 compile 'com.facebook.android:facebook-android-sdk:[4,5)'

And adding

compile 'com.facebook.android:facebook-android-sdk:4.26.0'


问:
Code Sign Error in macOS Monterey, Xcode - resource fork, Finder information, or similar detritus not allowed
Already tried : Code Sign Error on macOS Sierra, Xcode 8

Please see image showing error

```<code>CodeSign /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super\ Flow\ Flip.app
    cd "/Volumes/Development/Project/Top Best Games/19. Lets Flow/35/let's FLOW - source/proj.ios_mac"
    export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

Signing Identity:     "iPhone Distribution: New Free Games (2CHN583K4J)"
Provisioning Profile: "Super Flow Flipp AppStore"
                      (c6c30d2a-1025-4a23-8d12-1863ff684a05)

    /usr/bin/codesign --force --sign E48B98966150110E55EAA9B149F731901A41B37F --entitlements /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Intermediates/Flow.build/Debug-iphoneos/Super\ Flow\ Flip.build/Super\ Flow\ Flip.app.xcent --timestamp=none /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super\ Flow\ Flip.app

/Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super Flow Flip.app: resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1
</code>```

In Code Sign section its allowing me to select profile and certificate...but still giving error.

How to fix this problem ?

答:
Open terminal and just run this command.

xattr -cr "path to .app file"

ContentLicense: CC BY-SA 4.0

Body:
Already tried : Code Sign Error on macOS Sierra, Xcode 8

Please see image showing error

CodeSign /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super\ Flow\ Flip.app
    cd "/Volumes/Development/Project/Top Best Games/19. Lets Flow/35/let's FLOW - source/proj.ios_mac"
    export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

Signing Identity:     "iPhone Distribution: New Free Games (2CHN583K4J)"
Provisioning Profile: "Super Flow Flipp AppStore"
                      (c6c30d2a-1025-4a23-8d12-1863ff684a05)

    /usr/bin/codesign --force --sign E48B98966150110E55EAA9B149F731901A41B37F --entitlements /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Intermediates/Flow.build/Debug-iphoneos/Super\ Flow\ Flip.build/Super\ Flow\ Flip.app.xcent --timestamp=none /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super\ Flow\ Flip.app

/Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super Flow Flip.app: resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1

In Code Sign section its allowing me to select profile and certificate...but still giving error.

How to fix this problem ?


问:
Dynamic Arrays and memory
This is a very basic random question I had but saw no answers here or online.
When creating a dynamic array, we set it to a certain location in memory. Is it possible to make an array that eventually is too big for that memory slot? If so, how is this handled? Is this something that is automatically done by c++ or do we have to do it ourselves?

I am learning linked lists and I know we set each Node to a memory location. But
when using an array, we don't set each element to a memory location, we just set the whole array.

答: If you're using std::vector for these dynamic arrays, then it will be handled automatically as you can see in the reference</p>

Title: Dynamic Arrays and memory


问:
How can i restrict the request from the unauthorized users (url's)?
Here my problem is that in my spring project totally 3 Jsp pages are available.

home page

register page

register success full page

When i type url for the home page in a browser, i am getting home page.and inside one hyperlink is available to register data. automatically when i click on that link it will go to the register page.then after it will go to the register success full page.

So finally my problem is that when i gave home page url in browser, homepage comes and also if i give register page url it will go to the register page with out touches the home page. but actually i want to access the register page through home page.

答: Use a token like JWT, set the token on access through Home page. Use a MVC Interceptor or a Filter and check that the token is present in the request before presenting the register page . If token not present redirect to home page.</p>


问:
How do I move the apply coupon input below the order on the checkout page in Woocommerce?
On the woocommerce checkout page I want to move the field where the apply coupon input is and place it just below the order summary and above the payment options. I'm not sure how to change the php because the checkout page is comprised of multiple php files therefore I come to you genius people to help. Anybody know how I can achieve this? Thank you in advance!
P.S. I've added pictures; the first is of the top half of the page and the second is of the second half of the page.</p>

答:
@noufalcep you answer is not clear.

Finally after everything i came up with a working solution. i am using woocommerce 3.2.5 and wordpress version of 4.8.3.

As @noufalcep said the form inside form is not the issue. When we do

add_action( ‘woocommerce_checkout_after_order_review’, ‘woocommerce_checkout_coupon_form’ );

coupon container doesn't wrap up with form element. But the button has submit as input type. That's why when we apply coupon main form get suibmitted.

Therefore what i did is inserted the coupon form with jquery insertAfter. Below is the code. It is perfectly working.

```<code> var coupon = $(".checkout_coupon");
 coupon.insertAfter('.shop_table.woocommerce-checkout-review-order-table');
</code>```

Then this will add the form after review order table. if you want it with "Have a coupon? Click here to enter your code" text, you have to wrap the element with the form.

A working example can be seen here,
https://themovementfix.com/checkout/

Body:
@noufalcep you answer is not clear.

Finally after everything i came up with a working solution. i am using woocommerce 3.2.5 and wordpress version of 4.8.3.

As @noufalcep said the form inside form is not the issue. When we do

add_action( ‘woocommerce_checkout_after_order_review’, ‘woocommerce_checkout_coupon_form’ );

coupon container doesn't wrap up with form element. But the button has submit as input type. That's why when we apply coupon main form get suibmitted.

Therefore what i did is inserted the coupon form with jquery insertAfter. Below is the code. It is perfectly working.

 var coupon = $(".checkout_coupon");
 coupon.insertAfter('.shop_table.woocommerce-checkout-review-order-table');

Then this will add the form after review order table. if you want it with "Have a coupon? Click here to enter your code" text, you have to wrap the element with the form.

A working example can be seen here,
https://themovementfix.com/checkout/


问:
How can we achieve product filter page using angularjs with multi selection of checkboxes?
I have created a tabular page in which i need to filter the table with filters using a left side facets boxes of different category but with multi-selection options and i need to use Angularjs for this requirement.

I need to check/uncheck using the clear filter selection .

Any helping library can help to achieve the same or we need to do some logic around the checkboxes to achieve this.

My checkbox code looks like this:

```<code> <div class="col-sm-2" style="padding-top: 10px; padding-bottom: 20px;">
                <div class="facetBx sltBx" ng-show="tabFilters.length > 0">
                    <p class="facetBxTitle"><i class="fa fa-filter"></i> Filter Selection
                        <a class="clrSlt" ng-click="clearAllFilters();">Clear</a>
                    </p>

                    <div class="facetBxChld" id="uRslctn">

                        <ul>
                            <li ng-repeat="item in tabFilters">

                                <div class="crop">
                                    <strong title="{{item}}">{{item}}</strong>
                                </div>
                                <i class="fa fa-remove rmvThs" style="font-size: 14px;color:#000;float: right;" ng-click="checkItem(item, item,false);"></i>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="facetBx" ng-repeat="item in filters">
                    <p class="facetBxTitle bomtype">{{item.label}}</p>

                    <div class="facetBxChld" id="bomFacet">
                        <ul class="multiselect" style="max-height: 140px;overflow-y: auto;">
                            <li ng-repeat="(k,v) in item.values">
                                <input type="checkbox" ng-model='isSelected' ng-click='checkItem(item.name, k, isSelected)'>
                                <span> {{k}} ({{v}})</span>
                            </li>
                            <li ng-show="value.length == 0">
                                No Data Available.
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
</code>```

Below website are the reference of the code which i am trying to build:

www.jabong.com

The UI(HTML) is done but i am facing the trouble in the maintaining the checking and un-checking of the checkboxes which are not clearing off.

I believe i need to code something in the ng-model of checkbox to achieve it but i am not able to be successfull so need help on the same.

Sample Plunkur for the same:

enter link description here

Thanks in advance.

答:
Basically you need to keep track of ng-model of checkboxes with some property in your $scope. I did this by modifying your $scope.filters and adding selected property inside it, like below.

```<code>var filters = [{
  label: 'Brand',
  name: 'brand',
  values: {
    Blackberrys: 503,
    Arrow: 175,
    ParkAvenue: 358
  }
}, {
  label: 'Color',
  name: 'color',
  values: {
    Black: 100,
    Green: 200,
    Red: 300
  }
}]

function loadFilters() {
  $scope.filters = filters.map(function(filter) {
    var filter = angular.copy(filter);
    for (var key in filter.values) {
      filter.values[key] = {
        selected: false,
        count: filter.values[key]
      }
    }
    return filter;
  })
}

loadFilters();
</code>```

Then you can call loadFilters() any time you want to clear all filters. Please see POC attached below.

https://plnkr.co/edit/SADPoUpftnJkg1rMuSB9?p=preview

Body:
I have created a tabular page in which i need to filter the table with filters using a left side facets boxes of different category but with multi-selection options and i need to use Angularjs for this requirement.

I need to check/uncheck using the clear filter selection .

Any helping library can help to achieve the same or we need to do some logic around the checkboxes to achieve this.

My checkbox code looks like this:

 0">

 Filter Selection
                        Clear

                                    {{item}}

{{item.label}}

                                <input type="checkbox" ng-model='isSelected' ng-click='checkItem(item.name, k, isSelected)'>
                                 {{k}} ({{v}})

                                No Data Available.

Below website are the reference of the code which i am trying to build:

www.jabong.com

The UI(HTML) is done but i am facing the trouble in the maintaining the checking and un-checking of the checkboxes which are not clearing off.

I believe i need to code something in the ng-model of checkbox to achieve it but i am not able to be successfull so need help on the same.

Sample Plunkur for the same:

enter link description here

Thanks in advance.

Body:
Basically you need to keep track of ng-model of checkboxes with some property in your $scope. I did this by modifying your $scope.filters and adding selected property inside it, like below.

var filters = [{
  label: 'Brand',
  name: 'brand',
  values: {
    Blackberrys: 503,
    Arrow: 175,
    ParkAvenue: 358
  }
}, {
  label: 'Color',
  name: 'color',
  values: {
    Black: 100,
    Green: 200,
    Red: 300
  }
}]

function loadFilters() {
  $scope.filters = filters.map(function(filter) {
    var filter = angular.copy(filter);
    for (var key in filter.values) {
      filter.values[key] = {
        selected: false,
        count: filter.values[key]
      }
    }
    return filter;
  })
}

loadFilters();

Then you can call loadFilters() any time you want to clear all filters. Please see POC attached below.

https://plnkr.co/edit/SADPoUpftnJkg1rMuSB9?p=preview


问:
Flask Python Firebase storage
I'm trying to upload an image to Firebase.

```<code>storage = firebase.storage()
storage.child("images/example.jpg").put("cat.jpg")
</code>```

I can't seem to allow user to browse an image file from their PC and upload it to Firebase.
How should I go about doing this? Please kindly guide me in the right direction ,thank you!

答:
Use <input type="file".. to trigger the select window and may be listen the onChange="handleUpload()" event to handle your firebase upload.

```<code>function handleUpload(event) {
    // Use this event to get the input element
    const files = event.target.files;
    if (!files.length) {
      return alert('Please choose a file to upload first.');
    }

    // Always multiple files get the first file if no `multiple` in input
    var file = files[0];
    var fileName = file.name;
}
</code>```

Title: Flask Python Firebase storage

Body:
I'm trying to upload an image to Firebase.

storage = firebase.storage()
storage.child("images/example.jpg").put("cat.jpg")

I can't seem to allow user to browse an image file from their PC and upload it to Firebase.
How should I go about doing this? Please kindly guide me in the right direction ,thank you!

Body:
Use <input type="file".. to trigger the select window and may be listen the onChange="handleUpload()" event to handle your firebase upload.

function handleUpload(event) {
    // Use this event to get the input element
    const files = event.target.files;
    if (!files.length) {
      return alert('Please choose a file to upload first.');
    }

    // Always multiple files get the first file if no `multiple` in input
    var file = files[0];
    var fileName = file.name;
}


问:
Dictionary keys and strings
I'm just getting started with dictionaries in python and I got stumbled at the following code snippet:

```<code>for word in word_dict:
    print(word) # Obviously returns the key
print("draw" in word_dict) # returns False even though the key is existent
</code>```

I suppose the False is returned maybe due to the incompatibility of types like "draw" is a string and word in the loop is a some sort of string key type maybe.

But when I inspect the types I can see both are <class 'str'> type only !!

How do I convert the string key I provide like "draw" to be acceptable as a key and it returns True? I guess this is a simple oversight but I need to know what the problem here is !

答:
I think you are kinda lost here.

for variable in dict_var: - iterates over dict keys

dict.get(<key_name>) return value for key <key_name>

```<code>for word in word_dict:
    print(word_dict.get(word))
</code>```

Will return all values of your dict, since you iteration over all of its keys.

some_var in word_dict - checks if value of some_var in list of word_dict keys, so print("draw" in word_dict) just print True/False if key exist in your dict.

And i would strongly advise you to read docs on dictionaries.

Title: Dictionary keys and strings

Body:
I'm just getting started with dictionaries in python and I got stumbled at the following code snippet:

for word in word_dict:
    print(word) # Obviously returns the key
print("draw" in word_dict) # returns False even though the key is existent

I suppose the False is returned maybe due to the incompatibility of types like "draw" is a string and word in the loop is a some sort of string key type maybe.

But when I inspect the types I can see both are <class 'str'> type only !!

How do I convert the string key I provide like "draw" to be acceptable as a key and it returns True? I guess this is a simple oversight but I need to know what the problem here is !

Body:
I think you are kinda lost here.

for variable in dict_var: - iterates over dict keys

dict.get(<key_name>) return value for key <key_name>

for word in word_dict:
    print(word_dict.get(word))

Will return all values of your dict, since you iteration over all of its keys.

some_var in word_dict - checks if value of some_var in list of word_dict keys, so print("draw" in word_dict) just print True/False if key exist in your dict.

And i would strongly advise you to read docs on dictionaries.


问:
Filtering a Key Value from a Dictionary in C#
I'm new to C# and am currently trying to figure out the best way to implement the following:

I have a list of species with an associated group:

```<code>Bird: "Budgie", "Parrot"
Dog: "Pitbull", "Labrador"
Cat: "Cheetah", "Lion"
</code>```

Given a string of an animal, I need to return its group.
eg. "Cheetah" would return "Cat".

I have implemented the following:

```<code>// create list one and store values
List<string> valSetOne = new List<string>();
valSetOne.Add("Budgie");
valSetOne.Add("Parrot");

// create list two and store values
List<String> valSetTwo = new List<String>();
valSetTwo.Add("Lion");
valSetTwo.Add("Cheetah");

// create list three and store values
List<String> valSetThree = new List<String>();
valSetThree.Add("Labrador");
valSetThree.Add("Pitbull");

// add values into map
map.Add("Bird", valSetOne);
map.Add("Cat", valSetTwo);
map.Add("Dog", valSetThree);

foreach(KeyValuePair<string, List<string>> kvp in map){
    foreach(string value in kvp.Value)
    {
       Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, value);
    }
}
</code>```

Instead of having a foreach loop, is there a faster way to find the key given an animal value?

//EDIT:

Currently trying to initialize with a Tuple

```<code>var tupleList = new List<Tuple<string, List<string>>>
{
   new Tuple<string, List<string>>("cat", { "cheetah", "lion"})

};
</code>```

I'm getting the following error:     Unexpected symbol `{'

答:
As others have suggested I think you should use classes here. But other responses stop at 1 level of classes. I would recommend a more holistic object-oriented approach.

```<code>public abstract class Animal {}

public abstract class Dog : Animal {}
public abstract class Cat : Animal {}
public abstract class Bird : Animal {}

public sealed class Budgie : Bird {}
public sealed class Parrot : Bird {}
public sealed class Pitbull : Dog {}
public sealed class Labrador : Dog {}
public sealed class Cheetah : Cat {}
public sealed class Lion : Cat {}
</code>```

[note that sealed is optional here]

then you just say

```<code>Labrador spot = new Labrador();
</code>```

to check if it's a dog

```<code>if (spot is Dog) {
    print("it's a dog");
}
</code>```

This solution has the option of being easily extensible, and super easy to read. There's not weird code that distracts you from the fact that a Labrador is a dog, and a budgie is a bird. It's very clear what you're trying to do and what classes Dog, Cat, Cheetah, etc represent.

If you further wanted to split up labradors into Chocolate, Yellow, and Black, you could just add another layer of classes inheriting from Labrador. If you needed to define the properties of the animals, that's easy too. For example if you only wanted Dogs and Cats to have names, you could add a name field in their classes, whereas if you want all animals to have a name you can put the name field in the Animal class.

If you needed to move the animals, you could at the animal level define a method called Move() that forces its children to override this method in their own way, so perhaps dogs would Move() by Walking(), whereas birds would Move() by Flying().

I would seriously recommending abandoning the dictionary and think about using something similar to what I described. If you start to think this way it will really help you plan out more complex projects and tasks. There's a reason Object Oriented Programming is so widespread!

Body:
I'm new to C# and am currently trying to figure out the best way to implement the following:

I have a list of species with an associated group:

Bird: "Budgie", "Parrot"
Dog: "Pitbull", "Labrador"
Cat: "Cheetah", "Lion"

Given a string of an animal, I need to return its group.
eg. "Cheetah" would return "Cat".

I have implemented the following:

// create list one and store values
List<string> valSetOne = new List<string>();
valSetOne.Add("Budgie");
valSetOne.Add("Parrot");

// create list two and store values
List<String> valSetTwo = new List<String>();
valSetTwo.Add("Lion");
valSetTwo.Add("Cheetah");

// create list three and store values
List<String> valSetThree = new List<String>();
valSetThree.Add("Labrador");
valSetThree.Add("Pitbull");

// add values into map
map.Add("Bird", valSetOne);
map.Add("Cat", valSetTwo);
map.Add("Dog", valSetThree);

foreach(KeyValuePair<string, List<string>> kvp in map){
    foreach(string value in kvp.Value)
    {
       Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, value);
    }
}

Instead of having a foreach loop, is there a faster way to find the key given an animal value?

//EDIT:

Currently trying to initialize with a Tuple

var tupleList = new List<Tuple<string, List<string>>>
{
   new Tuple<string, List<string>>("cat", { "cheetah", "lion"})

};

I'm getting the following error:     Unexpected symbol `{'

Body:
As others have suggested I think you should use classes here. But other responses stop at 1 level of classes. I would recommend a more holistic object-oriented approach.

public abstract class Animal {}

public abstract class Dog : Animal {}
public abstract class Cat : Animal {}
public abstract class Bird : Animal {}

public sealed class Budgie : Bird {}
public sealed class Parrot : Bird {}
public sealed class Pitbull : Dog {}
public sealed class Labrador : Dog {}
public sealed class Cheetah : Cat {}
public sealed class Lion : Cat {}

[note that sealed is optional here]

then you just say

Labrador spot = new Labrador();

to check if it's a dog

if (spot is Dog) {
    print("it's a dog");
}

This solution has the option of being easily extensible, and super easy to read. There's not weird code that distracts you from the fact that a Labrador is a dog, and a budgie is a bird. It's very clear what you're trying to do and what classes Dog, Cat, Cheetah, etc represent.

If you further wanted to split up labradors into Chocolate, Yellow, and Black, you could just add another layer of classes inheriting from Labrador. If you needed to define the properties of the animals, that's easy too. For example if you only wanted Dogs and Cats to have names, you could add a name field in their classes, whereas if you want all animals to have a name you can put the name field in the Animal class.

If you needed to move the animals, you could at the animal level define a method called Move() that forces its children to override this method in their own way, so perhaps dogs would Move() by Walking(), whereas birds would Move() by Flying().

I would seriously recommending abandoning the dictionary and think about using something similar to what I described. If you start to think this way it will really help you plan out more complex projects and tasks. There's a reason Object Oriented Programming is so widespread!


问:
How define style in App.xaml Xamarin Forms for CustomButton?
How I can define style in App.xaml for CustomButton?

App.xaml

```<code> <Style x:Key="CustomButtonSmall" TargetType="CustomButton">
     <Setter Property="FontSize" Value="14" />
 </Style>
</code>```

MyPage.xaml

```<code><local:CustomButton Text="{i18n:Translate CreateAccountButton}"
      Grid.Column="0" Command="{Binding CreateAccountCommand}"
      Type="Normal" Style="{StaticResource CustomButtonSmall}" />
</code>```

答:
You define the style in for example Window.xaml:

```<code><Window>
<Window.Resources>
    <Style x:Key="myStyle" TargetType="Button">
       <Setter Property="Background" Value="Orange" />
       <Setter Property="FontStyle" Value="Italic" />
    </Style>
</Window.Resources>
</code>```

Then u target ur button with this:

```<code> <Button Style="{StaticResource myStyle}">Buttontext</Button>
</code>```

Body:
How I can define style in App.xaml for CustomButton?

App.xaml

MyPage.xaml

<local:CustomButton Text="{i18n:Translate CreateAccountButton}"
      Grid.Column="0" Command="{Binding CreateAccountCommand}"
      Type="Normal" Style="{StaticResource CustomButtonSmall}" />

Body:
You define the style in for example Window.xaml:

<Window>
<Window.Resources>
    <Style x:Key="myStyle" TargetType="Button">
       <Setter Property="Background" Value="Orange" />
       <Setter Property="FontStyle" Value="Italic" />
    </Style>
</Window.Resources>

Then u target ur button with this:

 <Button Style="{StaticResource myStyle}">Buttontext</Button>


问:
Which one to go first, Grails or Groovy?
I wanted to create a web application. I thought of selecting Groovy or Grails. But I don't know from where to start! To start with Groovy or Grails?</p>

答: If you know Java, go directly to grails. Groovy can be used with pure Java syntax, and you'll be learning its special syntax extras on the way.</p>

ContentLicense: CC BY-SA 2.5


问:
Fetch internal data from JSON
I want to fetch inner data from JSON

I have JSON as

```<code>{
"data": [{
    "id": 1,
    "cusname": "KFC Inc.",
    "accno": "31926819",
    "billStatus": "Pending",
    "billID1": {
        "ID": "BILL232244",
        "month": "Aug",
        "amount": "400"
    },
    "billID2": {
        "ID": "BILL232244",
        "month": "Aug",
        "amount": "400"
    },
    "billID1Amount": "Edinburgh",
    "extn": "4/Nov/2107"
}, {
    "id": 2,
    "cusname": "KFC Inc.",
    "accno": "31926819",
    "billStatus": "Pending",
    "billID1": {
        "ID": "BILL232244",
        "month": "Aug",
        "amount": "400"
    },
    "billID2": {
        "ID": "BILL232244",
        "month": "Aug",
        "amount": "400"
    },
    "billID1Amount": "Edinburgh",
    "extn": "4/Nov/2107"
}]
}
</code>```

I want to extract all the values of ID of all billID1 or billID2 for all id in data jsonObject
for Example: I want to get BILL232244 for billID1 & BILL232244 for billID2 for "id":1 and same goes for "id":2

Please suggest logic.

答:
```<code>JSONObject root = new JSONObject(yourJsonString);
JSONArray jsonArray = root.getJSONArray("data");

 for(int i=0; i<jsonArray.length(); i++){
// now loop the element:
JSONObject obj = jsonArray.getJSONObject(i);

String idval = obj.getString("id");
String billid1 = obj.getString("billID1");
String billid2 = obj.getString("billID2");
}
</code>```

Title: Fetch internal data from JSON

Body:
I want to fetch inner data from JSON

I have JSON as

{
"data": [{
    "id": 1,
    "cusname": "KFC Inc.",
    "accno": "31926819",
    "billStatus": "Pending",
    "billID1": {
        "ID": "BILL232244",
        "month": "Aug",
        "amount": "400"
    },
    "billID2": {
        "ID": "BILL232244",
        "month": "Aug",
        "amount": "400"
    },
    "billID1Amount": "Edinburgh",
    "extn": "4/Nov/2107"
}, {
    "id": 2,
    "cusname": "KFC Inc.",
    "accno": "31926819",
    "billStatus": "Pending",
    "billID1": {
        "ID": "BILL232244",
        "month": "Aug",
        "amount": "400"
    },
    "billID2": {
        "ID": "BILL232244",
        "month": "Aug",
        "amount": "400"
    },
    "billID1Amount": "Edinburgh",
    "extn": "4/Nov/2107"
}]
}

I want to extract all the values of ID of all billID1 or billID2 for all id in data jsonObject
for Example: I want to get BILL232244 for billID1 & BILL232244 for billID2 for "id":1 and same goes for "id":2

Please suggest logic.


问:
How to parse data between  and
I want to parse the information between ...	 under Number of samples	.For example, after parsing the following html will return 64.

```<code>...
<tr class="border">
    <th>Average FPKM</th>
    <td colspan="2">0.8</td>
</tr>
<tr class="border">
    <th>Number of samples</th>
    <td colspan="2">64</td>
</tr>
...
</code>```

How to get only return the value 64 here?

Thanks

答:
You can follow this approach with pure Javascript.I assumed the structure of table tr doesn't change.

Select all tr.border

Iterate them and find which one has Number of samples very simply. Then get what you want.

window.onload = () => {
    let tr = document.querySelectorAll('tr.border')
    tr.forEach((elm) => {
        if(elm.innerText.indexOf('Number of samples') == 0)
            console.log(elm.querySelector('td').innerText)
    })
};```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table>
<tr class="border">
    <th>Average FPKM</th>
    <td colspan="2">0.8</td>
</tr>
<tr class="border">
    <th>Number of samples</th>
    <td colspan="2">64</td>
</tr>
</table></code>```

Hope it helps

Title: How to parse data between <td colspan="2"> and </td>

Body:
I want to parse the information between ...	 under Number of samples	.For example, after parsing the following html will return 64.

...

    Average FPKM
    0.8

    Number of samples
    64

...

How to get only return the value 64 here?

Thanks

Body:
You can follow this approach with pure Javascript.I assumed the structure of table tr doesn't change.

Select all tr.border

Iterate them and find which one has Number of samples very simply. Then get what you want.

window.onload = () => {
    let tr = document.querySelectorAll('tr.border')
    tr.forEach((elm) => {
        if(elm.innerText.indexOf('Number of samples') == 0)
            console.log(elm.querySelector('td').innerText)
    })
};

<table>
<tr class="border">
    <th>Average FPKM</th>
    <td colspan="2">0.8</td>
</tr>
<tr class="border">
    <th>Number of samples</th>
    <td colspan="2">64</td>
</tr>
</table>

Hope it helps


问:
Rasa NLU:Entity Synonyms detection inconsistency
Me and my team have been using Rasa NLU as a replacement for MS LUIS for over 2 months now, and it has worked out pretty well for us so far. Now we have around 900 entries as Entity Synonyms(as we were using List entity in LUIS).

And only for some utterances, the entity is detected as synonyms and for the majority of utterances, it is unable to detect Entity Synonyms. In order to detect synonyms, I have to create another simple entity which again we are manually training with all the synonym values, once the intents are trained with this simple Entity Rasa seems to detect entity for this intent as both simple and synonyms.

And another quick question, Is the Entity Synonyms in Rasa designed to return only one matched entity(unlike LUIS which used to return all the matched entities values)?

Is there any alternative to list entity from LUIS here in Rasa?

答:
Firstly, I have downloaded some LUIS model JSON for doing this, as shown in the following screenshot:

Next, I have written a sample C# console app for converting LUIS Model Schema into RASA.

Here is the LUISModel model class.

```<code>using Newtonsoft.Json;
using System;
using System.Collections.Generic;

    namespace JSONConversion.Models
    {

        public class LuisSchema
        {
            public string luis_schema_version { get; set; }
            public string versionId { get; set; }
            public string name { get; set; }
            public string desc { get; set; }
            public string culture { get; set; }
            public List<Intent> intents { get; set; }
            public List<entity> entities { get; set; }
            public object[] composites { get; set; }
            public List<Closedlist> closedLists { get; set; }
            public List<string> bing_entities { get; set; }
            public object[] actions { get; set; }
            public List<Model_Features> model_features { get; set; }
            public List<regex_Features> regex_features { get; set; }
            public List<Utterance> utterances { get; set; }
        }

        public class regex_Features
        {
            public string name { get; set; }
            public string pattern { get; set; }
            public bool activated { get; set; }
        }
        public class Intent
        {
            public string name { get; set; }
        }

        public class entity
        {
            public string name { get; set; }
        }

        public class Closedlist
        {
            public string name { get; set; }
            public List<Sublist> subLists { get; set; }
        }

        public class Sublist
        {
            public string canonicalForm { get; set; }
            public List<string> list { get; set; }
        }

        public class Model_Features
        {
            public string name { get; set; }
            public bool mode { get; set; }
            public string words { get; set; }
            public bool activated { get; set; }
        }

        public class Utterance
        {
            public string text { get; set; }
            public string intent { get; set; }

            [JsonProperty("entities")]
            public List<Entities> Entities { get; set; }
        }

        public class Entities
        {
            [JsonProperty("entity")]
            public string Entity { get; set; }
            public int startPos { get; set; }
            public int endPos { get; set; }
        }
    }
</code>```

Here is the RASAModel model class:

```<code>using Newtonsoft.Json;
using System;
using System.Collections.Generic;

namespace JSONConversion.Models
{
    public class RASASchema
    {
        public Rasa_Nlu_Data rasa_nlu_data { get; set; }
    }

    public class Rasa_Nlu_Data
    {
        public List<Entity_Synonyms> entity_synonyms { get; set; }

        public List<Regex_Features> regex_features { get; set; }
        public List<Common_Examples> common_examples { get; set; }

    }

    public class Entity_Synonyms
    {
        public string value { get; set; }
        public List<string> synonyms { get; set; }
    }

    public class Common_Examples
    {
        public string text { get; set; }
        public string intent { get; set; }
        public List<Entity> entities { get; set; }
    }

    public class Entity
    {
        public string entity { get; set; }
        public string value { get; set; }
        public int start { get; set; }
        public int end { get; set; }
    }

    public class Regex_Features
    {
        public string name { get; set; }
        public string pattern { get; set; }
    }
}
</code>```

And I have written 2 methods which parse the LUISModel model class for synonyms from the phraselist section and adds them in the common_examples object in RASA_NLU training object.

```<code>using JSONConversion.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace JSONConversion.Services
{
    public static class JSONHelper
    {
        public static Task<string> ReadFromFile(string FilePath)
        {
            try
            {
                Task<string> readFromFileTask = Task.Run<string>(() =>
                {
                    return File.ReadAllText(FilePath);
                });
                return readFromFileTask;
            }
            catch(Exception ex)
            {
                throw;
            }
        }

        public static RASASchema ConvertLUISJSON(string StringifiedLUISJson)
        {
            try
            {
                LuisSchema luisSchema = JsonConvert.DeserializeObject<LuisSchema>(StringifiedLUISJson);

                RASASchema rasaSchema = new RASASchema();
                rasaSchema.rasa_nlu_data = new Rasa_Nlu_Data();
                rasaSchema.rasa_nlu_data.common_examples = new List<Common_Examples>();
                rasaSchema.rasa_nlu_data.entity_synonyms = new List<Entity_Synonyms>();
                rasaSchema.rasa_nlu_data.regex_features = new List<Regex_Features>();

                luisSchema.closedLists.ForEach(x =>
                {
                    x.subLists.ForEach(y =>
                    {
                        rasaSchema.rasa_nlu_data.entity_synonyms.Add(new Entity_Synonyms()
                        {
                            value = y.canonicalForm,
                            synonyms = y.list
                        });
                    });
                });

                luisSchema.model_features.ForEach(x =>
                {
                    rasaSchema.rasa_nlu_data.entity_synonyms.Add(new Entity_Synonyms()
                    {
                        value = x.name,
                        synonyms = x.words.Split(',').ToList()
                    });
                });

                luisSchema.regex_features.ForEach(x =>
                {
                    rasaSchema.rasa_nlu_data.regex_features.Add(new Regex_Features()
                    {
                        name = x.name,
                        pattern = x.pattern
                    });
                });

                luisSchema.utterances.ForEach(x =>
                {
                    Common_Examples rasaUtterances = new Common_Examples();
                    rasaUtterances.text = x.text;
                    rasaUtterances.intent = x.intent;

                    List<Entity> listOfRASAEntity = new List<Entity>();

                    x.Entities.ForEach(y =>
                    {
                        listOfRASAEntity.Add(new Entity()
                        {
                            start = y.startPos,
                            end = y.endPos,
                            entity = y.Entity,
                            value = x.text.Substring(y.startPos, (y.endPos - y.startPos) + 1)
                        });
                    });

                    rasaUtterances.entities = listOfRASAEntity;
                    rasaSchema.rasa_nlu_data.common_examples.Add(rasaUtterances);
                });

                return rasaSchema;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
    }
}
</code>```

And just called those JSON conversion methods to convert LUIS Models into RASA models.

```<code>using System.Text;
using JSONConversion.Services;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace JSONConversion
{
    class Program
    {
        static void Main(string[] args)
        {

            string json = JsonConvert.SerializeObject(JSONConversion.Services.JSONHelper.ConvertLUISJSON(JSONHelper.ReadFromFile(@"C:\Users\xyz\Documents\luis.json").Result), new JsonSerializerSettings()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                Formatting = Formatting.Indented
            });

            File.WriteAllText(@"C:\Users\xyz\Desktop\RASA\data\examples\RasaFormat.json", json, Encoding.UTF8);

        }
    }
}
</code>```

After getting the RASA model, you can just simply train RASA for synonyms.

Body:
Firstly, I have downloaded some LUIS model JSON for doing this, as shown in the following screenshot:

Next, I have written a sample C# console app for converting LUIS Model Schema into RASA.

Here is the LUISModel model class.

using Newtonsoft.Json;
using System;
using System.Collections.Generic;

    namespace JSONConversion.Models
    {

        public class LuisSchema
        {
            public string luis_schema_version { get; set; }
            public string versionId { get; set; }
            public string name { get; set; }
            public string desc { get; set; }
            public string culture { get; set; }
            public List<Intent> intents { get; set; }
            public List<entity> entities { get; set; }
            public object[] composites { get; set; }
            public List<Closedlist> closedLists { get; set; }
            public List<string> bing_entities { get; set; }
            public object[] actions { get; set; }
            public List<Model_Features> model_features { get; set; }
            public List<regex_Features> regex_features { get; set; }
            public List<Utterance> utterances { get; set; }
        }

        public class regex_Features
        {
            public string name { get; set; }
            public string pattern { get; set; }
            public bool activated { get; set; }
        }
        public class Intent
        {
            public string name { get; set; }
        }

        public class entity
        {
            public string name { get; set; }
        }

        public class Closedlist
        {
            public string name { get; set; }
            public List<Sublist> subLists { get; set; }
        }

        public class Sublist
        {
            public string canonicalForm { get; set; }
            public List<string> list { get; set; }
        }

        public class Model_Features
        {
            public string name { get; set; }
            public bool mode { get; set; }
            public string words { get; set; }
            public bool activated { get; set; }
        }

        public class Utterance
        {
            public string text { get; set; }
            public string intent { get; set; }

            [JsonProperty("entities")]
            public List<Entities> Entities { get; set; }
        }

        public class Entities
        {
            [JsonProperty("entity")]
            public string Entity { get; set; }
            public int startPos { get; set; }
            public int endPos { get; set; }
        }
    }

Here is the RASAModel model class:

using Newtonsoft.Json;
using System;
using System.Collections.Generic;

namespace JSONConversion.Models
{
    public class RASASchema
    {
        public Rasa_Nlu_Data rasa_nlu_data { get; set; }
    }

    public class Rasa_Nlu_Data
    {
        public List<Entity_Synonyms> entity_synonyms { get; set; }

        public List<Regex_Features> regex_features { get; set; }
        public List<Common_Examples> common_examples { get; set; }

    }

    public class Entity_Synonyms
    {
        public string value { get; set; }
        public List<string> synonyms { get; set; }
    }

    public class Common_Examples
    {
        public string text { get; set; }
        public string intent { get; set; }
        public List<Entity> entities { get; set; }
    }

    public class Entity
    {
        public string entity { get; set; }
        public string value { get; set; }
        public int start { get; set; }
        public int end { get; set; }
    }

    public class Regex_Features
    {
        public string name { get; set; }
        public string pattern { get; set; }
    }
}

And I have written 2 methods which parse the LUISModel model class for synonyms from the phraselist section and adds them in the common_examples object in RASA_NLU training object.

using JSONConversion.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace JSONConversion.Services
{
    public static class JSONHelper
    {
        public static Task<string> ReadFromFile(string FilePath)
        {
            try
            {
                Task<string> readFromFileTask = Task.Run<string>(() =>
                {
                    return File.ReadAllText(FilePath);
                });
                return readFromFileTask;
            }
            catch(Exception ex)
            {
                throw;
            }
        }

        public static RASASchema ConvertLUISJSON(string StringifiedLUISJson)
        {
            try
            {
                LuisSchema luisSchema = JsonConvert.DeserializeObject<LuisSchema>(StringifiedLUISJson);

                RASASchema rasaSchema = new RASASchema();
                rasaSchema.rasa_nlu_data = new Rasa_Nlu_Data();
                rasaSchema.rasa_nlu_data.common_examples = new List<Common_Examples>();
                rasaSchema.rasa_nlu_data.entity_synonyms = new List<Entity_Synonyms>();
                rasaSchema.rasa_nlu_data.regex_features = new List<Regex_Features>();

                luisSchema.closedLists.ForEach(x =>
                {
                    x.subLists.ForEach(y =>
                    {
                        rasaSchema.rasa_nlu_data.entity_synonyms.Add(new Entity_Synonyms()
                        {
                            value = y.canonicalForm,
                            synonyms = y.list
                        });
                    });
                });

                luisSchema.model_features.ForEach(x =>
                {
                    rasaSchema.rasa_nlu_data.entity_synonyms.Add(new Entity_Synonyms()
                    {
                        value = x.name,
                        synonyms = x.words.Split(',').ToList()
                    });
                });

                luisSchema.regex_features.ForEach(x =>
                {
                    rasaSchema.rasa_nlu_data.regex_features.Add(new Regex_Features()
                    {
                        name = x.name,
                        pattern = x.pattern
                    });
                });

                luisSchema.utterances.ForEach(x =>
                {
                    Common_Examples rasaUtterances = new Common_Examples();
                    rasaUtterances.text = x.text;
                    rasaUtterances.intent = x.intent;

                    List<Entity> listOfRASAEntity = new List<Entity>();

                    x.Entities.ForEach(y =>
                    {
                        listOfRASAEntity.Add(new Entity()
                        {
                            start = y.startPos,
                            end = y.endPos,
                            entity = y.Entity,
                            value = x.text.Substring(y.startPos, (y.endPos - y.startPos) + 1)
                        });
                    });

                    rasaUtterances.entities = listOfRASAEntity;
                    rasaSchema.rasa_nlu_data.common_examples.Add(rasaUtterances);
                });

                return rasaSchema;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
    }
}

And just called those JSON conversion methods to convert LUIS Models into RASA models.

using System.Text;
using JSONConversion.Services;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace JSONConversion
{
    class Program
    {
        static void Main(string[] args)
        {

            string json = JsonConvert.SerializeObject(JSONConversion.Services.JSONHelper.ConvertLUISJSON(JSONHelper.ReadFromFile(@"C:\Users\xyz\Documents\luis.json").Result), new JsonSerializerSettings()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                Formatting = Formatting.Indented
            });

            File.WriteAllText(@"C:\Users\xyz\Desktop\RASA\data\examples\RasaFormat.json", json, Encoding.UTF8);

        }
    }
}

After getting the RASA model, you can just simply train RASA for synonyms.


答:
Are you sure "draw" is one of the key of word_dict? check your dictionary.</p>

```<code>    >>> word_dict = {"draw":1,"xx":2}
    >>> print ("draw" in word_dict)
    True
    >>>
</code>```

Title: Dictionary keys and strings

Body:
Are you sure "draw" is one of the key of word_dict? check your dictionary.

    >>> word_dict = {"draw":1,"xx":2}
    >>> print ("draw" in word_dict)
    True
    >>>


问:
Run TestNG Tests in Parallel with Maven and Pass Parameter with Maven
I use @Parameters("DeviceModel") in my Tests
I run parallel 3 threads via testNG.xml file.
In TestNG.XML I pass 3 parameters.

```<code>1-st parameter: <parameter name="DeviceModel" value="devicemodel1">
2-nd parameter: <parameter name="DeviceModel" value="devicemodel2">
3-rd parameter: <parameter name="DeviceModel" value="devicemodel3">
</code>```

When testNG.xml is executing it takes 1-st param for thread1, 2-nd param for thread 2, and 3-rd for thread 3.
Thus i get 3 parallel threads with different params each.

Now i wish to do a parallel test via Maven SureFire plugin with TestNG.
I pass following values in pom.xml

```<code><groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<parallel>tests</parallel>
<threadCount>3</threadCount>
<includes>
<include>packageName/*Test.java</include>
</includes>
<systemPropertyVariables>
<DeviceModel>devicemodel1</DeviceModel>
<DeviceModel>devicemodel1</DeviceModel>
<DeviceModel>devicemodel1</DeviceModel>
</systemPropertyVariables>
</configuration>
</code>```

This does not work.
My Test executs only the third parameter for each thread.
How i can pass 3 different parameters to TestNg for 3 parallel threads with maven?

答:
It is possible to continue using the TestNG.xml also with Maven.

In this example the suite file TestNG.xml is located in src/test/resources subfolder:

```<code><build>
    <testResources>
        <testResource>
            <directory>src/test/resources</directory>
            <filtering>true</filtering>
        </testResource>
    </testResources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>src/test/resources/TestNG.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>
</code>```

Body:
I use @Parameters("DeviceModel") in my Tests
I run parallel 3 threads via testNG.xml file.
In TestNG.XML I pass 3 parameters.

1-st parameter: <parameter name="DeviceModel" value="devicemodel1">
2-nd parameter: <parameter name="DeviceModel" value="devicemodel2">
3-rd parameter: <parameter name="DeviceModel" value="devicemodel3">

When testNG.xml is executing it takes 1-st param for thread1, 2-nd param for thread 2, and 3-rd for thread 3.
Thus i get 3 parallel threads with different params each.

Now i wish to do a parallel test via Maven SureFire plugin with TestNG.
I pass following values in pom.xml

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<parallel>tests</parallel>
<threadCount>3</threadCount>
<includes>
<include>packageName/*Test.java</include>
</includes>
<systemPropertyVariables>
<DeviceModel>devicemodel1</DeviceModel>
<DeviceModel>devicemodel1</DeviceModel>
<DeviceModel>devicemodel1</DeviceModel>
</systemPropertyVariables>
</configuration>

This does not work.
My Test executs only the third parameter for each thread.
How i can pass 3 different parameters to TestNg for 3 parallel threads with maven?

Body:
It is possible to continue using the TestNG.xml also with Maven.

In this example the suite file TestNG.xml is located in src/test/resources subfolder:

<build>
    <testResources>
        <testResource>
            <directory>src/test/resources</directory>
            <filtering>true</filtering>
        </testResource>
    </testResources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>src/test/resources/TestNG.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>


问:
Regular Expression to match with exclusion of some pattern
I have a text

<1.1.1>This is para one with <1.1.2>more than five words. I <1.1.3>is trying to test grammar <1.1.4>API with this. <1.2.1>This are para two, let's <1.2.2>test it. I am using <1.2.3>it <1.3.1>

In this I want to match

 is para one with more than five words. I is trying to test grammar API with this. T

I have tried one reg ex

(?:(\<([0-9]*\.[0-9]*\.[0-9]*)\>))(This is para one with more)

I want in result as below :

 is para one with <1.1.2>more than five words. I <1.1.3>is trying to test grammar <1.1.4>API with this. <1.2.1>T

but not able to find solution, how I can match exclude word recursively.

答:
You can do

let str = "<1.1.1>This is para one with <1.1.2>more than five words. I <1.1.3>is trying to test grammar <1.1.4>API with this. <1.2.1>This are para two, let's <1.2.2>test it. I am using <1.2.3>it <1.3.1>";

str = str.replace(/<\d\.\d\.\d>/g, '');

console.log(str);```


问:
how to link the cells with numbers? python 3 (I tried zip function and another ways)
I'm attempting to replace each zero into the specific odd number in ascending order. For instance: I have a raw with this list of lists [[0], [0, 0], [0,0,0] and etc.] and I need to get this: [[1], [3,5], [7,9,11], [13,15,17,19] and etc.]

```<code>def x(n):
    obj = iter(list(range(1, 100, 2)))
    odds = list(range(1, 100, 2))
    a =[y*[0] for y,x in enumerate(odds,1)]
    for i in range(0,50):
        a[i] = next(obj)
    return odds
print(x(10))
</code>```

I need a small hint. How continue/fix this code.

Body:
I'm attempting to replace each zero into the specific odd number in ascending order. For instance: I have a raw with this list of lists [[0], [0, 0], [0,0,0] and etc.] and I need to get this: [[1], [3,5], [7,9,11], [13,15,17,19] and etc.]

def x(n):
    obj = iter(list(range(1, 100, 2)))
    odds = list(range(1, 100, 2))
    a =[y*[0] for y,x in enumerate(odds,1)]
    for i in range(0,50):
        a[i] = next(obj)
    return odds
print(x(10))

I need a small hint. How continue/fix this code.

Body:
Here is a solution that works on arbitrary depth list-of-list-of-list...s. It uses itertools.count, list comprehension and recursion.

import random
import itertools

def create(minchld = 2, mxchld = 4, p0 = 0.5, mxdpth = 4):
    return [0 if mxdpth==0 or random.random() < p0 else create(minchld, mxchld, p0, mxdpth-1)
            for i in range(random.randint(minchld, mxchld))]

def fill(zeros):
    odd = itertools.count(start=1, step=2)
    def replace(zeros):
        return [next(odd) if i==0 else replace(i) for i in zeros]
    return replace(zeros)

zeros = create()
print(zeros)
print(fill(zeros))

Sample runs:

# [[0, 0, [0, 0, 0]], 0, [0, 0, [[0, 0, [0, 0]], [[0, 0, 0], 0, 0], 0, 0], 0], 0]
# [[1, 3, [5, 7, 9]], 11, [13, 15, [[17, 19, [21, 23]], [[25, 27, 29], 31, 33], 35, 37], 39], 41]

# [0, [0, [0, [0, 0]]]]
# [1, [3, [5, [7, 9]]]]

# [[[0, [0, [0, 0]], [[0, 0, 0, 0], 0], [[0, 0], 0]], 0, 0, [[[0, 0, 0], [0, 0, 0, 0], [0, 0, 0], [0, 0, 0]], 0, 0]], 0]
# [[[1, [3, [5, 7]], [[9, 11, 13, 15], 17], [[19, 21], 23]], 25, 27, [[[29, 31, 33], [35, 37, 39, 41], [43, 45, 47], [49, 51, 53]], 55, 57]], 59]


问:
unable to access DB pod External IP from application
I've created two pods top of Azure Kubernetes cluster
1) Application
2) MS SQL server

both pods are exposed via Azure Loadbalancer and both having External IPs. I am unable to use the External IP in my application config file. But I can connect that SQL Server from anywhere. For some reason I am unable to telnet DB IP from Application container.

the connection is getting timeout. but I can ping/telnet the DB's cluster ip. So I have tried to use the DB cluster IP in my config file to check if the connection is successful but no luck.

Could someone help me with this ?

答:
This issue was fixed in other way. But still running a Application & DB as separate service is night mare in Azure container service(Kubernetes).

1) I've combined App+DB in same container and put the DB connection string as "localhost" or "localhost,1433" is my application config file.

2) Created Docker image with above setup

3) Created pod

4) Exposed pod with two listening ports "kubectl expose pods "xxx" --port=80,1433 --type=LoadBalancer

5) I can access the DB with 1433

In the above setup, we have planned to keep the container in auto scaled environment with persistent volume storage
Also we are planning to do the scheduled backup of container, So we do not want to loose the DB data.

Is anybody having other thoughts, what the major issue factors we need to consider in above setup ??


问:
My page scrolls horizontally on mobile
I just found out that my website is scrolling horizontally on mobile. However, I am not able to find out why this is happening.

The containers and body seem to have the correct width when I check it in my browser.

Any idea?

https://www.urban-zweirad.de

Cheers,
Mark

答:
There is some extra margin on your header or navigation which is having more width than your body/container.

add overflow-x:hidden in body

```<code>body{
    overflow-x:hidden
}
</code>```

Title: My page scrolls horizontally on mobile

Body:
There is some extra margin on your header or navigation which is having more width than your body/container.

add overflow-x:hidden in body

body{
    overflow-x:hidden
}


问:
Laravel Database Seeder Class
Here is my DatabaseSeeder Class Code

```<code><?php

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

        $this->call(
            AdminSeeder::class,
            CategorySeeder::class,
            UsersSeeder::class,);
    }
}
</code>```

My php Artisan Command is: php artisan db:seed
I want to migrate all Seeder class by one commad. but I can't do it. pls help me.

答:
The call() method expects an array, not a list of arguments, so the proper invocation is

```<code>    $this->call([
        AdminSeeder::class,
        CategorySeeder::class,
        UsersSeeder::class,
    ]);
</code>```

The key here is that array is accepted since version 5.5 of Laravel framework. Previously, including v5.4 you are now using, only allowed single class name (string) as argument. So if you cannot upgrade to 5.5, you need to call all the classes separately, i.e.:

```<code>    $cls = [
        AdminSeeder::class,
        CategorySeeder::class,
        UsersSeeder::class,
    ];
    foreach ($cls as $c) {
       $this->call($c);
    }
</code>```

Docs for v5.4 and docs for v5.5

Title: Laravel Database Seeder Class

Body:
Here is my DatabaseSeeder Class Code

<?php

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

        $this->call(
            AdminSeeder::class,
            CategorySeeder::class,
            UsersSeeder::class,);
    }
}

My php Artisan Command is: php artisan db:seed
I want to migrate all Seeder class by one commad. but I can't do it. pls help me.

Body:
The call() method expects an array, not a list of arguments, so the proper invocation is

    $this->call([
        AdminSeeder::class,
        CategorySeeder::class,
        UsersSeeder::class,
    ]);

The key here is that array is accepted since version 5.5 of Laravel framework. Previously, including v5.4 you are now using, only allowed single class name (string) as argument. So if you cannot upgrade to 5.5, you need to call all the classes separately, i.e.:

    $cls = [
        AdminSeeder::class,
        CategorySeeder::class,
        UsersSeeder::class,
    ];
    foreach ($cls as $c) {
       $this->call($c);
    }

Docs for v5.4 and docs for v5.5


问:
FormulaR1C1 and "=SUMIFS("
I'm trying to add up all the units that are in occupied locations in a specific location type depending on BUcode and Division of the business.

Note:

  - Variables binshelv and occupied are defined names in the worksheet.

  - Variables Division and BUcode are defined in the parent code that calls and passes along the values to this procedure.

Below is the code I am trying to enter:

```<code>ActiveCell.FormulaR1C1 = _
    "=IF(" & _
        "" & BUcode & "=Overall," & _
        "if(" & _
                "" & Division & "=Overall, " & _
                "SUMIFS(" & _
                        "DataDump[On Hand Qty (Units)]," & _
                        "DataDump[Occupied?], occupied," & _
                        "DataDump[Location Short Description], binshelv" & _
                ")," & _
                "Sumifs(" & _
                        "DataDump[On Hand Qty (Units)]," & _
                        "DataDump[Occupied?], occupied," & _
                        "DataDump[Location Short Description], binshelv," & _
                        "DataDump[Division Code], " & DivCode & "," & _
                ")" & _
        ")," & _
        "SUMIFS(" & _
                "DataDump[On Hand Qty (Units)]," & _
                "DataDump[Business Unit]," & BUcode & "," & _
                "DataDump[Location Short Description], binshelv" & _
        ")" & _

    ")"
</code>```

Why I'm currently getting Error '1004'?

答:
It seems that the problem is that your formula does not equate to a valid string.  If you copy and paste the following code into the VBA editor you will see that strFormula does not equate to a valid string.  This means you've got an error in the formula.  One thing to remember is that you need to double quote quotation marks in your formula, or use escape characters, to use literal quotes in a string.

Play around with trying to get "strFormula =" to equate to a valid string.

```<code>Sub aa()

    Dim strFormula As String
    Dim binshelv, occupied, Division, BUcode As String

    ' **--- Get this line to equate to a valid string**
    strFormula = _
    "=IF(" & _
    "" & BUcode & "=Overall," & _
    "if(" & _
            "" & Division & "=Overall, " & _
            "SUMIFS(" & _
                    "DataDump[On Hand Qty (Units)]," & _
                    "DataDump[Occupied?], occupied," & _
                    "DataDump[Location Short Description], binshelv" & _
            ")," & _
            "Sumifs(" & _
                    "DataDump[On Hand Qty (Units)]," & _
                    "DataDump[Occupied?], occupied," & _
                    "DataDump[Location Short Description], binshelv," & _
                    "DataDump[Division Code], " & DivCode & "," & _
            ")" & _
    ")," & _
    "SUMIFS(" & _
            "DataDump[On Hand Qty (Units)]," & _
            "DataDump[Business Unit]," & BUcode & "," & _
            "DataDump[Location Short Description], binshelv" & _
    ")" & _
    ")"

    ActiveCell.FormulaR1C1 = strFormula
End Sub
</code>```

Using double quotes to express a literal quote mark turns

```<code>=SUMIFS(C8:C11,A8:A11,"colACriteria",B8:B11,"ColBCriteria")
</code>```

into

```<code>"=SUMIFS(C8:C11,A8:A11,""colACriteria"",B8:B11,""ColBCriteria"")"
</code>```

Title: FormulaR1C1 and "=SUMIFS("

Body:
I'm trying to add up all the units that are in occupied locations in a specific location type depending on BUcode and Division of the business.

Note:

  - Variables binshelv and occupied are defined names in the worksheet.

  - Variables Division and BUcode are defined in the parent code that calls and passes along the values to this procedure.

Below is the code I am trying to enter:

ActiveCell.FormulaR1C1 = _
    "=IF(" & _
        "" & BUcode & "=Overall," & _
        "if(" & _
                "" & Division & "=Overall, " & _
                "SUMIFS(" & _
                        "DataDump[On Hand Qty (Units)]," & _
                        "DataDump[Occupied?], occupied," & _
                        "DataDump[Location Short Description], binshelv" & _
                ")," & _
                "Sumifs(" & _
                        "DataDump[On Hand Qty (Units)]," & _
                        "DataDump[Occupied?], occupied," & _
                        "DataDump[Location Short Description], binshelv," & _
                        "DataDump[Division Code], " & DivCode & "," & _
                ")" & _
        ")," & _
        "SUMIFS(" & _
                "DataDump[On Hand Qty (Units)]," & _
                "DataDump[Business Unit]," & BUcode & "," & _
                "DataDump[Location Short Description], binshelv" & _
        ")" & _

    ")"

Why I'm currently getting Error '1004'?

Body:
It seems that the problem is that your formula does not equate to a valid string.  If you copy and paste the following code into the VBA editor you will see that strFormula does not equate to a valid string.  This means you've got an error in the formula.  One thing to remember is that you need to double quote quotation marks in your formula, or use escape characters, to use literal quotes in a string.

Play around with trying to get "strFormula =" to equate to a valid string.

Sub aa()

    Dim strFormula As String
    Dim binshelv, occupied, Division, BUcode As String

    ' **--- Get this line to equate to a valid string**
    strFormula = _
    "=IF(" & _
    "" & BUcode & "=Overall," & _
    "if(" & _
            "" & Division & "=Overall, " & _
            "SUMIFS(" & _
                    "DataDump[On Hand Qty (Units)]," & _
                    "DataDump[Occupied?], occupied," & _
                    "DataDump[Location Short Description], binshelv" & _
            ")," & _
            "Sumifs(" & _
                    "DataDump[On Hand Qty (Units)]," & _
                    "DataDump[Occupied?], occupied," & _
                    "DataDump[Location Short Description], binshelv," & _
                    "DataDump[Division Code], " & DivCode & "," & _
            ")" & _
    ")," & _
    "SUMIFS(" & _
            "DataDump[On Hand Qty (Units)]," & _
            "DataDump[Business Unit]," & BUcode & "," & _
            "DataDump[Location Short Description], binshelv" & _
    ")" & _
    ")"

    ActiveCell.FormulaR1C1 = strFormula
End Sub

Using double quotes to express a literal quote mark turns

=SUMIFS(C8:C11,A8:A11,"colACriteria",B8:B11,"ColBCriteria")

into

"=SUMIFS(C8:C11,A8:A11,""colACriteria"",B8:B11,""ColBCriteria"")"


问:
Adding group permission to directory without changing group ownership?
I have a directory called "music" and two groups: music, singers.

I executed

```<code>chgrp music music
</code>```

I am looking to grant read and write access to the /music directory for the singers group, but I don't want to change the ownership.

Is this possible?

I am a bit confused with chown and chgrp. I believe chown changes ownership for a single user and not a group? and chgrp changes the group?

Is there a way to set group ownership, but grant permissions to another group?

答: You can change the group with chgrp command. Take a look at the first answer here</p>

Body:
I have a directory called "music" and two groups: music, singers.

I executed

chgrp music music

I am looking to grant read and write access to the /music directory for the singers group, but I don't want to change the ownership.

Is this possible?

I am a bit confused with chown and chgrp. I believe chown changes ownership for a single user and not a group? and chgrp changes the group?

Is there a way to set group ownership, but grant permissions to another group?


问:
Change temporary directory
I am using R on windows and need to change the temporary directory where tmp files are stored.

I checked a few answers, here, in R-help, etc., but no one is working.

Some links I tried: here, here, and here.

After trying those answers (I have to say that I do not get exactly the point on them),
tempdir() still is the default, as much as I try different ways.

Can anybody can give a detailed example procedure of how to do this?

My session Info:

```<code>R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] tools_2.15.2
</code>```

答:
In windows, for me what worked is creating a file named Renviron.site and filling it with

```<code>TMPDIR=E:/rtemp
TMP=E:/rtemp
TEMP=E:/rtemp
</code>```

Where E:/rtemp was the path to the directory where I wanted the temporary files.
So you create a new text file, fill it with the above, and change its name (and extension) to Renviron.site.

Put it inside the R installation directory, in the directory etc (e.g. C:\Program Files\R\R-3.3.2\etc)

Obviously, you need to restart R studio for the change to work! (I use R studio but it should work in R also).

For me, this change allowed me to run a script of species distribution modeling which was creating very large temporary files on the system partition, consuming all the space and killing the process in the end. I have moved the temp files to a usb SSD disk (partition E:), and voila, it worked.

PS - the answer was in one of the links you mentioned.

Title: Change temporary directory

Body:
I am using R on windows and need to change the temporary directory where tmp files are stored.

I checked a few answers, here, in R-help, etc., but no one is working.

Some links I tried: here, here, and here.

After trying those answers (I have to say that I do not get exactly the point on them),
tempdir() still is the default, as much as I try different ways.

Can anybody can give a detailed example procedure of how to do this?

My session Info:

R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] tools_2.15.2

Body:
In windows, for me what worked is creating a file named Renviron.site and filling it with

TMPDIR=E:/rtemp
TMP=E:/rtemp
TEMP=E:/rtemp

Where E:/rtemp was the path to the directory where I wanted the temporary files.
So you create a new text file, fill it with the above, and change its name (and extension) to Renviron.site.

Put it inside the R installation directory, in the directory etc (e.g. C:\Program Files\R\R-3.3.2\etc)

Obviously, you need to restart R studio for the change to work! (I use R studio but it should work in R also).

For me, this change allowed me to run a script of species distribution modeling which was creating very large temporary files on the system partition, consuming all the space and killing the process in the end. I have moved the temp files to a usb SSD disk (partition E:), and voila, it worked.

PS - the answer was in one of the links you mentioned.


问:
question on tomcat for serving of webapps and web-inf

There is a project deployed in Tomcat.

The web-app of course in is webapps of tomcat and the structure is as follows:

```<code>tomcat-home
|--webapps
       |
        -MyProject
                 |
                  -WEB-INF
                  -startingPoint.js
                  -client
                  -other dirs etc
</code>```

Now startingPoint.js is a javascript file that essentially loads an applet in the browser and is similar to this:

```<code>document.write('<OBJECT ');
document.write('  codebase = "jre.exe" WIDTH = "100%" HEIGHT = "100%" MAYSCRIPT > ');
document.write('  <PARAM NAME = CODE VALUE = "com/AnApplet.class" > ');
document.write('  <PARAM NAME = CODEBASE VALUE = "/MyProject/client/classes" >');
document.write('  <PARAM NAME = ARCHIVE VALUE = "/MyProject/client/lib/Appletclient.jar"> ');
document.write('  <PARAM NAME = "type" VALUE = "application/x-java-applet;version=1.6"> ');
document.write('  <PARAM NAME = "MAYSCRIPT" VALUE="true"> ');
etc.
</code>```

If I write in the IE url bar the url:

http://ip:port/MyProject  (tomcat is running of course) the applet is loaded in my browser but I can not understand how.

I mean from web.xml I can not see something that would serve the javascript file.

If a js file is in the roor directory of my project, does it get automatically served?

I feel I am missing something here.

Could someone please advice, what is it here I should be looking for?

Thanks

答:
Either this .js is included in your welcome-page specified in web.xml or in index page ,

That page will get loaded and with that if js is included it will load.

Body:
There is a project deployed in Tomcat.

The web-app of course in is webapps of tomcat and the structure is as follows:

tomcat-home
|--webapps
       |
        -MyProject
                 |
                  -WEB-INF
                  -startingPoint.js
                  -client
                  -other dirs etc

Now startingPoint.js is a javascript file that essentially loads an applet in the browser and is similar to this:

document.write('<OBJECT ');
document.write('  codebase = "jre.exe" WIDTH = "100%" HEIGHT = "100%" MAYSCRIPT > ');
document.write('  <PARAM NAME = CODE VALUE = "com/AnApplet.class" > ');
document.write('  <PARAM NAME = CODEBASE VALUE = "/MyProject/client/classes" >');
document.write('  <PARAM NAME = ARCHIVE VALUE = "/MyProject/client/lib/Appletclient.jar"> ');
document.write('  <PARAM NAME = "type" VALUE = "application/x-java-applet;version=1.6"> ');
document.write('  <PARAM NAME = "MAYSCRIPT" VALUE="true"> ');
etc.

If I write in the IE url bar the url:

http://ip:port/MyProject  (tomcat is running of course) the applet is loaded in my browser but I can not understand how.

I mean from web.xml I can not see something that would serve the javascript file.

If a js file is in the roor directory of my project, does it get automatically served?

I feel I am missing something here.

Could someone please advice, what is it here I should be looking for?

Thanks


问:
MongoDB query: filter and exclude fields
I have the following data structure:

```<code>{
"groups" : [
    {
        "internalName" : "Group1",
        "fields" : [
            {
                "internalName" : "Field1",
                "uiProperties" : {
                    "isShow" : true
                }
            },
            {
                "internalName" : "Field2",
                "uiProperties" : {
                    "isHide" : false
                }
            }
        ]
    },
    {
        "internalName" : "Group2",
        "fields" : [
            {
                "internalName" : "Field1",
                "uiProperties" : {
                    "IsHide" : false
                }
            }
        ]
    }
],
"internalName" : "Layout1"
},
{
"groups" : [
    {
        "internalName" : "Group3",
        "fields" : [
            {
                "internalName" : "Field2",
                "uiProperties" : {
                    "isShow" : true
                }
            },
            {
                "internalName" : "Field4",
                "uiProperties" : {
                    "isHide" : false
                }
            }
        ]
    },
    {
        "internalName" : "Group4",
        "fields" : [
            {
                "internalName" : "Field3",
                "uiProperties" : {
                    "IsHide" : false
                }
            }
        ]
    }
],
"internalName" : "Layout2"
}
</code>```

The goal is filter this data by fields internal names and return only needed data - only groups which contain only fields with selected internal names. For example with data above:
Filtered internal names - "Field2", "Field4"
Expected data to return:

```<code>{
"internalName" : "Layout1",
"groups" : [
    {
        "internalName" : "Group1",
        "fields" : [
            {
                "internalName" : "Field2",
                "uiProperties" : {
                    "isHide" : false
                }
            }
        ]
    }
]
},
{
"internalName" : "Layout2",
"groups" : [
    {
        "internalName" : "Group3",
        "fields" : [
            {
                "internalName" : "Field4",
                "uiProperties" : {
                    "isHide" : false
                }
            }
        ]
    }
]
}
</code>```

I'm try something like that

```<code>{
        $match: {
            "groups.fields.internalName": {
                $in: ["Field2", "Field4"]
            }
        }
   },
   {
        $unwind: "$groups"
   },
   {
        $unwind: "$groups.fields"
   },
   {
        $group: {
            _id:"$_id",
            internalName: {
                 $first: "$internalName",
            },
            groups:{
                 $push: {
                      internalName: "$groups.internalName",
                      fields: "$groups.fields"
                 }
            }
        }
    }
</code>```

But it's not worked well..
Can you help me with it?

答:
There is an error in your aggregation pipeline.. First unwind the group elements and then the fields element

```<code>{
  {$unwind: "$groups"},
  {$unwind: "$groups.fields"},
  {$match: {"groups.fields.internalName", {$eq: {$or: ["Field2", "Field4",...]}}}},

}
</code>```

Later group it the way you have done it.

Body:
I have the following data structure:

{
"groups" : [
    {
        "internalName" : "Group1",
        "fields" : [
            {
                "internalName" : "Field1",
                "uiProperties" : {
                    "isShow" : true
                }
            },
            {
                "internalName" : "Field2",
                "uiProperties" : {
                    "isHide" : false
                }
            }
        ]
    },
    {
        "internalName" : "Group2",
        "fields" : [
            {
                "internalName" : "Field1",
                "uiProperties" : {
                    "IsHide" : false
                }
            }
        ]
    }
],
"internalName" : "Layout1"
},
{
"groups" : [
    {
        "internalName" : "Group3",
        "fields" : [
            {
                "internalName" : "Field2",
                "uiProperties" : {
                    "isShow" : true
                }
            },
            {
                "internalName" : "Field4",
                "uiProperties" : {
                    "isHide" : false
                }
            }
        ]
    },
    {
        "internalName" : "Group4",
        "fields" : [
            {
                "internalName" : "Field3",
                "uiProperties" : {
                    "IsHide" : false
                }
            }
        ]
    }
],
"internalName" : "Layout2"
}

The goal is filter this data by fields internal names and return only needed data - only groups which contain only fields with selected internal names. For example with data above:
Filtered internal names - "Field2", "Field4"
Expected data to return:

{
"internalName" : "Layout1",
"groups" : [
    {
        "internalName" : "Group1",
        "fields" : [
            {
                "internalName" : "Field2",
                "uiProperties" : {
                    "isHide" : false
                }
            }
        ]
    }
]
},
{
"internalName" : "Layout2",
"groups" : [
    {
        "internalName" : "Group3",
        "fields" : [
            {
                "internalName" : "Field4",
                "uiProperties" : {
                    "isHide" : false
                }
            }
        ]
    }
]
}

I'm try something like that

{
        $match: {
            "groups.fields.internalName": {
                $in: ["Field2", "Field4"]
            }
        }
   },
   {
        $unwind: "$groups"
   },
   {
        $unwind: "$groups.fields"
   },
   {
        $group: {
            _id:"$_id",
            internalName: {
                 $first: "$internalName",
            },
            groups:{
                 $push: {
                      internalName: "$groups.internalName",
                      fields: "$groups.fields"
                 }
            }
        }
    }

But it's not worked well..
Can you help me with it?

Body:
There is an error in your aggregation pipeline.. First unwind the group elements and then the fields element

{
  {$unwind: "$groups"},
  {$unwind: "$groups.fields"},
  {$match: {"groups.fields.internalName", {$eq: {$or: ["Field2", "Field4",...]}}}},

}

Later group it the way you have done it.


问:
are there any gotchas for hosting a Silverlight app on a Linux server?
I'm building a new Silverlight app for a photography studio. I was about to say "you have to have a Windows-based server hosting it" and then I thought, wait is that right? Looks like it's not. So I could point him toward a Linux host.

I know you have to register the MIME types (from a different SO thread). Are there any other caveats or gotchas that I need to know about? Assume for a second that I know next to nothing about Linux.

Edit: what if the app needs to talk to a database (mySQL)? Seems like I'd need to have Moonlight to get that going, which isn't gonna fly.

答: Regarding your edit (on mysql) -- no you would not need Moonlight (as that is client only as well).  You'd need to expose your database functionality through a service layer of sorts as Shawn notes.</p>

OwnerDisplayName: jcollum

LastEditorDisplayName: jcollum

OwnerDisplayName: timheuer


问:
how to convert HH:MM representation to minutes in oracle sql
how to convert varchar(hh:mm) to minutes in oracle sql.

For example:

```<code>HH:MM    Minutes
08:00    480
08:45    525
07:57    477
</code>```

答:
If you require to Print 08:00 hours as 480 minutes,

Extract the Digit before : and multply with 60 and add the digit after :. So you can convert the HH:MM representation in to minutes.

```<code>SELECT REGEXP_SUBSTR(ATT.workdur,'[^:]+',1,1)*60 + REGEXP_SUBSTR(ATT.workdur,'[^:]+',1,2) MINUTES FROM DUAL;
</code>```

Body:
how to convert varchar(hh:mm) to minutes in oracle sql.

For example:

HH:MM    Minutes
08:00    480
08:45    525
07:57    477

Body:
If you require to Print 08:00 hours as 480 minutes,

Extract the Digit before : and multply with 60 and add the digit after :. So you can convert the HH:MM representation in to minutes.

SELECT REGEXP_SUBSTR(ATT.workdur,'[^:]+',1,1)*60 + REGEXP_SUBSTR(ATT.workdur,'[^:]+',1,2) MINUTES FROM DUAL;