问:
CSS Grid Layout in Chrome seems not to work properly with more than 1000 rows
I have created an example of a sliding grid with fixed headers, using the "CSS Grid Layout" and "sticky position" technologies. For convenience, the content of the grid is generated by a script, which I think works well.

function fillGrid(selector, rows) {
  let cols = 3;
  let grid = $(selector);

  grid.empty();

  //cr header
  grid.append($('
').addClass('hcr').text('#'));

  //col headers
  for (let c = 1; c <= cols; c++) {
    grid.append($('
').addClass('hc').text(`Column ${c}`));
  }

  for (let r = 1; r <= rows; r++) {
    //row header
    grid.append($('
').addClass('hr').text(r));

    //cells
    for (let c = 1; c <= cols; c++) {
      grid.append($('
').addClass('c').text(`Cell ${r}-${c}`));
    }
  }
}

$('#reload').click(e => {
  var rows = Number.parseInt($('#rows').val());
  fillGrid('#grid1', rows);
})

$(document).ready(function() {
  fillGrid('#grid1', 10);
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  font-family: 'Segoe UI', sans-serif;
  font-size: 12px;
}

.grid {
  display: grid;
  width: 600px;
  height: 300px;
  grid-template-columns: 40px 200px 100px 500px;
  grid-auto-rows: min-content;
  border: 1px solid #ccc;
  overflow: scroll;
  margin-top: 20px;
  background-color: #aaa;
  margin-right: 10px;
}

.hcr, .hc, .hr {
  background-color: #ddd;
  border-right: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  padding: 2px;
  position: sticky;
}

.hcr {
  top: 0;
  left: 0;
  z-index: 1;
  text-align: center;
}

.hc {
  top: 0;
  white-space: nowrap;
}

.hr {
  left: 0;
  text-align: center;
}

.c {
  padding: 2px;
  border-right: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  background-color: #fff;
}</code>```

  <input type="text" id="rows" value="10" />
  <input type="button" id="reload" value="Reload" />

```

Up to 999 rows the grid works perfectly. When more than 999 rows are loaded, only the cells up to row 999 are displayed, while the following cells are incorrectly positioned on the left above the header of row 999.

The same example works correctly in Firefox 56 and Edge 16 (version 16299).

Where am I wrong?

答:
Ok, the 1000 rows (and also 1000 columns) limit has been intentionally introduced into the Chrome engine for reasons of stability and RAM consumption. A new version of the Grid functionality seems to be in progress and should solve the problem.

Sources:

https://bugs.chromium.org/p/chromium/issues/detail?id=688640

https://github.com/w3c/csswg-drafts/issues/1009

UPD: from Chrome version 96.0.4642 items amount extended to 100,000 rows/columns

Body:
I have created an example of a sliding grid with fixed headers, using the "CSS Grid Layout" and "sticky position" technologies. For convenience, the content of the grid is generated by a script, which I think works well.

function fillGrid(selector, rows) {
  let cols = 3;
  let grid = $(selector);

  grid.empty();

  //cr header
  grid.append($('
').addClass('hcr').text('#'));

  //col headers
  for (let c = 1; c <= cols; c++) {
    grid.append($('
').addClass('hc').text(`Column ${c}`));
  }

  for (let r = 1; r <= rows; r++) {
    //row header
    grid.append($('
').addClass('hr').text(r));

    //cells
    for (let c = 1; c <= cols; c++) {
      grid.append($('
').addClass('c').text(`Cell ${r}-${c}`));
    }
  }
}

$('#reload').click(e => {
  var rows = Number.parseInt($('#rows').val());
  fillGrid('#grid1', rows);
})

$(document).ready(function() {
  fillGrid('#grid1', 10);
});

body {
  font-family: 'Segoe UI', sans-serif;
  font-size: 12px;
}

.grid {
  display: grid;
  width: 600px;
  height: 300px;
  grid-template-columns: 40px 200px 100px 500px;
  grid-auto-rows: min-content;
  border: 1px solid #ccc;
  overflow: scroll;
  margin-top: 20px;
  background-color: #aaa;
  margin-right: 10px;
}

.hcr, .hc, .hr {
  background-color: #ddd;
  border-right: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  padding: 2px;
  position: sticky;
}

.hcr {
  top: 0;
  left: 0;
  z-index: 1;
  text-align: center;
}

.hc {
  top: 0;
  white-space: nowrap;
}

.hr {
  left: 0;
  text-align: center;
}

.c {
  padding: 2px;
  border-right: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  background-color: #fff;
}

  <input type="text" id="rows" value="10" />
  <input type="button" id="reload" value="Reload" />

Up to 999 rows the grid works perfectly. When more than 999 rows are loaded, only the cells up to row 999 are displayed, while the following cells are incorrectly positioned on the left above the header of row 999.

The same example works correctly in Firefox 56 and Edge 16 (version 16299).

Where am I wrong?


来源: stackexchange

问:
Custom vertical viewpager not work with onClick listener on a child view
I have this custom ViewPager created from here (Android: Vertical ViewPager):

```<code>class VerticalViewPager : ViewPager {

@JvmOverloads
constructor(
        context: Context,
        attrs: AttributeSet? = null)
        : super(context, attrs){
    setPageTransformer(false, DefaultTransformer())
    overScrollMode = OVER_SCROLL_NEVER
}

override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
    val intercepted = super.onInterceptTouchEvent(swapXY(ev))
    swapXY(ev) // return touch coordinates to original reference frame for any child views
    return intercepted
}

override fun onTouchEvent(ev: MotionEvent?): Boolean {
    return super.onTouchEvent(ev)
}

/**
 * Swaps the X and Y coordinates of your touch event.
 */
private fun swapXY(ev: MotionEvent): MotionEvent {
    val width = width.toFloat()
    val height = height.toFloat()

    val newX = ev.y / height * width
    val newY = ev.x / width * height

    ev.setLocation(newX, newY)

    return ev
}

private class VerticalPageTransformer : ViewPager.PageTransformer{
    override fun transformPage(view: View, position: Float) {
        if (position < -1) { // [-Infinity,-1)
            // This page is way off-screen to the left.
            view.alpha = 0f

        } else if (position <= 1) { // [-1,1]
            view.alpha = 1f

            // Counteract the default slide transition
            view.translationX = view.getWidth() * -position

            //set Y position to swipe in from top
            val yPosition = position * view.getHeight()
            view.translationY = yPosition

        } else { // (1,+Infinity]
            // This page is way off-screen to the right.
            view.alpha = 0f
        }
    }

}

}
</code>```

I use an adapter that loads an ImageView inside each page. This ImageView has a onClickListener.

```<code>open class VerticalViewPagerAdapter(var mContext: Context, val photos : RealmList<ProfilePhoto>?, onPhotoClick: OnPhotoClick?) : PagerAdapter() {

var mLayoutInflater : LayoutInflater? = null
val onPhotoListener = onPhotoClick

init {
    mLayoutInflater = mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
}

override fun getCount(): Int {
    return photos?.size!!
}

override fun isViewFromObject(view: View, `object`: Any): Boolean {
    return view === `object` as FrameLayout
}

override fun instantiateItem(container: ViewGroup, position: Int): Any {
    val itemView = mLayoutInflater?.inflate(R.layout.view_image_profile_viewpager_item, container, false)

    val imageView = itemView?.findViewById(R.id.profileImageItemIv) as ImageView

    imageView.setOnClickListener{
        onPhotoListener?.onPhotoClick(position)
    }

    imageView.loadUrlImage(photos!![position]?.photo)

    container.addView(itemView)

    return itemView
}

override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
    container.removeView(`object` as FrameLayout)
}
}
</code>```

The swipe on the custom viewpager doesn't work if the ImageView has this listener. If I remove the listener, works fine.

Anybody know what can be the problem?

答:
Finally I solved the problem. I was to add logic to onInterceptTouchEvent to release the onTouch event if user only tap the viewpager and not swapping. This is the final code:

```<code>class VerticalViewPager : ViewPager {

var originalPosY = 0

@JvmOverloads
constructor(
        context: Context,
        attrs: AttributeSet? = null)
        : super(context, attrs){
    setPageTransformer(false, DefaultTransformer())
}

private fun swapTouchEvent(event: MotionEvent): MotionEvent {
    val width = width.toFloat()
    val height = height.toFloat()

    val swappedX = event.y / height * width
    val swappedY = event.x / width * height

    event.setLocation(swappedX, swappedY)

    return event
}

override fun onInterceptTouchEvent(event: MotionEvent): Boolean {

    var y : Int = event.rawY.toInt()

    return when (event.action) {

        MotionEvent.ACTION_DOWN -> {
            originalPosY = y
            val intercept = super.onInterceptTouchEvent(swapTouchEvent(event))
            swapTouchEvent(event)
            false
        }

        MotionEvent.ACTION_MOVE -> {

            val intercept = super.onInterceptTouchEvent(swapTouchEvent(event))
            val i = swapTouchEvent(event)
            true

        }

        MotionEvent.ACTION_UP -> {

            if (Math.abs(originalPosY - y) > 10) {
                super.onInterceptTouchEvent(swapTouchEvent(event))
                val i = swapTouchEvent(event)
                true
            }else
                false
        }

        else -> super.onInterceptTouchEvent(swapTouchEvent(event))

    }
}

override fun onTouchEvent(event: MotionEvent): Boolean = super.onTouchEvent(swapTouchEvent(event))
}
</code>```

The result is not all accurate that I want. If someone can improve it, it will be welcome

ContentLicense: CC BY-SA 4.0

Body:
I have this custom ViewPager created from here (Android: Vertical ViewPager):

class VerticalViewPager : ViewPager {

@JvmOverloads
constructor(
        context: Context,
        attrs: AttributeSet? = null)
        : super(context, attrs){
    setPageTransformer(false, DefaultTransformer())
    overScrollMode = OVER_SCROLL_NEVER
}

override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
    val intercepted = super.onInterceptTouchEvent(swapXY(ev))
    swapXY(ev) // return touch coordinates to original reference frame for any child views
    return intercepted
}

override fun onTouchEvent(ev: MotionEvent?): Boolean {
    return super.onTouchEvent(ev)
}

/**
 * Swaps the X and Y coordinates of your touch event.
 */
private fun swapXY(ev: MotionEvent): MotionEvent {
    val width = width.toFloat()
    val height = height.toFloat()

    val newX = ev.y / height * width
    val newY = ev.x / width * height

    ev.setLocation(newX, newY)

    return ev
}

private class VerticalPageTransformer : ViewPager.PageTransformer{
    override fun transformPage(view: View, position: Float) {
        if (position < -1) { // [-Infinity,-1)
            // This page is way off-screen to the left.
            view.alpha = 0f

        } else if (position <= 1) { // [-1,1]
            view.alpha = 1f

            // Counteract the default slide transition
            view.translationX = view.getWidth() * -position

            //set Y position to swipe in from top
            val yPosition = position * view.getHeight()
            view.translationY = yPosition

        } else { // (1,+Infinity]
            // This page is way off-screen to the right.
            view.alpha = 0f
        }
    }

}

}

I use an adapter that loads an ImageView inside each page. This ImageView has a onClickListener.

open class VerticalViewPagerAdapter(var mContext: Context, val photos : RealmList<ProfilePhoto>?, onPhotoClick: OnPhotoClick?) : PagerAdapter() {

var mLayoutInflater : LayoutInflater? = null
val onPhotoListener = onPhotoClick

init {
    mLayoutInflater = mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
}

override fun getCount(): Int {
    return photos?.size!!
}

override fun isViewFromObject(view: View, `object`: Any): Boolean {
    return view === `object` as FrameLayout
}

override fun instantiateItem(container: ViewGroup, position: Int): Any {
    val itemView = mLayoutInflater?.inflate(R.layout.view_image_profile_viewpager_item, container, false)

    val imageView = itemView?.findViewById(R.id.profileImageItemIv) as ImageView

    imageView.setOnClickListener{
        onPhotoListener?.onPhotoClick(position)
    }

    imageView.loadUrlImage(photos!![position]?.photo)

    container.addView(itemView)

    return itemView
}

override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
    container.removeView(`object` as FrameLayout)
}
}

The swipe on the custom viewpager doesn't work if the ImageView has this listener. If I remove the listener, works fine.

Anybody know what can be the problem?

Body:
Finally I solved the problem. I was to add logic to onInterceptTouchEvent to release the onTouch event if user only tap the viewpager and not swapping. This is the final code:

class VerticalViewPager : ViewPager {

var originalPosY = 0

@JvmOverloads
constructor(
        context: Context,
        attrs: AttributeSet? = null)
        : super(context, attrs){
    setPageTransformer(false, DefaultTransformer())
}

private fun swapTouchEvent(event: MotionEvent): MotionEvent {
    val width = width.toFloat()
    val height = height.toFloat()

    val swappedX = event.y / height * width
    val swappedY = event.x / width * height

    event.setLocation(swappedX, swappedY)

    return event
}

override fun onInterceptTouchEvent(event: MotionEvent): Boolean {

    var y : Int = event.rawY.toInt()

    return when (event.action) {

        MotionEvent.ACTION_DOWN -> {
            originalPosY = y
            val intercept = super.onInterceptTouchEvent(swapTouchEvent(event))
            swapTouchEvent(event)
            false
        }

        MotionEvent.ACTION_MOVE -> {

            val intercept = super.onInterceptTouchEvent(swapTouchEvent(event))
            val i = swapTouchEvent(event)
            true

        }

        MotionEvent.ACTION_UP -> {

            if (Math.abs(originalPosY - y) > 10) {
                super.onInterceptTouchEvent(swapTouchEvent(event))
                val i = swapTouchEvent(event)
                true
            }else
                false
        }

        else -> super.onInterceptTouchEvent(swapTouchEvent(event))

    }
}

override fun onTouchEvent(event: MotionEvent): Boolean = super.onTouchEvent(swapTouchEvent(event))
}

The result is not all accurate that I want. If someone can improve it, it will be welcome


问:
what is a dependency for android.media.tv
I try to move android TV app to Android studio. When I try to compile it, I had some import errors. I couldn't find the dependency that I can add to build.gradle to fix these problem. The list of the imports are:

```<code>import android.media.tv.TvContentRatingSystemInfo;
import android.media.tv.TvContract.WatchedPrograms;
import com.android.tv.tuner.data.nano.Track.AtscCaptionTrack;
import com.android.tv.tuner.data.nano.Track.AtscAudioTrack;
import com.android.tv.tuner.data.nano.Channel;
</code>```

The build.gradle is :

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

android {
 compileSdkVersion 26
 buildToolsVersion "26.0.1"

 defaultConfig {
     applicationId "com.android.tv"
     minSdkVersion 23
     targetSdkVersion 23
     versionCode 1
     versionName "1.0"

     ndk {
         moduleName "libtunertvinput_jni"
     }
 }
 sourceSets {
     main {
         res.srcDirs = ['src/main/res', 'src/main/usbtuner-res']
         jni.srcDirs = []
     }
 }
 buildTypes {
     release {
         minifyEnabled false
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
     }
     debug {
         minifyEnabled false
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
     }
 }
}

dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 compile files('libs/exoplayer.jar')
 compile project(':common')
 compile 'com.android.support:palette-v7:+'
 compile 'com.android.support:support-v4:+'
 compile 'com.android.support:support-annotations:+'
}
</code>```

答:
You can't import these because they have @SystemApi annotation. You can check this for the source code of TvContentRatingSystemInfo. I have also checked WatchedPrograms and it also has @SystemApi annotation. I have not checked the other three.

You need to be system app to access these. As you can see here, you need to push your app in the the \system\ folder. You can find detailed information about AOSP build system here.

Solution :
Changing your android.jar to the .jar in this github should enable you to access system API. The reason is your standard android.jar doesn't have system API. So you need to get framework.jar (by adb pull) from emulator and combine it with core.jar then you can have new android.jar which contains system API (system methods and classes are available in the framework.jar from emulator).

Moreover, you should push your apk to \system\priv-app\ folder to access some system API but I don't know why I can access system API without pushing my apk to \system\priv-app\ when I use .jar from that github account.

I feel like I don't write quite clearly but at least now you have more understandings of what you're facing.

Body:
I try to move android TV app to Android studio. When I try to compile it, I had some import errors. I couldn't find the dependency that I can add to build.gradle to fix these problem. The list of the imports are:

import android.media.tv.TvContentRatingSystemInfo;
import android.media.tv.TvContract.WatchedPrograms;
import com.android.tv.tuner.data.nano.Track.AtscCaptionTrack;
import com.android.tv.tuner.data.nano.Track.AtscAudioTrack;
import com.android.tv.tuner.data.nano.Channel;

The build.gradle is :

apply plugin: 'com.android.application'

android {
 compileSdkVersion 26
 buildToolsVersion "26.0.1"

 defaultConfig {
     applicationId "com.android.tv"
     minSdkVersion 23
     targetSdkVersion 23
     versionCode 1
     versionName "1.0"

     ndk {
         moduleName "libtunertvinput_jni"
     }
 }
 sourceSets {
     main {
         res.srcDirs = ['src/main/res', 'src/main/usbtuner-res']
         jni.srcDirs = []
     }
 }
 buildTypes {
     release {
         minifyEnabled false
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
     }
     debug {
         minifyEnabled false
         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
     }
 }
}

dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 compile files('libs/exoplayer.jar')
 compile project(':common')
 compile 'com.android.support:palette-v7:+'
 compile 'com.android.support:support-v4:+'
 compile 'com.android.support:support-annotations:+'
}


问:
Concatenate lists with LINQ
Is it possible to concatenate a List<List<T>> into a List<T> with a single operation in a way which isn't horrible slow, i.e:

```<code>List<List<int>> listOfLists = new List<List<int>>();
List<int> concatenatedList = listOfLists.Something...
</code>```

?

答:
```<code>listOfLists.SelectMany( l => l );
</code>```

full line:

```<code>List<int> concatenatedList = listOfLists.SelectMany( l => l ).ToList();
</code>```

ContentLicense: CC BY-SA 2.5

Title: Concatenate lists with LINQ

Body:
Is it possible to concatenate a List<List<T>> into a List<T> with a single operation in a way which isn't horrible slow, i.e:

List<List<int>> listOfLists = new List<List<int>>();
List<int> concatenatedList = listOfLists.Something...

?

Body:
listOfLists.SelectMany( l => l );

full line:

List<int> concatenatedList = listOfLists.SelectMany( l => l ).ToList();


问:
Bootstrap's collapsible navbar doesn't work with Angular2
I've not managed to get the collapsible navbar in Bootsrap 3 to work correctly with Angular2.  On reducing the window width, the menu is correctly replaced by the burger button,  but clicking it doesn’t display the drop-menu. The button activates (goes dark) but that's it.  I'd like to know if there's a workaround other than perhaps using ng-bootstrap?

Example: Plunk

```<code><nav class="navbar navbar-inverse" role="navigation">
<div class="container-fluid">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#collapseNav">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href='#'>Angular2 & Bootstrap</a>
    </div>
    <div class="collapse navbar-collapse" id="collapseNav">
        <ul class="nav navbar-nav">
            <li><a class="navbar-brand" href="#">Home</a></li>
            <li><a class="navbar-brand" href='#'>Item</a></li>
        </ul>
        <ul class="nav navbar-nav navbar-right">
            <li><a href="https://angular.io/">Angular</a></li>
        </ul>
    </div>
</div>
</code>```

答:
This is a limitation of navbar (https://github.com/valor-software/ngx-bootstrap/issues/540). So you need to manipulate the DOM element.

```<code><div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
    <span class="sr-only">Toggle navigation</span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
</button>
<a class="navbar-brand" routerLink="/">
    <img src="assets/images/logo.png">
</a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
    <ul class="nav navbar-nav navbar-right" >
    <li class="hidden">
        <a></a>
    </li>
        <li><a routerLink="/" (click)="onMenuClick()">Home</a></li>
        <li><a routerLink="/about" (click)="onMenuClick()">About</a></li>
    </ul>
</div>
</code>```

And on .ts file your minimal code shoul be:

```<code>import { Component, ElementRef, Renderer } from '@angular/core';
export class HeaderComponent {
constructor(private el: ElementRef, private renderer: Renderer) {
}
onMenuClick() {
    //this.el.nativeElement.querySelector('.navbar-ex1-collapse')  get the DOM
    //this.renderer.setElementClass('DOM-Element', 'css-class-you-want-to-add', false) if 3rd value is true
    //it will add the css class. 'in' class is responsible for showing the menu, remove it.
    this.renderer.setElementClass(this.el.nativeElement.querySelector('.navbar-ex1-collapse'), 'in', false);
}
</code>```

}

ContentLicense: CC BY-SA 3.0

Body:
I've not managed to get the collapsible navbar in Bootsrap 3 to work correctly with Angular2.  On reducing the window width, the menu is correctly replaced by the burger button,  but clicking it doesn’t display the drop-menu. The button activates (goes dark) but that's it.  I'd like to know if there's a workaround other than perhaps using ng-bootstrap?

Example: Plunk

        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#collapseNav">

        </button>
        Angular2 & Bootstrap

Home

Item

Angular

Body:
This is a limitation of navbar (https://github.com/valor-software/ngx-bootstrap/issues/540). So you need to manipulate the DOM element.

<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
    <span class="sr-only">Toggle navigation</span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
</button>
<a class="navbar-brand" routerLink="/">
    <img src="assets/images/logo.png">
</a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
    <ul class="nav navbar-nav navbar-right" >
    <li class="hidden">
        <a></a>
    </li>
        <li><a routerLink="/" (click)="onMenuClick()">Home</a></li>
        <li><a routerLink="/about" (click)="onMenuClick()">About</a></li>
    </ul>
</div>

And on .ts file your minimal code shoul be:

import { Component, ElementRef, Renderer } from '@angular/core';
export class HeaderComponent {
constructor(private el: ElementRef, private renderer: Renderer) {
}
onMenuClick() {
    //this.el.nativeElement.querySelector('.navbar-ex1-collapse')  get the DOM
    //this.renderer.setElementClass('DOM-Element', 'css-class-you-want-to-add', false) if 3rd value is true
    //it will add the css class. 'in' class is responsible for showing the menu, remove it.
    this.renderer.setElementClass(this.el.nativeElement.querySelector('.navbar-ex1-collapse'), 'in', false);
}

}


问:
Exception in Runtime Permissions
Method written for asking permissions. I am asking multiple permissions.

```<code>private void askForPermissions() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            int contactsPermission = checkSelfPermission(Manifest.permission.READ_CONTACTS);
            int extStoragePermission = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
            int cameraPermission = checkSelfPermission(Manifest.permission.CAMERA);
            int recordPermission = checkSelfPermission(Manifest.permission.RECORD_AUDIO);
            int internetPermission = checkSelfPermission(Manifest.permission.INTERNET);

            Log.e("Start_Permission1",""+(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M));
            Log.e("Start_Permission2",""+(contactsPermission != PackageManager.PERMISSION_GRANTED));
            Log.e("Start_Permission3",""+(extStoragePermission != PackageManager.PERMISSION_GRANTED));
            Log.e("Start_Permission4",""+(cameraPermission != PackageManager.PERMISSION_GRANTED));
            Log.e("Start_Permission5",""+(recordPermission != PackageManager.PERMISSION_GRANTED));
            Log.e("Start_Permission6",""+(internetPermission != PackageManager.PERMISSION_GRANTED));

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && contactsPermission != PackageManager.PERMISSION_GRANTED && extStoragePermission != PackageManager.PERMISSION_GRANTED && cameraPermission != PackageManager.PERMISSION_GRANTED && recordPermission != PackageManager.PERMISSION_GRANTED) {
                Log.e("Start","here i am");
                requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE,
                        Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_CONTACTS}, REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS);

            }
            Log.e("Start_permission","Asking done..");
}
In onCreate method:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);

    // First take all permissions
        askForPermissions();

        if (!checkNetworkAvailability()) {
            Toast.makeText(getApplicationContext(), "Sorry! You need Internet Connection", Toast.LENGTH_LONG).show();
            spinner.setVisibility(View.INVISIBLE);

        } else {

            if (populateUserData()) {
                spinner = (ProgressBar) findViewById(R.id.spinner);
                spinner.setVisibility(ProgressBar.VISIBLE);
                Log.e("Start_populateUSrData", "User data populated");

                fetchContacts();
    }

@Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions,
                                           int[] grantResults) {
        switch (requestCode) {
            case REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS:
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    // Permission Granted
                    //insertDummyContact();
                } else {
                    // Permission Denied
                    Toast.makeText(Start.this, "WRITE_CONTACTS Denied", Toast.LENGTH_SHORT)
                            .show();
                }
                break;
            default:
                super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }
</code>```

Logs:

```<code>12-24 16:53:26.251 1465-1465/com.moodoff E/Minikin: addFont failed to create font /system/fonts/NanumGothic.ttf
12-24 16:53:26.252 1465-1465/com.moodoff E/Minikin: addFont failed to create font /system/fonts/DroidSansFallback.ttf
12-24 16:53:26.252 1465-1465/com.moodoff E/Minikin: addFont failed to create font /system/fonts/MTLmr3m.ttf
12-24 16:53:26.434 1465-1465/com.moodoff E/MultiWindowProxy: getServiceInstance failed!
12-24 16:53:26.595 1465-1465/com.moodoff E/Start_Permission1: true
12-24 16:53:26.595 1465-1465/com.moodoff E/Start_Permission2: true
12-24 16:53:26.595 1465-1465/com.moodoff E/Start_Permission3: true
12-24 16:53:26.595 1465-1465/com.moodoff E/Start_Permission4: true
12-24 16:53:26.595 1465-1465/com.moodoff E/Start_Permission5: true
12-24 16:53:26.596 1465-1465/com.moodoff E/Start_Permission6: false
12-24 16:53:26.596 1465-1465/com.moodoff E/Start: here i am
12-24 16:53:26.618 1465-1465/com.moodoff E/Start_permission: Asking done..
12-24 16:53:26.876 1465-1572/com.moodoff E/AndroidRuntime: FATAL EXCEPTION: Thread-1132
                                                           Process: com.moodoff, PID: 1465
                                                           java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{292d428 1465:com.moodoff/u0a207} (pid=1465, uid=10207) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
                                                               at android.os.Parcel.readException(Parcel.java:1599)
                                                               at android.os.Parcel.readException(Parcel.java:1552)
                                                               at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:3847)
                                                               at android.app.ActivityThread.acquireProvider(ActivityThread.java:5062)
                                                               at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2026)
                                                               at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1517)
                                                               at android.content.ContentResolver.query(ContentResolver.java:482)
                                                               at android.content.ContentResolver.query(ContentResolver.java:441)
                                                               at com.moodoff.ContactList.getContactNames(ContactList.java:135)
                                                               at com.moodoff.helper.DBHelper$1.run(DBHelper.java:73)
                                                               at java.lang.Thread.run(Thread.java:818)
</code>```

Inspite of the fact that i added askForPermission in the beginning it is reading contacts and throwing up this permission denial error... without contacts read line the app is asking for permission properly and working fine.
What can be done?

答: Had same issue ,resolved it by adding the same permissions in manifest,even those were runtime permissions</p>

Title: Exception in Runtime Permissions

Body:
Method written for asking permissions. I am asking multiple permissions.

private void askForPermissions() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            int contactsPermission = checkSelfPermission(Manifest.permission.READ_CONTACTS);
            int extStoragePermission = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
            int cameraPermission = checkSelfPermission(Manifest.permission.CAMERA);
            int recordPermission = checkSelfPermission(Manifest.permission.RECORD_AUDIO);
            int internetPermission = checkSelfPermission(Manifest.permission.INTERNET);

            Log.e("Start_Permission1",""+(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M));
            Log.e("Start_Permission2",""+(contactsPermission != PackageManager.PERMISSION_GRANTED));
            Log.e("Start_Permission3",""+(extStoragePermission != PackageManager.PERMISSION_GRANTED));
            Log.e("Start_Permission4",""+(cameraPermission != PackageManager.PERMISSION_GRANTED));
            Log.e("Start_Permission5",""+(recordPermission != PackageManager.PERMISSION_GRANTED));
            Log.e("Start_Permission6",""+(internetPermission != PackageManager.PERMISSION_GRANTED));

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && contactsPermission != PackageManager.PERMISSION_GRANTED && extStoragePermission != PackageManager.PERMISSION_GRANTED && cameraPermission != PackageManager.PERMISSION_GRANTED && recordPermission != PackageManager.PERMISSION_GRANTED) {
                Log.e("Start","here i am");
                requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE,
                        Manifest.permission.RECORD_AUDIO, Manifest.permission.READ_CONTACTS}, REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS);

            }
            Log.e("Start_permission","Asking done..");
}
In onCreate method:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);

    // First take all permissions
        askForPermissions();

        if (!checkNetworkAvailability()) {
            Toast.makeText(getApplicationContext(), "Sorry! You need Internet Connection", Toast.LENGTH_LONG).show();
            spinner.setVisibility(View.INVISIBLE);

        } else {

            if (populateUserData()) {
                spinner = (ProgressBar) findViewById(R.id.spinner);
                spinner.setVisibility(ProgressBar.VISIBLE);
                Log.e("Start_populateUSrData", "User data populated");

                fetchContacts();
    }

@Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions,
                                           int[] grantResults) {
        switch (requestCode) {
            case REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS:
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    // Permission Granted
                    //insertDummyContact();
                } else {
                    // Permission Denied
                    Toast.makeText(Start.this, "WRITE_CONTACTS Denied", Toast.LENGTH_SHORT)
                            .show();
                }
                break;
            default:
                super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }

Logs:

12-24 16:53:26.251 1465-1465/com.moodoff E/Minikin: addFont failed to create font /system/fonts/NanumGothic.ttf
12-24 16:53:26.252 1465-1465/com.moodoff E/Minikin: addFont failed to create font /system/fonts/DroidSansFallback.ttf
12-24 16:53:26.252 1465-1465/com.moodoff E/Minikin: addFont failed to create font /system/fonts/MTLmr3m.ttf
12-24 16:53:26.434 1465-1465/com.moodoff E/MultiWindowProxy: getServiceInstance failed!
12-24 16:53:26.595 1465-1465/com.moodoff E/Start_Permission1: true
12-24 16:53:26.595 1465-1465/com.moodoff E/Start_Permission2: true
12-24 16:53:26.595 1465-1465/com.moodoff E/Start_Permission3: true
12-24 16:53:26.595 1465-1465/com.moodoff E/Start_Permission4: true
12-24 16:53:26.595 1465-1465/com.moodoff E/Start_Permission5: true
12-24 16:53:26.596 1465-1465/com.moodoff E/Start_Permission6: false
12-24 16:53:26.596 1465-1465/com.moodoff E/Start: here i am
12-24 16:53:26.618 1465-1465/com.moodoff E/Start_permission: Asking done..
12-24 16:53:26.876 1465-1572/com.moodoff E/AndroidRuntime: FATAL EXCEPTION: Thread-1132
                                                           Process: com.moodoff, PID: 1465
                                                           java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{292d428 1465:com.moodoff/u0a207} (pid=1465, uid=10207) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
                                                               at android.os.Parcel.readException(Parcel.java:1599)
                                                               at android.os.Parcel.readException(Parcel.java:1552)
                                                               at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:3847)
                                                               at android.app.ActivityThread.acquireProvider(ActivityThread.java:5062)
                                                               at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2026)
                                                               at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1517)
                                                               at android.content.ContentResolver.query(ContentResolver.java:482)
                                                               at android.content.ContentResolver.query(ContentResolver.java:441)
                                                               at com.moodoff.ContactList.getContactNames(ContactList.java:135)
                                                               at com.moodoff.helper.DBHelper$1.run(DBHelper.java:73)
                                                               at java.lang.Thread.run(Thread.java:818)

Inspite of the fact that i added askForPermission in the beginning it is reading contacts and throwing up this permission denial error... without contacts read line the app is asking for permission properly and working fine.
What can be done?


问:
Orderby multiple columns
I'm using Backpack for Laravel, Crud module.

How to use orderby() for multiple columns?

example:

```<code>$this->crud->orderBy('name','desc')->orderBy('year,'asc');
</code>```

I have seen the src and the orderby accepts only one parameter.

Any suggestion?

答:
You should be able to chain any number of orderBy methods to CRUD's query property, which is the actual query that will be executed:

```<code>$this->crud->query = $this->crud->query->orderBy('name', 'desc')->orderBy('year', 'asc');
</code>```

Title: Orderby multiple columns

Body:
I'm using Backpack for Laravel, Crud module.

How to use orderby() for multiple columns?

example:

$this->crud->orderBy('name','desc')->orderBy('year,'asc');

I have seen the src and the orderby accepts only one parameter.

Any suggestion?

Body:
You should be able to chain any number of orderBy methods to CRUD's query property, which is the actual query that will be executed:

$this->crud->query = $this->crud->query->orderBy('name', 'desc')->orderBy('year', 'asc');


问:
Push values into array jquery
I have created an empty array at the beginning of the form

```<code><script>
   var monthly_values = [];
   var i=0;
</script>
</code>```

Inside the loop trying to achieve below code....
but the push doesn't work without "alert" box nor if i remove "ready(function())"

```<code>$prodline=500$    /// CGI script loops till 500 iterations
<script>
 $(document).ready(function(){
     i++;
     monthly_values.push("$premium$");
     setTimeout(function() {
       alert("$premium$");
     }, 1);

 });
</script>
 $/prodline$//end of the iteration...
</code>```

I push values from loop into array which is working .But i need to remove alert box or at least OK from alert box ..

The Entire Code is here..

```<code>    <html>
    <head>
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
       <title>PHP FILE  - $licensee$</title>
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
       <meta name="Author" content="COMPULIFE Software, Inc.">
       <link href="../../css/styles_website.css" type="text/css" rel="stylesheet">
       <link href="../../css/termsampler.css" type="text/css" rel="stylesheet">
       <link href="../../css/$css$" type="text/css" rel="stylesheet">
    <script>
         var monthly_values = [];
         var i=0;
    </script>

    <script language="JavaScript" type="text/javascript">
      //     var monthly_values = [];
         // var i=0;
    function getbest (ambest, company, compcode)
    {
      document.comparisonform.AmBest.value = ambest;
      document.comparisonform.CompanyName.value = company;
      document.comparisonform.CompanyCode.value = compcode;
      document.comparisonform.OnClick=abc=window.open('','reason','width=700,height=500,left=20,top=20,scrollbars=yes');
      document.comparisonform.target='reason';
      abc.focus();
      document.comparisonform.submit();
    }
    </script>
    </head>
    <body>
    </tr>
    <style>
    .loader {
      border: 16px solid #f3f3f3;
      border-radius: 50%;
      border-top: 16px solid #3498db;
      width: 120px;
      height: 120px;
      -webkit-animation: spin 2s linear infinite;
      animation: spin 2s linear infinite;
      margin: auto;
      padding: 10px;
    }

    @-webkit-keyframes spin {
      0% { -webkit-transform: rotate(0deg); }
      100% { -webkit-transform: rotate(360deg); }
    }

    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
    </style>
    </head>
    <body>
    <div class="loader" style ></div>
    $prodline=500$

    <script>
      $(document).ready(function(){
        i++;
        monthly_values.push("$premium$");
        setTimeout(function() {
          alert("$premium$"+"$company$"+"$product$"+"$healthcat$"+"$PremiumAnnual$"+"$Premium$"+"$rgpfpp$"+"$guar$"+"$policyfee$"+"$comp$"+"$prod$"+"$rowEvenOdd$");
        }, 1);

      });
    </script>
    $/prodline$
    </table>

    </form>

    <br><br>

    <script>
      $(document).ready(function(){

        var len=monthly_values.length;
        var min_quote=monthly_values [0];
          var max_quote=monthly_values [monthly_values.length-1];

        window.location = 'http://loalhost/laravel/public/customised-quote?min_quote_val='+min_quote+'&max_quote_val='+max_quote;
      });
    </script>
</code>```

答:
This code should work without problems, check the snippet below.
Are you including jQuery in your html?

var monthly_values = [];
var i=0;

 $(document).ready(function(){
     i++;
     monthly_values.push("$premium$");
     setTimeout(function() {
      console.log(monthly_values)
     }, 1);

 });```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script></code>```

EDIT  after seeing your updated code, if i understand it right, in your loop you are rendering the the document $(document).ready() snippet 500 times, which is completely wrong approach.

Not sure what language you are using, and what exactly are you trying to achieve with your loop, but you could just print your $prodline$ array directly into javascript array variable without having to loop through it

Also, now i noticed in your $(document).ready() at the end of your file you are redirecting to new url immediately, if this is your intended result, generate the array just before you redirect like this:

```<code><script>
$(document).ready(function(){
    var monthly_values = []

$prodline=500$
    monthly_values.push("$premium$")
$/prodline$

    var len=monthly_values.length;
    var min_quote=monthly_values [0];
    var max_quote=monthly_values [monthly_values.length-1];

    window.location = 'http://localhost/laravel/public/customised-quote?min_quote_val='+min_quote+'&max_quote_val='+max_quote;

})
</script>
</code>```

Title: Push values into array jquery

Body:
I have created an empty array at the beginning of the form

Inside the loop trying to achieve below code....
but the push doesn't work without "alert" box nor if i remove "ready(function())"

$prodline=500$    /// CGI script loops till 500 iterations

 $/prodline$//end of the iteration...

I push values from loop into array which is working .But i need to remove alert box or at least OK from alert box ..

The Entire Code is here..

       <title>PHP FILE  - $licensee$</title>
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
       <meta name="Author" content="COMPULIFE Software, Inc.">
       <link href="../../css/styles_website.css" type="text/css" rel="stylesheet">
       <link href="../../css/termsampler.css" type="text/css" rel="stylesheet">
       <link href="../../css/$css$" type="text/css" rel="stylesheet">

    $prodline=500$

    $/prodline$

    </form>

Body:
This code should work without problems, check the snippet below.
Are you including jQuery in your html?

var monthly_values = [];
var i=0;

 $(document).ready(function(){
     i++;
     monthly_values.push("$premium$");
     setTimeout(function() {
      console.log(monthly_values)
     }, 1);

 });

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

EDIT  after seeing your updated code, if i understand it right, in your loop you are rendering the the document $(document).ready() snippet 500 times, which is completely wrong approach.

Not sure what language you are using, and what exactly are you trying to achieve with your loop, but you could just print your $prodline$ array directly into javascript array variable without having to loop through it

Also, now i noticed in your $(document).ready() at the end of your file you are redirecting to new url immediately, if this is your intended result, generate the array just before you redirect like this:

<script>
$(document).ready(function(){
    var monthly_values = []

$prodline=500$
    monthly_values.push("$premium$")
$/prodline$

    var len=monthly_values.length;
    var min_quote=monthly_values [0];
    var max_quote=monthly_values [monthly_values.length-1];

    window.location = 'http://localhost/laravel/public/customised-quote?min_quote_val='+min_quote+'&max_quote_val='+max_quote;

})
</script>


问:
Using patch from larger image as input dim to Keras CNN gives error 'Tensor' object has no attribute '_keras_history'*
I am trying to create a CNN with keras to process 20x20 patches from a larger image of 600x600.

When I attempt the run the code below I receive an error AttributeError: 'Tensor' object has no attribute '_keras_history'

The below code is only intended to look at the first 20 x 20 patch out of an total of 900, I am trying to get this functioning before attempting to loop through the entire input image.

I don't understand why it is returning the error as each layer is generated with an keras layer and I haven't applied any other operations to the tensor?

I am using tensorflow 1.3 and keras 2.0.6.

```<code>nb_filters=16

input_image=Input(shape=(600,600,3))
Input_1R=Reshape((900,20,20,3))(input_image)
conv1=Convolution2D(nb_filters,(5,5),activation='relu',padding='valid')(Input_1R[:,0])
conv4=Convolution2D(1,(6,6),activation='hard_sigmoid',padding='same')(conv1)
dense6=Dense(1)(conv4)
output_dense=dense6
model = Model(inputs=input_image, outputs=output_dense)
</code>```

答:
The error occurs because the slicing operation Input_1R[:,0] is not performed in a Keras layer.
You can wrap it into a Lambda layer:

sliced = Lambda(lambda x: x[:, 0])(Input_1R)
conv1 = Convolution2D(nb_filters, (5,5), activation='relu', padding='valid')(sliced)
```

Body:
I am trying to create a CNN with keras to process 20x20 patches from a larger image of 600x600.

When I attempt the run the code below I receive an error AttributeError: 'Tensor' object has no attribute '_keras_history'

The below code is only intended to look at the first 20 x 20 patch out of an total of 900, I am trying to get this functioning before attempting to loop through the entire input image.

I don't understand why it is returning the error as each layer is generated with an keras layer and I haven't applied any other operations to the tensor?

I am using tensorflow 1.3 and keras 2.0.6.

nb_filters=16

input_image=Input(shape=(600,600,3))
Input_1R=Reshape((900,20,20,3))(input_image)
conv1=Convolution2D(nb_filters,(5,5),activation='relu',padding='valid')(Input_1R[:,0])
conv4=Convolution2D(1,(6,6),activation='hard_sigmoid',padding='same')(conv1)
dense6=Dense(1)(conv4)
output_dense=dense6
model = Model(inputs=input_image, outputs=output_dense)


问:
Drop Down Value Not Returning To Default ng-if
I have the below angular form, using ng-if the drop downs appear when a radio button is clicked. When a different radio button is clicked again the drop downs go to a blank value, I would like them to go back to the "Choose" option. How do I do that?</p>

```<code><form name="addToolForm" ng-submit="vm.addStuff()">
    <div layout="row" style="padding-left:30px">
        <md-radio-group name="firstCategory" ng-model="vm.firstCategory" layout="row" ng-required="true">
            <md-radio-button value="item1">item1</md-radio-button>
            <md-radio-button value="item2">item2</md-radio-button>
        </md-radio-group>
    </div>
    <br><br>
    <div class="col-xs-12" id="secondCategory" style="padding-left:30px" ng-if="vm.firstCategory == 'item1'">
        <label class="col-xs-6 control-label">Sub Type:</label>
        <div class="col-xs-6">
            <select name="secondCategory" ng-model="vm.secondCategory" ng-dropdown required="true">
                <option value="" disabled selected>Choose</option>
                <option ng-option value="option1">option1</option>
                <option ng-option value="option2">option2</option>
            </select>
        </div>
    </div>
    <div class="col-xs-12" id="secondCategory" style="padding-left:30px" ng-if="vm.firstCategory == 'item2'">
        <label class="col-xs-6 control-label">Sub Type:</label>
        <div class="col-xs-6">
            <select name="secondCategory" ng-model="vm.secondCategory" ng-dropdown required="true">
                <option value="" disabled selected>Choose</option>
                <option ng-option value="option1">option3</option>
                <option ng-option value="option2">option4</option>
            </select>
        </div>
    </div>
</form>
</code>```

答:
I think your best option is going to be to use ng-change on the vm.firstCategory to set vm.secondCatefory to an empty string, like so

var myApp = angular.module('myApp', ['ngMaterial']).controller("MyCtrl", MyCtrl);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

function MyCtrl($scope) {

}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>

<div ng-app="myApp" ng-controller="MyCtrl as vm">
  <div layout="row" style="padding-left:30px">
    <md-radio-group name="firstCategory" ng-model="vm.firstCategory" layout="row" ng-required="true" ng-change="vm.secondCategory = ''">
      <md-radio-button value="item1">item1</md-radio-button>
      <md-radio-button value="item2">item2</md-radio-button>
    </md-radio-group>
  </div>
  <br>
  <br>
  <div class="col-xs-12" id="secondCategory" style="padding-left:30px" ng-if="vm.firstCategory == 'item1'">
    <label class="col-xs-6 control-label">Sub Type:</label>
    <div class="col-xs-6">
      <select name="secondCategory" ng-model="vm.secondCategory" ng-dropdown required="true">
        <option value="" disabled selected>Choose</option>
        <option ng-option value="option1">option1</option>
        <option ng-option value="option2">option2</option>
      </select>
    </div>
  </div>
  <div class="col-xs-12" id="secondCategory" style="padding-left:30px" ng-if="vm.firstCategory == 'item2'">
    <label class="col-xs-6 control-label">Sub Type:</label>
    <div class="col-xs-6">
      <select name="secondCategory" ng-model="vm.secondCategory" ng-dropdown required="true">
        <option value="" disabled selected>Choose</option>
        <option ng-option value="option1">option3</option>
        <option ng-option value="option2">option4</option>
      </select>
    </div>
  </div>

</div></code>```

But because you're using ng-if the dom elements will get removed, in this case it's not such a bad thing as it means you can use ng-init which allows you to set a value any time the element it's on is rendered so changing your code to below should get it to work.

var myApp = angular.module('myApp', ['ngMaterial']).controller("MyCtrl", MyCtrl);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

function MyCtrl($scope) {
  var vm = this;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl as vm">

  <div layout="row" style="padding-left:30px">
    <md-radio-group name="firstCategory" ng-model="vm.firstCategory" layout="row" ng-required="true">
      <md-radio-button value="item1">item1</md-radio-button>
      <md-radio-button value="item2">item2</md-radio-button>
    </md-radio-group>
  </div>
  <br>
  <br>
  <div class="col-xs-12" id="secondCategory" style="padding-left:30px" ng-if="vm.firstCategory == 'item1'">
    <label class="col-xs-6 control-label">Sub Type:</label>
    <div class="col-xs-6">
      <select name="secondCategory" ng-model="vm.secondCategory" ng-init="vm.secondCategory = ''" ng-dropdown required="true">
        <option value="" disabled selected>Choose</option>
        <option ng-option value="option1">option1</option>
        <option ng-option value="option2">option2</option>
      </select>
    </div>
  </div>
  <div class="col-xs-12" id="secondCategory" style="padding-left:30px" ng-if="vm.firstCategory == 'item2'">
    <label class="col-xs-6 control-label">Sub Type:</label>
    <div class="col-xs-6">
      <select name="secondCategory" ng-model="vm.secondCategory" ng-init="vm.secondCategory = ''" ng-dropdown required="true">
        <option value="" disabled selected>Choose</option>
        <option ng-option value="option1">option3</option>
        <option ng-option value="option2">option4</option>
      </select>
    </div>
  </div>

</div></code>```

Body:
I have the below angular form, using ng-if the drop downs appear when a radio button is clicked. When a different radio button is clicked again the drop downs go to a blank value, I would like them to go back to the "Choose" option. How do I do that?

<form name="addToolForm" ng-submit="vm.addStuff()">

        <md-radio-group name="firstCategory" ng-model="vm.firstCategory" layout="row" ng-required="true">
            <md-radio-button value="item1">item1</md-radio-button>
            <md-radio-button value="item2">item2</md-radio-button>
        </md-radio-group>

        Sub Type:

            <select name="secondCategory" ng-model="vm.secondCategory" ng-dropdown required="true">
                <option value="" disabled selected>Choose</option>
                <option ng-option value="option1">option1</option>
                <option ng-option value="option2">option2</option>
            </select>

        Sub Type:

            <select name="secondCategory" ng-model="vm.secondCategory" ng-dropdown required="true">
                <option value="" disabled selected>Choose</option>
                <option ng-option value="option1">option3</option>
                <option ng-option value="option2">option4</option>
            </select>

</form>

Body:
I think your best option is going to be to use ng-change on the vm.firstCategory to set vm.secondCatefory to an empty string, like so

var myApp = angular.module('myApp', ['ngMaterial']).controller("MyCtrl", MyCtrl);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

function MyCtrl($scope) {

}

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>

<div ng-app="myApp" ng-controller="MyCtrl as vm">
  <div layout="row" style="padding-left:30px">
    <md-radio-group name="firstCategory" ng-model="vm.firstCategory" layout="row" ng-required="true" ng-change="vm.secondCategory = ''">
      <md-radio-button value="item1">item1</md-radio-button>
      <md-radio-button value="item2">item2</md-radio-button>
    </md-radio-group>
  </div>
  <br>
  <br>
  <div class="col-xs-12" id="secondCategory" style="padding-left:30px" ng-if="vm.firstCategory == 'item1'">
    <label class="col-xs-6 control-label">Sub Type:</label>
    <div class="col-xs-6">
      <select name="secondCategory" ng-model="vm.secondCategory" ng-dropdown required="true">
        <option value="" disabled selected>Choose</option>
        <option ng-option value="option1">option1</option>
        <option ng-option value="option2">option2</option>
      </select>
    </div>
  </div>
  <div class="col-xs-12" id="secondCategory" style="padding-left:30px" ng-if="vm.firstCategory == 'item2'">
    <label class="col-xs-6 control-label">Sub Type:</label>
    <div class="col-xs-6">
      <select name="secondCategory" ng-model="vm.secondCategory" ng-dropdown required="true">
        <option value="" disabled selected>Choose</option>
        <option ng-option value="option1">option3</option>
        <option ng-option value="option2">option4</option>
      </select>
    </div>
  </div>

</div>

But because you're using ng-if the dom elements will get removed, in this case it's not such a bad thing as it means you can use ng-init which allows you to set a value any time the element it's on is rendered so changing your code to below should get it to work.

var myApp = angular.module('myApp', ['ngMaterial']).controller("MyCtrl", MyCtrl);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

function MyCtrl($scope) {
  var vm = this;
}

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl as vm">

  <div layout="row" style="padding-left:30px">
    <md-radio-group name="firstCategory" ng-model="vm.firstCategory" layout="row" ng-required="true">
      <md-radio-button value="item1">item1</md-radio-button>
      <md-radio-button value="item2">item2</md-radio-button>
    </md-radio-group>
  </div>
  <br>
  <br>
  <div class="col-xs-12" id="secondCategory" style="padding-left:30px" ng-if="vm.firstCategory == 'item1'">
    <label class="col-xs-6 control-label">Sub Type:</label>
    <div class="col-xs-6">
      <select name="secondCategory" ng-model="vm.secondCategory" ng-init="vm.secondCategory = ''" ng-dropdown required="true">
        <option value="" disabled selected>Choose</option>
        <option ng-option value="option1">option1</option>
        <option ng-option value="option2">option2</option>
      </select>
    </div>
  </div>
  <div class="col-xs-12" id="secondCategory" style="padding-left:30px" ng-if="vm.firstCategory == 'item2'">
    <label class="col-xs-6 control-label">Sub Type:</label>
    <div class="col-xs-6">
      <select name="secondCategory" ng-model="vm.secondCategory" ng-init="vm.secondCategory = ''" ng-dropdown required="true">
        <option value="" disabled selected>Choose</option>
        <option ng-option value="option1">option3</option>
        <option ng-option value="option2">option4</option>
      </select>
    </div>
  </div>

</div>


问:
How to choose Cassandra version?
I'm sql coder and new in Cassandra, which version should I choose, Cassandra 3.X or Cassandra 2.X?

We already have cassandra-2.1.17 but it could not support any aggregate function at all, I want to upgrade to cassandra 3.X but I don't know much about the difference, just want to get some advice, appreciate.

答:
Usually the best it's to go with latest versions.

Cassandra 2.x: You should have in mind that if you need stability, go for 2.2.x/2.1.x, but those will be out of support when Cassandra 4.0 will be out.
The latest releases are 2.2.11 (changes, release notes) and 2.1.19 (changes, release notes), both of them released in 2017.10.05. Go for 2.2.11 if you need something that goes well and you like playing it safe. 2.2.11 is low risk.

Cassandra 3.0: Probably it's better to skip this, because it's pretty buggy, especially on the storage. But you definitely should go with 3.0.15 if you plan to pick 3.0. You can check the changes and the release notes.
Also have in mind that materialized view are still in experimental phase or, better to say, the community might start marking those as experimental.
Probably it's best to skip 3.0 and go directly to 3.11.x.

Cassandra 3.x: Probably the latest version should be more stable. 3.11.1 has been released on 2017.10.10. You can check the changes and the release notes.

Final thoughts: at the end it's you who decides based on your use cases and data or if you know that are features that you need/don't need or if there are bugs that you can cope with.

Title: How to choose Cassandra version?


问:
Changing the format of date after picking from datepicker after SAPUI5
I have a datepicker from which I want to extract the date and display in a label. Currently the date is getting displayed in the format MM/DD/YYYY but I want it in the format MMM dd, yyyy (Nov 17, 2017). Below is the code : </p>

```<code>screenDate=view.byId("screeningDate").getValue();
var date = view.byId("__date");
date.setText(screenDate);
</code>```

<p>XML : </p>

```<code>    <HBox alignItems="Center" renderType="Bare">
                    <Label text="Date of Screening" width="50%"/>
                    <DatePicker class="sapUiLargeMarginBegin" width="50%" id="screeningDate"/>
                </HBox>
</code>```

答:
FYI, By getting view controls and updating the property in it is not good. It will be good if you have a model.

Solution for your problem is below,

```<code><Label text="{
            path: '/date',
            type: 'sap.ui.model.type.Date',
            formatOptions: {
                style: 'medium',
                pattern: 'MMM dd, yyyy'
            }}"/>
<DatePicker dateValue="{/date}"/>
</code>```

And in the controller I have a JSONModel as below,

```<code>onInit : function() {
    this.model = new JSONModel({
        date : new Date(0)
    });
    this.getView().setModel(this.model);
}
</code>```

Body:
I have a datepicker from which I want to extract the date and display in a label. Currently the date is getting displayed in the format MM/DD/YYYY but I want it in the format MMM dd, yyyy (Nov 17, 2017). Below is the code :

screenDate=view.byId("screeningDate").getValue();
var date = view.byId("__date");
date.setText(screenDate);

XML :

    <HBox alignItems="Center" renderType="Bare">

                    <DatePicker class="sapUiLargeMarginBegin" width="50%" id="screeningDate"/>
                </HBox>

Body:
FYI, By getting view controls and updating the property in it is not good. It will be good if you have a model.

Solution for your problem is below,

<Label text="{
            path: '/date',
            type: 'sap.ui.model.type.Date',
            formatOptions: {
                style: 'medium',
                pattern: 'MMM dd, yyyy'
            }}"/>
<DatePicker dateValue="{/date}"/>

And in the controller I have a JSONModel as below,

onInit : function() {
    this.model = new JSONModel({
        date : new Date(0)
    });
    this.getView().setModel(this.model);
}


问:
Exclude a field from LinqToSql generated class item list
Is it possible to exclude a field from a collection of linq to sql generated class items.

A database table contains field of Image data type. The table has a lot of data inserted, so the programm dies when I try to receive all the items inserted. I need to have all the information except this field.

Sample code looks like:

```<code>arc_developDataContext _dataContext = new arc_developDataContext(connectionString);
_dataContext.arcs.OrderByDescending(a => a.arc_id)
</code>```

答: Is this not what the 'Delay Loaded' property is for? See here for more information</p>

Body:
Is it possible to exclude a field from a collection of linq to sql generated class items.

A database table contains field of Image data type. The table has a lot of data inserted, so the programm dies when I try to receive all the items inserted. I need to have all the information except this field.

Sample code looks like:

arc_developDataContext _dataContext = new arc_developDataContext(connectionString);
_dataContext.arcs.OrderByDescending(a => a.arc_id)


问:
Spring 4.0 + hibernate 5.2 program getting below issue
```<code>Caused by: java.lang.ClassNotFoundException: org.springframework.orm.hibernate5.HibernateTransactionManager
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:247)
    at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:395)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1348)
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1319)
    ... 50 more

Nov 17, 2017 7:23:43 AM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring-mvc-crud-demo-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.hibernate5.LocalSessionFactoryBean
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring-mvc-crud-demo-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.hibernate5.LocalSessionFactoryBean
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate5.HibernateTransactionManager] for bean with name 'myTransactionManager' defined in ServletContext resource [/WEB-INF/spring-mvc-crud-demo-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.hibernate5.HibernateTransactionManager
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1269)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1182)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:853)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring-mvc-crud-demo-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.hibernate5.LocalSessionFactoryBean
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1327)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1396)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:385)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:362)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:348)
    at org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1051)
</code>```

答:
Looks like you didn't include needed library.

LocalSessionFactoryBean is a part of spring-orm, did you include it?

See here: https://mvnrepository.com/artifact/org.springframework/spring-orm


问:
Broken rows when reading inlineStr cells with EPPlus C#
I have xlsx-file which opens succesfully with Excel and which can be parsed with other excel-libraries than EPPlus. We are likely to continue using EPPlus, so it will be nice to get some advice with this issue.

Excel data in is plain text data without formatting.

When parsing with EPPlus with C#, let's say 3x3 sheet, parsed data is fragmented following way to memory (empty cells added to every row so total size is 3x9 or something):

```<code>r1c1 r1c2 r1c3
               r2c1 r2c2 r2c3
                              r3c1 r3c2 r3c3
</code>```

instead of 3x3 array

```<code>r1c1 r1c2 r1c3
r2c1 r2c2 r2c3
r3c1 r3c2 r3c3
</code>```

When opening xlsx-archive with zip viewer it seems that xl\worksheets\sheet.xml contains following data.

```<code><x:row>
  <x:c t="inlineStr">
    <x:is>
      <x:t>Data in cell</x:t>
    </x:is>
  </x:c>
  ..
</x:row>
</code>```

So no any row/column identifiers are present in previous snippet. Maybe the root cause of problem?

Another thing to notice is that when open and save same file in Excel without modifications, file size increases and sheet data seem to be moved from sheet.xml to sharedstrings.xml. After succesful saving in Excel, only row/column indices are present in sheet1.xml and file can be properly parsed with EPPlus.

答:
Problem in this case was that there were no row/column identifiers present in sheet data. Incorrect Excel file was created with custom program using Open XML SDK. </p>

<p>According to Open XML SDK Guidelines (https://msdn.microsoft.com/en-us/library/office/gg278309.aspx), missing row/column identifiers is error against Excel data format so problem was not in EPPlus library. </p>

Body:
I have xlsx-file which opens succesfully with Excel and which can be parsed with other excel-libraries than EPPlus. We are likely to continue using EPPlus, so it will be nice to get some advice with this issue.

Excel data in is plain text data without formatting.

When parsing with EPPlus with C#, let's say 3x3 sheet, parsed data is fragmented following way to memory (empty cells added to every row so total size is 3x9 or something):

r1c1 r1c2 r1c3
               r2c1 r2c2 r2c3
                              r3c1 r3c2 r3c3

instead of 3x3 array

r1c1 r1c2 r1c3
r2c1 r2c2 r2c3
r3c1 r3c2 r3c3

When opening xlsx-archive with zip viewer it seems that xl\worksheets\sheet.xml contains following data.

<x:row>
  <x:c t="inlineStr">
    <x:is>
      <x:t>Data in cell</x:t>
    </x:is>
  </x:c>
  ..
</x:row>

So no any row/column identifiers are present in previous snippet. Maybe the root cause of problem?

Another thing to notice is that when open and save same file in Excel without modifications, file size increases and sheet data seem to be moved from sheet.xml to sharedstrings.xml. After succesful saving in Excel, only row/column indices are present in sheet1.xml and file can be properly parsed with EPPlus.

Body:
Problem in this case was that there were no row/column identifiers present in sheet data. Incorrect Excel file was created with custom program using Open XML SDK.

According to Open XML SDK Guidelines (https://msdn.microsoft.com/en-us/library/office/gg278309.aspx), missing row/column identifiers is error against Excel data format so problem was not in EPPlus library.


问:
How do you generate a list of prime numbers using list comprehension from 1 to 10?
So, I've made this code:

```<code>y = 10
prime_num = [x for x in range(1,y) if y%x != 0]
</code>```

It's returned me:

[3, 4, 6, 7, 8, 9]

The purpose of this code is to generate prime numbers within 1 to 10, it returned me an odd number which I do not quiet get. I was expecting this to work since my list comprehension was an attempted replica of:

```<code>def is_prime(x):
    if x < 2:
        return False
    else:
        for n in range(2, x-1):
            if x % n == 0:
                return False
        return True
</code>```

Which I've created from codecademy, I've simply changed "x%n == 0" to "x%n != 0".

答:
What your code currently does

```<code>[x for x in range(1,y) if y%x != 0]
</code>```

You iterate through the range [1, y) and check if y is not divisible by x. Your code currently generates [1, y) \ Divisors(y), which is clearly not what you want. Instead, you want to a perform primality test on x, and how you shall do so is described below.

What you should do

You should change your list comprehension a bit, because you actually never use is_prime:

```<code>prime_nums = [x for x in range(2, y + 1) if is_prime(x)]
</code>```

By the way, you can improve the efficiency of the primality test significantly by visiting this thread.

If you want to avoid your is_prime() function, you can use the following code:

```<code>prime_nums = [x for x in range(2, y + 1) if all(x%k for k in range(2, x-1))]
</code>```

Body:
So, I've made this code:

y = 10
prime_num = [x for x in range(1,y) if y%x != 0]

It's returned me:

[3, 4, 6, 7, 8, 9]

The purpose of this code is to generate prime numbers within 1 to 10, it returned me an odd number which I do not quiet get. I was expecting this to work since my list comprehension was an attempted replica of:

def is_prime(x):
    if x < 2:
        return False
    else:
        for n in range(2, x-1):
            if x % n == 0:
                return False
        return True

Which I've created from codecademy, I've simply changed "x%n == 0" to "x%n != 0".

Body:
What your code currently does

[x for x in range(1,y) if y%x != 0]

You iterate through the range [1, y) and check if y is not divisible by x. Your code currently generates [1, y) \ Divisors(y), which is clearly not what you want. Instead, you want to a perform primality test on x, and how you shall do so is described below.

What you should do

You should change your list comprehension a bit, because you actually never use is_prime:

prime_nums = [x for x in range(2, y + 1) if is_prime(x)]

By the way, you can improve the efficiency of the primality test significantly by visiting this thread.

If you want to avoid your is_prime() function, you can use the following code:

prime_nums = [x for x in range(2, y + 1) if all(x%k for k in range(2, x-1))]


问:
Which data will be saved when updating an app?
I just know database and sharedPrefence data will be saved when updating an app.
Is there anything else?</p>

答: Everything. On an update, only the program (the binaries) is replaced.</p>


问:
how to get sql statement with tshark?
I have read the user guide carefully and using the command below to get the sql statement on my local macbook.

```<code>tshark  -Y mysql.query -T fields -e mysql.query
</code>```

I have installed mysql locally and run it at port 3306. I have tried the command on Loopback and en0(Wi-Fi).

After I ran the command above I didn't get any output. So I just capture the packet on port 3306, using the command:

```<code>tshark -f 'tcp src port 3306 or tcp dst port 3306'
</code>```

However ,I still can't get any packet at port 3306, though I have ran many sqls such as:

```<code>select * from wanshao_src;
show databases;
insert into wanshao_src(name,age) values('Jack',18).
</code>```

I am using mysql 5.7.20.

Do I miss some important point during my test?

答: I tried to connect to a remote db server and execute some sql, then the command works.</p>

Title: how to get sql statement with tshark?

Body:
I have read the user guide carefully and using the command below to get the sql statement on my local macbook.

tshark  -Y mysql.query -T fields -e mysql.query

I have installed mysql locally and run it at port 3306. I have tried the command on Loopback and en0(Wi-Fi).

After I ran the command above I didn't get any output. So I just capture the packet on port 3306, using the command:

tshark -f 'tcp src port 3306 or tcp dst port 3306'

However ,I still can't get any packet at port 3306, though I have ran many sqls such as:

select * from wanshao_src;
show databases;
insert into wanshao_src(name,age) values('Jack',18).

I am using mysql 5.7.20.

Do I miss some important point during my test?


问:
How to get substring between nth and n+1th occurrence of pipe '|' in shell script
I have a large text file (20 million records) with all rows in below format

```<code>task|action||r1_c1|r1_c2|r1_c3
task|action||r2_c1|r2_c2|r2_c3
task|action||r3_c1|r3_c2|r3_c3
task|action||r4_c1|r4_c2|r4_c3
</code>```

My requirement is to print column 2 from nth row where n is my input. Column number is fixed but row number will change based on input.

Expected Output  if Input parameter (Line Number) is 3 -

```<code>r3_c2
</code>```

I can read file line by line and read nth line in variable

```<code>LineOfInterest=$(awk 'NR == n' n=$line $InputFile)
</code>```

Next I need to print values between 4th and 5th occurrence of pipe.

I believe it can be achieved using sed but now sure how to write pattern for same.

答:
You can use the following command:

```<code>Line=3;
awk -v n="$Line" -F'|' 'NR == n {print $5;exit;}' file
</code>```

This will produce as requested:

```<code>r3_c2
</code>```

if I pass 3 as input

Body:
I have a large text file (20 million records) with all rows in below format

task|action||r1_c1|r1_c2|r1_c3
task|action||r2_c1|r2_c2|r2_c3
task|action||r3_c1|r3_c2|r3_c3
task|action||r4_c1|r4_c2|r4_c3

My requirement is to print column 2 from nth row where n is my input. Column number is fixed but row number will change based on input.

Expected Output  if Input parameter (Line Number) is 3 -

r3_c2

I can read file line by line and read nth line in variable

LineOfInterest=$(awk 'NR == n' n=$line $InputFile)

Next I need to print values between 4th and 5th occurrence of pipe.

I believe it can be achieved using sed but now sure how to write pattern for same.

Body:
You can use the following command:

Line=3;
awk -v n="$Line" -F'|' 'NR == n {print $5;exit;}' file

This will produce as requested:

r3_c2

if I pass 3 as input


问:
Configure Upsource to inspect PHP
Upsource supports inspections and I am trying to configure them.

I have created the Project_Default.xml file under git.

How do I go about inspecting PHP code in upsource?

答:
You also need to make sure you have PHP installed on the server where Upsource is and configure Code Intelligence in your project's settings. Here's the documentation.  https://www.jetbrains.com/help/upsource/creating-a-project-code-intelligence.html

TLDR: In Project's settings go to "Code Intelligence" tab, check "Enable Code Intelligence", check "Run inspections" and specify which PHP version your project's using.

Title: Configure Upsource to inspect PHP


问:
Trying to use Spring Boot REST to Read JSON String from POST
Am using the latest version of Spring Boot to read in a sample JSON via Restful Web Service...

Here's my pom.xml:

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
         http://maven.apache.org/maven-v4_0_0.xsd"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>

    <groupId>org.springframework</groupId>
    <artifactId>myservice</artifactId>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.2.RELEASE</version>
    </parent>

    <properties>
        <java.version>1.7</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-rest-webmvc</artifactId>
        </dependency>
        <dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </repository>
        <repository>
            <id>org.jboss.repository.releases</id>
            <name>JBoss Maven Release Repository</name>
            <url>https://repository.jboss.org/nexus/content/repositories/releases</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>

</project>
</code>```

Here's my web service code:

```<code>import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/myservice")
public class BaseService {

    @RequestMapping(value="/process", method = RequestMethod.POST)
    public void process(@RequestBody String payload) throws Exception {
        System.out.println(payload);
    }
}
</code>```

When I invoke it using the following command:

```<code>curl -H "Accept: application/json" -H "Content-type: application/json"
-X POST -d '{"name":"value"}' http://localhost:8080/myservice/process
</code>```

I get this error message:

```<code>{"timestamp":1427515733546,"status":400,
 "error":"Bad Request",

"exception":
"org.springframework.http.converter.HttpMessageNotReadableException","
 message":
 "Could not read JSON: Can not deserialize instance of java.lang.String
  out of START_OBJECT token\n at

 [Source: java.io.PushbackInputStream@8252f; line: 1, column: 1];
  nested    exception is com.fasterxml.jackson.databind.JsonMappingException:
  Can not deserialize instance of java.lang.String out of START_OBJECT token\n
  at [Source: java.io.PushbackInputStream@8252f; line: 1, column: 1]",
  "path":"/myservice/process"
</code>```

The only thing I am trying to do is pass in some valid JSON (as a string via curl) and to see if the String payload enters the process method as {"name":"value"}

What am I possibly doing wrong?

Thank you for taking the time to read this...

答:
To add on to Andrea's solution, if you are passing an array of JSONs for instance

```<code>[
    {"name":"value"},
    {"name":"value2"}
]
</code>```

Then you will need to set up the Spring Boot Controller like so:

```<code>@RequestMapping(
    value = "/process",
    method = RequestMethod.POST)
public void process(@RequestBody Map<String, Object>[] payload)
    throws Exception {

    System.out.println(payload);

}
</code>```

Body:
Am using the latest version of Spring Boot to read in a sample JSON via Restful Web Service...

Here's my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
         http://maven.apache.org/maven-v4_0_0.xsd"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>

    <groupId>org.springframework</groupId>
    <artifactId>myservice</artifactId>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.2.RELEASE</version>
    </parent>

    <properties>
        <java.version>1.7</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-rest-webmvc</artifactId>
        </dependency>
        <dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </repository>
        <repository>
            <id>org.jboss.repository.releases</id>
            <name>JBoss Maven Release Repository</name>
            <url>https://repository.jboss.org/nexus/content/repositories/releases</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>

</project>

Here's my web service code:

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/myservice")
public class BaseService {

    @RequestMapping(value="/process", method = RequestMethod.POST)
    public void process(@RequestBody String payload) throws Exception {
        System.out.println(payload);
    }
}

When I invoke it using the following command:

curl -H "Accept: application/json" -H "Content-type: application/json"
-X POST -d '{"name":"value"}' http://localhost:8080/myservice/process

I get this error message:

{"timestamp":1427515733546,"status":400,
 "error":"Bad Request",

"exception":
"org.springframework.http.converter.HttpMessageNotReadableException","
 message":
 "Could not read JSON: Can not deserialize instance of java.lang.String
  out of START_OBJECT token\n at

 [Source: java.io.PushbackInputStream@8252f; line: 1, column: 1];
  nested    exception is com.fasterxml.jackson.databind.JsonMappingException:
  Can not deserialize instance of java.lang.String out of START_OBJECT token\n
  at [Source: java.io.PushbackInputStream@8252f; line: 1, column: 1]",
  "path":"/myservice/process"

The only thing I am trying to do is pass in some valid JSON (as a string via curl) and to see if the String payload enters the process method as {"name":"value"}

What am I possibly doing wrong?

Thank you for taking the time to read this...

Body:
To add on to Andrea's solution, if you are passing an array of JSONs for instance

[
    {"name":"value"},
    {"name":"value2"}
]

Then you will need to set up the Spring Boot Controller like so:

@RequestMapping(
    value = "/process",
    method = RequestMethod.POST)
public void process(@RequestBody Map<String, Object>[] payload)
    throws Exception {

    System.out.println(payload);

}


问:
font-awesome is not working properly on second load in IE11 over https
I have an issue in angular 2 where we are using font-awesome for the styling and font. On local it is working as expected but when we deploy the code it is working on first load but when you refresh the page then it removes all the styles and behave differently. </p>

答:
This issue is probably due to caching problems.
Here, you can find a little documentation about Font-Awesome troubleshouting : https://github.com/FortAwesome/Font-Awesome/wiki/Troubleshooting

Check the following:

You properly configured server's MIME types (Ref: #5559);

You properly configured Cross-origin Resource Sharing (CORS);

For Internet Explorer: you don't serve files with no-store option in Cache-control header (Ref: #6454);

For Internet Explorer and HTTPS: you don't serve files with no-cache option in Pragma header;

For Internet Explorer: try to get rid of the query strings inside the @font-face definitions. You need a custom css file (Ref: #3286).

Try the Internet Explorer Compatibility Mode as well :

This feature will cause some random issues with IE, so please disable
it by adding the meta tag as the FIRST tag in your :
<meta http-equiv="X-UA-Compatible" content="IE=edge">