问:
Repeating rows with bootstrap
I am attempting to format my site to nicely play with the bootstrap custom content component. Trouble is the xml is being parsed and doesn't like the fact that I haven't closed my div tag. This assumes that I have multiples of 3 in my groups.

Code (updated to my complete code):

```<code> <ui:repeat var="crs" value="#{groups.getGroupRows(true)}" varStatus="status">

                    <c:if test="${(status.index mod 3) == 0}">
                        <div class="row">
                    </c:if>

                    <div class="col-sm-6 col-md-4">
                        <div class="thumbnail">
                            <ui:repeat value="#{crs.getObject('imageFiles').files}" var="image">
                                <h:link outcome="viewClassesInGroup" id="group_name" styleClass="thumbnail">
                                    <f:param name="group_id" id="group_id" value="#{crs.getInteger('group_id')}"/>
                                    <img src="#{image.imageAbsoluteUrl('large')}" data-src="holder.js/300x200" />
                                </h:link>
                            </ui:repeat>
                            <div class="caption">
                                <h3><h:link outcome="viewClassesInGroup"  id="group_name" value="#{crs.string}">
                                        <f:param name="group_id" id="group_id" value="#{crs.getInteger('group_id')}"/>
                                    </h:link></h3>
                                <p><h:outputText id="group_description" value="#{crs.string}"/></p>
                                <p><a href="#" class="btn btn-primary" role="button">View Group</a></p>
                            </div>
                        </div>
                    </div>

                    <c:if test="${(status.index mod 3) == 0}">
                        </div>
                    </c:if>

                </ui:repeat>
</code>```

Error:

```<code>SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [] threw exception [Error Parsing /index.xhtml: Error Traced[line: 31] The element type "div" must be terminated by the matching end-tag "</div>".] with root cause
javax.faces.view.facelets.FaceletException: Error Parsing /index.xhtml: Error Traced[line: 31] The element type "div" must be terminated by the matching end-tag "</div>".
    at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:450)
    at com.sun.faces.facelets.compiler.SAXCompiler.doMetadataCompile(SAXCompiler.java:433)
    at com.sun.faces.facelets.compiler.Compiler.metadataCompile(Compiler.java:130)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.createMetadataFacelet(DefaultFaceletFactory.java:495)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.access$200(DefaultFaceletFactory.java:106)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:205)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:203)
    at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:97)
    at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:92)
    at com.sun.faces.util.ExpiringConcurrentCache$1.call(ExpiringConcurrentCache.java:99)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at com.sun.faces.util.ExpiringConcurrentCache.get(ExpiringConcurrentCache.java:114)
    at com.sun.faces.facelets.impl.DefaultFaceletCache.getViewMetadataFacelet(DefaultFaceletCache.java:146)
    at com.sun.faces.facelets.impl.DefaultFaceletCache.getViewMetadataFacelet(DefaultFaceletCache.java:63)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:316)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:246)
    at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:113)
    at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:241)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:121)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
</code>```

Update

I have tried matching the expression, as well as switching places of the test. It still is throwing a javax.faces.view.facelets.FaceletException: Error Parsing /index.xhtml

答:
I am new here,

I have searched for a solution for several rows with bootstrap in jsf. When I looked at the solution here, I did not even look through this, because it looks a little overloaded. Why I came up with my own solution. I hope it is clearer.

MySolution:

```<code><div class="container">
  <ui:repeat step="3" value="#{bean.list}" varStatus="outerLoopIndex">
      <div class="row">
          <ui:repeat offset="#{outerLoopIndex.index}" size="#{(outerLoopIndex.index + 3) gt bean.list.size() ? bean.list.size() : outerLoopIndex.index + 3}"
          var="item" value="#{bean.list}" varStatus="innerLoopIndex">
           <div class="col-4">
            <label class="btn btn-secondary active">
                #{innerLoopIndex.index} #{item.foo}
            </label>
           </div>
          </ui:repeat>
      </div>
  </ui:repeat>
</div> <!-- container -->
</code>```

If you want to change the number of columns by row, the step must be adjusted in the outer repeat element, the size in the inner repeat element and, of course, the col class of the div element.

Change COLUMNSPERROW:

```<code><ui:repeat step="COLUMNSPERROW" var="permission" value="#{bean.list}" varStatus="outerLoopIndex">
      <div class="row">
          <ui:repeat offset="#{outerLoopIndex.index}" size="#{(outerLoopIndex.index + COLUMNSPERROW) gt bean.list.size() ? bean.list.size() : outerLoopIndex.index + COLUMNSPERROW}"
          var="item" value="#{bean.list}" varStatus="innerLoopIndex">
           <div class="col">
</code>```

Title: Repeating rows with bootstrap

Body:
I am attempting to format my site to nicely play with the bootstrap custom content component. Trouble is the xml is being parsed and doesn't like the fact that I haven't closed my div tag. This assumes that I have multiples of 3 in my groups.

Code (updated to my complete code):

 <ui:repeat var="crs" value="#{groups.getGroupRows(true)}" varStatus="status">

                    <c:if test="${(status.index mod 3) == 0}">

                    </c:if>

                            <ui:repeat value="#{crs.getObject('imageFiles').files}" var="image">
                                <h:link outcome="viewClassesInGroup" id="group_name" styleClass="thumbnail">
                                    <f:param name="group_id" id="group_id" value="#{crs.getInteger('group_id')}"/>

                                </h:link>
                            </ui:repeat>

<h:link outcome="viewClassesInGroup"  id="group_name" value="#{crs.string}">
                                        <f:param name="group_id" id="group_id" value="#{crs.getInteger('group_id')}"/>
                                    </h:link>

<h:outputText id="group_description" value="#{crs.string}"/>

View Group

                    <c:if test="${(status.index mod 3) == 0}">

                    </c:if>

                </ui:repeat>

Error:

SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [] threw exception [Error Parsing /index.xhtml: Error Traced[line: 31] The element type "div" must be terminated by the matching end-tag "
".] with root cause
javax.faces.view.facelets.FaceletException: Error Parsing /index.xhtml: Error Traced[line: 31] The element type "div" must be terminated by the matching end-tag "
".
    at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:450)
    at com.sun.faces.facelets.compiler.SAXCompiler.doMetadataCompile(SAXCompiler.java:433)
    at com.sun.faces.facelets.compiler.Compiler.metadataCompile(Compiler.java:130)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.createMetadataFacelet(DefaultFaceletFactory.java:495)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.access$200(DefaultFaceletFactory.java:106)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:205)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:203)
    at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:97)
    at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:92)
    at com.sun.faces.util.ExpiringConcurrentCache$1.call(ExpiringConcurrentCache.java:99)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at com.sun.faces.util.ExpiringConcurrentCache.get(ExpiringConcurrentCache.java:114)
    at com.sun.faces.facelets.impl.DefaultFaceletCache.getViewMetadataFacelet(DefaultFaceletCache.java:146)
    at com.sun.faces.facelets.impl.DefaultFaceletCache.getViewMetadataFacelet(DefaultFaceletCache.java:63)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:316)
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:246)
    at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:113)
    at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:241)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:121)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

Update

I have tried matching the expression, as well as switching places of the test. It still is throwing a javax.faces.view.facelets.FaceletException: Error Parsing /index.xhtml

Body:
I am new here,

I have searched for a solution for several rows with bootstrap in jsf. When I looked at the solution here, I did not even look through this, because it looks a little overloaded. Why I came up with my own solution. I hope it is clearer.

MySolution:

<div class="container">
  <ui:repeat step="3" value="#{bean.list}" varStatus="outerLoopIndex">
      <div class="row">
          <ui:repeat offset="#{outerLoopIndex.index}" size="#{(outerLoopIndex.index + 3) gt bean.list.size() ? bean.list.size() : outerLoopIndex.index + 3}"
          var="item" value="#{bean.list}" varStatus="innerLoopIndex">
           <div class="col-4">
            <label class="btn btn-secondary active">
                #{innerLoopIndex.index} #{item.foo}
            </label>
           </div>
          </ui:repeat>
      </div>
  </ui:repeat>
</div> <!-- container -->

If you want to change the number of columns by row, the step must be adjusted in the outer repeat element, the size in the inner repeat element and, of course, the col class of the div element.

Change COLUMNSPERROW:

<ui:repeat step="COLUMNSPERROW" var="permission" value="#{bean.list}" varStatus="outerLoopIndex">
      <div class="row">
          <ui:repeat offset="#{outerLoopIndex.index}" size="#{(outerLoopIndex.index + COLUMNSPERROW) gt bean.list.size() ? bean.list.size() : outerLoopIndex.index + COLUMNSPERROW}"
          var="item" value="#{bean.list}" varStatus="innerLoopIndex">
           <div class="col">

ContentLicense: CC BY-SA 4.0


来源: stackexchange

问:
List all privileges of a user
I have a windows service which I want to log on to it with a specific user - therefore I added user rights to log on as a service via ntrights.

In order to put that into effect - reboot is needed.

To avoid an unnecessary reboot - I would like to check if this user has this privilege already.

Is there a way to check it?

This is how I add the user rights:

```<code> ntrights +r SeServiceLogonRight -u "USER" -m \\%COMPUTERNAME%
</code>```

答:
Use this command to check if user has a particular privilege:

```<code>whoami /priv /fo CSV | convertFrom-Csv | Select-String -Pattern   "SeServiceLogonRight" -Quiet
</code>```

If this command returns True then user has the given privilege, else not.

ContentLicense: CC BY-SA 3.0

Title: List all privileges of a user

Body:
I have a windows service which I want to log on to it with a specific user - therefore I added user rights to log on as a service via ntrights.

In order to put that into effect - reboot is needed.

To avoid an unnecessary reboot - I would like to check if this user has this privilege already.

Is there a way to check it?

This is how I add the user rights:

 ntrights +r SeServiceLogonRight -u "USER" -m \\%COMPUTERNAME%

Body:
Use this command to check if user has a particular privilege:

whoami /priv /fo CSV | convertFrom-Csv | Select-String -Pattern   "SeServiceLogonRight" -Quiet

If this command returns True then user has the given privilege, else not.


问:
Bootstrap carousel slider arrows error
As the title says i have a problem with the arrows in the carousel. The arrows go up and merge with the navbar but i can still click to change the image. I've added background images as covers and i modified the code a little to the point i cant find out what is the problem. Can you help me here? How can i get the arrows down again and why is that happening?

Here's my code:

HTML

```<code><!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Web Paintings</title>
        <link href="style.css" rel="stylesheet">
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

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

        </script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    </head>

    <body>

        <!-- Navigation -->

    <nav class="navbar navbar-inverse navbar-fixed-top margin-top" role="navigation">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">Web Paintings</a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="#"><span class="glyphicon glyphicon-home"></span>Home</a>
                    </li>
                    <li>
                        <a href="#"><span class="fa fa-database"></span>Paintings</a>
                    </li>
                    <li>
                        <a href="#"><span class="fa fa-book"></span>Contact</a>
                    </li>
                            <li class="slide"><a href="#" class="btn-slide1"><span class="fa fa-pencil"></span>Register</a></li>
                            <li class="slide"><a href="#" class="btn-slide2"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
                </ul>
            </div>
        </div>
    </nav>

            <div class="margin-top">
                             <!-- START OF CAROUSEL -->
                            <div id="myCarousel" class="carousel slide">
                              <!-- Carousel items -->
                              <div class="carousel-inner">
                                 <div class="item active ad1">
                                    <div class="carousel-caption">
                                       <h4 class="mycaption">First Thumbnail label</h4>
                                       <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                                    </div>
                                 </div>
                                 <div class="item ad2">
                                    <div class="carousel-caption">
                                        <h4 class="mycaption">Second Thumbnail label</h4>
                                        <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                                     </div>
                                 </div>
                                 <div class="item ad3">
                                    <div class="carousel-caption">
                                       <h4 class="mycaption">Third Thumbnail label</h4>
                                       <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                                    </div>
                                </div>
                              </div>
                              <!-- Carousel nav -->
                              <a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
                              <a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
                            </div>

                               <!-- END OF CAROUSEL -->

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

    </body>
</html>
</code>```

CSS:

```<code>body {
    font-family: 'Raleway', sans-serif;
}

.marginTop{
  margin-top:60px;
}
.navbar {
  min-height: 32px !important;
}
 .navbar .navbar-brand{
  padding: 0 12px;
  font-size: 16px;
  line-height: 38px;
  height: 38px;
}
 .navbar .navbar-nav > li > a {
  padding-top: 0px;
  padding-bottom: 0px;
  line-height: 38px;
}
 .navbar .navbar-toggle {
  margin-top: 3px;
  margin-bottom: 0px;
  padding: 8px 9px;
}
 .navbar .navbar-collapse {
  border-color: #2f2f2f;
}
ul.nav a:hover {
    color: #129CF3 !important;
}

#myCarousel {
    width: 100%;
}
.carousel-control {
    margin-top: 20px;
}
.carousel-inner .item {
    width: 100%;
    height: 400px;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}
.ad1 {
    background: url(images/paint1.jpg) no-repeat center center fixed;
}
.ad2 {
    background: url(images/paint2.jpg) no-repeat center center fixed;
}
.ad3 {
    background: url(images/paint3.jpg) no-repeat center center fixed;
}
.mycaption {
  color: white;
    font: bold 24px/45px Helvetica, Sans-Serif; letter-spacing: -1px;
   background-color: rgba(0, 0, 0, 0.7);
    padding: 10px;
}
</code>```

答:
add line-height on .carousel-control  Depend on your .carousel-inner .item > height

```<code>.carousel-control {
   line-height:400px;
   font-size:100px !important;
   width:80px !important;
}
</code>```

body {
    font-family: 'Raleway', sans-serif;
}

.marginTop{
  margin-top:60px;
}
.navbar {
  min-height: 32px !important;
}
 .navbar .navbar-brand{
  padding: 0 12px;
  font-size: 16px;
  line-height: 38px;
  height: 38px;
}
 .navbar .navbar-nav > li > a {
  padding-top: 0px;
  padding-bottom: 0px;
  line-height: 38px;
}
 .navbar .navbar-toggle {
  margin-top: 3px;
  margin-bottom: 0px;
  padding: 8px 9px;
}
 .navbar .navbar-collapse {
  border-color: #2f2f2f;
}
ul.nav a:hover {
    color: #129CF3 !important;
}

#myCarousel {
    width: 100%;
}
.carousel-control {
    margin-top: 20px;
}
.carousel-inner .item {
    width: 100%;
    height: 400px;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}
    .carousel-control {
   line-height:400px;
   font-size:100px !important;
   width:80px !important;
}
.ad1 {
    background: url(images/paint1.jpg) no-repeat center center fixed;
}
.ad2 {
    background: url(images/paint2.jpg) no-repeat center center fixed;
}
.ad3 {
    background: url(images/paint3.jpg) no-repeat center center fixed;
}
.mycaption {
  color: white;
    font: bold 24px/45px Helvetica, Sans-Serif; letter-spacing: -1px;
   background-color: rgba(0, 0, 0, 0.7);
    padding: 10px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Web Paintings</title>
        <link href="style.css" rel="stylesheet">
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

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

        </script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    </head>

    <body>

        <!-- Navigation -->

    <nav class="navbar navbar-inverse navbar-fixed-top margin-top" role="navigation">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                Web Paintings
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <span class="glyphicon glyphicon-home"></span>Home
                    </li>
                    <li>
                        <span class="fa fa-database"></span>Paintings
                    </li>
                    <li>
                        <span class="fa fa-book"></span>Contact
                    </li>
                            <li class="slide"><span class="fa fa-pencil"></span>Register</li>
                            <li class="slide"><span class="glyphicon glyphicon-log-in"></span> Login</li>
                </ul>
            </div>
        </div>
    </nav>

            <div class="margin-top">
                             <!-- START OF CAROUSEL -->
                            <div id="myCarousel" class="carousel slide">
                              <!-- Carousel items -->
                              <div class="carousel-inner">
                                 <div class="item active ad1">
                                    <div class="carousel-caption">
                                       <h4 class="mycaption">First Thumbnail label</h4>
                                       <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                                    </div>
                                 </div>
                                 <div class="item ad2">
                                    <div class="carousel-caption">
                                        <h4 class="mycaption">Second Thumbnail label</h4>
                                        <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                                     </div>
                                 </div>
                                 <div class="item ad3">
                                    <div class="carousel-caption">
                                       <h4 class="mycaption">Third Thumbnail label</h4>
                                       <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                                    </div>
                                </div>
                              </div>
                              <!-- Carousel nav -->
                              ‹
                              ›
                            </div>

                               <!-- END OF CAROUSEL -->

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

    </body>
</html></code>```

Title: Bootstrap carousel slider arrows error

Body:
As the title says i have a problem with the arrows in the carousel. The arrows go up and merge with the navbar but i can still click to change the image. I've added background images as covers and i modified the code a little to the point i cant find out what is the problem. Can you help me here? How can i get the arrows down again and why is that happening?

Here's my code:

HTML

<!DOCTYPE html>

        <meta charset="utf-8">
        <title>Web Paintings</title>
        <link href="style.css" rel="stylesheet">

        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    Toggle navigation

                </button>
                Web Paintings

                        Home

                        Paintings

                        Contact

Register

 Login

First Thumbnail label

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.

Second Thumbnail label

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.

Third Thumbnail label

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.

                              ‹
                              ›

CSS:

body {
    font-family: 'Raleway', sans-serif;
}

.marginTop{
  margin-top:60px;
}
.navbar {
  min-height: 32px !important;
}
 .navbar .navbar-brand{
  padding: 0 12px;
  font-size: 16px;
  line-height: 38px;
  height: 38px;
}
 .navbar .navbar-nav > li > a {
  padding-top: 0px;
  padding-bottom: 0px;
  line-height: 38px;
}
 .navbar .navbar-toggle {
  margin-top: 3px;
  margin-bottom: 0px;
  padding: 8px 9px;
}
 .navbar .navbar-collapse {
  border-color: #2f2f2f;
}
ul.nav a:hover {
    color: #129CF3 !important;
}

#myCarousel {
    width: 100%;
}
.carousel-control {
    margin-top: 20px;
}
.carousel-inner .item {
    width: 100%;
    height: 400px;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}
.ad1 {
    background: url(images/paint1.jpg) no-repeat center center fixed;
}
.ad2 {
    background: url(images/paint2.jpg) no-repeat center center fixed;
}
.ad3 {
    background: url(images/paint3.jpg) no-repeat center center fixed;
}
.mycaption {
  color: white;
    font: bold 24px/45px Helvetica, Sans-Serif; letter-spacing: -1px;
   background-color: rgba(0, 0, 0, 0.7);
    padding: 10px;
}

Body:
add line-height on .carousel-control  Depend on your .carousel-inner .item > height

.carousel-control {
   line-height:400px;
   font-size:100px !important;
   width:80px !important;
}

body {
    font-family: 'Raleway', sans-serif;
}

.marginTop{
  margin-top:60px;
}
.navbar {
  min-height: 32px !important;
}
 .navbar .navbar-brand{
  padding: 0 12px;
  font-size: 16px;
  line-height: 38px;
  height: 38px;
}
 .navbar .navbar-nav > li > a {
  padding-top: 0px;
  padding-bottom: 0px;
  line-height: 38px;
}
 .navbar .navbar-toggle {
  margin-top: 3px;
  margin-bottom: 0px;
  padding: 8px 9px;
}
 .navbar .navbar-collapse {
  border-color: #2f2f2f;
}
ul.nav a:hover {
    color: #129CF3 !important;
}

#myCarousel {
    width: 100%;
}
.carousel-control {
    margin-top: 20px;
}
.carousel-inner .item {
    width: 100%;
    height: 400px;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}
    .carousel-control {
   line-height:400px;
   font-size:100px !important;
   width:80px !important;
}
.ad1 {
    background: url(images/paint1.jpg) no-repeat center center fixed;
}
.ad2 {
    background: url(images/paint2.jpg) no-repeat center center fixed;
}
.ad3 {
    background: url(images/paint3.jpg) no-repeat center center fixed;
}
.mycaption {
  color: white;
    font: bold 24px/45px Helvetica, Sans-Serif; letter-spacing: -1px;
   background-color: rgba(0, 0, 0, 0.7);
    padding: 10px;
}

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Web Paintings</title>
        <link href="style.css" rel="stylesheet">
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

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

        </script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    </head>

    <body>

        <!-- Navigation -->

    <nav class="navbar navbar-inverse navbar-fixed-top margin-top" role="navigation">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">Web Paintings</a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="#"><span class="glyphicon glyphicon-home"></span>Home</a>
                    </li>
                    <li>
                        <a href="#"><span class="fa fa-database"></span>Paintings</a>
                    </li>
                    <li>
                        <a href="#"><span class="fa fa-book"></span>Contact</a>
                    </li>
                            <li class="slide"><a href="#" class="btn-slide1"><span class="fa fa-pencil"></span>Register</a></li>
                            <li class="slide"><a href="#" class="btn-slide2"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
                </ul>
            </div>
        </div>
    </nav>

            <div class="margin-top">
                             <!-- START OF CAROUSEL -->
                            <div id="myCarousel" class="carousel slide">
                              <!-- Carousel items -->
                              <div class="carousel-inner">
                                 <div class="item active ad1">
                                    <div class="carousel-caption">
                                       <h4 class="mycaption">First Thumbnail label</h4>
                                       <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                                    </div>
                                 </div>
                                 <div class="item ad2">
                                    <div class="carousel-caption">
                                        <h4 class="mycaption">Second Thumbnail label</h4>
                                        <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                                     </div>
                                 </div>
                                 <div class="item ad3">
                                    <div class="carousel-caption">
                                       <h4 class="mycaption">Third Thumbnail label</h4>
                                       <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                                    </div>
                                </div>
                              </div>
                              <!-- Carousel nav -->
                              <a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
                              <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
                            </div>

                               <!-- END OF CAROUSEL -->

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

    </body>
</html>


问:
Client does not support authentication protocol requested by server; consider upgrading MySQL client
I am trying to connect MySQL client through a Perl script. But again and again I am getting error

ERROR 1251: Client does not support authentication protocol requested by server; consider upgrading MySQL client

My MySQL client has been upgraded from 5.1 to 5.6.

I am using Perl v5.12.0, DBD::mysql is 4.017, DBI is 1.613.

Is this problem with the Perl module or with MySQL.

答:
in my.conf
add

[mysqld]

skip-secure-auth=true

it permiss use old protocol, but your security exists no more. Do it only in development ambient.


问:
how to open pdf in webview for android in xamarin.forms?
I am creating an android app in xamarin.forms. I am getting an url for pdf in the app. First I have to download the pdf and save it locally. Then I have to show that downloaded pdf in webview. But I am getting white screen in webview. Its not showing the pdf. But if I open any url then it shows in webview.
Anyone know how I can do this?
Following is my code that I am using for opening the pdf:
  XAML:

```<code><WebView x:Name="browser" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"/>
</code>```

C#:

```<code> browser.Source = pdfFile;
</code>```

答:
the way to do that in xamarin android is
see the code below:</p>

```<code>WebView webview = FindViewById<WebView>(Resource.Id.webView1);
    urlPdf = ("example of url");
    WebSettings settings = webview.Settings;
    settings.JavaScriptEnabled = true;
    webview.LoadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url=" + urlPdf);
</code>```

Body:
I am creating an android app in xamarin.forms. I am getting an url for pdf in the app. First I have to download the pdf and save it locally. Then I have to show that downloaded pdf in webview. But I am getting white screen in webview. Its not showing the pdf. But if I open any url then it shows in webview.
Anyone know how I can do this?
Following is my code that I am using for opening the pdf:
  XAML:

<WebView x:Name="browser" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"/>

C#:

 browser.Source = pdfFile;

Body:
the way to do that in xamarin android is
see the code below:

WebView webview = FindViewById<WebView>(Resource.Id.webView1);
    urlPdf = ("example of url");
    WebSettings settings = webview.Settings;
    settings.JavaScriptEnabled = true;
    webview.LoadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url=" + urlPdf);


问:
python: compare data of different date types
I have a question of comparing data of datetime64[ns] and date like '2017-01-01'.

here is the code:
df.loc[(df['Date'] >= datetime.date(2017.1.1), 'TimeRange'] = '2017.1'

but , an error has been showed and said descriptor 'date' requires a 'datetime.datetime' object but received a 'int'.

how can i compare a datetime64 to data (2017-01-01 or 2-17-6-1 and likes)

Thanks

Body:
Demo:

Source DF:

In [83]: df = pd.DataFrame({'tm':pd.date_range('2000-01-01', freq='9999T', periods=20)})

In [84]: df
Out[84]:
                    tm
0  2000-01-01 00:00:00
1  2000-01-07 22:39:00
2  2000-01-14 21:18:00
3  2000-01-21 19:57:00
4  2000-01-28 18:36:00
5  2000-02-04 17:15:00
6  2000-02-11 15:54:00
7  2000-02-18 14:33:00
8  2000-02-25 13:12:00
9  2000-03-03 11:51:00
10 2000-03-10 10:30:00
11 2000-03-17 09:09:00
12 2000-03-24 07:48:00
13 2000-03-31 06:27:00
14 2000-04-07 05:06:00
15 2000-04-14 03:45:00
16 2000-04-21 02:24:00
17 2000-04-28 01:03:00
18 2000-05-04 23:42:00
19 2000-05-11 22:21:00

Filtering:

In [85]: df.loc[df.tm > '2000-03-01']
Out[85]:
                    tm
9  2000-03-03 11:51:00
10 2000-03-10 10:30:00
11 2000-03-17 09:09:00
12 2000-03-24 07:48:00
13 2000-03-31 06:27:00
14 2000-04-07 05:06:00
15 2000-04-14 03:45:00
16 2000-04-21 02:24:00
17 2000-04-28 01:03:00
18 2000-05-04 23:42:00
19 2000-05-11 22:21:00

In [86]: df.loc[df.tm > '2000-3-1']
Out[86]:
                    tm
9  2000-03-03 11:51:00
10 2000-03-10 10:30:00
11 2000-03-17 09:09:00
12 2000-03-24 07:48:00
13 2000-03-31 06:27:00
14 2000-04-07 05:06:00
15 2000-04-14 03:45:00
16 2000-04-21 02:24:00
17 2000-04-28 01:03:00
18 2000-05-04 23:42:00
19 2000-05-11 22:21:00

not standard date format:

In [87]: df.loc[df.tm > pd.to_datetime('03/01/2000')]
Out[87]:
                    tm
9  2000-03-03 11:51:00
10 2000-03-10 10:30:00
11 2000-03-17 09:09:00
12 2000-03-24 07:48:00
13 2000-03-31 06:27:00
14 2000-04-07 05:06:00
15 2000-04-14 03:45:00
16 2000-04-21 02:24:00
17 2000-04-28 01:03:00
18 2000-05-04 23:42:00
19 2000-05-11 22:21:00


问:
How do I get a function to be called when a menu item is clicked?
In Qt, I have a menubar that looks something like this:

```<code>|File|
+-------------------+
|Do Something       |
|Do Something Else  |
+-------------------+
</code>```

I have a function doSomething that I want to be called when the user clicks on the Do Something in the file menu, and a function doSomethingElse that I similarly want to be called when the user clicks on that menu item. How would I accomplish this?

答: Make your function a slot and connect menu action to the slot.</p>

ContentLicense: CC BY-SA 2.5

Body:
In Qt, I have a menubar that looks something like this:

|File|
+-------------------+
|Do Something       |
|Do Something Else  |
+-------------------+

I have a function doSomething that I want to be called when the user clicks on the Do Something in the file menu, and a function doSomethingElse that I similarly want to be called when the user clicks on that menu item. How would I accomplish this?


问:
Nested Soy templates
When I try to call a Soy template inside another Soy template I get Uncaught (in promise) Error: No template with namespace TestTemplate.incrementaldom has been loaded yet. in chrome console.

答: I imported the template but not the es file. This is resolved now.</p>

Title: Nested Soy templates


问:
Error parsing triggers: Cannot find module
I am trying to deploy my firebase function to cloud but getting an error:

Error: Error parsing triggers: Cannot find module 'EmailData'

1.I  compile my ts file to js.

2.the build of ts ok...
my code looks like:

the ts that importing the file...

```<code>var EmailDataClass = require("EmailData");
</code>```

and the file it self:

```<code>class EmailData {....
}export = EmailData;
</code>```

```<code>✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...

Error: Error parsing triggers: Cannot find module 'EmailData'
</code>```

答:
It's  not recommended to use mix of Typescript & ES6 export and import methods

it's better to use type script import

```<code>import { EmailDataClass } from "./EmailData";
</code>```

And to Export use

```<code>export class EmailData {....
}
</code>```

Body:
I am trying to deploy my firebase function to cloud but getting an error:

Error: Error parsing triggers: Cannot find module 'EmailData'

1.I  compile my ts file to js.

2.the build of ts ok...
my code looks like:

the ts that importing the file...

var EmailDataClass = require("EmailData");

and the file it self:

class EmailData {....
}export = EmailData;

✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...

Error: Error parsing triggers: Cannot find module 'EmailData'

Body:
It's  not recommended to use mix of Typescript & ES6 export and import methods

it's better to use type script import

import { EmailDataClass } from "./EmailData";

And to Export use

export class EmailData {....
}


问:
How to rename a link file on Windows with python?
I have some link files on windows, then I put them in a folder,  I want to rename them as 0 1 2 ... , so windows can sort them automatically.

I tried os.rename('src.txt.link', '0'), but the result is that the "0" file can not be opened.

Is there an another python api to do this?

答: You cannot rename a file with extension .lnk. Looks like Windows blocks that operation. Instead i suggest you copy the file with new name, in your case 0.lnk, and then remove the original file. </p>


问:
The font-awesome icon does not show up on Chrome
I meet problem that fontawesome Icon does not show up on Chrome. ( Safari and Moz both works fine ). Does anyone have a clew why this happened. Thanks All.

Here is the Snapshot:

I know that the default font path that fontawesome.min.css directs ../font/......, but I have changed path name to " ../fonts/ " for my project, still doesn't work. The icon never shows up.

答:
Is bootstrap working? It looks like your Css directory is capitalized which would cause your reference to the css file to not work.

Try replacing

./css/font-awesome.min.css

with

./Css/font-awesome.min.css

As mentioned in the comment on your original question, you could try using the CDN momentarily to see if the icon appears. If the icon does appear using the CDN, you know you have an issue with your path like I have mentioned above.

Here is the html code you would use for the CDN (version 3.2.1):

```<code><link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
</code>```

Aside from this, you are also using an outdated version of font-awesome. If possible in your circumstance, I recommend upgrading to the latest version. You can find more information on the latest version by visiting the following link.

http://fontawesome.io/get-started/

If you are going to use the latest version, make sure to look at examples as they have changed the way you write the html code.

Edit after updating Font-awesome:

If you are going to use the latest version of font-awesome, you need to change the HTML code to

```<code><i class="fa fa-times" aria-hidden="true"></i>
</code>```

CDN for the latest version (4.7):

```<code><link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
</code>```

Body:
Is bootstrap working? It looks like your Css directory is capitalized which would cause your reference to the css file to not work.

Try replacing

./css/font-awesome.min.css

with

./Css/font-awesome.min.css

As mentioned in the comment on your original question, you could try using the CDN momentarily to see if the icon appears. If the icon does appear using the CDN, you know you have an issue with your path like I have mentioned above.

Here is the html code you would use for the CDN (version 3.2.1):

<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">

Aside from this, you are also using an outdated version of font-awesome. If possible in your circumstance, I recommend upgrading to the latest version. You can find more information on the latest version by visiting the following link.

http://fontawesome.io/get-started/

If you are going to use the latest version, make sure to look at examples as they have changed the way you write the html code.

Edit after updating Font-awesome:

If you are going to use the latest version of font-awesome, you need to change the HTML code to

<i class="fa fa-times" aria-hidden="true"></i>

CDN for the latest version (4.7):

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">


问:
Android message object PendingIntent, getting null Intent.getExtras().getString("mystring")
I am calling fragment inside the activity on clicking on bottom bar.
the fragment has following message object in fragment.

```<code>@Override
public void onItemClick(AdapterView<?> parent, View view, int position,long id) {

      Intent moreSelectionIntent = new Intent(getActivity(), MainActivity.class);
      moreSelectionIntent.putExtra("selection",Integer.toString(position));
     PendingIntent pendingIntent = PendingIntent.getActivity(getActivity().getApplicationContext(), 0, moreSelectionIntent, PendingIntent.FLAG_UPDATE_CURRENT);
     }        `
</code>```

the fragment calls activity and passes PendingIntent. when I get string from the intent using below code I am getting NULL in activity
below is the piece of code in activity

```<code> Intent i = this.getIntent();
    Log.i(TAG, "intenet------->"+i);

    String moreSelection = i.getExtras().getString("selection");
    Log.i(TAG, "moreSelection Bundle------->"+moreSelection);

    if(moreSelection!=null)
    { System.out.println("message"+moreSelection);}
</code>```

答:
Use this code...</p>

```<code>    Intent intent = new Intent(this, NextActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
    PendingIntent.FLAG_ONE_SHOT);
</code>```

Body:
I am calling fragment inside the activity on clicking on bottom bar.
the fragment has following message object in fragment.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position,long id) {

      Intent moreSelectionIntent = new Intent(getActivity(), MainActivity.class);
      moreSelectionIntent.putExtra("selection",Integer.toString(position));
     PendingIntent pendingIntent = PendingIntent.getActivity(getActivity().getApplicationContext(), 0, moreSelectionIntent, PendingIntent.FLAG_UPDATE_CURRENT);
     }        `

the fragment calls activity and passes PendingIntent. when I get string from the intent using below code I am getting NULL in activity
below is the piece of code in activity

 Intent i = this.getIntent();
    Log.i(TAG, "intenet------->"+i);

    String moreSelection = i.getExtras().getString("selection");
    Log.i(TAG, "moreSelection Bundle------->"+moreSelection);

    if(moreSelection!=null)
    { System.out.println("message"+moreSelection);}

Body:
Use this code...

    Intent intent = new Intent(this, NextActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
    PendingIntent.FLAG_ONE_SHOT);


问:
non-deterministic behavior for tf.cond on is_variable_initialized
Consider this demo code:

```<code>import logging
logging.getLogger('tensorflow').disabled = True
import tensorflow as tf
import sys

sess = tf.InteractiveSession()

def test_var_2():
  v = tf.Variable(initial_value=True, trainable=False, name="test_var_3")
  print("is initialized:", tf.is_variable_initialized(v).eval(), file=sys.__stdout__)

  def make_init():
    with tf.control_dependencies([tf.Print(0, ["var is not initialized", tf.is_variable_initialized(v)])]):
      return tf.variables_initializer([v])

  def on_already_init():
    return tf.group(tf.no_op(), tf.Print(0, ["var is initialized", tf.is_variable_initialized(v)]))

  maybe_init = tf.cond(
    tf.is_variable_initialized(v),
    on_already_init,
    make_init,
    name="init")
  with tf.control_dependencies([maybe_init, tf.Print(0, ["cd init"])]):
    x = tf.where(v.read_value(), True, False)

  print("x:", x.eval())
  print("is initialized:", tf.is_variable_initialized(v).eval(), file=sys.__stdout__)
  print("x:", x.eval())
  print("is initialized:", tf.is_variable_initialized(v).eval(), file=sys.__stdout__)

if __name__ == "__main__":
  test_var_2()
</code>```

The output is non-deterministic. I either get this (1):

```<code>is initialized: False
.../logging_ops.cc:79] [cd init]
.../logging_ops.cc:79] [var is not initialized][0]
x: True
is initialized: True
.../logging_ops.cc:79] [cd init]
.../logging_ops.cc:79] [var is initialized][1]
x: True
is initialized: True
</code>```

Or this (2):

```<code>is initialized: False
.../logging_ops.cc:79] [cd init]
.../logging_ops.cc:79] [var is not initialized][1]
x: True
is initialized: True
.../logging_ops.cc:79] [cd init]
.../logging_ops.cc:79] [var is initialized][1]
x: True
is initialized: True
</code>```

Or this (3):

```<code>is initialized: False
.../logging_ops.cc:79] [cd init]
.../logging_ops.cc:79] [var is initialized][1]
x: True
is initialized: True
.../logging_ops.cc:79] [cd init]
.../logging_ops.cc:79] [var is initialized][1]
x: True
is initialized: True
</code>```

The variant 3 (where the var is initialized at the first x.eval()) makes no sense at all to me. How can it end up in that cond-branch? Why is it suddenly initialized?

The difference between variant 1 and 2 is probably because the tf.Print is not fully evaluated as part of the tf.control_dependencies?

答:
This is an even more tricky case of this and this. The point is that tf.variables_initializer([v]) does not really creates a new op for the init (i.e. the assign to the initial value) but this assign-op was already created earlier (inside the tf.Variable constructor) and is just used here. Thus, my solution is to not use this initializer but to create my own, which must be created inside the make_init function, i.e.:

```<code>def make_init():
  with tf.control_dependencies([tf.Print(0, ["var is not initialized", tf.is_variable_initialized(v)])]):
    return tf.assign(v, True)
</code>```

This solves the problem.

Body:
Consider this demo code:

import logging
logging.getLogger('tensorflow').disabled = True
import tensorflow as tf
import sys

sess = tf.InteractiveSession()

def test_var_2():
  v = tf.Variable(initial_value=True, trainable=False, name="test_var_3")
  print("is initialized:", tf.is_variable_initialized(v).eval(), file=sys.__stdout__)

  def make_init():
    with tf.control_dependencies([tf.Print(0, ["var is not initialized", tf.is_variable_initialized(v)])]):
      return tf.variables_initializer([v])

  def on_already_init():
    return tf.group(tf.no_op(), tf.Print(0, ["var is initialized", tf.is_variable_initialized(v)]))

  maybe_init = tf.cond(
    tf.is_variable_initialized(v),
    on_already_init,
    make_init,
    name="init")
  with tf.control_dependencies([maybe_init, tf.Print(0, ["cd init"])]):
    x = tf.where(v.read_value(), True, False)

  print("x:", x.eval())
  print("is initialized:", tf.is_variable_initialized(v).eval(), file=sys.__stdout__)
  print("x:", x.eval())
  print("is initialized:", tf.is_variable_initialized(v).eval(), file=sys.__stdout__)

if __name__ == "__main__":
  test_var_2()

The output is non-deterministic. I either get this (1):

is initialized: False
.../logging_ops.cc:79] [cd init]
.../logging_ops.cc:79] [var is not initialized][0]
x: True
is initialized: True
.../logging_ops.cc:79] [cd init]
.../logging_ops.cc:79] [var is initialized][1]
x: True
is initialized: True

Or this (2):

is initialized: False
.../logging_ops.cc:79] [cd init]
.../logging_ops.cc:79] [var is not initialized][1]
x: True
is initialized: True
.../logging_ops.cc:79] [cd init]
.../logging_ops.cc:79] [var is initialized][1]
x: True
is initialized: True

Or this (3):

is initialized: False
.../logging_ops.cc:79] [cd init]
.../logging_ops.cc:79] [var is initialized][1]
x: True
is initialized: True
.../logging_ops.cc:79] [cd init]
.../logging_ops.cc:79] [var is initialized][1]
x: True
is initialized: True

The variant 3 (where the var is initialized at the first x.eval()) makes no sense at all to me. How can it end up in that cond-branch? Why is it suddenly initialized?

The difference between variant 1 and 2 is probably because the tf.Print is not fully evaluated as part of the tf.control_dependencies?

Body:
This is an even more tricky case of this and this. The point is that tf.variables_initializer([v]) does not really creates a new op for the init (i.e. the assign to the initial value) but this assign-op was already created earlier (inside the tf.Variable constructor) and is just used here. Thus, my solution is to not use this initializer but to create my own, which must be created inside the make_init function, i.e.:

def make_init():
  with tf.control_dependencies([tf.Print(0, ["var is not initialized", tf.is_variable_initialized(v)])]):
    return tf.assign(v, True)

This solves the problem.


问:
list view problem with respect to my problem
I have a listview in wpf and i am swapping two items index..

the swapping must be visible to the user.

i tried giving thread delay..

it didnt work

How to do that..

答:
If I was going to do this I would delete the list view and lock it up where you can't use it again. Then code whatever your list view was outputting in C# using whatever you use to query your database(I think LINQ to SQL is the most robust solution right now) and then use a string builder to construct the html. This way you can assign a id to each div and append an incrementing number to the end of the id. Finally you could write your javascript and use the id's. Here is a link that shows how to build a gridview without using a gridview control.

See the first answer to the question in this link: How to show pop up menu from database in gridview on each gridview row items?


问:
Functional switch statement in Javascript
Say I have a switch statement that takes a variable myData between 1 and some larger value, i.e. 300.

Depending on the "status code" variable, the result is the text value of another variable. For example, if myData == 1, I want to return the a variable called code1. If myData == 300, I want to return the a variable called code300. Code1 and code300 variables store unrelated strings, i.e. "This is a summary", or "This is a note". Some psuedo-code below:

```<code>var myData = statusCode;

var code1 = "This is a summary";
var code300 = "This is a note";

switch(myData) {
    case statusCode:
        scriptletResult = returnCode("code", statusCode); // code1 if myData == 1
        break;
    default:
        scriptletResult = code1;
}

function returnCode(code, statusCode) {
    return code + statusCode; // Returns a variable "code1" if statusCode == 1
}
</code>```

How can I get this to work?

答:
```<code>var myData=300;
var code1="This is a summary";
var code300=" this is a note";
var result=(function(){
switch(myData) {
case 1:
    return code1;
case 300:
   return code300,
default:
    return "not defined";
}
})();

alert(result);
</code>```

Perfect usecase for an IIFE + switch combo.

However best would be:

```<code>alert([code1,code2][myData]);
</code>```

Body:
Say I have a switch statement that takes a variable myData between 1 and some larger value, i.e. 300.

Depending on the "status code" variable, the result is the text value of another variable. For example, if myData == 1, I want to return the a variable called code1. If myData == 300, I want to return the a variable called code300. Code1 and code300 variables store unrelated strings, i.e. "This is a summary", or "This is a note". Some psuedo-code below:

var myData = statusCode;

var code1 = "This is a summary";
var code300 = "This is a note";

switch(myData) {
    case statusCode:
        scriptletResult = returnCode("code", statusCode); // code1 if myData == 1
        break;
    default:
        scriptletResult = code1;
}

function returnCode(code, statusCode) {
    return code + statusCode; // Returns a variable "code1" if statusCode == 1
}

How can I get this to work?

Body:
var myData=300;
var code1="This is a summary";
var code300=" this is a note";
var result=(function(){
switch(myData) {
case 1:
    return code1;
case 300:
   return code300,
default:
    return "not defined";
}
})();

alert(result);

Perfect usecase for an IIFE + switch combo.

However best would be:

alert([code1,code2][myData]);


问:
React Native Animation push animation downward, not upward over existing view
I am trying to have my Animated View come downward and over the content of the ScrollView instead of over my top fixed position bar, but when the Animation begins the animated view ends up eating the space of the container bar. I have played with paddingTop, marginTop, but seems to be a hack.

Here is a self contained code sample that shows what I'm trying to do:

```<code>import React, { Component } from 'react';
import {
  AppRegistry, StyleSheet, Text, View, Animated, Dimensions, ScrollView,
  Button
} from 'react-native';

const { width } = Dimensions.get('window');

const make_text = (text='Hello', color='blue') => (
  <Text
    style={{textAlign: 'center', fontSize: 24, backgroundColor: color, margin: 20}}>
    {text}
  </Text>
);

class Fix_bar extends Component {

  state = { height: new Animated.Value(0) };

  expand_dropdown = () => {
    Animated.timing(this.state.height, {
      toValue: 100
    }).start();
  }

  fold_dropdown = () => {
    Animated.timing(this.state.height, {
      toValue: 0
    }).start();
  }

  render () {

    const s = {
      position: 'absolute', height: 150, backgroundColor: 'red', paddingTop: 20, width
    };

    return (
      <View style={s}>
        <View style={{flexDirection: 'row', flex: 1, justifyContent: 'space-between'}}>
          <Text style={{fontSize: 24, paddingTop: 50}}> Left side thing</Text>
          <Text style={{fontSize: 24, paddingTop: 50}}> Right side thing</Text>
        </View>

        <Button title={'Expand'} onPress={this.expand_dropdown}/>
        <Button title={'Fold'} onPress={this.fold_dropdown}/>

        <View style={{backgroundColor: 'black', height: 1}}/>
        <Animated.View style={{height: this.state.height}}>
          {make_text('world', 'aliceblue')}
          {make_text('world', 'aliceblue')}
          {make_text('world', 'aliceblue')}
        </Animated.View>
      </View>
    );
  }
}

class animate_example extends Component {
  render() {
    return (
      <View style={{backgroundColor: 'orange', flex: 1}}>
        <Fix_bar/>
        <ScrollView style={{marginTop: 150}}>
          <View style={{justifyContent: 'space-between'}}>
            {make_text()}
            {make_text()}
            {make_text()}
            {make_text()}
            {make_text()}
          </View>
        </ScrollView>
      </View>
    );
  }
}

AppRegistry.registerComponent('animate_example', () => animate_example);
</code>```

One idea I had was to make a trailing View in that fix_bar component with transparency with the height that I intend for the dropdown but haven't explored that idea.

答:
I would suggest the following hierarchy:

```<code>const ScrollViewContainer = () =>
  <ScrollView style={{marginTop: 150}}>
    <View style={{justifyContent: 'space-between'}}>
      {make_text()}
      {make_text()}
      {make_text()}
      {make_text()}
      {make_text()}
    </View>
  </ScrollView>;

const ExpandableBar = (props: {expanded: boolean}) =>
  <View style={{position: "absolute", top: 0, left: 0, right: 0, bottom: 0}} />

const render = () =>
  <View>
    <Fix_bar />
    <View style={{flex: 1}}> // container which fills remaining space
    <ScrollViewContainer />
    <ExpandableBar />
  </View>
</code>```

Then in ExpandableBar you'd animate down if expanded is true. also please note that ExpandableBar should be a class (obviously).

Body:
I am trying to have my Animated View come downward and over the content of the ScrollView instead of over my top fixed position bar, but when the Animation begins the animated view ends up eating the space of the container bar. I have played with paddingTop, marginTop, but seems to be a hack.

Here is a self contained code sample that shows what I'm trying to do:

import React, { Component } from 'react';
import {
  AppRegistry, StyleSheet, Text, View, Animated, Dimensions, ScrollView,
  Button
} from 'react-native';

const { width } = Dimensions.get('window');

const make_text = (text='Hello', color='blue') => (
  <Text
    style={{textAlign: 'center', fontSize: 24, backgroundColor: color, margin: 20}}>
    {text}
  </Text>
);

class Fix_bar extends Component {

  state = { height: new Animated.Value(0) };

  expand_dropdown = () => {
    Animated.timing(this.state.height, {
      toValue: 100
    }).start();
  }

  fold_dropdown = () => {
    Animated.timing(this.state.height, {
      toValue: 0
    }).start();
  }

  render () {

    const s = {
      position: 'absolute', height: 150, backgroundColor: 'red', paddingTop: 20, width
    };

    return (
      <View style={s}>
        <View style={{flexDirection: 'row', flex: 1, justifyContent: 'space-between'}}>
          <Text style={{fontSize: 24, paddingTop: 50}}> Left side thing</Text>
          <Text style={{fontSize: 24, paddingTop: 50}}> Right side thing</Text>
        </View>

        <Button title={'Expand'} onPress={this.expand_dropdown}/>
        <Button title={'Fold'} onPress={this.fold_dropdown}/>

        <View style={{backgroundColor: 'black', height: 1}}/>
        <Animated.View style={{height: this.state.height}}>
          {make_text('world', 'aliceblue')}
          {make_text('world', 'aliceblue')}
          {make_text('world', 'aliceblue')}
        </Animated.View>
      </View>
    );
  }
}

class animate_example extends Component {
  render() {
    return (
      <View style={{backgroundColor: 'orange', flex: 1}}>
        <Fix_bar/>
        <ScrollView style={{marginTop: 150}}>
          <View style={{justifyContent: 'space-between'}}>
            {make_text()}
            {make_text()}
            {make_text()}
            {make_text()}
            {make_text()}
          </View>
        </ScrollView>
      </View>
    );
  }
}

AppRegistry.registerComponent('animate_example', () => animate_example);

One idea I had was to make a trailing View in that fix_bar component with transparency with the height that I intend for the dropdown but haven't explored that idea.

Body:
I would suggest the following hierarchy:

const ScrollViewContainer = () =>
  <ScrollView style={{marginTop: 150}}>
    <View style={{justifyContent: 'space-between'}}>
      {make_text()}
      {make_text()}
      {make_text()}
      {make_text()}
      {make_text()}
    </View>
  </ScrollView>;

const ExpandableBar = (props: {expanded: boolean}) =>
  <View style={{position: "absolute", top: 0, left: 0, right: 0, bottom: 0}} />

const render = () =>
  <View>
    <Fix_bar />
    <View style={{flex: 1}}> // container which fills remaining space
    <ScrollViewContainer />
    <ExpandableBar />
  </View>

Then in ExpandableBar you'd animate down if expanded is true. also please note that ExpandableBar should be a class (obviously).


问:
Initialize function by file contents at compile time
Is there a way to initialize a function

```<code>someText :: Text
</code>```

which value will be stored in a file available at compile time?

I thought I could use TH for that, but for now I just found

```<code>embedFile :: FilePath -> Q Exp
runQ :: Quasi m => Q a -> m a
</code>```

I can only unwrap Q into IO:

```<code>instance Quasi IO
instance Quasi Q
</code>```

I guess I need Identity instance of Quasi, but there is no one.

答:
Isn't this just

```<code>someText :: Text
someText = $(embedStringFile "path/to/file")
</code>```

Am I missing something?

(It's the TH splice itself that turns Q Exp into some other type at run-time. You shouldn't need any typeclass instances or anything...)

Body:
Is there a way to initialize a function

someText :: Text

which value will be stored in a file available at compile time?

I thought I could use TH for that, but for now I just found

embedFile :: FilePath -> Q Exp
runQ :: Quasi m => Q a -> m a

I can only unwrap Q into IO:

instance Quasi IO
instance Quasi Q

I guess I need Identity instance of Quasi, but there is no one.

Body:
Isn't this just

someText :: Text
someText = $(embedStringFile "path/to/file")

Am I missing something?

(It's the TH splice itself that turns Q Exp into some other type at run-time. You shouldn't need any typeclass instances or anything...)


问:
How to change the background colour gradient of view dynamically
I want to make a custom view for my android app which has a functionality to change its background colour "gradient".

Something like this, but the centre handle can be moved left and right using code

The catch is that I want a function something like in the view:

```<code>changeBackgroundGradient(ratio, startColour, centreColour, endColour);
</code>```

ratio (having value between 0 to 1) which is given by formula
leftValue/rightValue determining the shape of the gradient

startColour, centreColour and endColour being the colours of which the gradient consists of

How would i make this function?

Regards

答:
You can try below code as this is working for me to change my toolbar color dynamically

```<code>private void setGradientColor(View header)
{
    String primaryColor = "#f4f3f2"; // any color code
    String primaryDarkColor = "#000000";

    GradientDrawable gd = new GradientDrawable (
    GradientDrawable.Orientation.BR_TL, // check below link for this you can change this value
    new int[] {
        Color.parseColor(primaryColor),
        Color.parseColor(primaryDarkColor)
        }
    );

    gd.setCornerRadius(1f);

    header.setBackground(gd);
}
</code>```

Update

Check this for more options to apply gradient color in view.

Body:
I want to make a custom view for my android app which has a functionality to change its background colour "gradient".

Something like this, but the centre handle can be moved left and right using code

The catch is that I want a function something like in the view:

changeBackgroundGradient(ratio, startColour, centreColour, endColour);

ratio (having value between 0 to 1) which is given by formula
leftValue/rightValue determining the shape of the gradient

startColour, centreColour and endColour being the colours of which the gradient consists of

How would i make this function?

Regards

Body:
You can try below code as this is working for me to change my toolbar color dynamically

private void setGradientColor(View header)
{
    String primaryColor = "#f4f3f2"; // any color code
    String primaryDarkColor = "#000000";

    GradientDrawable gd = new GradientDrawable (
    GradientDrawable.Orientation.BR_TL, // check below link for this you can change this value
    new int[] {
        Color.parseColor(primaryColor),
        Color.parseColor(primaryDarkColor)
        }
    );

    gd.setCornerRadius(1f);

    header.setBackground(gd);
}

Update

Check this for more options to apply gradient color in view.


问:
SQL Server connection handling, connection pooling, lifetime and leaked connections
I am trying to identify SQL connection leaks in my application. After some operations, when my application is idle (user not doing any activity), I see 7 connections with my database in the result set returned by sp_who2. The status for all connections is Sleeping and Command value for all of them is AWAITING COMMAND.

I am using connection pooling but Connection Lifetime is not specified in the connection string. This means that it's default value 0 will be used if I am right. Connection Lifetime having value zero means SQL server should not close connection ever, right?

I keep my application idle for some time (15-20 minutes) and then I see  that sp_who2 does NOT show any connection with my database. I am wondering why I get this result when Connection Lifetime is zero. Does SQL Server terminates unused connection after some time regardless of the Connection Lifetime value?

How can I identify which connection is open due to leakage and which is hanging around there due to connection pooling?

My application supports SQL Server 2008, 2014 and 2016. It's ASP.NEt application.

答:
Connection Lifetime having value zero means SQL server should not close connection ever, right?

No. The rules used to purge the pool are not well documented AFAIK, but they can be closed by the pooler. Refer https://msdn.microsoft.com/en-us/library/8xx3tyca%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396.

I don't think there is a reliable/documented method to identify pooled connections from within the database engine.


问:
How can I define my javascript to display the images I found in my php script
first of all I am new in this and I thank all the people here I learned of.

My problem:
I created a setting where you can upload pictures in the folder "test"in two different ways.
I want to display the picutes in an automatic slideshow which takes the pictures out of the folder. (Imag 1.jpg, 2.jpg, 3.jpg are in the folder TEST.)

my PHP CODE:

```<code><?php
$dir_path = "test/";
$extensions_array = array('jpg','png','jpeg');
$phpArray = array();

$dateien=scandir($dir_path);
$anzahl=count($dateien);

    //echo "Anzahl $anzahl";

if(is_dir($dir_path))
{
$files = scandir($dir_path);

for($i = 0; $i < count($files); $i++)
{
if($files[$i] !='.' && $files[$i] !='..')
    {
        $file = pathinfo($files[$i]);
        $extension = $file['extension'];

        while(in_array($extension, $extensions_array))
        {
        // show image

        echo "<img src='$dir_path$files[$i]' style='width:500px;height:500px;'><br>";
           $phpArray []= array($dir_path, $files[$i]);
           $filename[]= array($files[$i]);
            //echo $i;
            $i++;
        //echo "Anzahl $anzahl";

                if ($i>$anzahl)
                    {break;}
            }
    }
}
}
$dir_path2 = "uplaods/";
$dateien2=scandir($dir_path);
$anzahl2=count($dateien2);

if ($anzahl2>$anzahl)

?>
</code>```

with the php code I get the folder path and the file name and I could display the pictures seperatly, but not in an slideshow:

MY HTML/JAVASCRIPT CODE

```<code><!DOCTYPE html>
<html>
<title>automatic slideshow</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<style>
.mySlides {display:none;}
</style>
<body>

<h2 class="w3-center">Automatic Slideshow</h2>

<div class="w3-content w3-section" style="max-width:500px">
<img class="mySlides" src="1.jpg" style="width:100%" >
<img class="mySlides" src="2.jpg" style="width:100%">
<img class="mySlides" src="3.jpg"style="width:100%">
</div>

<script>

var myIndex = 0;
carousel();

function carousel() {
var i;
 var x = document.getElementsByClassName("mySlides");  / HERE I NEED HELP
for (i = 0; i < x.length; i++) {
   x[i].style.display = "none";
}
myIndex++;
if (myIndex > x.length) {myIndex = 1}
x[myIndex-1].style.display = "block";
setTimeout(carousel, 2000); // Change image every 2 seconds
}

</script>

</body>
</html>
</code>```

the slideshow code works for the images I defined in the div, but I want to have it out of the folder. I was able to get the filename and the folder path from php to javascript but I was not able to tell javascript to display the picutes out of the folder.

is it even possible?

答: There are several ways you can go about this, but JavaScript is unable to iterate through files in a directory on a file system (unless you are using server-side JavaScript). One option is to have your PHP script output the URIs (relative or absolute) of the images to a JavaScript array. Another option is to have the PHP script output JavaScript in the HTML head that creates image objects utilizing the URIs (this is good for preloading the images) and place the objects in a JavaScript array. A more complex solution would be for your PHP script to return a JSON array of the image URIs which you could retrieve from your JavaScript with an AJAX GET request.</p>

Body:
first of all I am new in this and I thank all the people here I learned of.

My problem:
I created a setting where you can upload pictures in the folder "test"in two different ways.
I want to display the picutes in an automatic slideshow which takes the pictures out of the folder. (Imag 1.jpg, 2.jpg, 3.jpg are in the folder TEST.)

my PHP CODE:

<?php
$dir_path = "test/";
$extensions_array = array('jpg','png','jpeg');
$phpArray = array();

$dateien=scandir($dir_path);
$anzahl=count($dateien);

    //echo "Anzahl $anzahl";

if(is_dir($dir_path))
{
$files = scandir($dir_path);

for($i = 0; $i < count($files); $i++)
{
if($files[$i] !='.' && $files[$i] !='..')
    {
        $file = pathinfo($files[$i]);
        $extension = $file['extension'];

        while(in_array($extension, $extensions_array))
        {
        // show image

        echo "
";
           $phpArray []= array($dir_path, $files[$i]);
           $filename[]= array($files[$i]);
            //echo $i;
            $i++;
        //echo "Anzahl $anzahl";

                if ($i>$anzahl)
                    {break;}
            }
    }
}
}
$dir_path2 = "uplaods/";
$dateien2=scandir($dir_path);
$anzahl2=count($dateien2);

if ($anzahl2>$anzahl)

?>

with the php code I get the folder path and the file name and I could display the pictures seperatly, but not in an slideshow:

MY HTML/JAVASCRIPT CODE

<!DOCTYPE html>

<title>automatic slideshow</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">

Automatic Slideshow

the slideshow code works for the images I defined in the div, but I want to have it out of the folder. I was able to get the filename and the folder path from php to javascript but I was not able to tell javascript to display the picutes out of the folder.

is it even possible?


问:
Can we change textbox properties through javascript validator rules?
I want to change my text box properties to read-only. I have two values in my list box, local and domain. When I select domain then my next text box field should be set to read-only.
How I can change this property?

          ×
          Create User

                Username:

                  First Name:

                  Last Name:

                  Email:

                  User Type:

                      Local User
                      Domain User

                  Password:

                  Re-enter Password:

          Cancel
          Add

Here is my code.

答:
You will need to add listener on your select change to be able to modify next input field

window.onload = function() {
  var elem = document.getElementById('our-select')

  elem.addEventListener('change', function(event) {
    if(event.target.value === 'local'){
      document.getElementById('our-input').disabled = true;
    } else {
      document.getElementById('our-input').disabled = false;
    }
  });
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><select id="our-select">
  <option>domain</option>
  <option>local</option>
</select>
<input id="our-input" /></code>```

Body:
You will need to add listener on your select change to be able to modify next input field

window.onload = function() {
  var elem = document.getElementById('our-select')

  elem.addEventListener('change', function(event) {
    if(event.target.value === 'local'){
      document.getElementById('our-input').disabled = true;
    } else {
      document.getElementById('our-input').disabled = false;
    }
  });
}

<select id="our-select">
  <option>domain</option>
  <option>local</option>
</select>
<input id="our-input" />


问:
Oracle SQL- Update Query with Case Statement Missing Keyword Error
I'm extremely new to SQL (started learning 3 days ago), so I'm assuming I have some horrendous syntax errors in my code.

I've been at it since yesterday, trying to create an update query that uses cases to modify the value column based on the following conditions:

When value contains the letter 'a', make value uppercase.

When value contains the letter 'd', but doesn't contain the letter 'a', make value lowercase.

When value doesn't meet the conditions above, change the first and last letters from value to 1 and 2.

I have tried to do this a bunch of different ways, but I always end up with some kind of error. This code returns Missing Keyword Error:

```<code>UPDATE t1
SET value =
CASE   WHEN value LIKE '%a%' THEN SET value = UPPER(value)
       WHEN value LIKE '%d%' AND value NOT LIKE '%a' THEN SET value = LOWER(value)
       ELSE REPLACE(value,'_%','1') AND REPLACE(value,'%_','2')
END
Where value IS NOT NULL;
</code>```

答:
CASE returns a value so you don't need the SET there. AND is a conditional operator, it's not for running commands together.

REPLACE() does not work the way you're trying to use it. It takes literals not wildcards. So unless value starts and finishes with underscores, '_%' the command won't change anything. Instead of REPLACE() I suggest you use SUBSTR() and concatenate the replacement characters.

```<code>UPDATE t1
SET value =
    CASE   WHEN value LIKE '%a%' THEN UPPER(value)
           WHEN value LIKE '%d%' AND value NOT LIKE '%a' THEN LOWER(value)
           ELSE '1'||substr(value, 2, length(value)-2) ||'2'
    END
Where value IS NOT NULL;
</code>```

Alternatively, you could use the regular expression replace function

```<code>ELSE regexp_replace(value, '^(.)(.*)(.)$', '1\22'
</code>```

However, this has slightly different output when the length of value is 1.

Body:
I'm extremely new to SQL (started learning 3 days ago), so I'm assuming I have some horrendous syntax errors in my code.

I've been at it since yesterday, trying to create an update query that uses cases to modify the value column based on the following conditions:

When value contains the letter 'a', make value uppercase.

When value contains the letter 'd', but doesn't contain the letter 'a', make value lowercase.

When value doesn't meet the conditions above, change the first and last letters from value to 1 and 2.

I have tried to do this a bunch of different ways, but I always end up with some kind of error. This code returns Missing Keyword Error:

UPDATE t1
SET value =
CASE   WHEN value LIKE '%a%' THEN SET value = UPPER(value)
       WHEN value LIKE '%d%' AND value NOT LIKE '%a' THEN SET value = LOWER(value)
       ELSE REPLACE(value,'_%','1') AND REPLACE(value,'%_','2')
END
Where value IS NOT NULL;

Body:
CASE returns a value so you don't need the SET there. AND is a conditional operator, it's not for running commands together.

REPLACE() does not work the way you're trying to use it. It takes literals not wildcards. So unless value starts and finishes with underscores, '_%' the command won't change anything. Instead of REPLACE() I suggest you use SUBSTR() and concatenate the replacement characters.

UPDATE t1
SET value =
    CASE   WHEN value LIKE '%a%' THEN UPPER(value)
           WHEN value LIKE '%d%' AND value NOT LIKE '%a' THEN LOWER(value)
           ELSE '1'||substr(value, 2, length(value)-2) ||'2'
    END
Where value IS NOT NULL;

Alternatively, you could use the regular expression replace function

ELSE regexp_replace(value, '^(.)(.*)(.)$', '1\22'

However, this has slightly different output when the length of value is 1.


问:
WPF Grid not showing content
i´m using a Window with a Grid wich loads Objects from a MongoDB. This Objects contains Lists. Now i want to Load a List from one of this Objects. This is the Source from the Window:

```<code>        public void btn_load_Click(object sender, RoutedEventArgs e)
    {
        MainWindow M = new MainWindow();

        ArtikelLaden();
        M.RefreshGrid();

        Close();

    }`
public void ArtikelLaden()
    {

        MainWindow M = new MainWindow();
        rowindexArtikel = dg_Artikel.SelectedIndex;
        Artikel B = new Artikel();
        B = artikelList[rowindexArtikel];
        M.loadArtikel(B);
    }
</code>```

The List should get loaded in the MainWindow:`

```<code>public void loadArtikel(Artikel B)
    {
        dg_test.ItemsSource = null;
        dg_test.ItemsSource = B.kaufList;
        dg_test.Items.Refresh();
        MessageBox.Show(dg_test.HasItems.ToString());
        MessageBox.Show(dg_test.Items.Count.ToString());

        dg_Teile.ItemsSource = null;
        dg_Teile.ItemsSource =B.teilList;
        dg_Teile.Items.Refresh();

        //dg_Teile.Items.Refresh();
        //dg_BauGrp.ItemsSource = B.bauList ;
    }
    public void RefreshGrid()
    {
        //dg_Kaufteile.UpdateLayout();
        //dg_Kaufteile.Items.Refresh();
        //dg_Teile.UpdateLayout();
        MessageBox.Show(dg_Kaufteile.HasItems.ToString());
        MessageBox.Show(dg_Kaufteile.Items.Count.ToString());
    }
</code>```

When u see some curios things in the source is just because i test now thousands of possibilities. But the Grids in the MainWindow always simply stays empty.

The first MsgBox says that the grid has Content. Later in second MsgBox in the Refresh Method it says its empty?!

When i load the Lists in the first Window it works. The Grids have AutoColumn enabled.

`

答:
You are creating a new instance of MainWindow but you probably want to access the already existing one that you see on the screen. Try this:

```<code>public void btn_load_Click(object sender, RoutedEventArgs e)
{
    MainWindow M = Application.Current.Windows.OfType<MainWindow>().FirstOrDefault();

    ArtikelLaden(M);
    M.RefreshGrid();

    Close();
}

public void ArtikelLaden(MainWindow M)
{
    rowindexArtikel = dg_Artikel.SelectedIndex;
    Artikel B = new Artikel();
    B = artikelList[rowindexArtikel];
    M.loadArtikel(B);
}
</code>```

Title: WPF Grid not showing content

Body:
i´m using a Window with a Grid wich loads Objects from a MongoDB. This Objects contains Lists. Now i want to Load a List from one of this Objects. This is the Source from the Window:

        public void btn_load_Click(object sender, RoutedEventArgs e)
    {
        MainWindow M = new MainWindow();

        ArtikelLaden();
        M.RefreshGrid();

        Close();

    }`
public void ArtikelLaden()
    {

        MainWindow M = new MainWindow();
        rowindexArtikel = dg_Artikel.SelectedIndex;
        Artikel B = new Artikel();
        B = artikelList[rowindexArtikel];
        M.loadArtikel(B);
    }

The List should get loaded in the MainWindow:`

public void loadArtikel(Artikel B)
    {
        dg_test.ItemsSource = null;
        dg_test.ItemsSource = B.kaufList;
        dg_test.Items.Refresh();
        MessageBox.Show(dg_test.HasItems.ToString());
        MessageBox.Show(dg_test.Items.Count.ToString());

        dg_Teile.ItemsSource = null;
        dg_Teile.ItemsSource =B.teilList;
        dg_Teile.Items.Refresh();

        //dg_Teile.Items.Refresh();
        //dg_BauGrp.ItemsSource = B.bauList ;
    }
    public void RefreshGrid()
    {
        //dg_Kaufteile.UpdateLayout();
        //dg_Kaufteile.Items.Refresh();
        //dg_Teile.UpdateLayout();
        MessageBox.Show(dg_Kaufteile.HasItems.ToString());
        MessageBox.Show(dg_Kaufteile.Items.Count.ToString());
    }

When u see some curios things in the source is just because i test now thousands of possibilities. But the Grids in the MainWindow always simply stays empty.

The first MsgBox says that the grid has Content. Later in second MsgBox in the Refresh Method it says its empty?!

When i load the Lists in the first Window it works. The Grids have AutoColumn enabled.

`

Body:
You are creating a new instance of MainWindow but you probably want to access the already existing one that you see on the screen. Try this:

public void btn_load_Click(object sender, RoutedEventArgs e)
{
    MainWindow M = Application.Current.Windows.OfType<MainWindow>().FirstOrDefault();

    ArtikelLaden(M);
    M.RefreshGrid();

    Close();
}

public void ArtikelLaden(MainWindow M)
{
    rowindexArtikel = dg_Artikel.SelectedIndex;
    Artikel B = new Artikel();
    B = artikelList[rowindexArtikel];
    M.loadArtikel(B);
}


问:
Gulp-uglify : throw er; // Unhandled 'error' event
i'm pretty new to gulp , and I follow tutorials in http://leveluptuts.com/tutorials/learning-gulp , I get this error:

```<code>events.js:141
  throw er; // Unhandled 'error' event
  ^
Error
at new JS_Parse_Error (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:196:18)
at js_error (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:204:11)
at croak (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:680:9)
at token_error (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:688:9)
at unexpected (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:694:9)
at expr_atom (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1201:9)
at maybe_unary (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1363:19)
at expr_ops (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1398:24)
at maybe_conditional (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1403:20)
at maybe_assign (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1427:20)
</code>```

here is my code :

```<code> var gulp = require('gulp')
    uglify = require('gulp-uglify');

gulp.task('default', function() {
    // body...
    gulp.src('js/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('minjs'));

});
</code>```

and the tree of directory, just simple

```<code>-gulp
     -js/
     -gulpfile.js
</code>```

thanks a lot

答:
I had the same issue and was getting the same error.
The problem was, one of my JS files had @charset "UTF-8"; in the first line. So the syntax was breaking due to @ symbol. I removed it and it worked well.

```<code>{
SyntaxError: Unexpected character '@' at JS_Parse_Error.get
(eval at <anonymous> (C:\xampp\htdocs\catch\node_moles\uglify-js\tools\node.js:21:1),
<anonymous>:86:23) at formatError (util.js:649:15)
at formatValue (util.js:554:18)
at formatProperty (util.js:795:15)
at util.js:655:12
at Array.map (native)
at formatObject (util.js:654:15)
at formatValue (util.js:593:16)
at inspect (util.js:186:10)
at exports.format (util.js:72:24)
message: 'Unexpected character \'@\'',
filename: 'all.min.css', line: 1, col: 0, pos: 0 },
plugin: 'gulp-uglify',
....
....
}
</code>```

Body:
i'm pretty new to gulp , and I follow tutorials in http://leveluptuts.com/tutorials/learning-gulp , I get this error:

events.js:141
  throw er; // Unhandled 'error' event
  ^
Error
at new JS_Parse_Error (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:196:18)
at js_error (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:204:11)
at croak (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:680:9)
at token_error (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:688:9)
at unexpected (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:694:9)
at expr_atom (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1201:9)
at maybe_unary (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1363:19)
at expr_ops (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1398:24)
at maybe_conditional (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1403:20)
at maybe_assign (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1427:20)

here is my code :

 var gulp = require('gulp')
    uglify = require('gulp-uglify');

gulp.task('default', function() {
    // body...
    gulp.src('js/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('minjs'));

});

and the tree of directory, just simple

-gulp
     -js/
     -gulpfile.js

thanks a lot

Body:
I had the same issue and was getting the same error.
The problem was, one of my JS files had @charset "UTF-8"; in the first line. So the syntax was breaking due to @ symbol. I removed it and it worked well.

{
SyntaxError: Unexpected character '@' at JS_Parse_Error.get
(eval at <anonymous> (C:\xampp\htdocs\catch\node_moles\uglify-js\tools\node.js:21:1),
<anonymous>:86:23) at formatError (util.js:649:15)
at formatValue (util.js:554:18)
at formatProperty (util.js:795:15)
at util.js:655:12
at Array.map (native)
at formatObject (util.js:654:15)
at formatValue (util.js:593:16)
at inspect (util.js:186:10)
at exports.format (util.js:72:24)
message: 'Unexpected character \'@\'',
filename: 'all.min.css', line: 1, col: 0, pos: 0 },
plugin: 'gulp-uglify',
....
....
}


问:
angular - get data from server
I'm new to angularJS (started to learn it yesterday).
I'm trying to get data from a server.
The curl command works perfectly:

curl -i 175.36.8.90:5000/todo/api/v1.0/tasks

(It will not work for you since this is not the real IP of the server).

How can I get the same thing using angular?

I couldn't find anything - maybe because I'm so new to the subject that I don't even know to search for the right terms.

答:
I'm using this piece of code and works perfectly for me:

```<code>var MyApp = angular.module('MyApp');
MyApp.factory('DB_Services', ['$http' , '$q' , function($http , $q) {
    var l_Result ;
    var DB_Services = function(p_URL_Root , p_Query) {
        var l_deferred = $q.defer();
        var l_params   = JSON.stringify(p_Query) ;
        var l_url      = "http://localhost:8080/BLABLA/BLABLA_2";
        var req = { url    : l_url,
                    method :"GET",
                    timeout:10000 ,
                    headers: {
                        'Content-Type': 'application/json ; charset=UTF-8'
                    },
                   params:{request:p_Query}
                  } ;
        $http(req ).
                    success(function(data, status, headers, config) {
                         l_deferred.resolve({Server_Response:data , Server_Status: status});
                    }).
                    error(function(data, status, headers, config) {
                         l_deferred.resolve(status);
                    });
                    return l_deferred.promise;
        return l_deferred.promise;
    } ;

    return DB_Services;

}]);
</code>```

EDIT:

I should add that this code approaches a SERVLET who in its turn accessed the DB (I'm guessing that you do not intend to have direct access from the client to the DB, right?).

Title: angular - get data from server

Body:
I'm using this piece of code and works perfectly for me:

var MyApp = angular.module('MyApp');
MyApp.factory('DB_Services', ['$http' , '$q' , function($http , $q) {
    var l_Result ;
    var DB_Services = function(p_URL_Root , p_Query) {
        var l_deferred = $q.defer();
        var l_params   = JSON.stringify(p_Query) ;
        var l_url      = "http://localhost:8080/BLABLA/BLABLA_2";
        var req = { url    : l_url,
                    method :"GET",
                    timeout:10000 ,
                    headers: {
                        'Content-Type': 'application/json ; charset=UTF-8'
                    },
                   params:{request:p_Query}
                  } ;
        $http(req ).
                    success(function(data, status, headers, config) {
                         l_deferred.resolve({Server_Response:data , Server_Status: status});
                    }).
                    error(function(data, status, headers, config) {
                         l_deferred.resolve(status);
                    });
                    return l_deferred.promise;
        return l_deferred.promise;
    } ;

    return DB_Services;

}]);

EDIT:

I should add that this code approaches a SERVLET who in its turn accessed the DB (I'm guessing that you do not intend to have direct access from the client to the DB, right?).