问:
Why do I need a $watch when using function in controller in combination with a directive
I know and can imagine why I need the commented lines of code to let this work. But I can't found the technical reason. Why is the field not update when you click on the button? (the $watch fixed the problem. See comments)

Code:

angular.module('app', []).directive('foo', function() {
    return {
            scope: {
                value: '='
            },
            link: function($scope, element){
              element.html($scope.value);
              //$scope.$watch(function() { return $scope.value }, function(){
               //element.html($scope.value);
               //})
            }
        };
}).controller('FooController', ['$scope', function($scope) {
  $scope.bar = "Hi"

   $scope.sayHallo = function(){
     return $scope.bar;
    }

    $scope.changeHallo = function(){
     $scope.bar = "Héj";
    }
}]);```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app">
    <div ng-controller="FooController">
        <div foo value="sayHallo()" ></div>
        <button ng-click="changeHallo()">
            Click
        </button>
    </div>
</div></code>```

答:
A watch is needed in your use case.

A directive doesn't go through the link function every time one of the scope variables change. So with the watch commented out the link function will get executed and the html of the element will be set and that's the end of the link function. It doesn't get executed any more for that instance of the directive.

So if you want to update the html of the element every time the scope variable changes you will need a watcher.

Body:
I know and can imagine why I need the commented lines of code to let this work. But I can't found the technical reason. Why is the field not update when you click on the button? (the $watch fixed the problem. See comments)

Code:

angular.module('app', []).directive('foo', function() {
    return {
            scope: {
                value: '='
            },
            link: function($scope, element){
              element.html($scope.value);
              //$scope.$watch(function() { return $scope.value }, function(){
               //element.html($scope.value);
               //})
            }
        };
}).controller('FooController', ['$scope', function($scope) {
  $scope.bar = "Hi"

   $scope.sayHallo = function(){
     return $scope.bar;
    }

    $scope.changeHallo = function(){
     $scope.bar = "Héj";
    }
}]);

        <button ng-click="changeHallo()">
            Click
        </button>


来源: stackexchange

问:
Cannot login to admin with custom backend in Django 1.11.rc1
Using Django 1.10 I have no problem using my custom backend to login (not a custom user just the auth) but in 1.11rc1 I get the following exception:

```<code>Request Method:     POST
Request URL:    http://127.0.0.1:8000/admin/login/?next=/admin/
Django Version:     1.11rc1
Exception Type:     FieldError
Exception Value:

Cannot resolve keyword 'request' into field. Choices are: clientcontact, crudevent, date_joined, email, <...just more fields>
</code>```

The backend:

```<code>    def authenticate(self, **kwargs):
        if kwargs:
            username = kwargs.pop("username", None)
            if username:
                username_or_email = Q(username=username) | Q(email=username)
                password = kwargs.pop("password", None)
                try:
                    user = User.objects.get(username_or_email, **kwargs)
                except User.DoesNotExist:
                    pass
                else:
                    if user.check_password(password):
                        return user
        else:
            ...
</code>```

In settings.py:

```<code>AUTHENTICATION_BACKENDS = ('base_app.auth_backend.JbcBackend', 'guardian.backends.ObjectPermissionBackend',)
</code>```

I haven't been able to find anything, if someone could point me in the right direction that would be great.
Here is the full Traceback:

```<code>Traceback:

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/channels/handler.py" in process_exception_by_middleware
  237.             return super(AsgiHandler, self).process_exception_by_middleware(exception, request)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/contrib/admin/sites.py" in login
  393.         return LoginView.as_view(**defaults)(request)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  76.             return view(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/contrib/auth/views.py" in dispatch
  90.         return super(LoginView, self).dispatch(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/generic/edit.py" in post
  182.         if form.is_valid():

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/forms/forms.py" in is_valid
  183.         return self.is_bound and not self.errors

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/forms/forms.py" in errors
  175.             self.full_clean()

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/forms/forms.py" in full_clean
  385.         self._clean_form()

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/forms/forms.py" in _clean_form
  412.             cleaned_data = self.clean()

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/contrib/auth/forms.py" in clean
  187.             self.user_cache = authenticate(self.request, username=username, password=password)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/contrib/auth/__init__.py" in authenticate
  100.             user = backend.authenticate(*args, **credentials)

File "/home/mat/PycharmProjects/jbc_services/base_app/auth_backend.py" in authenticate
  19.                     user = User.objects.get(username_or_email, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/manager.py" in manager_method
  85.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/query.py" in get
  370.         clone = self.filter(*args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/query.py" in filter
  781.         return self._filter_or_exclude(False, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/query.py" in _filter_or_exclude
  799.             clone.query.add_q(Q(*args, **kwargs))

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in add_q
  1260.         clause, _ = self._add_q(q_object, self.used_aliases)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in _add_q
  1286.                     allow_joins=allow_joins, split_subq=split_subq,

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in build_filter
  1164.         lookups, parts, reffed_expression = self.solve_lookup_type(arg)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in solve_lookup_type
  1044.         _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in names_to_path
  1362.                                      "Choices are: %s" % (name, ", ".join(available)))

Exception Type: FieldError at /admin/login/
Exception Value: Cannot resolve keyword 'request' into field. Choices are: clientcontact, crudevent, date_joined, email, first_name, groups, id, is_active, is_staff, is_superuser, last_login, last_name, logentry, logged_in_user, loginevent, password, thirdpartycontact, user_bookmarks, user_permissions, user_preferences, username, userobjectpermission
</code>```

答:
```<code>try:
    user = User.objects.get(username_or_email)
    # The user is found, now check if the password matches
    if user.check_password(password):
        return user
except User.DoesNotExist:
    pass
...
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Using Django 1.10 I have no problem using my custom backend to login (not a custom user just the auth) but in 1.11rc1 I get the following exception:

Request Method:     POST
Request URL:    http://127.0.0.1:8000/admin/login/?next=/admin/
Django Version:     1.11rc1
Exception Type:     FieldError
Exception Value:

Cannot resolve keyword 'request' into field. Choices are: clientcontact, crudevent, date_joined, email, <...just more fields>

The backend:

    def authenticate(self, **kwargs):
        if kwargs:
            username = kwargs.pop("username", None)
            if username:
                username_or_email = Q(username=username) | Q(email=username)
                password = kwargs.pop("password", None)
                try:
                    user = User.objects.get(username_or_email, **kwargs)
                except User.DoesNotExist:
                    pass
                else:
                    if user.check_password(password):
                        return user
        else:
            ...

In settings.py:

AUTHENTICATION_BACKENDS = ('base_app.auth_backend.JbcBackend', 'guardian.backends.ObjectPermissionBackend',)

I haven't been able to find anything, if someone could point me in the right direction that would be great.
Here is the full Traceback:

Traceback:

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/channels/handler.py" in process_exception_by_middleware
  237.             return super(AsgiHandler, self).process_exception_by_middleware(exception, request)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/contrib/admin/sites.py" in login
  393.         return LoginView.as_view(**defaults)(request)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  76.             return view(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/contrib/auth/views.py" in dispatch
  90.         return super(LoginView, self).dispatch(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/views/generic/edit.py" in post
  182.         if form.is_valid():

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/forms/forms.py" in is_valid
  183.         return self.is_bound and not self.errors

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/forms/forms.py" in errors
  175.             self.full_clean()

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/forms/forms.py" in full_clean
  385.         self._clean_form()

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/forms/forms.py" in _clean_form
  412.             cleaned_data = self.clean()

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/contrib/auth/forms.py" in clean
  187.             self.user_cache = authenticate(self.request, username=username, password=password)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/contrib/auth/__init__.py" in authenticate
  100.             user = backend.authenticate(*args, **credentials)

File "/home/mat/PycharmProjects/jbc_services/base_app/auth_backend.py" in authenticate
  19.                     user = User.objects.get(username_or_email, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/manager.py" in manager_method
  85.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/query.py" in get
  370.         clone = self.filter(*args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/query.py" in filter
  781.         return self._filter_or_exclude(False, *args, **kwargs)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/query.py" in _filter_or_exclude
  799.             clone.query.add_q(Q(*args, **kwargs))

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in add_q
  1260.         clause, _ = self._add_q(q_object, self.used_aliases)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in _add_q
  1286.                     allow_joins=allow_joins, split_subq=split_subq,

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in build_filter
  1164.         lookups, parts, reffed_expression = self.solve_lookup_type(arg)

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in solve_lookup_type
  1044.         _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())

File "/home/mat/.virtualenvs/jbcarcenv/lib/python3.6/site-packages/django/db/models/sql/query.py" in names_to_path
  1362.                                      "Choices are: %s" % (name, ", ".join(available)))

Exception Type: FieldError at /admin/login/
Exception Value: Cannot resolve keyword 'request' into field. Choices are: clientcontact, crudevent, date_joined, email, first_name, groups, id, is_active, is_staff, is_superuser, last_login, last_name, logentry, logged_in_user, loginevent, password, thirdpartycontact, user_bookmarks, user_permissions, user_preferences, username, userobjectpermission


问:
Function arithmetic library for python
I'm searching for a library that will let me manipulate functions with the standard operators (*, -, *, /, etc.).

Lets suppose you have a function f(x) = x ** 2 and g(x) = x + 2. I'd like to be able to write f * g and get a new functor that is essentialy x ** 2 * (x + 2) or f(g) and get (x + 2) ** 2.

I know this is not too hard to implement, you'll just have to make a Functor class and overload it's __call__ function, but I'm hoping there is a 3rd party library for it.

I'm not trying to use this for anything heavyweight just for learning. Thanks for the help.

答: Sympy should do what you want.</p>

ContentLicense: CC BY-SA 2.5

Title: Function arithmetic library for python

Body: Sympy should do what you want.


问:
How to Group by with Count()
```<code>[OrderNo]   [OrderStatus]
PO-01       Received
PO-01       Pending
PO-01       Received
PO-02       Pending
PO-02       Pending
PO-03       Received
PO-03       Received
</code>```

In a Table a have two Column OrderNo and OrderStatus
I want a Result like.

```<code>[OrderNo]   [OrderStatus]
PO-01       Partially Received
PO-02       Pending
PO-03       Received in Full
</code>```

If All Rows of Particular [OrderNo] is Received then Make its Status 'Received in Full' and if Not make its status 'Partially received' and if Every Row is in Pending Status make its Status 'Pending'

答:
```<code>with Orders
as (
  select distinct OrderNo from TableOrders
)

select OrderNo,

       case when not exists (select *
                             from TableOrders
                             where TableOrders.OrderNo = Orders.OrderNo and
                                   OrderStatus = 'Received')
                 then 'Pending'

             when exists (select *
                          from TableOrders
                          where TableOrders.OrderNo = Orders.OrderNo and
                                OrderStatus = 'Pending')
                  then 'Partially Received'

              else 'Received in Full'
       end as Status

from Orders
</code>```

Title: How to Group by with Count()

Body:
[OrderNo]   [OrderStatus]
PO-01       Received
PO-01       Pending
PO-01       Received
PO-02       Pending
PO-02       Pending
PO-03       Received
PO-03       Received

In a Table a have two Column OrderNo and OrderStatus
I want a Result like.

[OrderNo]   [OrderStatus]
PO-01       Partially Received
PO-02       Pending
PO-03       Received in Full

If All Rows of Particular [OrderNo] is Received then Make its Status 'Received in Full' and if Not make its status 'Partially received' and if Every Row is in Pending Status make its Status 'Pending'

ContentLicense: CC BY-SA 4.0


问:
set a variable content one byte at a time
I'm reading a message one byte (char) at a time and I would like to set the value of a variable based on that.
Is there a way to concatenate the bytes an then use a cast to set the value?

Something like:

```<code>mytype packet = (mytype) byteconcat;
</code>```

If I'm rigth strings have an extra byte so that would be an issue.

Or alternatively can I create the variable and set the bytes as I receive them?

答:
You could use a union for that.

Let's assume you're sending integers over the net, catching them byte by byte on the other side.

Your union could look like this:

```<code>union Data {
   unsigned char bytes[4];
   int val;
}
</code>```

and the code like this:

```<code>bool read(Data& outBuff, int& offset, unsigned char receivedByte)
{
   outBuff.bytes[offset++]= receivedByte;

   bool readyToRead = offset >= 4;
   if(readyToRead) {offset=0;}

   return readyToRead;
}
</code>```

Body:
I'm reading a message one byte (char) at a time and I would like to set the value of a variable based on that.
Is there a way to concatenate the bytes an then use a cast to set the value?

Something like:

mytype packet = (mytype) byteconcat;

If I'm rigth strings have an extra byte so that would be an issue.

Or alternatively can I create the variable and set the bytes as I receive them?

Body:
You could use a union for that.

Let's assume you're sending integers over the net, catching them byte by byte on the other side.

Your union could look like this:

union Data {
   unsigned char bytes[4];
   int val;
}

and the code like this:

bool read(Data& outBuff, int& offset, unsigned char receivedByte)
{
   outBuff.bytes[offset++]= receivedByte;

   bool readyToRead = offset >= 4;
   if(readyToRead) {offset=0;}

   return readyToRead;
}


问:
Using Bootstrap Panel - How do I put form next to title?
I have tried at least three proposed solutions from searching on this site, but nothing worked. I got close, but was getting cheated on the panel defeault backround color. For some reason, the background wasn't showing its full height behind my elements. I want to put a form next to the heading. Here is what I have tried.

```<code><div class="panel panel-default">
    <div class="panel-heading">

      <div class="no-wrap">
        <h3 class="panel-title">My Title</h3>
      </div>

      <div class="no-wrap">
          <form>
            <div class="form-group">
              <select class="form-control" id="sel1">
              <option>1</option>
              <option>2</option>
              </select>
            </div>
          </form>
      </div>

</div> <!-- end panel-heading -->

<div class="panel-body">
    Body Text
</div>

</div> <!-- end panel -->
</code>```

All the class you see are bootstrap EXCEPT no-wrap. My css for no-wrap is

```<code>.no-wrap {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
 }
</code>```

So this was my most hopeful solution but it still doesn't work. The form sits below the h3.

I also tried using bootstrap columns inside the panel heading, but that's when the default gray background got obscured.

How can I get this form next to the h3 - all inside the panel heading?? Please note, you can assume that there is plenty of screen width. 99.9% of users will be using a laptop to access this page. The panel is being used to display business reports. Mobile responsiveness is not a priority.

Below is screenshot of what I do NOT want. I want the input form next to the heading.

答:
You can try this one. You just need to include GRID OF BOOTSTRAP in your code such as col-xs-* , col-sm-* , col-md-* , col-lg-*. Don't need custom css in your case. You could ask me for further question as well.

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

My Title

          <form>

              <select class="form-control" id="sel1">
                <option>1</option>
                <option>2</option>
              </select>

          </form>

      Body Text

```

Body:
I have tried at least three proposed solutions from searching on this site, but nothing worked. I got close, but was getting cheated on the panel defeault backround color. For some reason, the background wasn't showing its full height behind my elements. I want to put a form next to the heading. Here is what I have tried.

My Title

          <form>

              <select class="form-control" id="sel1">
              <option>1</option>
              <option>2</option>
              </select>

          </form>

    Body Text

All the class you see are bootstrap EXCEPT no-wrap. My css for no-wrap is

.no-wrap {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
 }

So this was my most hopeful solution but it still doesn't work. The form sits below the h3.

I also tried using bootstrap columns inside the panel heading, but that's when the default gray background got obscured.

How can I get this form next to the h3 - all inside the panel heading?? Please note, you can assume that there is plenty of screen width. 99.9% of users will be using a laptop to access this page. The panel is being used to display business reports. Mobile responsiveness is not a priority.

Below is screenshot of what I do NOT want. I want the input form next to the heading.

Body:
You can try this one. You just need to include GRID OF BOOTSTRAP in your code such as col-xs-* , col-sm-* , col-md-* , col-lg-*. Don't need custom css in your case. You could ask me for further question as well.

<HTML>
<head>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
  <div class="panel panel-default">
    <div class="panel-heading">

      <div class="row">
        <div class="col-xs-4 col-md-6 col-lg-6">
          <h3 class="panel-title">My Title</h3>
        </div>

        <div class="col-xs-8 col-md-6 col-lg-6">
          <form>
            <div class="form-group">
              <select class="form-control" id="sel1">
                <option>1</option>
                <option>2</option>
              </select>
            </div>
          </form>
        </div>
      </div>

    </div>
    <!-- end panel-heading -->

    <div class="panel-body">
      Body Text
    </div>

  </div>
  <!-- end panel -->
</body>
</HTML>


问:
Unity Multiple displays not working
I am using Unity 5.4.1f1 personal edition and working on Windows standalone build. I want to use multiple displays in my game. I have 2 cameras and set the target display of one camera to display 1 and target display of second camera to display 2.

Also, I have activated the display but Display.displays.Length is always one on editor as well as on build.

So it does not display anything on the second screen. What should I do to display on second screen?

答:
This bug was in unity 5.4.1 i have tested with unity 5.6.1f1 and above unity multiple displays works just fine there is no need of expanding screen or setting parameters just need to activate the displays and set the target display property of camera

Unity documentation is a bit ambiguous about this feature.

Also Display.displays.Length always return 1 in editor mode but in build it works fine.

I have found a solution to this problem reference to post http://answers.unity3d.com/questions/309819/getting-unity-to-render-across-multiple-monitors.html. That is we have to call Screen.SetResolution(sum of width of all displays , height, false); the false is because we do not want to render in fullscreen mode. This is because unity does not creates multiple windows it only create one window we have to extend it to match the resolution of multiple displays.

Activate the aditional displays by calling Activate() and aslo set the setparams to give the each display a starting value. I worked it out for 3 displays.

```<code>if (Display.displays.Length > 1)
{
 //display 0 is set by default
    Display.displays[1].Activate();
    Display.displays[1].SetParams(Width of display 1,height of display 1,starting x for display 1,starting y for display 1);
}
if (Display.displays.Length > 2)
{
    Display.displays[2].Activate();
    Display.displays[2].SetParams(Width of display 2,height of display 2,starting x for display 2,starting y for display 2);
}
</code>```

In the build setting set 'Display Resolution Dialog' to 'Disabled' make sure 'Default Is Full Screen' is NOT checked.

Create the build and then there is a final step run the exe wtih -popupwindow or -multidisplay command line argument.

If it still not worked open your screen resolution dialog and verify the positioning of monitors.

It works good but it produces fish eye effect.

Title: Unity Multiple displays not working

Body:
This bug was in unity 5.4.1 i have tested with unity 5.6.1f1 and above unity multiple displays works just fine there is no need of expanding screen or setting parameters just need to activate the displays and set the target display property of camera

Unity documentation is a bit ambiguous about this feature.

Also Display.displays.Length always return 1 in editor mode but in build it works fine.

I have found a solution to this problem reference to post http://answers.unity3d.com/questions/309819/getting-unity-to-render-across-multiple-monitors.html. That is we have to call Screen.SetResolution(sum of width of all displays , height, false); the false is because we do not want to render in fullscreen mode. This is because unity does not creates multiple windows it only create one window we have to extend it to match the resolution of multiple displays.

Activate the aditional displays by calling Activate() and aslo set the setparams to give the each display a starting value. I worked it out for 3 displays.

if (Display.displays.Length > 1)
{
 //display 0 is set by default
    Display.displays[1].Activate();
    Display.displays[1].SetParams(Width of display 1,height of display 1,starting x for display 1,starting y for display 1);
}
if (Display.displays.Length > 2)
{
    Display.displays[2].Activate();
    Display.displays[2].SetParams(Width of display 2,height of display 2,starting x for display 2,starting y for display 2);
}

In the build setting set 'Display Resolution Dialog' to 'Disabled' make sure 'Default Is Full Screen' is NOT checked.

Create the build and then there is a final step run the exe wtih -popupwindow or -multidisplay command line argument.

If it still not worked open your screen resolution dialog and verify the positioning of monitors.

It works good but it produces fish eye effect.


问:
How to ask if I have saved my text document before closing the jframe
I'm developing a text editor and I need to check whether I have saved chances typed (even a space) in my Text Area.

If I have typed even a space, the dialog should pop and ask me to save the text before closing the application.

I need to define all the keys in a single way without checking all the keyboards keys are pressed or not... This is my code:

```<code> private void isAnyKeyWasPressed() {
    jTextPane1.addKeyListener(new KeyListener() {

        @Override
        public void keyTyped(KeyEvent e) {
            if (e.getKeyChar()==e.VK_0 || e.getKeyChar()==e.VK_1) {//need to define all the keyboard keys without defining one by one like this
                //my dialog box goes here
            }
        }

        @Override
        public void keyPressed(KeyEvent e) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void keyReleased(KeyEvent e) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });
}
</code>```

答:
If I understand you correctly, you are asking how to detect whether a document in a JTextPane was edited or not. Listening to keys is not optimal. I would rather recommend one of two ways:

A) Listen to changes to the underlying document:

```<code>    jTextPanel.getDocument().addDocumentListener(new DocumentListener(){
        @Override
        public void changedUpdate(DocumentEvent e) {
            isModified=true;
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            isModified=true;
        }
        @Override
        public void removeUpdate(DocumentEvent e) {
            isModified=true;
        }
    });
</code>```

The field isModified has to be initialized to false, and will be set to truewhenever the document is changed in any way. You have to reset it to false after saving.

B) Keep a copy of the original document and compare both when the frame is about to be closed. How you do this depends a bit on the kind of document that you have. If it is an HTMLDocument, then comparing the actual HTML source code is the most accurate method:

Before editing starts:

```<code>HTMLDocument doc=(HTMLDocument)jTextPanel.getDocument();
String originalHtml=getHTML(doc);
</code>```

After editing / upon closing the frame:

```<code>HTMLDocument doc=(HTMLDocument)jTextPanel.getDocument();
String editedHtml=getHTML(doc);
if(!editedHtml.equals(originalHtml))
   // ... text has been edited
</code>```

The getHTML() method:

```<code>public String getHTML(HTMLDocument doc){
    StringWriter writer = new StringWriter();
    kit.write(writer, doc, 0, doc.getLength());
    return writer.toString();
}
</code>```

The advantage of approach B) is that you don't have to check each edit operation (the overhead of which is negligible in most cases, though) and that you can accurately detect when changes have been reverted (e.g. user added text, then deleted that text, or an undo has been performed).

Body:
I'm developing a text editor and I need to check whether I have saved chances typed (even a space) in my Text Area.

If I have typed even a space, the dialog should pop and ask me to save the text before closing the application.

I need to define all the keys in a single way without checking all the keyboards keys are pressed or not... This is my code:

 private void isAnyKeyWasPressed() {
    jTextPane1.addKeyListener(new KeyListener() {

        @Override
        public void keyTyped(KeyEvent e) {
            if (e.getKeyChar()==e.VK_0 || e.getKeyChar()==e.VK_1) {//need to define all the keyboard keys without defining one by one like this
                //my dialog box goes here
            }
        }

        @Override
        public void keyPressed(KeyEvent e) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void keyReleased(KeyEvent e) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });
}

Body:
If I understand you correctly, you are asking how to detect whether a document in a JTextPane was edited or not. Listening to keys is not optimal. I would rather recommend one of two ways:

A) Listen to changes to the underlying document:

    jTextPanel.getDocument().addDocumentListener(new DocumentListener(){
        @Override
        public void changedUpdate(DocumentEvent e) {
            isModified=true;
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            isModified=true;
        }
        @Override
        public void removeUpdate(DocumentEvent e) {
            isModified=true;
        }
    });

The field isModified has to be initialized to false, and will be set to truewhenever the document is changed in any way. You have to reset it to false after saving.

B) Keep a copy of the original document and compare both when the frame is about to be closed. How you do this depends a bit on the kind of document that you have. If it is an HTMLDocument, then comparing the actual HTML source code is the most accurate method:

Before editing starts:

HTMLDocument doc=(HTMLDocument)jTextPanel.getDocument();
String originalHtml=getHTML(doc);

After editing / upon closing the frame:

HTMLDocument doc=(HTMLDocument)jTextPanel.getDocument();
String editedHtml=getHTML(doc);
if(!editedHtml.equals(originalHtml))
   // ... text has been edited

The getHTML() method:

public String getHTML(HTMLDocument doc){
    StringWriter writer = new StringWriter();
    kit.write(writer, doc, 0, doc.getLength());
    return writer.toString();
}

The advantage of approach B) is that you don't have to check each edit operation (the overhead of which is negligible in most cases, though) and that you can accurately detect when changes have been reverted (e.g. user added text, then deleted that text, or an undo has been performed).


问:
jquery and jqueryUI conflicting
Is jquery 1.3.2 conflicting with jqueryui 1.8.4? I get the error "Too much recursion" (using the code below).

When I combine jquery 1.3.2 with jqueryui 1.7.2 I don't get this error, but it breaks my code...

Is there somewhere a reference table which jquery version works with which jqueryui code?

```<code><html>
<head>
<title>This is the title</title>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js'></script>
</head>
<body>nothing here</body>
</html>
</code>```

答:
Yes there is a conflict between these versions --
and I got stuck because Drupal doesn't like JQuery newer than 1.3.2 -- I read somebody having the same issue because Greasemonkey doesn't work with any JQuery above 1.3.2 either.

I found this ticket:
http://bugs.jqueryui.com/ticket/6689

There is a .zip file posted there with a modified version of the JQuery UI library.  I was getting this error while trying to use ui.dialog -- I just copied that part of the modified library into my code and it works.

Title: jquery and jqueryUI conflicting

Body:
Is jquery 1.3.2 conflicting with jqueryui 1.8.4? I get the error "Too much recursion" (using the code below).

When I combine jquery 1.3.2 with jqueryui 1.7.2 I don't get this error, but it breaks my code...

Is there somewhere a reference table which jquery version works with which jqueryui code?

<title>This is the title</title>

nothing here


问:
How to make normal function to be returning in node.js
```<code>    function puts(error, stdout, stderr) {
    if (error) {
        console.log("error", "Error connecting");
        result = "Failed";
        console.log(result)
    }
    else {
        sys.puts(stdout)
        result = "Success"
        console.log(result)
    }
    }

//The calling function is mentioned as below:
app.get('/api/platforms1', function(req, res){
    exec("ping localhost",puts);
});
</code>```

<p>//I am working under mean stack.I have created a method to ping ip address and display their result.But now I want to display the result as a return function.How can we do it??</p>

答:
First:

In windows, if you use:

ping google.com

You will get only 4 information ping, but on Ubuntu, if you use that command, the ping can't stop until you stop it with Ctrl+C.

To fix this we need to use -c flag. The -c option tells ping program to stop after sending (or receiving) specified number of ECHO_RESPONSE packets.

Second:

you need to use res.send to send back the ping response but due to your callback function i.e puts you don't have the access for res and req.

Use this wrapper func to pass another arguments you want to access with your callback

```<code>function execute(command, callback, res) {
    exec(command, function(error, stdout, stderr) {
        // Notice extra params I have passed here^,  ^
        callback(error, stdout, stderr, res);
    });
}
</code>```

and you can use this as

```<code>    execute("ping -c 2 google.com", puts, /*pass extra params*/ res);
</code>```

and catch extra params here after your callback function

```<code>                                    ||
                         ---------- \/

function execute(command, callback, res) {
  ...
}
</code>```

Complete code:

```<code>var exec = require('child_process').exec;

function puts(error, stdout, stderr, res) {
        // Notice extra params here  ^
    if (error) {
        console.log("error", "Error connecting");
        result = "Failed";
        console.log(result)
    } else {
        sys.puts(stdout)
        result = "Success"
        console.log(result)
        //send response to client
        res.send(result)
    }
}

//The calling function is mentioned as below:
app.get('/api/platforms1', function(req, res) {
    execute("ping -c 1 google.com", puts, /*pass extra params*/ res);
});

function execute(command, callback, res) {
    exec(command, function(error, stdout, stderr) {
        // Notice extra params I have passed here^,  ^
        callback(error, stdout, stderr, res);
    });
}
</code>```

Ref:

https://askubuntu.com/questions/200989/ping-for-4-times

Get the output of a shell command in node.js

Body:
    function puts(error, stdout, stderr) {
    if (error) {
        console.log("error", "Error connecting");
        result = "Failed";
        console.log(result)
    }
    else {
        sys.puts(stdout)
        result = "Success"
        console.log(result)
    }
    }

//The calling function is mentioned as below:
app.get('/api/platforms1', function(req, res){
    exec("ping localhost",puts);
});

//I am working under mean stack.I have created a method to ping ip address and display their result.But now I want to display the result as a return function.How can we do it??

Body:
First:

In windows, if you use:

ping google.com

You will get only 4 information ping, but on Ubuntu, if you use that command, the ping can't stop until you stop it with Ctrl+C.

To fix this we need to use -c flag. The -c option tells ping program to stop after sending (or receiving) specified number of ECHO_RESPONSE packets.

Second:

you need to use res.send to send back the ping response but due to your callback function i.e puts you don't have the access for res and req.

Use this wrapper func to pass another arguments you want to access with your callback

function execute(command, callback, res) {
    exec(command, function(error, stdout, stderr) {
        // Notice extra params I have passed here^,  ^
        callback(error, stdout, stderr, res);
    });
}

and you can use this as

    execute("ping -c 2 google.com", puts, /*pass extra params*/ res);

and catch extra params here after your callback function

                                    ||
                         ---------- \/

function execute(command, callback, res) {
  ...
}

Complete code:

var exec = require('child_process').exec;

function puts(error, stdout, stderr, res) {
        // Notice extra params here  ^
    if (error) {
        console.log("error", "Error connecting");
        result = "Failed";
        console.log(result)
    } else {
        sys.puts(stdout)
        result = "Success"
        console.log(result)
        //send response to client
        res.send(result)
    }
}

//The calling function is mentioned as below:
app.get('/api/platforms1', function(req, res) {
    execute("ping -c 1 google.com", puts, /*pass extra params*/ res);
});

function execute(command, callback, res) {
    exec(command, function(error, stdout, stderr) {
        // Notice extra params I have passed here^,  ^
        callback(error, stdout, stderr, res);
    });
}

Ref:

https://askubuntu.com/questions/200989/ping-for-4-times

Get the output of a shell command in node.js


问:
Bootstrap 3 nesting tabs
I'm creating an application and there's a lot of content so I am putting them in nested tabs. All works well except when I click on the nested tab, the content does not show.

```<code><ul class="nav nav-tabs">
  <li class="active"><a href="#minecraft" data-toggle="tab">Minecraft</a></li>
  <li><a href="#website" data-toggle="tab">Forums</a></li>
  <li><a href="#pokemasters" data-toggle="tab">Pokemasters</a></li>
  <li><a href="#runerage" data-toggle="tab">Rune Rage</a></li>
</ul>

<div class="tab-content">
  <div class="tab-pane fade in active" id="minecraft">
    <ul class="nav nav-pills" id="pills">
      <li class="active"><a href="#minecraft-registration" data-toggle="tab">Minecraft Registration</a></li>
      <li><a href="#minecraft-rules" data-toggle="tab">Rules</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane fade in active" id="minecraft-registration">
            <div class="tab-pane fade" id="minecraft-registration">
                test
            </div>
        </div>
    </div>
  </div>

  <div class="tab-pane fade" id="website">Forums</div>
  <div class="tab-pane fade" id="pokemasters">Pokemasters</div>
  <div class="tab-pane fade" id="runerage">Rune Rage</div>
</div>
</code>```

The code above produces this:

It's functional however, the content of the nested tab isn't shown. The content should show
test but it's blank.

答:
Had a similor problem: Fixed it as follows: Try this :</p>

```<code><div class="row">
        <div class="col-md-12">
         <!-- Custom Tabs -->
          <div class="nav-tabs-custom">
          <ul class="nav nav-tabs">
        <li class="active"><a href="#set1">New</a>
        </li>
        <li><a href="#set2">Confirmed</a>
        </li>
    </ul>
    <div class="tab-content">

        <div class="tab-pane fade active in" id="set1">

            <div class="tabbable">
                 <ul class="nav nav-tabs">
              <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">Web Design and Development</a></li>
              <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">Domain Registration</a></li>
              <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">Cloud Computing Services</a></li>
              <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">Android application Development</a></li>
              <li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false">Web Hosting</a></li>
              <li class=""><a href="#tab_6" data-toggle="tab" aria-expanded="false">SEO and Online Marketing</a></li>
              <li class="pull-right"><a href="#" class="text-muted"><i class="fa fa-gear"></i></a></li>
            </ul>
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
                <b>Web Deign and development hires:</b>

                <table class="table" id="webdesignTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>

              </div>
              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_2">
              <b>Domain Registration</b>

              <table class="table" id="domainregistrationTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>

              </div>
              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_3">
               <b>Cloud Computing</b>

              <table class="table" id="cloudcomputingTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->

              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_4">
               <b>Android application Development</b>

              <table class="table" id="androidappTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->

              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_5">
               <b>Web Hosting</b>

              <table class="table" id="webhostingTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->

              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_6">
               <b>SEO and Online Marketing</b>

              <table class="table" id="seoTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->
            </div>
            <!-- /.tab-content -->
            </div>

        </div>

        <div class="tab-pane fade" id="set2">
            <div class="tabbable">
                   <ul class="nav nav-tabs">
              <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">Web Design and Development</a></li>
              <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">Domain Registration</a></li>
              <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">Cloud Computing Services</a></li>
              <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">Android application Development</a></li>
              <li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false">Web Hosting</a></li>
              <li class=""><a href="#tab_6" data-toggle="tab" aria-expanded="false">SEO and Online Marketing</a></li>
              <li class="pull-right"><a href="#" class="text-muted"><i class="fa fa-gear"></i></a></li>
            </ul>
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
                <b>Web Deign and development hires:</b>

                <table class="table" id="webdesignTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>

              </div>
              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_2">
              <b>Domain Registration</b>

              <table class="table" id="domainregistrationTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>

              </div>
              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_3">
               <b>Cloud Computing</b>

              <table class="table" id="cloudcomputingTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->

              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_4">
               <b>Android application Development</b>

              <table class="table" id="androidappTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->

              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_5">
               <b>Web Hosting</b>

              <table class="table" id="webhostingTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->

              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_6">
               <b>SEO and Online Marketing</b>

              <table class="table" id="seoTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->
            </div>
            <!-- /.tab-content -->
            </div>
        </div>

    </div>
          </div>
        </div>
        </div>
</code>```

Title: Bootstrap 3 nesting tabs

Body:
I'm creating an application and there's a lot of content so I am putting them in nested tabs. All works well except when I click on the nested tab, the content does not show.

Minecraft

Forums

Pokemasters

Rune Rage

Minecraft Registration

Rules

                test

Forums

Pokemasters

Rune Rage

The code above produces this:

It's functional however, the content of the nested tab isn't shown. The content should show
test but it's blank.

Body:
Had a similor problem: Fixed it as follows: Try this :

<div class="row">
        <div class="col-md-12">
         <!-- Custom Tabs -->
          <div class="nav-tabs-custom">
          <ul class="nav nav-tabs">
        <li class="active"><a href="#set1">New</a>
        </li>
        <li><a href="#set2">Confirmed</a>
        </li>
    </ul>
    <div class="tab-content">

        <div class="tab-pane fade active in" id="set1">

            <div class="tabbable">
                 <ul class="nav nav-tabs">
              <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">Web Design and Development</a></li>
              <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">Domain Registration</a></li>
              <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">Cloud Computing Services</a></li>
              <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">Android application Development</a></li>
              <li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false">Web Hosting</a></li>
              <li class=""><a href="#tab_6" data-toggle="tab" aria-expanded="false">SEO and Online Marketing</a></li>
              <li class="pull-right"><a href="#" class="text-muted"><i class="fa fa-gear"></i></a></li>
            </ul>
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
                <b>Web Deign and development hires:</b>

                <table class="table" id="webdesignTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>

              </div>
              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_2">
              <b>Domain Registration</b>

              <table class="table" id="domainregistrationTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>

              </div>
              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_3">
               <b>Cloud Computing</b>

              <table class="table" id="cloudcomputingTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->

              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_4">
               <b>Android application Development</b>

              <table class="table" id="androidappTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->

              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_5">
               <b>Web Hosting</b>

              <table class="table" id="webhostingTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->

              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_6">
               <b>SEO and Online Marketing</b>

              <table class="table" id="seoTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->
            </div>
            <!-- /.tab-content -->
            </div>

        </div>

        <div class="tab-pane fade" id="set2">
            <div class="tabbable">
                   <ul class="nav nav-tabs">
              <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">Web Design and Development</a></li>
              <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">Domain Registration</a></li>
              <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">Cloud Computing Services</a></li>
              <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">Android application Development</a></li>
              <li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false">Web Hosting</a></li>
              <li class=""><a href="#tab_6" data-toggle="tab" aria-expanded="false">SEO and Online Marketing</a></li>
              <li class="pull-right"><a href="#" class="text-muted"><i class="fa fa-gear"></i></a></li>
            </ul>
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
                <b>Web Deign and development hires:</b>

                <table class="table" id="webdesignTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>

              </div>
              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_2">
              <b>Domain Registration</b>

              <table class="table" id="domainregistrationTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>

              </div>
              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_3">
               <b>Cloud Computing</b>

              <table class="table" id="cloudcomputingTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->

              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_4">
               <b>Android application Development</b>

              <table class="table" id="androidappTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->

              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_5">
               <b>Web Hosting</b>

              <table class="table" id="webhostingTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->

              <!-- /.tab-pane -->
              <div class="tab-pane" id="tab_6">
               <b>SEO and Online Marketing</b>

              <table class="table" id="seoTable">
                    <thead>
                        <tr>
                            <th>S.no</th>
                            <th>Order By</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Message</th>
                            <th>Date</th>
                            <th>Status</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                </table>
              </div>
              <!-- /.tab-pane -->
            </div>
            <!-- /.tab-content -->
            </div>
        </div>

    </div>
          </div>
        </div>
        </div>


问:
Should I have multiple repositories?
Does having multiple repositories increase resource usage?

I have followed this tutorial for adding a repository service that holds a database context: https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api

In the tutorial the repository is for managing a Todo item.  In my own app I have several different types of items and activities that I need a context for.  Should I create an individual repository for each?  For instance one repository for enquiries, another for user usage metrics?  Is there any overhead or penalty for doing this?

答:
As shown in the link provided The Repository pattern can be used to abstract the data access into an interface, in the example: ITodoRepository.

Why do you abstract data access? This way you could easily switch data-access layer by implementing a different class of ITodoRepository Say if you want to test your logic with unit tests, or if the possibility exists you wont be using entity framework anymore in the future.

If this is not the case and you are building a small project with no such future additions (unit tests/switch data-access layer) Making use of the Repository pattern is only extra work without any benefits.

So you should decide if the extra work of making the repository pattern outweighs the benefits for your project.

Title: Should I have multiple repositories?


问:
ReactJS: Have one className with binding and another className without
How do I have a static className with a className that is dynamic?  For example, in this:
https://jsfiddle.net/uwadhwnr/112/

<button className={this.state.color}>, if I do <button className="cheese {this.state.color}">, the this.state.color won't render because it's in quotations, but I want to have both classes.

答:
If you need to add the state color as className to "cheese" then you can do it like

```<code><button className={"cheese " + this.state.color}>
</code>```

Working code

```<code>var Hello = React.createClass({
    getInitialState: function(){
        return {
            color: 'blue'
        };
    },
    handleClick: function(){
        if (this.state.color === 'blue'){
            this.setState({color: 'green'});
        } else {
            this.setState({color: 'blue'});
        }
    },
    render: function() {
        return <button className={"cheese " + this.state.color} onClick={this.handleClick}>My background is: {this.state.color}, Click me to change</button>;
    }
});

React.render(<Hello name="World" />, document.getElementById('container'));
</code>```

JSFIDDLE

Body:
If you need to add the state color as className to "cheese" then you can do it like

<button className={"cheese " + this.state.color}>

Working code

var Hello = React.createClass({
    getInitialState: function(){
        return {
            color: 'blue'
        };
    },
    handleClick: function(){
        if (this.state.color === 'blue'){
            this.setState({color: 'green'});
        } else {
            this.setState({color: 'blue'});
        }
    },
    render: function() {
        return <button className={"cheese " + this.state.color} onClick={this.handleClick}>My background is: {this.state.color}, Click me to change</button>;
    }
});

React.render(<Hello name="World" />, document.getElementById('container'));

JSFIDDLE


问:
Qmail - Local Queue stacking up
I have a big problem!
My customer contacted me, and told me that he isn't recieving emails from his websites contactform. I checked the mail-queue in Plesk, and I can see that they're stuck in "local"(!)

I tried to force send by running this in SSH kill -ALRM ps ax | grep [q]mail-send | awk '{print $1}'

It's not working - returns a empty line in my SSH.
I have tried similar solutions - but no luck.
Is there anything I can do, to get some more information about this issue?
I'm not an expert in Plesk at all - and all the help I can get is GREATLY appreciated.

Maillog:

```<code>Mar 29 08:14:12 opening qmail-local-handlers[28962]: from=lyg@lyg.dk
Mar 29 08:14:12 opening qmail-local-handlers[28962]: to=opening.dk-ak@opening.dk
Mar 29 08:14:12 opening qmail-local-handlers[28962]: mailbox: /var/qmail/mailnam                                                 es/opening.dk
Mar 29 08:14:12 opening qmail: 1490775252.408838 delivery 55: deferral: /bin/sh:                                                 _/deliverquota:_No_such_file_or_directory/
Mar 29 08:14:12 opening qmail: 1490775252.408855 status: local 5/10 remote 0/20
Mar 29 08:14:12 opening qmail: 1490775252.411033 delivery 57: deferral: /bin/sh:                                                 _/deliverquota:_No_such_file_or_directory/
Mar 29 08:14:12 opening qmail: 1490775252.411060 status: local 4/10 remote 0/20
Mar 29 08:14:12 opening qmail: 1490775252.412893 delivery 54: deferral: /bin/sh:                                                 _/deliverquota:_No_such_file_or_directory/
Mar 29 08:14:12 opening qmail: 1490775252.412910 status: local 3/10 remote 0/20
Mar 29 08:14:12 opening qmail: 1490775252.414351 delivery 53: deferral: /bin/sh:                                                 _/deliverquota:_No_such_file_or_directory/
Mar 29 08:14:12 opening qmail: 1490775252.414369 status: local 2/10 remote 0/20
Mar 29 08:14:12 opening qmail: 1490775252.414377 delivery 58: deferral: /bin/sh:                                                 _/deliverquota:_No_such_file_or_directory/
Mar 29 08:14:12 opening qmail: 1490775252.414384 status: local 1/10 remote 0/20
Mar 29 08:14:12 opening qmail: 1490775252.414554 delivery 56: deferral: /bin/sh:                                                 _/deliverquota:_No_such_file_or_directory/
Mar 29 08:14:12 opening qmail: 1490775252.414570 status: local 0/10 remote 0/20
Mar 29 08:14:41 opening qmail-queue-handlers[29038]: Unable to change group ID:                                                  Operation not permitted
Mar 29 08:14:41 opening qmail: 1490775281.517412 warning: trouble injecting boun                                                 ce message, will try later
Mar 29 08:14:41 opening qmail-queue-handlers[29039]: Unable to change group ID:                                                  Operation not permitted
Mar 29 08:14:41 opening qmail: 1490775281.518755 warning: trouble injecting boun                                                 ce message, will try later
</code>```

And if I run ps -ef|grep mail I get the following output:

```<code>[opening@opening log]$ ps -ef|grep mail
qmails   28182     1  0 08:10 ?        00:00:00 qmail-send
qmaill   28184 28182  0 08:10 ?        00:00:00 splogger qmail
root     28185 28182  0 08:10 ?        00:00:00 qmail-lspawn | /deliverquota ./Maildir
qmailr   28186 28182  0 08:10 ?        00:00:00 qmail-rspawn
qmailq   28187 28182  0 08:10 ?        00:00:00 qmail-clean
opening  29554 28582  0 08:20 pts/0    00:00:00 grep mail
root     64808     1  0 Mar23 ?        00:01:10 /usr/bin/spamd --nouser-config --username=popuser --daemonize --helper-home-dir=/var/qmail --virtual-config-dir=/var/qmail/mailnames/%d/%l/.spamassassin --create-prefs --max-children=5 -r /var/run/spamd.pid
</code>```

When I run plesk repair mail -y -v I get the following output:

```<code>[opening@opening log]$ sudo plesk repair mail -y -v Repairing the mail server configuration Reconfiguring all domains and mailboxes ......................... [OK] Error messages: 0; Warnings: 0; Errors resolved: 0
</code>```

Btw. Plesk is installed on an Azure server - if that is to any help at all.

Please let me know if I can provide any other info - and how.

Best regards

Aris Kuckovic

答:
If you experience issues/errors/problems with QMAIL on servers where Plesk ( > 12.5 ) is installed, consider to use the "Plesk repair utility" with the example command :

```<code>plesk repair mail -y -v
</code>```

More possible options for the "Plesk repair utility" can be found at:

=> Plesk Repair Utility ( official Plesk online documentation - Administrator's Guide )

Another option to solve possible issues/errors/problems is to switch from QMAIL to POSTFIX and backwards to QMAIL again:

```<code>plesk installer --select-product-id plesk --select-release-current --install-component postfix

plesk installer --select-product-id plesk --select-release-current --install-component qmail
</code>```

Title: Qmail - Local Queue stacking up

Body:
I have a big problem!
My customer contacted me, and told me that he isn't recieving emails from his websites contactform. I checked the mail-queue in Plesk, and I can see that they're stuck in "local"(!)

I tried to force send by running this in SSH kill -ALRM ps ax | grep [q]mail-send | awk '{print $1}'

It's not working - returns a empty line in my SSH.
I have tried similar solutions - but no luck.
Is there anything I can do, to get some more information about this issue?
I'm not an expert in Plesk at all - and all the help I can get is GREATLY appreciated.

Maillog:

Mar 29 08:14:12 opening qmail-local-handlers[28962]: from=lyg@lyg.dk
Mar 29 08:14:12 opening qmail-local-handlers[28962]: to=opening.dk-ak@opening.dk
Mar 29 08:14:12 opening qmail-local-handlers[28962]: mailbox: /var/qmail/mailnam                                                 es/opening.dk
Mar 29 08:14:12 opening qmail: 1490775252.408838 delivery 55: deferral: /bin/sh:                                                 _/deliverquota:_No_such_file_or_directory/
Mar 29 08:14:12 opening qmail: 1490775252.408855 status: local 5/10 remote 0/20
Mar 29 08:14:12 opening qmail: 1490775252.411033 delivery 57: deferral: /bin/sh:                                                 _/deliverquota:_No_such_file_or_directory/
Mar 29 08:14:12 opening qmail: 1490775252.411060 status: local 4/10 remote 0/20
Mar 29 08:14:12 opening qmail: 1490775252.412893 delivery 54: deferral: /bin/sh:                                                 _/deliverquota:_No_such_file_or_directory/
Mar 29 08:14:12 opening qmail: 1490775252.412910 status: local 3/10 remote 0/20
Mar 29 08:14:12 opening qmail: 1490775252.414351 delivery 53: deferral: /bin/sh:                                                 _/deliverquota:_No_such_file_or_directory/
Mar 29 08:14:12 opening qmail: 1490775252.414369 status: local 2/10 remote 0/20
Mar 29 08:14:12 opening qmail: 1490775252.414377 delivery 58: deferral: /bin/sh:                                                 _/deliverquota:_No_such_file_or_directory/
Mar 29 08:14:12 opening qmail: 1490775252.414384 status: local 1/10 remote 0/20
Mar 29 08:14:12 opening qmail: 1490775252.414554 delivery 56: deferral: /bin/sh:                                                 _/deliverquota:_No_such_file_or_directory/
Mar 29 08:14:12 opening qmail: 1490775252.414570 status: local 0/10 remote 0/20
Mar 29 08:14:41 opening qmail-queue-handlers[29038]: Unable to change group ID:                                                  Operation not permitted
Mar 29 08:14:41 opening qmail: 1490775281.517412 warning: trouble injecting boun                                                 ce message, will try later
Mar 29 08:14:41 opening qmail-queue-handlers[29039]: Unable to change group ID:                                                  Operation not permitted
Mar 29 08:14:41 opening qmail: 1490775281.518755 warning: trouble injecting boun                                                 ce message, will try later

And if I run ps -ef|grep mail I get the following output:

[opening@opening log]$ ps -ef|grep mail
qmails   28182     1  0 08:10 ?        00:00:00 qmail-send
qmaill   28184 28182  0 08:10 ?        00:00:00 splogger qmail
root     28185 28182  0 08:10 ?        00:00:00 qmail-lspawn | /deliverquota ./Maildir
qmailr   28186 28182  0 08:10 ?        00:00:00 qmail-rspawn
qmailq   28187 28182  0 08:10 ?        00:00:00 qmail-clean
opening  29554 28582  0 08:20 pts/0    00:00:00 grep mail
root     64808     1  0 Mar23 ?        00:01:10 /usr/bin/spamd --nouser-config --username=popuser --daemonize --helper-home-dir=/var/qmail --virtual-config-dir=/var/qmail/mailnames/%d/%l/.spamassassin --create-prefs --max-children=5 -r /var/run/spamd.pid

When I run plesk repair mail -y -v I get the following output:

[opening@opening log]$ sudo plesk repair mail -y -v Repairing the mail server configuration Reconfiguring all domains and mailboxes ......................... [OK] Error messages: 0; Warnings: 0; Errors resolved: 0

Btw. Plesk is installed on an Azure server - if that is to any help at all.

Please let me know if I can provide any other info - and how.

Best regards

Aris Kuckovic

Body:
If you experience issues/errors/problems with QMAIL on servers where Plesk ( > 12.5 ) is installed, consider to use the "Plesk repair utility" with the example command :

plesk repair mail -y -v

More possible options for the "Plesk repair utility" can be found at:

=> Plesk Repair Utility ( official Plesk online documentation - Administrator's Guide )

Another option to solve possible issues/errors/problems is to switch from QMAIL to POSTFIX and backwards to QMAIL again:

plesk installer --select-product-id plesk --select-release-current --install-component postfix

plesk installer --select-product-id plesk --select-release-current --install-component qmail


问:
Scroll button hide after 5 seconds using jQuery?
I can scroll on the top or the bottom of my page. But after 5seconds, I want my scroll div disapear. I use the property delay & hide of Jquery.
I must refresh my page to works my code once my div disapear.</p>

```<code>$(function () {

        var scrollTrigger = 100, // px
                backToTop = function () {
                    var scrollTop = $(window).scrollTop();
                    if (scrollTop > scrollTrigger) {

                        $("a[href='#top']").addClass('show').delay(2000).hide(500);
                        $("a[href='#bottom']").addClass('show').delay(2000).hide(500);

                    } else {
                        $("a[href='#top']").removeClass('show');
                        $("a[href='#bottom']").removeClass('show');
                    }
                };
        backToTop();

        $(window).on('scroll', function () {
            backToTop();
        });
        $("a[href='#top']").click(function() {
            $("html, body").animate({ scrollTop: 0 }, "slow");
            return false;
        });

        $("a[href='#bottom']").click(function() {
        $('html,body').animate({ scrollTop: 9999 }, 'slow');
        return false;
        });
    });
</code>```

答:
use the setTimeout()  function.
ref.

https://www.w3schools.com/jsref/met_win_settimeout.asp,
https://www.sitepoint.com/jquery-settimeout-function-examples/

example

```<code>               backToTop = function () {

                    $("a[href='#top']").show(500);
                    $("a[href='#bottom']").show(500);

                setTimeout(function() {
                    $("a[href='#top']").hide(500);
                    $("a[href='#bottom']").hide(500);
                }, 5000)
            };
</code>```

Body:
I can scroll on the top or the bottom of my page. But after 5seconds, I want my scroll div disapear. I use the property delay & hide of Jquery.
I must refresh my page to works my code once my div disapear.

$(function () {

        var scrollTrigger = 100, // px
                backToTop = function () {
                    var scrollTop = $(window).scrollTop();
                    if (scrollTop > scrollTrigger) {

                        $("a[href='#top']").addClass('show').delay(2000).hide(500);
                        $("a[href='#bottom']").addClass('show').delay(2000).hide(500);

                    } else {
                        $("a[href='#top']").removeClass('show');
                        $("a[href='#bottom']").removeClass('show');
                    }
                };
        backToTop();

        $(window).on('scroll', function () {
            backToTop();
        });
        $("a[href='#top']").click(function() {
            $("html, body").animate({ scrollTop: 0 }, "slow");
            return false;
        });

        $("a[href='#bottom']").click(function() {
        $('html,body').animate({ scrollTop: 9999 }, 'slow');
        return false;
        });
    });

Body:
use the setTimeout()  function.
ref.

https://www.w3schools.com/jsref/met_win_settimeout.asp,
https://www.sitepoint.com/jquery-settimeout-function-examples/

example

               backToTop = function () {

                    $("a[href='#top']").show(500);
                    $("a[href='#bottom']").show(500);

                setTimeout(function() {
                    $("a[href='#top']").hide(500);
                    $("a[href='#bottom']").hide(500);
                }, 5000)
            };


问:
What is the best Linq Query for this?
I have a table with this column:

```<code>Code        //int
Type        //int
Point       //int
</code>```

I want to have query that do this work:

Based on Code and Type do a select and add sum of point to Point. I think I can't explain what I want correctly and for this reason I show you the result what I want in below.

My table:

```<code>Code           Type            Point        Date
1              1               10           someDate
1              1               20           someDate
1              2               10           someDate
1              1               30           someDate
1              2               10           someDate
2              1               30           someDate
2              2               20           someDate
2              1               10           someDate
1              2               10           someDate
1              1               10           someDate
3              2               20           someDate
</code>```

The result I want :

```<code>row[0] : Code:1, Type:1, Point:70,
row[1] : Code:1, Type:2, Point:30,
row[2] : Code:2, Type:1, Point:40,
row[3] : Code:2, Type:2, Point:20,
row[4] : Code:3, Type:2, Point:20,
</code>```

UPDATE:
If I want a result like this what is the best query?

```<code>row[0] : Code:1, pointType1:70, pointType2:30,
row[0] : Code:2, pointType1:40, pointType2:20,
row[0] : Code:3, pointType1:0, pointType2:20,
</code>```

答:
You can group on Code and Type property your list and then Project the both keys with aggregate sum of the Point property from the grouping result like:

```<code>var result = list.GroupBy(x=> new { x.Code, x.Type})
                 .Select(g=>
                             new {
                                   Code = g.Key.Code,
                                   Type= g.Key.Type,
                                   Point = g.Sum(x=>x.Point)
                             })
                 .ToList();
</code>```

UPDATE:

after question example output updated, the following would give you expected result:

```<code>var result = list.GroupBy(x=> x.Code)
                     .Select(g=>
                                 new {
                                       Code = g.Key.Code,
                                       PointType1= g.Where(x=>x.Type==1)
                                                    .Sum(x=>x.Point)
                                                   Key.Type,
                                       PointType2 = g.Where(x=>x.Type==2)
                                                     .Sum(x=>x.Point)
                                 })
                     .ToList();
</code>```

Title: What is the best Linq Query for this?

Body:
I have a table with this column:

Code        //int
Type        //int
Point       //int

I want to have query that do this work:

Based on Code and Type do a select and add sum of point to Point. I think I can't explain what I want correctly and for this reason I show you the result what I want in below.

My table:

Code           Type            Point        Date
1              1               10           someDate
1              1               20           someDate
1              2               10           someDate
1              1               30           someDate
1              2               10           someDate
2              1               30           someDate
2              2               20           someDate
2              1               10           someDate
1              2               10           someDate
1              1               10           someDate
3              2               20           someDate

The result I want :

row[0] : Code:1, Type:1, Point:70,
row[1] : Code:1, Type:2, Point:30,
row[2] : Code:2, Type:1, Point:40,
row[3] : Code:2, Type:2, Point:20,
row[4] : Code:3, Type:2, Point:20,

UPDATE:
If I want a result like this what is the best query?

row[0] : Code:1, pointType1:70, pointType2:30,
row[0] : Code:2, pointType1:40, pointType2:20,
row[0] : Code:3, pointType1:0, pointType2:20,

Body:
You can group on Code and Type property your list and then Project the both keys with aggregate sum of the Point property from the grouping result like:

var result = list.GroupBy(x=> new { x.Code, x.Type})
                 .Select(g=>
                             new {
                                   Code = g.Key.Code,
                                   Type= g.Key.Type,
                                   Point = g.Sum(x=>x.Point)
                             })
                 .ToList();

UPDATE:

after question example output updated, the following would give you expected result:

var result = list.GroupBy(x=> x.Code)
                     .Select(g=>
                                 new {
                                       Code = g.Key.Code,
                                       PointType1= g.Where(x=>x.Type==1)
                                                    .Sum(x=>x.Point)
                                                   Key.Type,
                                       PointType2 = g.Where(x=>x.Type==2)
                                                     .Sum(x=>x.Point)
                                 })
                     .ToList();


问:
Unable to deploy WAR in an EAR on WebLogic
I have a web application running on JSF 2.2 on WebLogic Application server 12.2.1.1.

I have a simple java class and trying to initialize it as an ApplicationScoped object using CDI. This gets deployed perfectly fine as a WAR.

```<code>import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;

@Named
@ApplicationScoped
public class AppContext {
    public AppContext() {
    }
}
</code>```

However, when I add this WAR to an EAR it fails to deploy. I am trying all possible solutions and nothing seems to work at this point. The exception log is as below:

```<code>weblogic.management.DeploymentException: CDI deployment failure:WELD-001414: Bean name is ambiguous. Name appContext resolves to beans: [Managed Bean [class beans.AppContext] with qualifiers [@Default @Any @Named], Managed Bean [class beans.AppContext] with qualifiers [@Default @Any @Named]]:org.jboss.weld.exceptions.DeploymentException:WELD-001414: Bean name is ambiguous. Name appContext resolves to beans: [Managed Bean [class beans.AppContext] with qualifiers [@Default @Any @Named], Managed Bean [class beans.AppContext] with qualifiers [@Default @Any @Named]]
    at org.jboss.weld.bootstrap.Validator.validateBeanNames(Validator.java:641)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:487)
    at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:446)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
    at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:150)
    Truncated. see log file for complete stacktrace
</code>```

Also WEB-INF\beans.xml is as follows:

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
</code>```

Application Running On:

```<code>NetBeans IDE 8.2;
JDK 1.8 b121;
Mojarra JSF 2.2;
WebLogic 12.2.1.1;
</code>```

Any hint on fixing this issue is highly appreciated.

答:
It seems that any bean is already registered with name "appContext" in bean server.

Either provide different bean name explicitly or change the class name.

Body:
I have a web application running on JSF 2.2 on WebLogic Application server 12.2.1.1.

I have a simple java class and trying to initialize it as an ApplicationScoped object using CDI. This gets deployed perfectly fine as a WAR.

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;

@Named
@ApplicationScoped
public class AppContext {
    public AppContext() {
    }
}

However, when I add this WAR to an EAR it fails to deploy. I am trying all possible solutions and nothing seems to work at this point. The exception log is as below:

weblogic.management.DeploymentException: CDI deployment failure:WELD-001414: Bean name is ambiguous. Name appContext resolves to beans: [Managed Bean [class beans.AppContext] with qualifiers [@Default @Any @Named], Managed Bean [class beans.AppContext] with qualifiers [@Default @Any @Named]]:org.jboss.weld.exceptions.DeploymentException:WELD-001414: Bean name is ambiguous. Name appContext resolves to beans: [Managed Bean [class beans.AppContext] with qualifiers [@Default @Any @Named], Managed Bean [class beans.AppContext] with qualifiers [@Default @Any @Named]]
    at org.jboss.weld.bootstrap.Validator.validateBeanNames(Validator.java:641)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:487)
    at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:446)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
    at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:150)
    Truncated. see log file for complete stacktrace

Also WEB-INF\beans.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>

Application Running On:

NetBeans IDE 8.2;
JDK 1.8 b121;
Mojarra JSF 2.2;
WebLogic 12.2.1.1;

Any hint on fixing this issue is highly appreciated.