问:
Using Vue with Tween JS makes tween sometimes reset
I'm trying to animate a counter that I've made with Vue.js.

The value is being animated by Tween.js and then formatted with Numeral js but I'm having an issue.

I'd like to increment by a random amount, and when I increment, animate the number from whatever it is currently showing to the new total.

I have num which holds the final value of the counter, and displayNum which holds the animating value.

The issue is that my current code (if you hammer the increment button) sometimes starts animating the number from 0, rather than the current total. Especially when you get to over 1,000.

How can I stop this behaviour?

At present, whenever you click increment it takes the currently displayed number and starts a new tween to the target number.

function animate(time) {
    requestAnimationFrame(animate);
    TWEEN.update(time);
}
requestAnimationFrame(animate);

var v = new Vue({
  'el' : '#app',
  'data' : {
    num : 0,
    displayNum : 0,
    tween : false
  },
  methods:{
    increment(){
      var vm = this;
      // select a random number and add it to our target
      vm.num += Math.round(Math.random() * 300);
      // create an object that we can use tween.js to animate
      var anim = { num: vm.displayNum };
      // if we are already animating, stop the animation
      if( vm.tween ){
        vm.tween.stop();
      }
      // create a new animation from the current number
      vm.tween = new TWEEN.Tween(anim)
        // to our new target
        .to({ num : vm.num }, 3000)
        .easing(TWEEN.Easing.Quadratic.Out)
        .onUpdate(function() {

          // Failed attempt to debug
          if( anim.num < vm.displayNum ){
            console.log("Something isn't right");
          }
          // on update, replace the display number with a rounded, formatted
          // version of the animating number
          vm.displayNum = numeral(Math.round(anim.num)).format('0,0');
        })
        // if the tween ever stops, set the vm's current tween to
        // false
        .onStop(function(){
          vm.tween = false;
        })
        .start();
    }
  }
})```
<pre class="snippet-code-css lang-css prettyprint-override"><code>html, body{
  height:100%;
}
body{
  display:flex;
  align-items:center;
  justify-content:center;
}
.window{
  width:200px;
}</code>```

<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.1/css/bulma.min.css" rel="stylesheet"/>

      <button class="button" @click="increment">Increment</button>

```

答:
The problem is you are mixing strings and integers up. First, make sure displayNum is a string on the model and then when you initialize the animation make sure to parseInt it while removing the comma that shows up when you go over 999.

function animate(time) {
    requestAnimationFrame(animate);
    TWEEN.update(time);
}
requestAnimationFrame(animate);

var v = new Vue({
  'el' : '#app',
  'data' : {
    num : 0,
    displayNum : "0",
    tween : false
  },
  methods:{
    increment(){
      var vm = this;
      // select a random number and add it to our target
      vm.num += Math.round(Math.random() * 300);
      // create an object that we can use tween.js to animate
      var anim = { num: parseInt(vm.displayNum.replace(",","")) };
      // if we are already animating, stop the animation
      if( vm.tween ){
        vm.tween.stop();
      }
      // create a new animation from the current number
      vm.tween = new TWEEN.Tween(anim)
        // to our new target
        .to({ num : vm.num }, 3000)
        .easing(TWEEN.Easing.Quadratic.Out)
        .onUpdate(function() {

          // Failed attempt to debug
          //if( anim.num < vm.displayNum ){
          //  console.log("Something isn't right", anim, vm.displayNum);
          //}
          // on update, replace the display number with a rounded, formatted
          // version of the animating number
          vm.displayNum = numeral(Math.round(anim.num)).format('0,0');
        })
        // if the tween ever stops, set the vm's current tween to
        // false
        .onStop(function(){
          vm.tween = false;
        })
        .start();
    }
  }
})```
<pre class="snippet-code-css lang-css prettyprint-override"><code>html, body{
  height:100%;
}
body{
  display:flex;
  align-items:center;
  justify-content:center;
}
.window{
  width:200px;
}</code>```

<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.1/css/bulma.min.css" rel="stylesheet"/>

      <button class="button" @click="increment">Increment</button>

```

Body:
I'm trying to animate a counter that I've made with Vue.js.

The value is being animated by Tween.js and then formatted with Numeral js but I'm having an issue.

I'd like to increment by a random amount, and when I increment, animate the number from whatever it is currently showing to the new total.

I have num which holds the final value of the counter, and displayNum which holds the animating value.

The issue is that my current code (if you hammer the increment button) sometimes starts animating the number from 0, rather than the current total. Especially when you get to over 1,000.

How can I stop this behaviour?

At present, whenever you click increment it takes the currently displayed number and starts a new tween to the target number.

function animate(time) {
    requestAnimationFrame(animate);
    TWEEN.update(time);
}
requestAnimationFrame(animate);

var v = new Vue({
  'el' : '#app',
  'data' : {
    num : 0,
    displayNum : 0,
    tween : false
  },
  methods:{
    increment(){
      var vm = this;
      // select a random number and add it to our target
      vm.num += Math.round(Math.random() * 300);
      // create an object that we can use tween.js to animate
      var anim = { num: vm.displayNum };
      // if we are already animating, stop the animation
      if( vm.tween ){
        vm.tween.stop();
      }
      // create a new animation from the current number
      vm.tween = new TWEEN.Tween(anim)
        // to our new target
        .to({ num : vm.num }, 3000)
        .easing(TWEEN.Easing.Quadratic.Out)
        .onUpdate(function() {

          // Failed attempt to debug
          if( anim.num < vm.displayNum ){
            console.log("Something isn't right");
          }
          // on update, replace the display number with a rounded, formatted
          // version of the animating number
          vm.displayNum = numeral(Math.round(anim.num)).format('0,0');
        })
        // if the tween ever stops, set the vm's current tween to
        // false
        .onStop(function(){
          vm.tween = false;
        })
        .start();
    }
  }
})

html, body{
  height:100%;
}
body{
  display:flex;
  align-items:center;
  justify-content:center;
}
.window{
  width:200px;
}

<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.1/css/bulma.min.css" rel="stylesheet"/>

      <button class="button" @click="increment">Increment</button>

Body:
The problem is you are mixing strings and integers up. First, make sure displayNum is a string on the model and then when you initialize the animation make sure to parseInt it while removing the comma that shows up when you go over 999.

function animate(time) {
    requestAnimationFrame(animate);
    TWEEN.update(time);
}
requestAnimationFrame(animate);

var v = new Vue({
  'el' : '#app',
  'data' : {
    num : 0,
    displayNum : "0",
    tween : false
  },
  methods:{
    increment(){
      var vm = this;
      // select a random number and add it to our target
      vm.num += Math.round(Math.random() * 300);
      // create an object that we can use tween.js to animate
      var anim = { num: parseInt(vm.displayNum.replace(",","")) };
      // if we are already animating, stop the animation
      if( vm.tween ){
        vm.tween.stop();
      }
      // create a new animation from the current number
      vm.tween = new TWEEN.Tween(anim)
        // to our new target
        .to({ num : vm.num }, 3000)
        .easing(TWEEN.Easing.Quadratic.Out)
        .onUpdate(function() {

          // Failed attempt to debug
          //if( anim.num < vm.displayNum ){
          //  console.log("Something isn't right", anim, vm.displayNum);
          //}
          // on update, replace the display number with a rounded, formatted
          // version of the animating number
          vm.displayNum = numeral(Math.round(anim.num)).format('0,0');
        })
        // if the tween ever stops, set the vm's current tween to
        // false
        .onStop(function(){
          vm.tween = false;
        })
        .start();
    }
  }
})

html, body{
  height:100%;
}
body{
  display:flex;
  align-items:center;
  justify-content:center;
}
.window{
  width:200px;
}

<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.1/css/bulma.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tween.js/r14/Tween.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.3/vue.min.js"></script>

<div id="app">
  <div class="window has-text-centered">
    <div class="is-size-1">
      <span v-html="displayNum"></span>
    </div>
    <div>
      <button class="button" @click="increment">Increment</button>
    </div>
    <div class="is-size-7">
      <span v-html="num"></span>
    </div>
  </div>
</div>


来源: stackexchange

问:
When I use aspect - bean does not injected
When I use spring-aspect - bean myClass does not injected. Why it possible, and what can i do to enable injection it this case?

If aop:config is commented out in the XML, output is:

```<code>myClass from constructor: MyClass{myInt=3333}
myClass from main: MyClass{myInt=3333}
app logEvent
</code>```

If aop:config is NOT commented out in the XML, output is:

```<code>myClass from constructor: MyClass{myInt=3333}
myClass from main: null
LOG: BEFORE : App logEvent
app logEvent
</code>```

App.java

```<code>public class App {
    MyClass myClass;

    public static void main(String[] args) {
        ApplicationContext ctx;
        ctx = new ClassPathXmlApplicationContext("conf.xml");
        App app = (App) ctx.getBean("app");

        System.out.println("myClass from main: " + app.myClass);
        app.logEvent();
    }

    public App(MyClass myClass) {
        this.myClass = myClass;
        System.out.println("myClass from constructor: " + this.myClass);
    }

    public void logEvent(){
        System.out.println("app logEvent");
    }
}
</code>```

MyClass.java

```<code>public class MyClass {
    int myInt=6789;

    public int getMyInt() {return myInt;}

    public void setMyInt(int myInt) {this.myInt = myInt;}

    @Override
    public String toString() {return "MyClass{myInt=" + myInt +'}'; }
}
</code>```

MyAspect.java

```<code>public class MyAspect {
    public void logBefore(JoinPoint joinPoint) {
        System.out.println("LOG: BEFORE : " +
                joinPoint.getTarget()
                        .getClass().getSimpleName() + " " +
                joinPoint.getSignature()
                        .getName()
        );
    }
}
</code>```

Conf.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:c="http://www.springframework.org/schema/c" xmlns:p="http://www.springframework.org/schema/p"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

<bean id="app" class="com.geka.spring2.App" c:myClass-ref="myClass"/>
<bean id="myClass" class="com.geka.spring2.MyClass" p:myInt="3333" />

<bean id="aBean" class="com.geka.spring2.MyAspect"  />

<aop:aspectj-autoproxy />

<aop:config>
    <aop:aspect id="myAspect" ref="aBean">
        <aop:pointcut id="cLogg" expression="execution(* *.logEvent(..))"/>
        <aop:before pointcut-ref="cLogg" method="logBefore"/>
    </aop:aspect>
</aop:config>
</code>```

答: MyClass does not seem to be a @Component and will therefore probably not be found in the ComponentScan

ContentLicense: CC BY-SA 3.0

Body:
When I use spring-aspect - bean myClass does not injected. Why it possible, and what can i do to enable injection it this case?

If aop:config is commented out in the XML, output is:

myClass from constructor: MyClass{myInt=3333}
myClass from main: MyClass{myInt=3333}
app logEvent

If aop:config is NOT commented out in the XML, output is:

myClass from constructor: MyClass{myInt=3333}
myClass from main: null
LOG: BEFORE : App logEvent
app logEvent

App.java

public class App {
    MyClass myClass;

    public static void main(String[] args) {
        ApplicationContext ctx;
        ctx = new ClassPathXmlApplicationContext("conf.xml");
        App app = (App) ctx.getBean("app");

        System.out.println("myClass from main: " + app.myClass);
        app.logEvent();
    }

    public App(MyClass myClass) {
        this.myClass = myClass;
        System.out.println("myClass from constructor: " + this.myClass);
    }

    public void logEvent(){
        System.out.println("app logEvent");
    }
}

MyClass.java

public class MyClass {
    int myInt=6789;

    public int getMyInt() {return myInt;}

    public void setMyInt(int myInt) {this.myInt = myInt;}

    @Override
    public String toString() {return "MyClass{myInt=" + myInt +'}'; }
}

MyAspect.java

public class MyAspect {
    public void logBefore(JoinPoint joinPoint) {
        System.out.println("LOG: BEFORE : " +
                joinPoint.getTarget()
                        .getClass().getSimpleName() + " " +
                joinPoint.getSignature()
                        .getName()
        );
    }
}

Conf.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:c="http://www.springframework.org/schema/c" xmlns:p="http://www.springframework.org/schema/p"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

<bean id="app" class="com.geka.spring2.App" c:myClass-ref="myClass"/>
<bean id="myClass" class="com.geka.spring2.MyClass" p:myInt="3333" />

<bean id="aBean" class="com.geka.spring2.MyAspect"  />

<aop:aspectj-autoproxy />

<aop:config>
    <aop:aspect id="myAspect" ref="aBean">
        <aop:pointcut id="cLogg" expression="execution(* *.logEvent(..))"/>
        <aop:before pointcut-ref="cLogg" method="logBefore"/>
    </aop:aspect>
</aop:config>


问:
Loop Through Immutable JS Record
I'm new to using the ImmutableJS library and I've been having some trouble figuring this out. I have an Immutable Record object called Options. I want to be able to loop through this Record, getting the key and value for each item in the Record. Here's what my Options model looks like:

```<code>export class Option extends Record ({
  height: '10px',
  width: '47px',
  title: 'foo',
  isAvailable: false
}) {
  constructor(props) {
    if (!props) {
      super();
      return;
    }
  }
}
</code>```

I've written the following to loop through each element inside my Options Record, but it doesn't seem to work:

```<code>var options = new Options();
options.toSeq().map((value, key) => {
  console.log(key + ': ' + value);
});
</code>```

I would expect that this writes each key/value pair inside my Options Immutable Record to the console window. However, it doesn't print anything and doesn't even seem to run the code within the map function at all.

Please let me know if you have any idea what is wrong here. Thanks in advance! :)

答:
Use toMap instead of toSeq

```<code>var options = new Options();
options.toMap().map((value, key) => {
  console.log(key + ': ' + value);
});
</code>```

http://jsfiddle.net/w6h4soay/

Title: Loop Through Immutable JS Record

Body:
I'm new to using the ImmutableJS library and I've been having some trouble figuring this out. I have an Immutable Record object called Options. I want to be able to loop through this Record, getting the key and value for each item in the Record. Here's what my Options model looks like:

export class Option extends Record ({
  height: '10px',
  width: '47px',
  title: 'foo',
  isAvailable: false
}) {
  constructor(props) {
    if (!props) {
      super();
      return;
    }
  }
}

I've written the following to loop through each element inside my Options Record, but it doesn't seem to work:

var options = new Options();
options.toSeq().map((value, key) => {
  console.log(key + ': ' + value);
});

I would expect that this writes each key/value pair inside my Options Immutable Record to the console window. However, it doesn't print anything and doesn't even seem to run the code within the map function at all.

Please let me know if you have any idea what is wrong here. Thanks in advance! :)

Body:
Use toMap instead of toSeq

var options = new Options();
options.toMap().map((value, key) => {
  console.log(key + ': ' + value);
});

http://jsfiddle.net/w6h4soay/


问:
RoR - Nested attributes wrong number of arguments?
Currently following a tutorial, where a nested form should be implemented. However, when i run rails c and try to create a new Portfolio with the nested attributes, i get an

```<code>ArgumentError: wrong number of arguments (given 1, expected 0)
    from app/models/portfolio.rb:4:in `block in <class:Portfolio>'
    from (irb):15
</code>```

Command i ran inside rails c:

```<code>Portfolio.create!(title: 'Title', subtitle:'Title1', body:'Title3',
technologies_attributes:[{name: 'Ruby'}])
</code>```

The Portfolio.rb file:

```<code>class Portfolio < ApplicationRecord
  has_many :technologies
  accepts_nested_attributes_for :technologies,
                                reject_if: lambda { |attrs| attrs['name'].blank? }

  include Placeholder
  validates_presence_of :title, :body, :main_image, :thumb_image

  def self.angular
    where(subtitle: 'Angular!')
  end

  def self.ruby
    where(subtitle: 'Ruby on Rails!')
  end

  after_initialize :set_defaults

  def set_defaults
    self.main_image ||= Placeholder.image_generator(height: '600', width: '400')
    self.thumb_image ||= Placeholder.image_generator(height: '350', width: '200')
  end

end
</code>```

Any ideas what would cause that?

Thanks in advance!

答:
It looks like like you're passing an array of hashes as the nested attributes here

Portfolio.create!(title: 'Title', subtitle:'Title1', body:'Title3',
technologies_attributes:[{name: 'Ruby'}])

Try passing the attributes like this

```<code>params = {
    portfolio: { title: 'Title', subtitle:'Title1', body:'Title3',
        technologies_attributes:[
            {name: 'Ruby'}
        ]
    }
}
Portfolio.create!(params)
</code>```

Body:
Currently following a tutorial, where a nested form should be implemented. However, when i run rails c and try to create a new Portfolio with the nested attributes, i get an

ArgumentError: wrong number of arguments (given 1, expected 0)
    from app/models/portfolio.rb:4:in `block in <class:Portfolio>'
    from (irb):15

Command i ran inside rails c:

Portfolio.create!(title: 'Title', subtitle:'Title1', body:'Title3',
technologies_attributes:[{name: 'Ruby'}])

The Portfolio.rb file:

class Portfolio < ApplicationRecord
  has_many :technologies
  accepts_nested_attributes_for :technologies,
                                reject_if: lambda { |attrs| attrs['name'].blank? }

  include Placeholder
  validates_presence_of :title, :body, :main_image, :thumb_image

  def self.angular
    where(subtitle: 'Angular!')
  end

  def self.ruby
    where(subtitle: 'Ruby on Rails!')
  end

  after_initialize :set_defaults

  def set_defaults
    self.main_image ||= Placeholder.image_generator(height: '600', width: '400')
    self.thumb_image ||= Placeholder.image_generator(height: '350', width: '200')
  end

end

Any ideas what would cause that?

Thanks in advance!

Body:
It looks like like you're passing an array of hashes as the nested attributes here

Portfolio.create!(title: 'Title', subtitle:'Title1', body:'Title3',
technologies_attributes:[{name: 'Ruby'}])

Try passing the attributes like this

params = {
    portfolio: { title: 'Title', subtitle:'Title1', body:'Title3',
        technologies_attributes:[
            {name: 'Ruby'}
        ]
    }
}
Portfolio.create!(params)


问:
how to add this in fragment
I am trying to combine fragment with activity. But I end up with an error.

FRAGMENT CODE:

```<code>public class QFragment extends Fragment {@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    //returning our layout file
    //change R.layout.yourlayoutfilename for each of your fragments
    return inflater.inflate(R.layout.fragment_q, container, false);
}

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        //you can set the title for your toolbar here for different fragments different titles
        getActivity().setTitle("QFragment");
    }
}
</code>```

One is being used as an activity other is a fragment. I am new to fragment concept.

Main Activity code:

```<code>    public class SpinnerEx4Activity extends Activity implements
    OnItemSelectedListener{
    Spinner s1,s2;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_spinner_ex4);
            s1 = (Spinner)findViewById(R.id.spinner1);
            s2 = (Spinner)findViewById(R.id.spinner2);
            s1.setOnItemSelectedListener(this);
        }
        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub
            String sp1= String.valueOf(s1.getSelectedItem());
            Toast.makeText(this, sp1, Toast.LENGTH_SHORT).show();
            if(sp1.contentEquals("Income")) {
                List<String> list = new ArrayList<String>();
                list.add("Salary");
                list.add("Sales");
                list.add("Others");
                ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_spinner_item, list);
                dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                dataAdapter.notifyDataSetChanged();
                s2.setAdapter(dataAdapter);
            }
            if(sp1.contentEquals("Expense")) {
                List<String> list = new ArrayList<String>();
                list.add("Conveyance");
                list.add("Breakfast");
                list.add("Purchase");
                ArrayAdapter<String> dataAdapter2 = new ArrayAdapter<String>(this,
                    android.R.layout.simple_spinner_item, list);
                dataAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                dataAdapter2.notifyDataSetChanged();
                s2.setAdapter(dataAdapter2);
            }

        }
        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }
    }
</code>```

So what is the way to solve this? I want the Bottom navigation bar in my app.

答:
for the 3 errors you mentioned, please replace this with your class name
SpinnerEx4Activity.this for all three lines like this.

```<code>Toast.makeText(SpinnerEx4Activity.this, sp1, Toast.LENGTH_SHORT).show();

ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(SpinnerEx4Activity.this, android.R.layout.simple_spinner_item, list);

ArrayAdapter<String> dataAdapter2 = new ArrayAdapter<String>(SpinnerEx4Activity.this, android.R.layout.simple_spinner_item, list);
</code>```

ContentLicense: CC BY-SA 4.0

Title: how to add this in fragment

Body:
I am trying to combine fragment with activity. But I end up with an error.

FRAGMENT CODE:

public class QFragment extends Fragment {@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    //returning our layout file
    //change R.layout.yourlayoutfilename for each of your fragments
    return inflater.inflate(R.layout.fragment_q, container, false);
}

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        //you can set the title for your toolbar here for different fragments different titles
        getActivity().setTitle("QFragment");
    }
}

One is being used as an activity other is a fragment. I am new to fragment concept.

Main Activity code:

    public class SpinnerEx4Activity extends Activity implements
    OnItemSelectedListener{
    Spinner s1,s2;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_spinner_ex4);
            s1 = (Spinner)findViewById(R.id.spinner1);
            s2 = (Spinner)findViewById(R.id.spinner2);
            s1.setOnItemSelectedListener(this);
        }
        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub
            String sp1= String.valueOf(s1.getSelectedItem());
            Toast.makeText(this, sp1, Toast.LENGTH_SHORT).show();
            if(sp1.contentEquals("Income")) {
                List<String> list = new ArrayList<String>();
                list.add("Salary");
                list.add("Sales");
                list.add("Others");
                ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_spinner_item, list);
                dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                dataAdapter.notifyDataSetChanged();
                s2.setAdapter(dataAdapter);
            }
            if(sp1.contentEquals("Expense")) {
                List<String> list = new ArrayList<String>();
                list.add("Conveyance");
                list.add("Breakfast");
                list.add("Purchase");
                ArrayAdapter<String> dataAdapter2 = new ArrayAdapter<String>(this,
                    android.R.layout.simple_spinner_item, list);
                dataAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                dataAdapter2.notifyDataSetChanged();
                s2.setAdapter(dataAdapter2);
            }

        }
        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }
    }

So what is the way to solve this? I want the Bottom navigation bar in my app.

Body:
for the 3 errors you mentioned, please replace this with your class name
SpinnerEx4Activity.this for all three lines like this.

Toast.makeText(SpinnerEx4Activity.this, sp1, Toast.LENGTH_SHORT).show();

ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(SpinnerEx4Activity.this, android.R.layout.simple_spinner_item, list);

ArrayAdapter<String> dataAdapter2 = new ArrayAdapter<String>(SpinnerEx4Activity.this, android.R.layout.simple_spinner_item, list);


问:
Tab Key Functionality Using Enter Key in VB.Net
I have a form with nearly 20 Textbox and 5 Combobox  and one control in dependent on the other,
Now I want to write the code for the form in such a way that, Pressing Enter Key and Tab Key should have the same functionality.

Like on pressing Tab Key the focus moves to next control should also be performed when I press the Enter Key.
Similarly when I press the Enter Key, there is some process code written in key press event but this should also be performed when I press the Tab Key.

答:
I was able to accomplish this without having to manually create or set event handlers for each control.  At the initialization of the form, I run a function that loops through every control and adds a generic handler function.</p>

```<code>Private Sub AddHandlers()
    Try
        'Get the first control in the tab order.
        Dim ctl As Windows.Forms.Control = Me.GetNextControl(Me, True)
        Do Until ctl Is Nothing
            If TypeOf ctl Is System.Windows.Forms.TextBox Or TypeOf ctl Is System.Windows.Forms.ComboBox _
                    Or TypeOf ctl Is System.Windows.Forms.CheckBox Or TypeOf ctl Is System.Windows.Forms.DateTimePicker Then

                AddHandler ctl.KeyDown, AddressOf ReturnKeyTabs
            End If
            'Get the next control in the tab order.
            ctl = Me.GetNextControl(ctl, True)
        Loop
    Catch ex As Exception
    End Try
End Sub

Private Sub ReturnKeyTabs(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
    If e.KeyCode = System.Windows.Forms.Keys.Return Then
        e.Handled = True
        e.SuppressKeyPress = True
    End If
    ReturnKeyTabs(e.KeyCode)
End Sub

Private Sub ReturnKeyTabs(ByVal KeyCode As System.Windows.Forms.Keys)
    If KeyCode = System.Windows.Forms.Keys.Return Then
        System.Windows.Forms.SendKeys.Send("{Tab}")
        KeyCode = 0
    End If
End Sub
</code>```

Body:
I was able to accomplish this without having to manually create or set event handlers for each control.  At the initialization of the form, I run a function that loops through every control and adds a generic handler function.

Private Sub AddHandlers()
    Try
        'Get the first control in the tab order.
        Dim ctl As Windows.Forms.Control = Me.GetNextControl(Me, True)
        Do Until ctl Is Nothing
            If TypeOf ctl Is System.Windows.Forms.TextBox Or TypeOf ctl Is System.Windows.Forms.ComboBox _
                    Or TypeOf ctl Is System.Windows.Forms.CheckBox Or TypeOf ctl Is System.Windows.Forms.DateTimePicker Then

                AddHandler ctl.KeyDown, AddressOf ReturnKeyTabs
            End If
            'Get the next control in the tab order.
            ctl = Me.GetNextControl(ctl, True)
        Loop
    Catch ex As Exception
    End Try
End Sub

Private Sub ReturnKeyTabs(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
    If e.KeyCode = System.Windows.Forms.Keys.Return Then
        e.Handled = True
        e.SuppressKeyPress = True
    End If
    ReturnKeyTabs(e.KeyCode)
End Sub

Private Sub ReturnKeyTabs(ByVal KeyCode As System.Windows.Forms.Keys)
    If KeyCode = System.Windows.Forms.Keys.Return Then
        System.Windows.Forms.SendKeys.Send("{Tab}")
        KeyCode = 0
    End If
End Sub


问:
Can I use Firebase Remote config in an Android library module and still alow the library consumer to use it?
Is it possible to use Firebase Remote config in an Android library module and still allow the library consumer to use Firebase Remote Config with their own acount?

I have created an Android library that uses Firebase Remote Config to update the library configuration from my Firebase console account.

In my reference/test app that references the library I have my google-services.json in the app directory. Everything works perfectly.

I have just realised that once I provide my library to others as an aar they will potentially have their own google-services.json and use Firebase directly in their own app.

I have searched google but I'm finding it difficult to find out if this is even possible? Has anyone had experience with this setup or know how it should work? The only thing I could think of trying was moving my google-services.json into the library but I couldn't get this working.

Thanks in advance for any help!

答:
Use of Firebase SDKs in third-party modules was never intended by the Firebase team.  The SDKs all depend very heavily on a host project that's configured by the app as a whole, not by a module.  In fact, you can't use the google-services plugin in the library module, only in an app module.

Remote Config is even more complicated in that it depends heavily on Analytics, which is definitely only viable as an app-level dependency (you can't have two projects collecting Analytics from a single app).

If you try really hard, you might be able to use something like Realtime Database in a third party module where all apps that use it all have access to the same database, but then you'd have to initialize a special FirebaseApp that points to your common project, and make your database world-readable, because you won't have Authentication in place to gate access to individual users.


问:
What is the Aggregate root in this case
I have these entities

User

Task - every task must have a user assigned

Project - a task can be assigned to a project but it's not necessary, user must be assigned as a project creator

TaskStatus - every task must have a status assigned

and I designed the aggregate roots as follows

Aggregate roots

User with entities:Task, Task status

Project

Am I going in right direction ?

答:
Yeah, sounds quite right. This is my improvisation in c#:

```<code>//aggregate root
public class User{/*first name, last name, contacts, etc.*/}

//aggregate root
public class Project{
  public IList Tasks{get; private set;}
  public User CreatedBy{get; private set;}
  public Project(User createdBy){
    CreatedBy=createdBy;
  }
  public RegisterTask(string taskDescription, User assignedTo){
    Tasks.Add(new Task(taskDescription, assignedTo));
  }
  public StartWorkOn(Task task){
    if(!Tasks.Contains(task))
      throw new Exception("Task is not registered");
    task.StartWork();
  }
}

//entity
public class Task{
  public User AssignedTo{get;private set;}
  public string Description{get; private set;}
  public TaskStatus Status{get; private set;}
  internal Task(string description, User assignedTo){
    AssignedTo=assignedTo;
    Description=description;
    Status=TaskStatus.Pending;
  }
  internal void StartWork(){
    if(Status!=TaskStatus.Pending)
      throw new Exception("Can't start what's ongoing");
    Status=TaskStatus.InProgress;
  }
  internal void Finish(){
    if(Status!=TaskStatus.InProgress)
      throw new Exception("Can't finish what has not started");
    Status=TaskStatus.Finished;
  }
}

//value object
public enum TaskStatus{ Pending, InProgress, Finished }

var me=new User();
_users.Save(me);

var you=new User();
_users.Save(you);

var project=new Project(me);
project.RegisterTask("Have a nice day!", you);
project.StartWorkOn(project.Tasks.First());
_projects.Save(project);
</code>```

Keep in mind - that's just a sketch. Don't take it too seriously.

ContentLicense: CC BY-SA 2.5

Title: What is the Aggregate root in this case

Body:
Yeah, sounds quite right. This is my improvisation in c#:

//aggregate root
public class User{/*first name, last name, contacts, etc.*/}

//aggregate root
public class Project{
  public IList Tasks{get; private set;}
  public User CreatedBy{get; private set;}
  public Project(User createdBy){
    CreatedBy=createdBy;
  }
  public RegisterTask(string taskDescription, User assignedTo){
    Tasks.Add(new Task(taskDescription, assignedTo));
  }
  public StartWorkOn(Task task){
    if(!Tasks.Contains(task))
      throw new Exception("Task is not registered");
    task.StartWork();
  }
}

//entity
public class Task{
  public User AssignedTo{get;private set;}
  public string Description{get; private set;}
  public TaskStatus Status{get; private set;}
  internal Task(string description, User assignedTo){
    AssignedTo=assignedTo;
    Description=description;
    Status=TaskStatus.Pending;
  }
  internal void StartWork(){
    if(Status!=TaskStatus.Pending)
      throw new Exception("Can't start what's ongoing");
    Status=TaskStatus.InProgress;
  }
  internal void Finish(){
    if(Status!=TaskStatus.InProgress)
      throw new Exception("Can't finish what has not started");
    Status=TaskStatus.Finished;
  }
}

//value object
public enum TaskStatus{ Pending, InProgress, Finished }

var me=new User();
_users.Save(me);

var you=new User();
_users.Save(you);

var project=new Project(me);
project.RegisterTask("Have a nice day!", you);
project.StartWorkOn(project.Tasks.First());
_projects.Save(project);

Keep in mind - that's just a sketch. Don't take it too seriously.


问:
Issue with recycler view inside constraint layout
I'm trying to create a bottom sheet dialog based on a complex layout.
What I have to achieve is a dialog with an header layout, a recycler view with a list of element and a bottom bar with a couple of buttons.
Here is my code:

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

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <!-- Layout injected inside this linear layout container programmatically -->
        <LinearLayout
            android:id="@+id/header_dialog_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintBottom_toTopOf="@id/form_dialog_recycler_view"
            app:layout_constraintTop_toTopOf="parent" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/form_dialog_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:scrollbars="vertical"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            app:layout_constraintBottom_toTopOf="@id/bottom_sheet_container_buttons"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/header_dialog_container" />

        <LinearLayout
            android:id="@+id/bottom_sheet_container_buttons"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="horizontal"
            app:layout_constraintBottom_toBottomOf="parent">

            <Button
                android:id="@+id/dialog_sheet_button_reset"
                style="@style/ActionSheetTitle"
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="0.5"
                android:background="@color/bottomBarContainerColor"
                android:text="@string/general_reset"
                android:textColor="@color/dangerColor" />

            <Button
                android:id="@+id/dialog_sheet_button_close"
                style="@style/ActionSheetTitle"
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="0.5"
                android:background="@color/bottomBarContainerColor"
                android:text="@string/general_close" />

        </LinearLayout>
    </android.support.constraint.ConstraintLayout>
</layout>
</code>```

Unfortunately my recycler view height is always equal to zero. I tried to change android:layout_height="0dp" to android:layout_height="wrap_content" but as expected it goes below the bottom container. Am I missing something?

答:
I ended up with a different solution. I changed constraint layout with a Linear Layout. And I set up bottom margins.</p>

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/header_dialog_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/form_dialog_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="60dp"
            android:scrollbars="vertical"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

        <LinearLayout
            android:id="@+id/bottom_sheet_container_buttons"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_marginTop="-60dp"
            android:orientation="horizontal">

            <Button
                android:id="@+id/dialog_sheet_button_reset"
                style="@style/ActionSheetTitle"
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="0.5"
                android:background="@color/bottomBarContainerColor"
                android:text="@string/general_reset"
                android:textColor="@color/dangerColor" />

            <Button
                android:id="@+id/dialog_sheet_button_close"
                style="@style/ActionSheetTitle"
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="0.5"
                android:background="@color/bottomBarContainerColor"
                android:text="@string/general_close" />

        </LinearLayout>
    </LinearLayout>
</layout>
</code>```

Body:
I'm trying to create a bottom sheet dialog based on a complex layout.
What I have to achieve is a dialog with an header layout, a recycler view with a list of element and a bottom bar with a couple of buttons.
Here is my code:

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

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/header_dialog_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintBottom_toTopOf="@id/form_dialog_recycler_view"
            app:layout_constraintTop_toTopOf="parent" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/form_dialog_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:scrollbars="vertical"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            app:layout_constraintBottom_toTopOf="@id/bottom_sheet_container_buttons"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/header_dialog_container" />

        <LinearLayout
            android:id="@+id/bottom_sheet_container_buttons"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:orientation="horizontal"
            app:layout_constraintBottom_toBottomOf="parent">

            <Button
                android:id="@+id/dialog_sheet_button_reset"
                style="@style/ActionSheetTitle"
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="0.5"
                android:background="@color/bottomBarContainerColor"
                android:text="@string/general_reset"
                android:textColor="@color/dangerColor" />

            <Button
                android:id="@+id/dialog_sheet_button_close"
                style="@style/ActionSheetTitle"
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="0.5"
                android:background="@color/bottomBarContainerColor"
                android:text="@string/general_close" />

        </LinearLayout>
    </android.support.constraint.ConstraintLayout>
</layout>

Unfortunately my recycler view height is always equal to zero. I tried to change android:layout_height="0dp" to android:layout_height="wrap_content" but as expected it goes below the bottom container. Am I missing something?

Body:
I ended up with a different solution. I changed constraint layout with a Linear Layout. And I set up bottom margins.

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/header_dialog_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/form_dialog_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="60dp"
            android:scrollbars="vertical"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

        <LinearLayout
            android:id="@+id/bottom_sheet_container_buttons"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_marginTop="-60dp"
            android:orientation="horizontal">

            <Button
                android:id="@+id/dialog_sheet_button_reset"
                style="@style/ActionSheetTitle"
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="0.5"
                android:background="@color/bottomBarContainerColor"
                android:text="@string/general_reset"
                android:textColor="@color/dangerColor" />

            <Button
                android:id="@+id/dialog_sheet_button_close"
                style="@style/ActionSheetTitle"
                android:layout_width="0dp"
                android:layout_height="60dp"
                android:layout_weight="0.5"
                android:background="@color/bottomBarContainerColor"
                android:text="@string/general_close" />

        </LinearLayout>
    </LinearLayout>
</layout>


问:
Removing duplicate rows with condition
User sessions are tracked on the system and stored in the following format. Sometimes I get multiple records for the same session id.

```<code>Row session_id                              user_actions
1   8a88d75c-6385-4e36-8d10-e22ac4d976a3    118,139,141
2   8a88d75c-6385-4e36-8d10-e22ac4d976a3    118,139,141,142,143,146
3   e85731b6-4472-40fb-ab2b-33ebd1278ba9    211,114,117,118,141,142,143,146
4   e85731b6-4472-40fb-ab2b-33ebd1278ba9    211,114,117
</code>```

I used to run a sql query with DISTINCT(session_id to keep only one of the multiple records for each session id. BUT I just realized that my query picks the row on the top even when if the bottom row recorded more actions for the same session. So you look at the following table, my query keeps Row 1 & 3, like this;

```<code>Row session_id                              user_actions
1   8a88d75c-6385-4e36-8d10-e22ac4d976a3    118,139,141
3   e85731b6-4472-40fb-ab2b-33ebd1278ba9    211,114,117,118,141,142,143,146
</code>```

Whereas, I would like to keep row 2 and 3, like this;

```<code>Row session_id                              user_actions
2   8a88d75c-6385-4e36-8d10-e22ac4d976a3    118,139,141,142,143,146
3   e85731b6-4472-40fb-ab2b-33ebd1278ba9    211,114,117,118,141,142,143,146
</code>```

Is there anyway to do it with a sql query? Thank you!

答:
Below is one of the option for BigQuery Standard SQL

#standardSQL
SELECT row, session_id, user_actions
FROM (
  SELECT
    row, session_id, user_actions,
    ROW_NUMBER() OVER(PARTITION BY session_id
      ORDER BY ARRAY_LENGTH(SPLIT(user_actions)) DESC
    ) = 1 win
  FROM `project.dataset.table`
)
WHERE win
```

<p>You can test / play with above using dummy data from your question as below   </p>

<pre class="lang-sql prettyprint-override"><code>#standardSQL
WITH `project.dataset.table` AS (
  SELECT 1 row, '8a88d75c-6385-4e36-8d10-e22ac4d976a3' session_id, '118,139,141' user_actions UNION ALL
  SELECT 2, '8a88d75c-6385-4e36-8d10-e22ac4d976a3', '118,139,141,142,143,146' UNION ALL
  SELECT 3, 'e85731b6-4472-40fb-ab2b-33ebd1278ba9', '211,114,117,118,141,142,143,146' UNION ALL
  SELECT 4, 'e85731b6-4472-40fb-ab2b-33ebd1278ba9', '211,114,117'
)
SELECT row, session_id, user_actions
FROM (
  SELECT
    row, session_id, user_actions,
    ROW_NUMBER() OVER(PARTITION BY session_id
      ORDER BY ARRAY_LENGTH(SPLIT(user_actions)) DESC
    ) = 1 win
  FROM `project.dataset.table`
)
WHERE win
ORDER BY row
</code>```

result is

row session_id                              user_actions
2   8a88d75c-6385-4e36-8d10-e22ac4d976a3    118,139,141,142,143,146
3   e85731b6-4472-40fb-ab2b-33ebd1278ba9    211,114,117,118,141,142,143,146
```

<p>Another option would be as below   </p>

<pre class="lang-sql prettyprint-override"><code>#standardSQL
WITH `project.dataset.table` AS (
  SELECT 1 row, '8a88d75c-6385-4e36-8d10-e22ac4d976a3' session_id, '118,139,141' user_actions UNION ALL
  SELECT 2, '8a88d75c-6385-4e36-8d10-e22ac4d976a3', '118,139,141,142,143,146' UNION ALL
  SELECT 3, 'e85731b6-4472-40fb-ab2b-33ebd1278ba9', '211,114,117,118,141,142,143,146' UNION ALL
  SELECT 4, 'e85731b6-4472-40fb-ab2b-33ebd1278ba9', '211,114,117'
)
SELECT session_id,
  ARRAY_AGG(user_actions ORDER BY ARRAY_LENGTH(SPLIT(user_actions)) DESC LIMIT 1)[SAFE_OFFSET(0)] user_actions
FROM `project.dataset.table`
GROUP BY session_id
</code>```

This one looks a little cleaner :o)

You can extend above with for example combining distinct codes from deduplicated entries in case if (for example) some actions are missing in one row but not another and etc.)

Update:

Try below to separate expenses of calculating array_length from ordering in partition:

#standardSQL
SELECT row, session_id, user_actions
FROM (
  SELECT
    row, session_id, user_actions,
    ROW_NUMBER() OVER(PARTITION BY session_id ORDER BY len DESC) = 1 win
  FROM (
    SELECT *, ARRAY_LENGTH(SPLIT(user_actions)) len
    FROM `project.dataset.table`
  )
)
WHERE win
```

Title: Removing duplicate rows with condition

Body:
User sessions are tracked on the system and stored in the following format. Sometimes I get multiple records for the same session id.

Row session_id                              user_actions
1   8a88d75c-6385-4e36-8d10-e22ac4d976a3    118,139,141
2   8a88d75c-6385-4e36-8d10-e22ac4d976a3    118,139,141,142,143,146
3   e85731b6-4472-40fb-ab2b-33ebd1278ba9    211,114,117,118,141,142,143,146
4   e85731b6-4472-40fb-ab2b-33ebd1278ba9    211,114,117

I used to run a sql query with DISTINCT(session_id to keep only one of the multiple records for each session id. BUT I just realized that my query picks the row on the top even when if the bottom row recorded more actions for the same session. So you look at the following table, my query keeps Row 1 & 3, like this;

Row session_id                              user_actions
1   8a88d75c-6385-4e36-8d10-e22ac4d976a3    118,139,141
3   e85731b6-4472-40fb-ab2b-33ebd1278ba9    211,114,117,118,141,142,143,146

Whereas, I would like to keep row 2 and 3, like this;

Row session_id                              user_actions
2   8a88d75c-6385-4e36-8d10-e22ac4d976a3    118,139,141,142,143,146
3   e85731b6-4472-40fb-ab2b-33ebd1278ba9    211,114,117,118,141,142,143,146

Is there anyway to do it with a sql query? Thank you!

Body:
Below is one of the option for BigQuery Standard SQL

#standardSQL
SELECT row, session_id, user_actions
FROM (
  SELECT
    row, session_id, user_actions,
    ROW_NUMBER() OVER(PARTITION BY session_id
      ORDER BY ARRAY_LENGTH(SPLIT(user_actions)) DESC
    ) = 1 win
  FROM `project.dataset.table`
)
WHERE win

You can test / play with above using dummy data from your question as below

#standardSQL
WITH `project.dataset.table` AS (
  SELECT 1 row, '8a88d75c-6385-4e36-8d10-e22ac4d976a3' session_id, '118,139,141' user_actions UNION ALL
  SELECT 2, '8a88d75c-6385-4e36-8d10-e22ac4d976a3', '118,139,141,142,143,146' UNION ALL
  SELECT 3, 'e85731b6-4472-40fb-ab2b-33ebd1278ba9', '211,114,117,118,141,142,143,146' UNION ALL
  SELECT 4, 'e85731b6-4472-40fb-ab2b-33ebd1278ba9', '211,114,117'
)
SELECT row, session_id, user_actions
FROM (
  SELECT
    row, session_id, user_actions,
    ROW_NUMBER() OVER(PARTITION BY session_id
      ORDER BY ARRAY_LENGTH(SPLIT(user_actions)) DESC
    ) = 1 win
  FROM `project.dataset.table`
)
WHERE win
ORDER BY row

result is

row session_id                              user_actions
2   8a88d75c-6385-4e36-8d10-e22ac4d976a3    118,139,141,142,143,146
3   e85731b6-4472-40fb-ab2b-33ebd1278ba9    211,114,117,118,141,142,143,146

Another option would be as below

#standardSQL
WITH `project.dataset.table` AS (
  SELECT 1 row, '8a88d75c-6385-4e36-8d10-e22ac4d976a3' session_id, '118,139,141' user_actions UNION ALL
  SELECT 2, '8a88d75c-6385-4e36-8d10-e22ac4d976a3', '118,139,141,142,143,146' UNION ALL
  SELECT 3, 'e85731b6-4472-40fb-ab2b-33ebd1278ba9', '211,114,117,118,141,142,143,146' UNION ALL
  SELECT 4, 'e85731b6-4472-40fb-ab2b-33ebd1278ba9', '211,114,117'
)
SELECT session_id,
  ARRAY_AGG(user_actions ORDER BY ARRAY_LENGTH(SPLIT(user_actions)) DESC LIMIT 1)[SAFE_OFFSET(0)] user_actions
FROM `project.dataset.table`
GROUP BY session_id

This one looks a little cleaner :o)

You can extend above with for example combining distinct codes from deduplicated entries in case if (for example) some actions are missing in one row but not another and etc.)

Update:

Try below to separate expenses of calculating array_length from ordering in partition:

#standardSQL
SELECT row, session_id, user_actions
FROM (
  SELECT
    row, session_id, user_actions,
    ROW_NUMBER() OVER(PARTITION BY session_id ORDER BY len DESC) = 1 win
  FROM (
    SELECT *, ARRAY_LENGTH(SPLIT(user_actions)) len
    FROM `project.dataset.table`
  )
)
WHERE win


问:
Xamarin Forms Android Compile Error
I'm trying to update my Xamarin Forms app to the latest Xamarin Forms and target the Android version against 7.1. After updating the build and target framework to 7.1 I'm getting the following compile time error:

/Users/austingrigg/Projects/ArtCloud/Droid/ERROR: Error APT0000: In  AppBarLayout, unable to find attribute android:keyboardNavigationCluster (APT0000) (ArtCloud.Droid)

I'm using Visual Studio for Mac (7.3), Xamarin Forms 2.5.0.121934, and Xamarin Support Libraries 25.4.0.2

答: Make sure ALL of your Nugets are the same version. Open up your packages.xml and double check, then do a full clean/rebuild and try to delete your bin/obj folders.</p>

Title: Xamarin Forms Android Compile Error


问:
R does not compile tex files to PDF
I am trying to produce pdf files from tex files in R studio but I am getting this error:

```<code>tools::texi2pdf("myFirstAlignment.tex", clean=TRUE)
Warning message:
running command '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texify.exe" --quiet --pdf "myFirstAlignment.tex" --max-iterations=20 -I "C:/PROGRA~1/R/R-34~1.1/share/texmf/tex/latex" -I "C:/PROGRA~1/R/R-34~1.1/share/texmf/bibtex/bst"' had status 1
</code>```

It worked once, but I don't know why isn't anymore.
Can anyone help me?

EDITED:

```<code>> traceback()
3: stop(gettextf("unable to run '%s' on '%s'", latex, file), domain = NA)
2: texi2dvi(texfile, quiet = !verbose, pdf = identical(output, "pdf"),
       texinputs = system.file("tex", package = "msa"), clean = TRUE,
       index = FALSE)
1: msaPrettyPrint(myFirstAlignment, output = "pdf", showNames = "left",
       showLogo = "none", askForOverwrite = FALSE, verbose = FALSE)
</code>```

EDITED2:

```<code>Error: running 'texi2dvi' on 'my.tex' failed

LaTeX errors:
C:/Users/tiago/Documents/R Estatistica/go_tropismo/my.tex:37:  ==> Fatal error
occurred, no output PDF file produced!
In addition: Warning message:
running command '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texify.exe" --quiet --pdf "my.tex" --max-iterations=20 -I "C:/PROGRA~1/R/R-34~1.1/share/texmf/tex/latex" -I "C:/PROGRA~1/R/R-34~1.1/share/texmf/bibtex/bst"' had status 1

> traceback()
3: stop(msg, call. = FALSE, domain = NA)
2: texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet,
       texi2dvi = texi2dvi, texinputs = texinputs, index = index)
1: tools::texi2pdf("my.tex", clean = TRUE)
</code>```

EDITED3, this is the log that came after the error. Can anyone tell if there is any useful tip for fixing it? I have already tried everything I could think. Any help would be appreciated.

```<code>This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6500 64-bit) (preloaded format=pdflatex 2017.11.21)  7 DEC 2017 14:23
entering extended mode
**"C:/Users/tiago/Documents/R Estatistica/go_tropismo/myFirstAlignment.tex"
("C:/Users/tiago/Documents/R Estatistica/go_tropismo/myFirstAlignment.tex"
LaTeX2e <2017-04-15>
Babel <3.15> and hyphenation patterns for 75 language(s) loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
) ("C:\Program Files\MiKTeX 2.9\tex\latex\texshade\texshade.sty"
Package: texshade 2011/05/13 LaTeX TeXshade (v1.24)
Package `texshade', Version 1.24 of 2011/12/01. ("C:\Program Files\MiKTeX 2.9\t
ex\latex\graphics\color.sty"
Package: color 2016/07/10 v1.1e Standard LaTeX Color (DPC)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-cfg\color.cfg"
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package color Info: Driver file: dvips.def on input line 147.
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-def\dvips.def"
File: dvips.def 2017/06/20 v3.1d Graphics/color driver for dvips
) ("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\dvipsnam.def"
File: dvipsnam.def 2016/06/17 v3.0m Driver-dependent file (DPC,SPQR)
)) ("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphics.sty"
Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\trig.sty"
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
) ("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-cfg\graphics.cfg"
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 99.
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-def\pdftex.def"
File: pdftex.def 2017/06/24 v1.0g Graphics/color driver for pdftex
))
\structurefile=\read1
\featurefile=\write3
\alignfile=\read2
\sublogofile=\read3
\exp@rtfile=\write4
("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amssymb.sty"
Package: amssymb 2013/01/14 v3.01 AMS font symbols
("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amsfonts.sty"
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
\@emptytoks=\toks14
\symAMSa=\mathgroup4
\symAMSb=\mathgroup5
LaTeX Font Info:    Overwriting math alphabet `\mathfrak' in version `bold'
(Font)                  U/euf/m/n --> U/euf/b/n on input line 106.
))
\symalphahelix=\mathgroup6
\loopcount=\count87
\innerloopcount=\count88
\outerloopcount=\count89
\seq@count=\count90
\killseq@count=\count91
\seq@percent=\count92
\res@count=\count93
\seq@pointer=\count94
\pos@count=\count95
\res@perline=\count96
\end@count=\count97
\cons@count=\count98
\total@count=\count99
\temp@count=\count100
\triple@count=\count101
\temp@@count=\count102
\pos@sum=\count103
\box@width=\skip43
\name@width=\skip44
\box@depth=\skip45
\width@tmp=\skip46
\box@height=\skip47
\number@width=\skip48
\line@stretch=\skip49
\center@fill=\skip50
\arrow@width=\skip51
\arrow@height=\skip52
\rule@thick=\skip53
\arrow@thick=\skip54
\logo@height=\skip55
\equal@width=\skip56
\equal@tmp=\skip57
\equal@height=\skip58
\temp@@length=\skip59
\vspace@legend=\skip60
\hspace@legend=\skip61
Package color Info: Redefining color LightGray on input line 1704.
Package color Info: Redefining color LightLightGray on input line 1805.
Package color Info: Redefining color LightLightLightGray on input line 1907.
)
No file myFirstAlignment.aux.
\openout1 = `myFirstAlignment.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 24.
LaTeX Font Info:    ... okay on input line 24.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 24.
LaTeX Font Info:    ... okay on input line 24.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 24.
LaTeX Font Info:    ... okay on input line 24.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 24.
LaTeX Font Info:    ... okay on input line 24.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 24.
LaTeX Font Info:    ... okay on input line 24.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 24.
LaTeX Font Info:    ... okay on input line 24.
("C:\Program Files\MiKTeX 2.9\tex\context\base\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count104
\scratchdimen=\dimen103
\scratchbox=\box26
\nofMPsegments=\count105
\nofMParguments=\count106
\everyMPshowfont=\toks15
\MPscratchCnt=\count107
\MPscratchDim=\dimen104
\MPnumerator=\count108
\makeMPintoPDFobject=\count109
\everyMPtoPDFconversion=\toks16
) ("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\epstopdf-base.sty"
Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty"
Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
) ("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\grfext.sty"
Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO)
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\kvdefinekeys.sty"
Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO)
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty"
Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
))) ("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\kvoptions.sty"
Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty"
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks17
) ("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\kvsetkeys.sty"
Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\etexcmds.sty"
Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifluatex.sty"
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
)
Package etexcmds Info: Could not find \expanded.
(etexcmds)             That can mean that you are not using pdfTeX 1.50 or
(etexcmds)             that some package has redefined \expanded.
(etexcmds)             In the latter case, load this package earlier.
))) ("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\pdftexcmds.sty"
Package: pdftexcmds 2017/03/19 v0.25 Utility functions of pdfTeX for LuaTeX (HO
)
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty"
Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
)
Package pdftexcmds Info: LuaTeX not detected.
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
)
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
38.
Package grfext Info: Graphics extension search list:
(grfext)             [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE
G,.JBIG2,.JB2,.eps]
(grfext)             \AppendGraphicsExtensions on input line 456.
) (C:/Users/tiago/AppData/Local/Temp/RtmpmKnM7O/seq60787a941199.fasta: . . . .
. . . . . . . . . [1
Non-PDF special ignored!

{C:/Users/tiago/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] . . . . . .
. . . . . [2] . . . . . . . . . . . [3] . . . . . . . . . . . [4] . . . . . . .
. . . . [5] . . . . . . . . . . . [6] . . . . . . . . . . . [7] . . . . . . . .
. . . [8] . . . . . . . . . . . [9] . . . . . . . . . . . [10] . . . . . . . .
. . . [11] . . . . . . . . . . . [12] . . . . . . . . . . . [13] . . . . . . .
. . . . [14] . . . . . . . . . . . [15] . . . . . . . . . . . [16] . . . . . .
. . . . . [17] . . . . . . . . . . . [18] . . . . . . . . . . . [19] . . . . .
. . . . . . [20] . . . . . . . . . . . [21] . . . . . . . . . . . [22] . . . .
. . . . . . . [23] . . . . . . . . . . . [24
</code>```

答: I found the origin of the problem. The text length was too big for the paper size. Simple as that. Using line breaks in the text file solved the problem.</p>

Title: R does not compile tex files to PDF

Body:
I am trying to produce pdf files from tex files in R studio but I am getting this error:

tools::texi2pdf("myFirstAlignment.tex", clean=TRUE)
Warning message:
running command '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texify.exe" --quiet --pdf "myFirstAlignment.tex" --max-iterations=20 -I "C:/PROGRA~1/R/R-34~1.1/share/texmf/tex/latex" -I "C:/PROGRA~1/R/R-34~1.1/share/texmf/bibtex/bst"' had status 1

It worked once, but I don't know why isn't anymore.
Can anyone help me?

EDITED:

> traceback()
3: stop(gettextf("unable to run '%s' on '%s'", latex, file), domain = NA)
2: texi2dvi(texfile, quiet = !verbose, pdf = identical(output, "pdf"),
       texinputs = system.file("tex", package = "msa"), clean = TRUE,
       index = FALSE)
1: msaPrettyPrint(myFirstAlignment, output = "pdf", showNames = "left",
       showLogo = "none", askForOverwrite = FALSE, verbose = FALSE)

EDITED2:

Error: running 'texi2dvi' on 'my.tex' failed

LaTeX errors:
C:/Users/tiago/Documents/R Estatistica/go_tropismo/my.tex:37:  ==> Fatal error
occurred, no output PDF file produced!
In addition: Warning message:
running command '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texify.exe" --quiet --pdf "my.tex" --max-iterations=20 -I "C:/PROGRA~1/R/R-34~1.1/share/texmf/tex/latex" -I "C:/PROGRA~1/R/R-34~1.1/share/texmf/bibtex/bst"' had status 1

> traceback()
3: stop(msg, call. = FALSE, domain = NA)
2: texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet,
       texi2dvi = texi2dvi, texinputs = texinputs, index = index)
1: tools::texi2pdf("my.tex", clean = TRUE)

EDITED3, this is the log that came after the error. Can anyone tell if there is any useful tip for fixing it? I have already tried everything I could think. Any help would be appreciated.

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6500 64-bit) (preloaded format=pdflatex 2017.11.21)  7 DEC 2017 14:23
entering extended mode
**"C:/Users/tiago/Documents/R Estatistica/go_tropismo/myFirstAlignment.tex"
("C:/Users/tiago/Documents/R Estatistica/go_tropismo/myFirstAlignment.tex"
LaTeX2e <2017-04-15>
Babel <3.15> and hyphenation patterns for 75 language(s) loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
) ("C:\Program Files\MiKTeX 2.9\tex\latex\texshade\texshade.sty"
Package: texshade 2011/05/13 LaTeX TeXshade (v1.24)
Package `texshade', Version 1.24 of 2011/12/01. ("C:\Program Files\MiKTeX 2.9\t
ex\latex\graphics\color.sty"
Package: color 2016/07/10 v1.1e Standard LaTeX Color (DPC)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-cfg\color.cfg"
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package color Info: Driver file: dvips.def on input line 147.
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-def\dvips.def"
File: dvips.def 2017/06/20 v3.1d Graphics/color driver for dvips
) ("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\dvipsnam.def"
File: dvipsnam.def 2016/06/17 v3.0m Driver-dependent file (DPC,SPQR)
)) ("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphics.sty"
Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\trig.sty"
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
) ("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-cfg\graphics.cfg"
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 99.
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-def\pdftex.def"
File: pdftex.def 2017/06/24 v1.0g Graphics/color driver for pdftex
))
\structurefile=\read1
\featurefile=\write3
\alignfile=\read2
\sublogofile=\read3
\exp@rtfile=\write4
("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amssymb.sty"
Package: amssymb 2013/01/14 v3.01 AMS font symbols
("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amsfonts.sty"
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
\@emptytoks=\toks14
\symAMSa=\mathgroup4
\symAMSb=\mathgroup5
LaTeX Font Info:    Overwriting math alphabet `\mathfrak' in version `bold'
(Font)                  U/euf/m/n --> U/euf/b/n on input line 106.
))
\symalphahelix=\mathgroup6
\loopcount=\count87
\innerloopcount=\count88
\outerloopcount=\count89
\seq@count=\count90
\killseq@count=\count91
\seq@percent=\count92
\res@count=\count93
\seq@pointer=\count94
\pos@count=\count95
\res@perline=\count96
\end@count=\count97
\cons@count=\count98
\total@count=\count99
\temp@count=\count100
\triple@count=\count101
\temp@@count=\count102
\pos@sum=\count103
\box@width=\skip43
\name@width=\skip44
\box@depth=\skip45
\width@tmp=\skip46
\box@height=\skip47
\number@width=\skip48
\line@stretch=\skip49
\center@fill=\skip50
\arrow@width=\skip51
\arrow@height=\skip52
\rule@thick=\skip53
\arrow@thick=\skip54
\logo@height=\skip55
\equal@width=\skip56
\equal@tmp=\skip57
\equal@height=\skip58
\temp@@length=\skip59
\vspace@legend=\skip60
\hspace@legend=\skip61
Package color Info: Redefining color LightGray on input line 1704.
Package color Info: Redefining color LightLightGray on input line 1805.
Package color Info: Redefining color LightLightLightGray on input line 1907.
)
No file myFirstAlignment.aux.
\openout1 = `myFirstAlignment.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 24.
LaTeX Font Info:    ... okay on input line 24.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 24.
LaTeX Font Info:    ... okay on input line 24.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 24.
LaTeX Font Info:    ... okay on input line 24.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 24.
LaTeX Font Info:    ... okay on input line 24.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 24.
LaTeX Font Info:    ... okay on input line 24.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 24.
LaTeX Font Info:    ... okay on input line 24.
("C:\Program Files\MiKTeX 2.9\tex\context\base\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count104
\scratchdimen=\dimen103
\scratchbox=\box26
\nofMPsegments=\count105
\nofMParguments=\count106
\everyMPshowfont=\toks15
\MPscratchCnt=\count107
\MPscratchDim=\dimen104
\MPnumerator=\count108
\makeMPintoPDFobject=\count109
\everyMPtoPDFconversion=\toks16
) ("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\epstopdf-base.sty"
Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty"
Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
) ("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\grfext.sty"
Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO)
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\kvdefinekeys.sty"
Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO)
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty"
Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
))) ("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\kvoptions.sty"
Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty"
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks17
) ("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\kvsetkeys.sty"
Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\etexcmds.sty"
Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifluatex.sty"
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
)
Package etexcmds Info: Could not find \expanded.
(etexcmds)             That can mean that you are not using pdfTeX 1.50 or
(etexcmds)             that some package has redefined \expanded.
(etexcmds)             In the latter case, load this package earlier.
))) ("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\pdftexcmds.sty"
Package: pdftexcmds 2017/03/19 v0.25 Utility functions of pdfTeX for LuaTeX (HO
)
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty"
Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
)
Package pdftexcmds Info: LuaTeX not detected.
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
)
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
38.
Package grfext Info: Graphics extension search list:
(grfext)             [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE
G,.JBIG2,.JB2,.eps]
(grfext)             \AppendGraphicsExtensions on input line 456.
) (C:/Users/tiago/AppData/Local/Temp/RtmpmKnM7O/seq60787a941199.fasta: . . . .
. . . . . . . . . [1
Non-PDF special ignored!

{C:/Users/tiago/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] . . . . . .
. . . . . [2] . . . . . . . . . . . [3] . . . . . . . . . . . [4] . . . . . . .
. . . . [5] . . . . . . . . . . . [6] . . . . . . . . . . . [7] . . . . . . . .
. . . [8] . . . . . . . . . . . [9] . . . . . . . . . . . [10] . . . . . . . .
. . . [11] . . . . . . . . . . . [12] . . . . . . . . . . . [13] . . . . . . .
. . . . [14] . . . . . . . . . . . [15] . . . . . . . . . . . [16] . . . . . .
. . . . . [17] . . . . . . . . . . . [18] . . . . . . . . . . . [19] . . . . .
. . . . . . [20] . . . . . . . . . . . [21] . . . . . . . . . . . [22] . . . .
. . . . . . . [23] . . . . . . . . . . . [24


问:
in tab 2 of front window returns Terminal got an error: Can’t get tab 2 of window 1. (-1728) since High Sierra update
As the title says I have an Apple Script that does:

```<code>in tab 2 of front window
</code>```

...which used to work fine but since the High Sierra upgrade returns:

```<code>Terminal got an error: Can’t get tab 2 of window 1. (-1728)
</code>```

Which corresponds to errAENoSuchObject I can't find any documentation around this having changed - is this a bug? Is there a new or better way to do this?

答:
The object hierarchy has changed slightly.  Each tab is referenced in AppleScript as tab 1 belonging to a unique parent window object.

So, previously, if there were three tabs open in a single window, we could refer to them as tab 1, tab 2, and tab 3 of window 1.  Now, we have tab 1 of window 1, tab 1 of window 2, and tab 1 of window 3.

I’ve found the most convenient and reliable way to target a specific tab is to identify the window object that contains the tab object with a specific tty property value.  I use a command that looks something like this:

```<code>    tell application "Terminal"
        get the id of the first window ¬
            whose first tab's tty contains "003"

        set w to result
        close window id w
    end tell
</code>```

If you want to get a slightly clearer picture of things, run this:

```<code>    tell application “Terminal” to ¬
        get every tab of every window
</code>```

and this:

```<code>    tell application “Terminal” to ¬
        get properties of every window
</code>```

and this:

```<code>    tell application “Terminal” to ¬
        get properties of tab 1 of every window
</code>```

Body:
As the title says I have an Apple Script that does:

in tab 2 of front window

...which used to work fine but since the High Sierra upgrade returns:

Terminal got an error: Can’t get tab 2 of window 1. (-1728)

Which corresponds to errAENoSuchObject I can't find any documentation around this having changed - is this a bug? Is there a new or better way to do this?

Body:
The object hierarchy has changed slightly.  Each tab is referenced in AppleScript as tab 1 belonging to a unique parent window object.

So, previously, if there were three tabs open in a single window, we could refer to them as tab 1, tab 2, and tab 3 of window 1.  Now, we have tab 1 of window 1, tab 1 of window 2, and tab 1 of window 3.

I’ve found the most convenient and reliable way to target a specific tab is to identify the window object that contains the tab object with a specific tty property value.  I use a command that looks something like this:

    tell application "Terminal"
        get the id of the first window ¬
            whose first tab's tty contains "003"

        set w to result
        close window id w
    end tell

If you want to get a slightly clearer picture of things, run this:

    tell application “Terminal” to ¬
        get every tab of every window

and this:

    tell application “Terminal” to ¬
        get properties of every window

and this:

    tell application “Terminal” to ¬
        get properties of tab 1 of every window


问:
How to disable a RadioGroup until checkbox is checked
I have a radio group which I do not want to user to be able to select any of the buttons until a particular checkbox is selected within my app. If the checkbox is unticked then this disables the radio-group. How do I go about doing this.</p>

答:
RadioGroup cannot be disabled directly, we have to loop through the radio button and setEnabled as false.</p>

```<code>// To disable the Radio Buttons of radio group.
    for (int i = 0; i < radioGroup.getChildCount(); i++) {
        radioUser.getChildAt(i).setEnabled(false);
    }
</code>```

Body:
RadioGroup cannot be disabled directly, we have to loop through the radio button and setEnabled as false.

// To disable the Radio Buttons of radio group.
    for (int i = 0; i < radioGroup.getChildCount(); i++) {
        radioUser.getChildAt(i).setEnabled(false);
    }


问:
Multiple mysql query resulting in null return
While doing a PHP function using two mysql query, the second one returns null, which shouldn't have, since both of them works in phpmyadmin SQL query submition.

Here is the function:

```<code>  public static function getStates($countryId) {
     try {
       $query    = "SELECT * FROM `Apostas` WHERE `idConfronto` = ".$countryId;
       $result = dbconfig::run($query);
       if(!$result) {
         throw new exception("Confronto invalido.");
       }
       $res = array();
       while($resultSet = mysqli_fetch_assoc($result)) {
        $sql2   = "SELECT * FROM `Mercados` WHERE `idMercado` = ".$resultSet["idMercado"];
        $result2 = dbconfig::run($sql2);
        if(!$result2) {
            throw new exception("Não há mercados.");
        }
        while ($row2 = mysqli_fetch_assoc($result2)) {
            $res[$resultSet['idMercado']] = $row2['nomeMercado'];
        }
       }
       $data = array('status'=>'success', 'tp'=>1, 'msg'=>"States fetched successfully.", 'result'=>$res);
     } catch (Exception $e) {
       $data = array('status'=>'error', 'tp'=>0, 'msg'=>$e->getMessage());
     } finally {
        return $data;
     }
   }
</code>```

The first query works everytime, but the second one goes towards the  exception "Não há mercados".

After debugging the function the variable $resultSet["idMercado"] is working and the sql query also works, but the code results in the exception.

What I'm doing wrong? Perhaps something with the syntax?

--EDIT1:
As requested, the code for dbconfig::run:

```<code>  public static function run($query) {
    try {
      if(empty($query) && !isset($query)) {
        throw new exception("Query string is not set.");
      }
      $result = mysqli_query(self::$con, $query);
      self::close();
     return $result;
    } catch (Exception $e) {
      echo "Error: ".$e->getMessage();
    }

  }
</code>```

--EDIT2:
As Cavid suggested, do all querys before closing the connection, here is how the function turned out:

```<code>public static function getStates($countryId) {
     try {
       $query    = "SELECT * FROM `Apostas` WHERE `idConfronto` = ".$countryId;
       $result = $conn->query($query);
       if(!$result) {
         throw new exception("Confronto invalido.");
       }
       $res = array();
       if ($result->num_rows > 0) {
        while ($resultSet = $result->fetch_assoc()) {
            $sql2   = "SELECT * FROM `Mercados` WHERE `idMercado` = ".$resultSet['idMercado'];
            $result2 = $conn->query($sql2);
            if ($result2->num_rows > 0) {
                while ($row2 = $result2->fetch_assoc()) {
                    $res[$resultSet['idMercado']] = $row2['nomeMercado'];
                }
            }
           }
       }
       $data = array('status'=>'success', 'tp'=>1, 'msg'=>"States fetched successfully.", 'result'=>$res);
     } catch (Exception $e) {
       $data = array('status'=>'error', 'tp'=>0, 'msg'=>$e->getMessage());
     } finally {
        return $data;
     }
     $conn->close();
   }
</code>```

Its giving me now a error code 500 "Internal server error"

答:
Instead of going in two different tables that has a Reference id in both, i suggest you to JOIN them and only use one while loop:</p>

```<code>public static function getStates($countryId) {
    try {
        // Inner join both tables
        $query    = "SELECT a.idMercado, a.idConfronto, b.nomeMercado FROM Apostas AS a ";
        $query    .= "INNER JOIN ";
        $query    .= "Mercados AS b ";
        $query    .= "ON a.idMercado = b.idMercado ";
        $query    .= "WHERE a.idConfronto = " . $countryId;
        $result = dbconfig::run($query);
        if(!$result) {
            throw new exception("Confronto invalido.");
        }
        // Results
        $res = array();
        while ($row = mysqli_fetch_assoc($result)) {
            $res[$row['idMercado']] = $row['nomeMercado'];
        }
        $data = array('status'=>'success', 'tp'=>1, 'msg'=>"States fetched successfully.", 'result'=>$res);
    } catch (Exception $e) {
        $data = array('status'=>'error', 'tp'=>0, 'msg'=>$e->getMessage());
    } finally {
        return $data;
    }
}
</code>```

Body:
While doing a PHP function using two mysql query, the second one returns null, which shouldn't have, since both of them works in phpmyadmin SQL query submition.

Here is the function:

  public static function getStates($countryId) {
     try {
       $query    = "SELECT * FROM `Apostas` WHERE `idConfronto` = ".$countryId;
       $result = dbconfig::run($query);
       if(!$result) {
         throw new exception("Confronto invalido.");
       }
       $res = array();
       while($resultSet = mysqli_fetch_assoc($result)) {
        $sql2   = "SELECT * FROM `Mercados` WHERE `idMercado` = ".$resultSet["idMercado"];
        $result2 = dbconfig::run($sql2);
        if(!$result2) {
            throw new exception("Não há mercados.");
        }
        while ($row2 = mysqli_fetch_assoc($result2)) {
            $res[$resultSet['idMercado']] = $row2['nomeMercado'];
        }
       }
       $data = array('status'=>'success', 'tp'=>1, 'msg'=>"States fetched successfully.", 'result'=>$res);
     } catch (Exception $e) {
       $data = array('status'=>'error', 'tp'=>0, 'msg'=>$e->getMessage());
     } finally {
        return $data;
     }
   }

The first query works everytime, but the second one goes towards the  exception "Não há mercados".

After debugging the function the variable $resultSet["idMercado"] is working and the sql query also works, but the code results in the exception.

What I'm doing wrong? Perhaps something with the syntax?

--EDIT1:
As requested, the code for dbconfig::run:

  public static function run($query) {
    try {
      if(empty($query) && !isset($query)) {
        throw new exception("Query string is not set.");
      }
      $result = mysqli_query(self::$con, $query);
      self::close();
     return $result;
    } catch (Exception $e) {
      echo "Error: ".$e->getMessage();
    }

  }

--EDIT2:
As Cavid suggested, do all querys before closing the connection, here is how the function turned out:

public static function getStates($countryId) {
     try {
       $query    = "SELECT * FROM `Apostas` WHERE `idConfronto` = ".$countryId;
       $result = $conn->query($query);
       if(!$result) {
         throw new exception("Confronto invalido.");
       }
       $res = array();
       if ($result->num_rows > 0) {
        while ($resultSet = $result->fetch_assoc()) {
            $sql2   = "SELECT * FROM `Mercados` WHERE `idMercado` = ".$resultSet['idMercado'];
            $result2 = $conn->query($sql2);
            if ($result2->num_rows > 0) {
                while ($row2 = $result2->fetch_assoc()) {
                    $res[$resultSet['idMercado']] = $row2['nomeMercado'];
                }
            }
           }
       }
       $data = array('status'=>'success', 'tp'=>1, 'msg'=>"States fetched successfully.", 'result'=>$res);
     } catch (Exception $e) {
       $data = array('status'=>'error', 'tp'=>0, 'msg'=>$e->getMessage());
     } finally {
        return $data;
     }
     $conn->close();
   }

Its giving me now a error code 500 "Internal server error"

Body:
Instead of going in two different tables that has a Reference id in both, i suggest you to JOIN them and only use one while loop:

public static function getStates($countryId) {
    try {
        // Inner join both tables
        $query    = "SELECT a.idMercado, a.idConfronto, b.nomeMercado FROM Apostas AS a ";
        $query    .= "INNER JOIN ";
        $query    .= "Mercados AS b ";
        $query    .= "ON a.idMercado = b.idMercado ";
        $query    .= "WHERE a.idConfronto = " . $countryId;
        $result = dbconfig::run($query);
        if(!$result) {
            throw new exception("Confronto invalido.");
        }
        // Results
        $res = array();
        while ($row = mysqli_fetch_assoc($result)) {
            $res[$row['idMercado']] = $row['nomeMercado'];
        }
        $data = array('status'=>'success', 'tp'=>1, 'msg'=>"States fetched successfully.", 'result'=>$res);
    } catch (Exception $e) {
        $data = array('status'=>'error', 'tp'=>0, 'msg'=>$e->getMessage());
    } finally {
        return $data;
    }
}


问:
Undefined index: (this is for multiple lines of code in 2 different documents)
The error can be seen in the title. "undefined index" I am wondering the reason for these errors as it was working in school but at home it doesn't... Sorry im pretty new to this ive looked and was hoping for an explanation/solution in plain terms if you can please! Many thanks!

(in 1 document)

```<code>$id=$_POST['id'];
$a_name=$_POST['a_name'];
$a_email=$_POST['a_email'];
$a_answer=$_POST['a_answer'];
</code>```

(in another document)

```<code>$id=$_GET['id'];
</code>```

If you need any more information please ask i can post more code and data base stuff if needed!

答:
This error means that there is nothing in the $_POST array with a key you're asking for.

If you have an array that looks like this:

```<code>$myArray = array (
    'a' => 1,
    'b' => 2,
    'c' => 3
);
</code>```

You would get this error if you do:

```<code>$value = $myArray['d'];
</code>```

Because the key 'd' does not exist in that array.

Make sure all of your form elements have a name attribute. The name should match the values you're using as your array keys (id, a_name, a_email, a_answer).

Body:
The error can be seen in the title. "undefined index" I am wondering the reason for these errors as it was working in school but at home it doesn't... Sorry im pretty new to this ive looked and was hoping for an explanation/solution in plain terms if you can please! Many thanks!

(in 1 document)

$id=$_POST['id'];
$a_name=$_POST['a_name'];
$a_email=$_POST['a_email'];
$a_answer=$_POST['a_answer'];

(in another document)

$id=$_GET['id'];

If you need any more information please ask i can post more code and data base stuff if needed!

Body:
This error means that there is nothing in the $_POST array with a key you're asking for.

If you have an array that looks like this:

$myArray = array (
    'a' => 1,
    'b' => 2,
    'c' => 3
);

You would get this error if you do:

$value = $myArray['d'];

Because the key 'd' does not exist in that array.

Make sure all of your form elements have a name attribute. The name should match the values you're using as your array keys (id, a_name, a_email, a_answer).


问:
Python read numbers in text file to list to calculate mean
I have a file with a lot of numbers and I want to try to read it in python into a list of a list. Then calculate its mean or sum or whatever.

Here is my text file:

```<code>   1,2,5349,2398,19,3450
   10,95,201,5943,234,2319482,12
</code>```

then here is my code:

```<code>def ReadList(fileName):
    with open(fileName, 'r') as numbers:
        datalist = []
        for line in numbers:
            datalist.append(line.strip().split(' '))
    return datalist
</code>```

but my results turn up as datalist = ['1,2,5349....3450'],['10,95...,12'] they have the apostraphe at the beinning and the end, and I can't calculate the mean with it. I have tried to use:
                     datalist.appent(int(line.strip().split(' ')))already and it doesn't make the data into numbers but adds some other errors.

EDIT: The data seem okay now that I changed it to datalist.append([int(x) for x in line.strip().split(',')]).

But I can't calculate the mean when my method is

```<code>numbers = ReadList('data.txt')

total = 0.0
for num in numbers:
     total = total + num
return total/len(nums)
</code>```

the same errors still appear:"TypeError: unsupported operand type(s) for +: 'float' and 'list'"

My goal is to have it as a few separate list of a list and calculate each separate list's means and then display it in a column for example:

```<code>List# Mean
1     (Mean value of the first list( 1,2,5349,2398,19,3450))
2     (Mean value of the second list(10,95,201,5943,234,2319482,12))
</code>```

答:
You need to split at "," and not " " so make this change

line.strip().split(',')

Body:
I have a file with a lot of numbers and I want to try to read it in python into a list of a list. Then calculate its mean or sum or whatever.

Here is my text file:

   1,2,5349,2398,19,3450
   10,95,201,5943,234,2319482,12

then here is my code:

def ReadList(fileName):
    with open(fileName, 'r') as numbers:
        datalist = []
        for line in numbers:
            datalist.append(line.strip().split(' '))
    return datalist

but my results turn up as datalist = ['1,2,5349....3450'],['10,95...,12'] they have the apostraphe at the beinning and the end, and I can't calculate the mean with it. I have tried to use:
                     datalist.appent(int(line.strip().split(' ')))already and it doesn't make the data into numbers but adds some other errors.

EDIT: The data seem okay now that I changed it to datalist.append([int(x) for x in line.strip().split(',')]).

But I can't calculate the mean when my method is

numbers = ReadList('data.txt')

total = 0.0
for num in numbers:
     total = total + num
return total/len(nums)

the same errors still appear:"TypeError: unsupported operand type(s) for +: 'float' and 'list'"

My goal is to have it as a few separate list of a list and calculate each separate list's means and then display it in a column for example:

List# Mean
1     (Mean value of the first list( 1,2,5349,2398,19,3450))
2     (Mean value of the second list(10,95,201,5943,234,2319482,12))