问:
Bootstrap 3 col-xs-12 affect others screen siez
I have a block that take full width on mobile, but 3/12 columns on others screen.

So I have a .container class, then a row class, and finally I have a
.

What I have
When I add the .col-xs-12 this affect the result on large, medium and small screen !

What I would like
Take col-lg-3 on large, medium and small screen. And full width on mobile (col-xs-12)

Do you have an idea ?

HTML :

```<code><div class="container">
<div class="row">
    <div class="col-xs-offset-3 col-xs-6 col-sm-3 col-md-3 col-lg-3">
        <img src="image.jpg" class="img-responsive" alt="Image">
    </div>

    <a href="#"
       class="lien active">
        <div class="col-xs-6 col-sm-2 col-md-2 col-lg-2">
            Bétons
        </div>
    </a>

    <a href="#"
       class="lien active">
        <div class="col-xs-6 col-sm-3 col-md-3 col-lg-3">
            Sables, graviers ...
        </div>
    </a>

    <div class="col-xs-12 col-sm-4 col-md-4 col-lg-4 conseil-et-devis-gratuits">
        <p>CONSEILS ET DEVIS GRATUITS</p>
        <img src="image.jpg" class="img-responsive" alt="Image">
        <p>Lundi au vendredi : 8h-12h - 13h-18h - Samedi : 8h-12h</p>
    </div>
</div>
</code>```

答:
If I understood what you want, you need to reset the offset for larger screens:

```<code><div class="col-xs-offset-3 col-xs-9 col-sm-3 col-sm-offset-0"></div>
</code>```

See http://getbootstrap.com/css/#grid-offsetting

If all you want is full width on mobile then you wouldn't need to be using offset at all.

 would be good enough.

Body:
I have a block that take full width on mobile, but 3/12 columns on others screen.

So I have a .container class, then a row class, and finally I have a
.

What I have
When I add the .col-xs-12 this affect the result on large, medium and small screen !

What I would like
Take col-lg-3 on large, medium and small screen. And full width on mobile (col-xs-12)

Do you have an idea ?

HTML :

            Bétons

            Sables, graviers ...

CONSEILS ET DEVIS GRATUITS

Lundi au vendredi : 8h-12h - 13h-18h - Samedi : 8h-12h

Body:
If I understood what you want, you need to reset the offset for larger screens:

<div class="col-xs-offset-3 col-xs-9 col-sm-3 col-sm-offset-0"></div>

See http://getbootstrap.com/css/#grid-offsetting

If all you want is full width on mobile then you wouldn't need to be using offset at all.

<div class="col-xs-12 col-sm-3"></div> would be good enough.


来源: stackexchange

问:
Windows service (hosting WCF service) stops immediately on start up
My Question: I cannot navigate to the base address once the service is installed because the service won't remain running (stops immediately). Is there anything I need to do on the server or my machine to make the baseAddress valid?

Background: I'm trying to learn how to use WCF services hosted in Windows Services.  I have read several tutorials on how to accomplish this and it seems very straight forward.  I've looked at this MSDN article and built it step-by-step.  I can install the service on my machine and on a server, but when I start the service, it stops immediately.  I then found this tutorial, which is essentially the same thing, but it contains some clients that consume the WCF service. I downloaded the source code, compiled, installed, but when I started the service, it stopped immediately.

Searching SO, I found a possible solution that said to define the baseAddress when instantiating the ServiceHost, but that didnt help either.

My serviceHost is defined as:

```<code>serviceHost = new ServiceHost( typeof( CalculatorService ),
                 new Uri( "http://localhost:8000/ServiceModelSamples/service" ) );
</code>```

My service name, base address, and endpoint:

```<code><service name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior">
        <host>
            <baseAddresses>
                <add baseAddress="http://localhost:8000/ServiceModelSamples/service"/>
            </baseAddresses>
        </host>
        <endpoint address="" binding="wsHttpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    </service>
</code>```

I've verified the namespaces are identical.  It's just getting frustrating that the tutorials seem to assume that the Windows service will start as long as all the stated steps are followed.  I'm missing something and it's probably right in front of me. Please help!

答:
Late to this, but I find this line as the first line in OnStart to be immensely helpful in debugging services:

```<code>System.Diagnostics.Debugger.Launch();
</code>```

You can then select a running session of Visual Studio with your project already loaded (note: you might need to have that running as admin) and start stepping through your code.

ContentLicense: CC BY-SA 2.5

Body:
My Question: I cannot navigate to the base address once the service is installed because the service won't remain running (stops immediately). Is there anything I need to do on the server or my machine to make the baseAddress valid?

Background: I'm trying to learn how to use WCF services hosted in Windows Services.  I have read several tutorials on how to accomplish this and it seems very straight forward.  I've looked at this MSDN article and built it step-by-step.  I can install the service on my machine and on a server, but when I start the service, it stops immediately.  I then found this tutorial, which is essentially the same thing, but it contains some clients that consume the WCF service. I downloaded the source code, compiled, installed, but when I started the service, it stopped immediately.

Searching SO, I found a possible solution that said to define the baseAddress when instantiating the ServiceHost, but that didnt help either.

My serviceHost is defined as:

serviceHost = new ServiceHost( typeof( CalculatorService ),
                 new Uri( "http://localhost:8000/ServiceModelSamples/service" ) );

My service name, base address, and endpoint:

<service name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior">
        <host>
            <baseAddresses>
                <add baseAddress="http://localhost:8000/ServiceModelSamples/service"/>
            </baseAddresses>
        </host>
        <endpoint address="" binding="wsHttpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    </service>

I've verified the namespaces are identical.  It's just getting frustrating that the tutorials seem to assume that the Windows service will start as long as all the stated steps are followed.  I'm missing something and it's probably right in front of me. Please help!

Body:
Late to this, but I find this line as the first line in OnStart to be immensely helpful in debugging services:

System.Diagnostics.Debugger.Launch();

You can then select a running session of Visual Studio with your project already loaded (note: you might need to have that running as admin) and start stepping through your code.

ContentLicense: CC BY-SA 3.0


问:
When is manual mapping using Jackson's ObjectMapper needed for converting pojo to json in Spring Rest's @ResponseBody annotated controller method?
I want to know what is the rule followed by MappingJackson2HttpMessageConverter to convert the object (returned from controller method annotated by @ResponseBody) to a json? In some situations I see that just having Jackson2 on classpath (pom.xml) is enough and the controller simply returns back its object e.g. String or a collection e.g. List<Employee> successfully to browser in json format. But, in other cases I have seen that the solution asks me to use an ObjectMapper and use method writeValueAsString to get a string and return that as a response, example HashMaps! Are there some implicit rules which MappingJackson2HttpMessageConverter uses to decide if it is able to do the conversion on its own or I need to manually do it using Objectmapper ? If I have a pojo object, which internally has few String fields, would I still need to use ObjectMapper etc? If not then would I need it if my pojo class has fields like , some List<CustomObject> and some HashMaps?
For example : example 1 does not use any ObjectMapper to convert List<Company> to json in controller method. But, example 2 needs an ObjectMapper and writeValueAsString ? plus, it's return type now is String instead of a HashMap!

答: If you use @RestController and you have jackson in the class path everything will be handled OK. see https://spring.io/guides/gs/rest-service/ and https://www.leveluplunch.com/java/tutorials/014-post-json-to-spring-rest-webservice/</p>


问:
How to run STS on Java version 1.7
I need to  run eclipse(java 1.7) and  STS 3.8.1  ( java 1.8) but if i select the  java 7 as default i am getting error in the  STS 3.8.1.
 I am using OS : ubuntu 14.10

```<code>Error  : Version 1.7.0_80 of the JVM is not suitable for this product. Version: 1.8 or greater is required.
</code>```

Or I select java 1.8 as default eclipse is not working fine.

My requirement is  to build a Project using java 1.7  with STS.  and latest version 3.8.1 doesnot  support the  java 1.7.

and i try to search which version of STS support 1.7 but i am not getting any answer .

答:
It is asking for jdk 1.8 to open and run the STS (eclipse). It will still allow you to build your project/code with whatever JDK version you want.

Install jdk1.8, set your JAVA_HOME and PATH env variables so that 1.8 becomes your default jdk. After this your should be able to open STS. Then setup project and set project's JDK to 1.7 or whatever you want.

I hope it helps.

Title: How to run STS on Java version 1.7

Body:
I need to  run eclipse(java 1.7) and  STS 3.8.1  ( java 1.8) but if i select the  java 7 as default i am getting error in the  STS 3.8.1.
 I am using OS : ubuntu 14.10

Error  : Version 1.7.0_80 of the JVM is not suitable for this product. Version: 1.8 or greater is required.

Or I select java 1.8 as default eclipse is not working fine.

My requirement is  to build a Project using java 1.7  with STS.  and latest version 3.8.1 doesnot  support the  java 1.7.

and i try to search which version of STS support 1.7 but i am not getting any answer .


问:
Can consecutive updates to different fields on a row in Cassandra lead to inconsistency?
Assuming you have a table with a field (column) that serves as the primary (partition) key (let say its name is "id") and the rest of the fields columns are "regular" (no clustering) - lets call them "field1", "field2", field3", "field4", etc. The logic that currently exists in the system might generate 2 separate update commands to the same row. For example:

```<code>UPDATE table SET field1='value1' WHERE id='key';
UPDATE table SET field2='value2' WHERE id='key';
</code>```

These commands run one after the other in quorum.

Seldom, when you retrieve the row (quorum read) from the DB, its as if one of the updates did not happen. Is it possible that the inconsistency is because of this write pattern and can be circumvented by making one update call like this:

```<code>UPDATE table SET field1='value1',field2='value2' WHERE id='key';
</code>```

This is happening on Cassandra 2.1.17

答:
What I would have done,is change the table definition

```<code>        CREATE TABLE TABLE_NAME(
      id text,
      field text,
      value text
    PRIMARY KEY( id , field )
</code>```

This way you don't have to worry about updates to fields for a particular key.

Your queries would be ,

```<code>        INSERT INTO TABLE_NAME (id , field , value  ) VALUES ('key','fieldname1', 'value1' );
    INSERT INTO TABLE_NAME (id , field , value  ) VALUES ('key','fieldname2', 'value2' );
</code>```

The drawback of design is, if you have too many data for 'key',it would created wide row.

For select queries -

```<code>SELECT * from TABLE_NAME where id ='key';
</code>```

On client side, build your object.

Body:
Assuming you have a table with a field (column) that serves as the primary (partition) key (let say its name is "id") and the rest of the fields columns are "regular" (no clustering) - lets call them "field1", "field2", field3", "field4", etc. The logic that currently exists in the system might generate 2 separate update commands to the same row. For example:

UPDATE table SET field1='value1' WHERE id='key';
UPDATE table SET field2='value2' WHERE id='key';

These commands run one after the other in quorum.

Seldom, when you retrieve the row (quorum read) from the DB, its as if one of the updates did not happen. Is it possible that the inconsistency is because of this write pattern and can be circumvented by making one update call like this:

UPDATE table SET field1='value1',field2='value2' WHERE id='key';

This is happening on Cassandra 2.1.17

Body:
What I would have done,is change the table definition

        CREATE TABLE TABLE_NAME(
      id text,
      field text,
      value text
    PRIMARY KEY( id , field )

This way you don't have to worry about updates to fields for a particular key.

Your queries would be ,

        INSERT INTO TABLE_NAME (id , field , value  ) VALUES ('key','fieldname1', 'value1' );
    INSERT INTO TABLE_NAME (id , field , value  ) VALUES ('key','fieldname2', 'value2' );

The drawback of design is, if you have too many data for 'key',it would created wide row.

For select queries -

SELECT * from TABLE_NAME where id ='key';

On client side, build your object.


问:
JNDI Ldap Class Not Found
I am using JNDI Ldap to connect to an LDAP server in a Maven project.

```<code>    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.LdapCtxFactory");
</code>```

It fails at this line because it cannot find this class. I originally added the dependency from the main maven repository but then had to manually download it and install it into maven from the Java website. The jar containing com.sun.jndi.LdapCtxFactory is definitely within the build path but it still throws a Class Not Found exception. Has anyone seen anything similar or know how to resolve?

Thanks

答: You've got the class name wrong. It is com.sun.jndi.ldap.LdapCtxFactory.</p>

Title: JNDI Ldap Class Not Found

Body:
I am using JNDI Ldap to connect to an LDAP server in a Maven project.

    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.LdapCtxFactory");

It fails at this line because it cannot find this class. I originally added the dependency from the main maven repository but then had to manually download it and install it into maven from the Java website. The jar containing com.sun.jndi.LdapCtxFactory is definitely within the build path but it still throws a Class Not Found exception. Has anyone seen anything similar or know how to resolve?

Thanks


问:
Aspect for class or subclass annotated with
I want to be able to track methods that are anotated with @RequestMapping that are annotated with a certain annotation (for instance @LooseController).

I have two pointcuts: requestMappings() and looseController()

this works well if the method that is annotated with @RequestMapping is in a class that has @LooseController but not if the @LooseController is in a subclass

for instance, when update(id) is called on Controller1 it is not caught by this aspect

Update to include more information:

```<code>package de.scrum_master.app;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class MyAspect {

    @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
    private static void requestMapping() {}

    @Pointcut("@within(de.scrum_master.app.LooseController)")
    private static void looseController() {}

//    @Pointcut("@this(de.scrum_master.app.LooseController)")
//    private static void looseController() {}

    @Before("requestMapping() && looseController()")
    public void myAdvice(JoinPoint thisJoinPoint) {
        System.out.println(thisJoinPoint);
    }

}
</code>```

```<code>package de.scrum_master.app;

import org.springframework.web.bind.annotation.RequestMapping;

//@LooseController
public abstract class PutController {

    @RequestMapping("/{id}")
    public void update(String id) {
    }

}
</code>```

```<code>package de.scrum_master.app;

import java.lang.annotation.Retention;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Retention(RUNTIME)
public @interface LooseController {
}
</code>```

```<code>package de.scrum_master.app;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

@Component
@LooseController
@RequestMapping("/something")
public class Controller1 extends PutController {
}
</code>```

```<code>package de.scrum_master.app;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class AspectApplication implements CommandLineRunner {

    @Autowired
    private Controller1 controller1;

    @Autowired
    private ConfigurableApplicationContext context;

    public static void main(String[] args) {
        SpringApplication.run(AspectApplication.class, "--logging.level.root=WARN", "--spring.main.banner-mode=off");
    }

    @Override
    public void run(String... strings) throws Exception {
        controller1.update("test");
        context.close();
    }

}
</code>```

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

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>aspects</groupId>
    <artifactId>aspects</artifactId>
    <version>1.0-SNAPSHOT</version>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

    </dependencies>

</project>
</code>```

答:
As I said in my comment, I have to speculate:

It begins with your exact pointcut (which you do not show)

and goes on with the question whether you use Spring AOP or full AspectJ via LTW (load-time weaving).

In the former case you do not explain if your target classes are actual Spring beans because Spring AOP can only proxy Spring beans/components.

In the latter case you have more options but have to configure your application in a different way.

You also do not show your own annotation's implementation, especially not if it has the required runtime retention.

My hypothesis for now is that

you use proxy-based Spring AOP and

all classes and aspects are @Components or otherwise declared as Spring beans in your configuration.

But in order to show you what happens I will use a stand-alone Java example with AspectJ, not a Spring application. I only put spring-web.jar and sprint-context.jar on my classpath so as to resolve the Spring annotations.

Annotation:

package de.scrum_master.app;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @interface LooseController {}
```

<p><strong>Abstract base class:</strong></p>

<pre class="lang-java prettyprint-override"><code>package de.scrum_master.app;

import org.springframework.web.bind.annotation.RequestMapping;

public abstract class PutController {
  @RequestMapping("/{id}")
  public void update(String id) {}
}
</code>```

Subclass + main method:

package de.scrum_master.app;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

@Component
@LooseController
@RequestMapping("/something")
public class Controller1 extends PutController {
  public static void main(String[] args) {
    new Controller1().update("foo");
  }
}
```

<p><strong>The aspect which I guess you might use:</strong></p>

<p>Please note that your own pointcut <code>within(@blabla.LooseController)</code> is syntactically invalid, this is why I changed it to <code>@within(blabla.LooseController)</code>.</p>

<pre class="lang-java prettyprint-override"><code>package de.scrum_master.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class MyAspect {
  @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
  private static void requestMapping() {}

  @Pointcut("@within(de.scrum_master.app.LooseController)")
  private static void looseController() {}

  @Before("requestMapping() && looseController()")
  public void myAdvice(JoinPoint thisJoinPoint) {
    System.out.println(thisJoinPoint);
  }
}
</code>```

Console log when running Controller1.main:

staticinitialization(de.scrum_master.app.Controller1.<clinit>)
call(void de.scrum_master.app.Controller1.update(String))
```

<p>Now you see the problem: AspectJ can intercept a few joinpoints for the given pointcut, but neither <code>call</code> nor <code>staticinitialization</code> are supported by Spring AOP according to the documentation.</p>

<p>So either you need to switch to AspectJ with LTW or devise another pointcut strategy.</p>

<p><em>To be continued, I have to interrupt the answer here for a while because I have an appointment, but will add some more info later.</em></p>

<hr>

<p><strong>Update:</strong> Okay, here is your problem and a solution: <code>@within(de.scrum_master.app.LooseController)</code> looks inside classes with the <code>@LooseController</code> annotation, but the parent class with the annotated method you are trying to intercept does not have that annotation. Thus, <code>@within()</code> is not the right pointcut type for you. What you want to express is that the instance, i.e. the current <code>target</code> object upon which the method is called, belongs to an annotated class. Therefore, you need a <code>@target()</code> pointcut:</p>

<pre class="lang-java prettyprint-override"><code>@Pointcut("@target(de.scrum_master.app.LooseController)")
private static void looseController() {}
</code>```

Alternatively you could also use this workaround (a little ugly, but works too):

@Pointcut("target(@de.scrum_master.app.LooseController Object)")
private static void looseController() {}
```

<p>Now the console log says:</p>

<pre class="lang-none prettyprint-override"><code>execution(void de.scrum_master.app.PutController.update(String))
</code>```

This should also work in Spring AOP because execution() is a supported pointcut type there.

Body:
I want to be able to track methods that are anotated with @RequestMapping that are annotated with a certain annotation (for instance @LooseController).

I have two pointcuts: requestMappings() and looseController()

this works well if the method that is annotated with @RequestMapping is in a class that has @LooseController but not if the @LooseController is in a subclass

for instance, when update(id) is called on Controller1 it is not caught by this aspect

Update to include more information:

package de.scrum_master.app;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class MyAspect {

    @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
    private static void requestMapping() {}

    @Pointcut("@within(de.scrum_master.app.LooseController)")
    private static void looseController() {}

//    @Pointcut("@this(de.scrum_master.app.LooseController)")
//    private static void looseController() {}

    @Before("requestMapping() && looseController()")
    public void myAdvice(JoinPoint thisJoinPoint) {
        System.out.println(thisJoinPoint);
    }

}

package de.scrum_master.app;

import org.springframework.web.bind.annotation.RequestMapping;

//@LooseController
public abstract class PutController {

    @RequestMapping("/{id}")
    public void update(String id) {
    }

}

package de.scrum_master.app;

import java.lang.annotation.Retention;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Retention(RUNTIME)
public @interface LooseController {
}

package de.scrum_master.app;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

@Component
@LooseController
@RequestMapping("/something")
public class Controller1 extends PutController {
}

package de.scrum_master.app;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class AspectApplication implements CommandLineRunner {

    @Autowired
    private Controller1 controller1;

    @Autowired
    private ConfigurableApplicationContext context;

    public static void main(String[] args) {
        SpringApplication.run(AspectApplication.class, "--logging.level.root=WARN", "--spring.main.banner-mode=off");
    }

    @Override
    public void run(String... strings) throws Exception {
        controller1.update("test");
        context.close();
    }

}

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

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

    <groupId>aspects</groupId>
    <artifactId>aspects</artifactId>
    <version>1.0-SNAPSHOT</version>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

    </dependencies>

</project>

Body:
As I said in my comment, I have to speculate:

It begins with your exact pointcut (which you do not show)

and goes on with the question whether you use Spring AOP or full AspectJ via LTW (load-time weaving).

In the former case you do not explain if your target classes are actual Spring beans because Spring AOP can only proxy Spring beans/components.

In the latter case you have more options but have to configure your application in a different way.

You also do not show your own annotation's implementation, especially not if it has the required runtime retention.

My hypothesis for now is that

you use proxy-based Spring AOP and

all classes and aspects are @Components or otherwise declared as Spring beans in your configuration.

But in order to show you what happens I will use a stand-alone Java example with AspectJ, not a Spring application. I only put spring-web.jar and sprint-context.jar on my classpath so as to resolve the Spring annotations.

Annotation:

package de.scrum_master.app;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @interface LooseController {}

Abstract base class:

package de.scrum_master.app;

import org.springframework.web.bind.annotation.RequestMapping;

public abstract class PutController {
  @RequestMapping("/{id}")
  public void update(String id) {}
}

Subclass + main method:

package de.scrum_master.app;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

@Component
@LooseController
@RequestMapping("/something")
public class Controller1 extends PutController {
  public static void main(String[] args) {
    new Controller1().update("foo");
  }
}

The aspect which I guess you might use:

Please note that your own pointcut within(@blabla.LooseController) is syntactically invalid, this is why I changed it to @within(blabla.LooseController).

package de.scrum_master.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class MyAspect {
  @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
  private static void requestMapping() {}

  @Pointcut("@within(de.scrum_master.app.LooseController)")
  private static void looseController() {}

  @Before("requestMapping() && looseController()")
  public void myAdvice(JoinPoint thisJoinPoint) {
    System.out.println(thisJoinPoint);
  }
}

Console log when running Controller1.main:

staticinitialization(de.scrum_master.app.Controller1.<clinit>)
call(void de.scrum_master.app.Controller1.update(String))

Now you see the problem: AspectJ can intercept a few joinpoints for the given pointcut, but neither call nor staticinitialization are supported by Spring AOP according to the documentation.

So either you need to switch to AspectJ with LTW or devise another pointcut strategy.

To be continued, I have to interrupt the answer here for a while because I have an appointment, but will add some more info later.

Update: Okay, here is your problem and a solution: @within(de.scrum_master.app.LooseController) looks inside classes with the @LooseController annotation, but the parent class with the annotated method you are trying to intercept does not have that annotation. Thus, @within() is not the right pointcut type for you. What you want to express is that the instance, i.e. the current target object upon which the method is called, belongs to an annotated class. Therefore, you need a @target() pointcut:

@Pointcut("@target(de.scrum_master.app.LooseController)")
private static void looseController() {}

Alternatively you could also use this workaround (a little ugly, but works too):

@Pointcut("target(@de.scrum_master.app.LooseController Object)")
private static void looseController() {}

Now the console log says:

execution(void de.scrum_master.app.PutController.update(String))

This should also work in Spring AOP because execution() is a supported pointcut type there.


问:
SKStoreReviewController not working
Why is "SKStoreReviewController's" send button is greyed out and doesn't respond on touch?
Maybe it's related to that I am in DEBUG mode?</p>

答:
I have met the same question and have tried RELEASE mode(dev provision&sign). The submit button is also disabled.

Maybe we are in DEV mode and the rating is real, So they block us submitting rating in dev mode.

Title: SKStoreReviewController not working


问:
Save regular expression result in variable
I would like to split a string into separated, single strings and save each in a new variable. That's the use case:

Direct user input with BC1 = input("BC1: ") in the following format: '17899792270101010000000000', '17899792270102010000000000', '17899792270103010000000000'

Now I want each number - and just the number in a single variable:

```<code>a = 17899792270101010000000000
b = 17899792270102010000000000
c = 17899792270103010000000000
</code>```

How to realise that in python 3?

Sadly I'm not able to create a suitable regular expression for it and neither a way to save string parts in separate variables. I hope someone of you could help me.
Thanks already in advance!

Body:
I would like to split a string into separated, single strings and save each in a new variable. That's the use case:

Direct user input with BC1 = input("BC1: ") in the following format: '17899792270101010000000000', '17899792270102010000000000', '17899792270103010000000000'

Now I want each number - and just the number in a single variable:

a = 17899792270101010000000000
b = 17899792270102010000000000
c = 17899792270103010000000000

How to realise that in python 3?

Sadly I'm not able to create a suitable regular expression for it and neither a way to save string parts in separate variables. I hope someone of you could help me.
Thanks already in advance!

Body:
if it's already "format" at the input :

>>> BC1 = input("BC1: ")
BC1: '17899792270101010000000000', '17899792270102010000000000', '17899792270103010000000000'
>>> a=int(BC1[0])
>>> b=int(BC1[1])
>>> c=int(BC1[2])
>>> a
17899792270101010000000000
>>> b
17899792270102010000000000
>>> c
17899792270103010000000000


问:
Bitbucket enforce prefixes to keep developers from creating branches at the root
Under origin I'd like to keep the root level relatively clean with just the develop and perhaps the master branch.  All the features, hotfixes, releases etc, I'd like to be created under the appropriate prefixes.  Most of the time people are following this, but then some are not.

Is there a way to enforce branches to be created only under a prefix?

Right now the remote looks like this

origin
   DC-123_Account_Creation
   DC-124_Permissions_Setup
   develop
   HEAD
   master
   ^feature
      DC-456_Repository_Setup

DC-123 & DC-124 are out of place.  I either have to let the errant branches ride until completed and merged or check them out and manually rename them to use the prefix and check them back in.  Then the developer gets irritated because their branch has moved and they have changes etc etc...

Since they won't play by the rules, can I remove their ability not to?

答: How about not allowing them to write on origin and let only someone more "sensible" about the subject to take care of that? Given git's dynamic nature, I'm sure you can use something like a gatekeeper to take care of pulling from the "misbehaving" guys. https://git-scm.com/book/it/v2/Distributed-Git-Distributed-Workflows (Integration manager workflow)</p>


问:
Error C2143 (missing ; before namespace) in MS VC include
I am extremely confused why I am getting this strange error all the sudden:

Time.h is a very simple class, and it has a semicolon at the end of the class description, so I am pretty sure my code is correct here.. Then I get the same errors in: Microsoft Visual Studio 10.0\VC\include\memory.. Any ideas!?!? Thanks!

Compiler Output

```<code>1>ClCompile:
1>  Stop.cpp
1>c:\projectnextbus\Time.h(17): error C2143: syntax error : missing ';' before 'using'
1>c:\projectnextbus\Time.h(17): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>  NextBusDriver.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\memory(16): error C2143: syntax error : missing ';' before 'namespace'
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\memory(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
</code>```

Update:
Can't really post all the code as this is for a school project and we aren't supposed to post before we submit, but small snippets should be ok..

Time.h

```<code>#ifndef TIME_HPP
#define TIME_HPP

#include <string>
#include <sstream>

using namespace std;

class Time {
// Defines a time in a 24 hour clock

public:
    // Time constructor
    Time(int hours = 0 , int minutes= 0);

    // POST: Set hours int
    void setHours(int h);

    // POST: Set minutes int
    void setMinutes(int m);

    // POST: Returns hours int
    int getHours();

    // POST: Returns minutes int
    int getMinutes();

    // POST: Returns human readable string describing the time
    // This method can be overridden in inheriting classes, so should be virtual so pointers will work as desired
    string toString();

private:
    string intToString(int num);
    // POST: Converts int to string type

    int hours_;
    int minutes_;

};

#endif
</code>```

DepartureTime.h (inherited class)

```<code>#ifndef DEPARTURE_TIME_HPP
#define DEPARTURE_TIME_HPP

#include <string>
#include "Time.h"

using namespace std;

class DepartureTime: public Time {
public:
    // Departure Time constructor
    DepartureTime(string headsign, int hours=0, int minutes=0) : Time(hours, minutes), headsign_(headsign) { }

    // POST: Returns bus headsign
    string getHeadsign();

    // POST: Sets the bus headsign
    void setHeadsign(string headsign);

    // POST: Returns human readable string describing the departure
    string toString();

private:
    // Class variables
    string headsign_;
};
#endif
</code>```

答:
This can happen when one include file has an error (or missing semicolon) at the end of the file and that file is included immediately before another. The error that is generated indicates that there is a problem in the second include file rather than the first. So as a starting point, make sure that, if you have a file that's included before Time.h, that is doesn't have any errors in it.

Pasting the content of your .h and .cpp files would certainly be helpful rather than just the error message.

Body:
I am extremely confused why I am getting this strange error all the sudden:

Time.h is a very simple class, and it has a semicolon at the end of the class description, so I am pretty sure my code is correct here.. Then I get the same errors in: Microsoft Visual Studio 10.0\VC\include\memory.. Any ideas!?!? Thanks!

Compiler Output

1>ClCompile:
1>  Stop.cpp
1>c:\projectnextbus\Time.h(17): error C2143: syntax error : missing ';' before 'using'
1>c:\projectnextbus\Time.h(17): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>  NextBusDriver.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\memory(16): error C2143: syntax error : missing ';' before 'namespace'
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\memory(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Update:
Can't really post all the code as this is for a school project and we aren't supposed to post before we submit, but small snippets should be ok..

Time.h

#ifndef TIME_HPP
#define TIME_HPP

#include <string>
#include <sstream>

using namespace std;

class Time {
// Defines a time in a 24 hour clock

public:
    // Time constructor
    Time(int hours = 0 , int minutes= 0);

    // POST: Set hours int
    void setHours(int h);

    // POST: Set minutes int
    void setMinutes(int m);

    // POST: Returns hours int
    int getHours();

    // POST: Returns minutes int
    int getMinutes();

    // POST: Returns human readable string describing the time
    // This method can be overridden in inheriting classes, so should be virtual so pointers will work as desired
    string toString();

private:
    string intToString(int num);
    // POST: Converts int to string type

    int hours_;
    int minutes_;

};

#endif

DepartureTime.h (inherited class)

#ifndef DEPARTURE_TIME_HPP
#define DEPARTURE_TIME_HPP

#include <string>
#include "Time.h"

using namespace std;

class DepartureTime: public Time {
public:
    // Departure Time constructor
    DepartureTime(string headsign, int hours=0, int minutes=0) : Time(hours, minutes), headsign_(headsign) { }

    // POST: Returns bus headsign
    string getHeadsign();

    // POST: Sets the bus headsign
    void setHeadsign(string headsign);

    // POST: Returns human readable string describing the departure
    string toString();

private:
    // Class variables
    string headsign_;
};
#endif


问:
Fetching Tags in Google Cloud Builder
In the newly created google container builder I am unable to fetch git tags during a build.  During the build process the default cloning does not seem to fetch git tags.  I added a custom build process which calls git fetch --tags but this results in the error:

Fetching origin
git: 'credential-gcloud.sh' is not a git command. See 'git --help'.
fatal: could not read Username for 'https://source.developers.google.com': No such device or address

```<code># cloudbuild.yaml
#!/bin/bash

openssl aes-256-cbc -k "$ENC_TOKEN" -in gcr_env_vars.sh.enc -out gcr_env_vars.sh -
source gcr_env_vars.sh
env
git config --global url.https://${CI_USER_TOKEN}@github.com/.insteadOf git@github.com:

pushd vendor
git submodule update --init --recursive
popd

docker build -t gcr.io/project-compute/continuous-deploy/project-ui:$COMMIT_SHA -f /workspace/installer/docker/ui/Dockerfile .
docker build -t gcr.io/project-compute/continuous-deploy/project-auth:$COMMIT_SHA -f /workspace/installer/docker/auth/Dockerfile .
</code>```

答:
To be clear, you want all tags to be available in the Git repo, not just to trigger on tag changes?  In the latter, the triggering tag should be available IIUC.

I'll defer to someone on the Container Builder team for a more detailed explanation, but that error tells me that they used gcloud to clone the Google Cloud Source Repository (GCSR), which configures a Git credential helper named as such.  They likely did this in another container before invoking yours, or on the host.  Since gcloud and/or the gcloud credential helper aren't available in your container, you can't authenticate properly with GCSR.

You can learn a bit more about the credential helper here.

Title: Fetching Tags in Google Cloud Builder

Body:
In the newly created google container builder I am unable to fetch git tags during a build.  During the build process the default cloning does not seem to fetch git tags.  I added a custom build process which calls git fetch --tags but this results in the error:

Fetching origin
git: 'credential-gcloud.sh' is not a git command. See 'git --help'.
fatal: could not read Username for 'https://source.developers.google.com': No such device or address

# cloudbuild.yaml
#!/bin/bash

openssl aes-256-cbc -k "$ENC_TOKEN" -in gcr_env_vars.sh.enc -out gcr_env_vars.sh -
source gcr_env_vars.sh
env
git config --global url.https://${CI_USER_TOKEN}@github.com/.insteadOf git@github.com:

pushd vendor
git submodule update --init --recursive
popd

docker build -t gcr.io/project-compute/continuous-deploy/project-ui:$COMMIT_SHA -f /workspace/installer/docker/ui/Dockerfile .
docker build -t gcr.io/project-compute/continuous-deploy/project-auth:$COMMIT_SHA -f /workspace/installer/docker/auth/Dockerfile .


问:
Swift UIFont IBInspectable - is it possible?
I have a UIView subclass. In this view I create instances of UIlabel.
Now I want to set the font attributes for these labels in the Storyboard. Is it possible to make an IBInspectable for UIFont?

One of my approaches was this:

@IBInspectable var fontName: UIFont

But it won't work.

To wrap it up: I trying to get this for the UIView:

I hope someone can help me, thank you! :)

答:
Idea

You can use Int enums to select one of the certain fonts.

Details

xCode 8.2.1, Swift 3

Code

enum FontType: Int

```<code>import UIKit
enum FontType: Int {
    case Default = 0, Small, Large

    var fount: UIFont {
        switch self {
            case .Default:
                return UIFont.systemFont(ofSize: 17)
            case .Small:
                return UIFont.systemFont(ofSize: 12)
            case .Large:
                return UIFont.systemFont(ofSize: 24)
        }
    }

    static func getFont(rawValue: Int) -> UIFont  {
        if let fontType = FontType(rawValue: rawValue) {
            return fontType.fount
        }
        return FontType.Default.fount
    }
}
</code>```

class View: UIView

```<code>import UIKit
@IBDesignable
class View: UIView {

    private var label: UILabel!

    @IBInspectable var textFont:Int = 0

    override func draw(_ rect: CGRect) {
        super.draw(rect)
        label = UILabel(frame: CGRect(x: 20, y: 20, width: 120, height: 40))
        label.text = "Text"
        label.textColor = .black
        label.font = FontType.getFont(rawValue: textFont)
        addSubview(label)
    }

}
</code>```

Main.storyboard

Results

Body:
Idea

You can use Int enums to select one of the certain fonts.

Details

xCode 8.2.1, Swift 3

Code

enum FontType: Int

import UIKit
enum FontType: Int {
    case Default = 0, Small, Large

    var fount: UIFont {
        switch self {
            case .Default:
                return UIFont.systemFont(ofSize: 17)
            case .Small:
                return UIFont.systemFont(ofSize: 12)
            case .Large:
                return UIFont.systemFont(ofSize: 24)
        }
    }

    static func getFont(rawValue: Int) -> UIFont  {
        if let fontType = FontType(rawValue: rawValue) {
            return fontType.fount
        }
        return FontType.Default.fount
    }
}

class View: UIView

import UIKit
@IBDesignable
class View: UIView {

    private var label: UILabel!

    @IBInspectable var textFont:Int = 0

    override func draw(_ rect: CGRect) {
        super.draw(rect)
        label = UILabel(frame: CGRect(x: 20, y: 20, width: 120, height: 40))
        label.text = "Text"
        label.textColor = .black
        label.font = FontType.getFont(rawValue: textFont)
        addSubview(label)
    }

}

Main.storyboard

Results


问:
How can I Create a Tableview Under Custom Tableview cell
I am just thinking. Suppose, i have a tableview which have custom cell. It's simple. But My idea is that, when i click a tableview cell then another tableview is appear under that tableview cell, and again i click that cell then that sub tableview disappear. Similarly when i click second cell than work same. Is it possible? Please Provide me any idea or reference.</p>

答: If you want to show additional cell information, you can add more cells after the cell indexpath you have clicked.</p>


问:
PHP Online/Offline Script
I'm trying to code a script where a person logs in, and his last login time stamp is updated to the table. If he has logged in for more than 1 hour, immediately log him out even if he was interacting. I wonder how would I do that? I am using time() function to store the login time like this:

```<code>$lastlogin = time();
</code>```

This has been marked duplicate: Automatic Logout after 15 minutes of inactive in php

But no, this is different. I want that to happen automatically without the user having to refresh the page. The answer on that question will only execute if the user interacts to the site, but I want the user to get logged out even if the user is away and not interacting.

答:
I can't understand fully your want, but give you simple,

this just simple php for check you login, this example you user $_SESSION['USER'] for checking user login and set in this session array's
and in this set is:

```<code>$_SESSION['user']['THE SESSION KEY FOR LOGIN (EX. USERNAME)'] = "User"
$_SESSION['user']['time'] = "900"
</code>```

And this validation:

```<code><?php
session_start();
//create session (JUST FOR ONE TIME)
if (isset($_SESSION['user']['THE SESSION KEY FOR LOGIN (EX. USERNAME)']) and time() -$_SESSION['user']['TIME'] > 900){
     unset($_SESSION['user']);
     echo "logout"
    }
?>
</code>```

in client you must create Ajax to validation, i recommend if you dont fully understand, you just use ajax from jQuery in you page,

```<code><script src"{YOUR JQUERY PLACE}">
setTimeout(function(){
$.ajax({
   url:"checker.php",
   dataType:"html",
   type:"GET",
   success:function(html){
      if(html == "logout"){
      //whatever you want..
      //window.location.reload(); for reload you page,
      }
   }
});
}, 3000); // this check from client for server every 3 second
</script>
</code>```

and in you page you must validation again by PHP, this idea is, Server set time for user, in client PC, you script request to your server for checking this user. if user time's more than 15 mnt, this php send to server for refresh your browser and in you php for all page, you must give syntax logout if user time's more that 15 mnt.

Title: PHP Online/Offline Script

Body:
I'm trying to code a script where a person logs in, and his last login time stamp is updated to the table. If he has logged in for more than 1 hour, immediately log him out even if he was interacting. I wonder how would I do that? I am using time() function to store the login time like this:

$lastlogin = time();

This has been marked duplicate: Automatic Logout after 15 minutes of inactive in php

But no, this is different. I want that to happen automatically without the user having to refresh the page. The answer on that question will only execute if the user interacts to the site, but I want the user to get logged out even if the user is away and not interacting.

Body:
I can't understand fully your want, but give you simple,

this just simple php for check you login, this example you user $_SESSION['USER'] for checking user login and set in this session array's
and in this set is:

$_SESSION['user']['THE SESSION KEY FOR LOGIN (EX. USERNAME)'] = "User"
$_SESSION['user']['time'] = "900"

And this validation:

<?php
session_start();
//create session (JUST FOR ONE TIME)
if (isset($_SESSION['user']['THE SESSION KEY FOR LOGIN (EX. USERNAME)']) and time() -$_SESSION['user']['TIME'] > 900){
     unset($_SESSION['user']);
     echo "logout"
    }
?>

in client you must create Ajax to validation, i recommend if you dont fully understand, you just use ajax from jQuery in you page,

<script src"{YOUR JQUERY PLACE}">
setTimeout(function(){
$.ajax({
   url:"checker.php",
   dataType:"html",
   type:"GET",
   success:function(html){
      if(html == "logout"){
      //whatever you want..
      //window.location.reload(); for reload you page,
      }
   }
});
}, 3000); // this check from client for server every 3 second
</script>

and in you page you must validation again by PHP, this idea is, Server set time for user, in client PC, you script request to your server for checking this user. if user time's more than 15 mnt, this php send to server for refresh your browser and in you php for all page, you must give syntax logout if user time's more that 15 mnt.


问:
jQuery to Align Decimals for a Bootstrap DataTable Column
For reference, please see this: https://datatables.net/reference/api/row.add() . My code is instantiating a table as:

```<code>var table =  $('#search_details_drilldowns').DataTable();
</code>```

and then, in a loop, adding a bunch of rows. Cope snippet:

```<code>var unit_price = dynamicdata[0].toFixed(4);

//somehow modify the unit_price variable here?

table.row.add([unit_price]);
</code>```

The value of unit_price can be like: 170.0000 or 14.2494 or 99999.0000 ; so always four decimals! The way the Datatable is displaying, the decimals are not aligned. I can't change the  column to right-align because I don't want to shift that.

So, what I am thinking of is to add spaces or somehow pad to the left of decimal points so long as the decimal points align. The values are for display only and so string is quite okay!

Any idea?

Thanks!

答:
Never mind. I found this library: https://github.com/ndp-software/align-column and used this:

```<code> $('#search_details_drilldowns').alignColumn(8);
</code>```

after table.draw(); method and seems to be working.

HTH someone!

Update This answer will NOT work for me--this basically puts in two columns within each column of the DataTable and the data is not shown correctly. So the original Question still needs help! Thanks.

Updated Answer Given Below!!

The above Answer got me started into manipulating the CSS of individual cells. And here's how I fixed the problem!

Loaded a modified version of the Github library and then simply this in the For Loop--no splitting etc.

```<code>$cell.css('text-align', 'right');
$cell.css('padding-right', '20%');
</code>```

I could do this without loading the extra library by calling some function in my main JS file but I thought to keep the code clean. Anyway, the new Answer works for me--although it is padding the th header as well which I will figure out to fix.

HTH!

Body:
For reference, please see this: https://datatables.net/reference/api/row.add() . My code is instantiating a table as:

var table =  $('#search_details_drilldowns').DataTable();

and then, in a loop, adding a bunch of rows. Cope snippet:

var unit_price = dynamicdata[0].toFixed(4);

//somehow modify the unit_price variable here?

table.row.add([unit_price]);

The value of unit_price can be like: 170.0000 or 14.2494 or 99999.0000 ; so always four decimals! The way the Datatable is displaying, the decimals are not aligned. I can't change the  column to right-align because I don't want to shift that.

So, what I am thinking of is to add spaces or somehow pad to the left of decimal points so long as the decimal points align. The values are for display only and so string is quite okay!

Any idea?

Thanks!

Body:
Never mind. I found this library: https://github.com/ndp-software/align-column and used this:

 $('#search_details_drilldowns').alignColumn(8);

after table.draw(); method and seems to be working.

HTH someone!

Update This answer will NOT work for me--this basically puts in two columns within each column of the DataTable and the data is not shown correctly. So the original Question still needs help! Thanks.

Updated Answer Given Below!!

The above Answer got me started into manipulating the CSS of individual cells. And here's how I fixed the problem!

Loaded a modified version of the Github library and then simply this in the For Loop--no splitting etc.

$cell.css('text-align', 'right');
$cell.css('padding-right', '20%');

I could do this without loading the extra library by calling some function in my main JS file but I thought to keep the code clean. Anyway, the new Answer works for me--although it is padding the th header as well which I will figure out to fix.

HTH!


问:
Angular Router issue - links are not clickable
I have a simple routing module, and then a template where I have links.
- The first  link doesn't display as a clickable link, it shows as static text.

The second  shows as link, only because of the href. Is this required?

app-routing.module.ts:

```<code>import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {AppComponent} from "./app.component";
import {ListComponent} from "./list/list.component"

const appRoutes: Routes = [
    {path: 'List', component: ListComponent},
    {path: 'Home', component: AppComponent}
];

@NgModule({
    imports: [
        RouterModule.forRoot(appRoutes)
    ],
    exports: [
        RouterModule
    ]
})
export class AppRoutingModule {}
</code>```

app.component.ts

```<code>import { Component } from '@angular/core';
import {RouterModule} from '@angular/router';
import { AppRoutingModule } from './app-routing.module';

@Component({
    moduleId: module.id,
    selector: 'my-app',
    templateUrl: './app.component.html'
})
export class AppComponent {
}
</code>```

app.component.html

```<code> <a routerLink="/List" routerLinkActive="active">List</a> |
    <a href="./list/list.component.html" routerlink="/List" routerLinkActive="active">List</a>

<router-outlet></router-outlet>
</code>```

答:
First of all the href is not required and the second one it should be routerLink not routerlink.

Try using lower caps in your links

Why would you need both links to point to the same thing

Body:
I have a simple routing module, and then a template where I have links.
- The first  link doesn't display as a clickable link, it shows as static text.

The second  shows as link, only because of the href. Is this required?

app-routing.module.ts:

import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {AppComponent} from "./app.component";
import {ListComponent} from "./list/list.component"

const appRoutes: Routes = [
    {path: 'List', component: ListComponent},
    {path: 'Home', component: AppComponent}
];

@NgModule({
    imports: [
        RouterModule.forRoot(appRoutes)
    ],
    exports: [
        RouterModule
    ]
})
export class AppRoutingModule {}

app.component.ts

import { Component } from '@angular/core';
import {RouterModule} from '@angular/router';
import { AppRoutingModule } from './app-routing.module';

@Component({
    moduleId: module.id,
    selector: 'my-app',
    templateUrl: './app.component.html'
})
export class AppComponent {
}

app.component.html

 List |
    List

<router-outlet></router-outlet>


问:
How to simulate a button click using HttpClient
I am trying to navigate to a REST API, however the owner of the web page has inserted an HTML message page in front of the REST API URL.  So, when I make the request to the REST API, instead of being returned the XML file that I requested, I get back an HTML page that has some informational message on it, and requires a button click to acknowledge the message.

The button itself, when inspected with Fiddler, shows no onclick event:

```<code><div class="dialog-buttons">
    <button id="frmMessages:btnAcknowledge" name="frmMessages:btnAcknowledge" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" onclick="" title="Acknowledge and continue" type="submit">
        <span class="ui-button-text ui-c">OK</span>
    </button>
</div>
</code>```

I am not able to navigate directly to the page where the button-click sends you, because it doesn't send you anywhere, it just acknowledges that you clicked the button, and closes the message.

I am trying to simulate this button click.  I have tried using a System.Windows.Forms.WebBrowser class, but I have not been able to load my resultContent into the Browser, the DocumentText property remains empty, so when I try to invoke the button click, I get a null reference exception.

```<code>handler = new HttpClientHandler();
handler.CookieContainer = cookies;
handler.AllowAutoRedirect = false;

using (var client = new HttpClient(handler)){
    string resultContent = result.Content.ReadAsStringAsync().Result;
    System.Windows.Forms.WebBrowser b = new System.Windows.Forms.WebBrowser();
    b.Navigate("about:blank");
    HtmlDocument doc = b.Document;
    doc.Write(string.Empty);
    b.DocumentText = resultContent;
    var resp = b.Document.GetElementById("frmMessages:btnAcknowledge").InvokeMember("onclick");
}
</code>```

It seems to me that the owner of the web page screwed something up here by inserting the HTML message page in front of a REST API call, and I have contacted them about that, however between now and when they can fix it (if it is even an issue to them) I need a method of bypassing this message box.

答: The owner of the website fixed the issue on their end.  I was never able to find a way to do this, but the issue has been resolved.</p>

Body:
I am trying to navigate to a REST API, however the owner of the web page has inserted an HTML message page in front of the REST API URL.  So, when I make the request to the REST API, instead of being returned the XML file that I requested, I get back an HTML page that has some informational message on it, and requires a button click to acknowledge the message.

The button itself, when inspected with Fiddler, shows no onclick event:

    <button id="frmMessages:btnAcknowledge" name="frmMessages:btnAcknowledge" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" onclick="" title="Acknowledge and continue" type="submit">
        OK
    </button>

I am not able to navigate directly to the page where the button-click sends you, because it doesn't send you anywhere, it just acknowledges that you clicked the button, and closes the message.

I am trying to simulate this button click.  I have tried using a System.Windows.Forms.WebBrowser class, but I have not been able to load my resultContent into the Browser, the DocumentText property remains empty, so when I try to invoke the button click, I get a null reference exception.

handler = new HttpClientHandler();
handler.CookieContainer = cookies;
handler.AllowAutoRedirect = false;

using (var client = new HttpClient(handler)){
    string resultContent = result.Content.ReadAsStringAsync().Result;
    System.Windows.Forms.WebBrowser b = new System.Windows.Forms.WebBrowser();
    b.Navigate("about:blank");
    HtmlDocument doc = b.Document;
    doc.Write(string.Empty);
    b.DocumentText = resultContent;
    var resp = b.Document.GetElementById("frmMessages:btnAcknowledge").InvokeMember("onclick");
}

It seems to me that the owner of the web page screwed something up here by inserting the HTML message page in front of a REST API call, and I have contacted them about that, however between now and when they can fix it (if it is even an issue to them) I need a method of bypassing this message box.


问:
Swift border color
I want to have color border on button:

```<code>buyButton.layer.borderColor = UIColor(red: 83.0, green: 186.0, blue: 183.0, alpha: 1.0).cgColor
</code>```

doesn't work for me, but

```<code> buyButton.layer.borderColor = UIColor.blue.cgColor
</code>```

works. What is wrong with my color?

Thank you

答:
The input values needs to be between 0 and 1, so divide them by 255.</p>

```<code>buyButton.layer.borderColor = UIColor(red: 83.0/255.0, green: 186.0/255.0, blue: 183.0/255.0, alpha: 1.0).cgColor
</code>```

Title: Swift border color

Body:
I want to have color border on button:

buyButton.layer.borderColor = UIColor(red: 83.0, green: 186.0, blue: 183.0, alpha: 1.0).cgColor

doesn't work for me, but

 buyButton.layer.borderColor = UIColor.blue.cgColor

works. What is wrong with my color?

Thank you

Body:
The input values needs to be between 0 and 1, so divide them by 255.

buyButton.layer.borderColor = UIColor(red: 83.0/255.0, green: 186.0/255.0, blue: 183.0/255.0, alpha: 1.0).cgColor


答:
This is almost always caused by a missing ; in the header BEFORE the one where the error is reported.

What does Stop.cpp include before Time.h? Look at the end of that file and you'll probably see where the problem is.

Title: Error C2143 (missing ; before namespace) in MS VC include


问:
TableLayout rows don't shrink equally but only last row does on different screen sizes
I have created a table in which i want to display 9 animals and a next arrow button. Each row has 3 animals, so that's 3 rows for the animals and one last row for the next arrow button. My problem is that on different screen sizes, the rows don't shrink equally but only the last row does having as a result, the next arrow button to disappear.

This is how it looks on a Nexus 4

And that's how it looks an a smaller screen that has a 3.2" size

And here is my XML code

```<code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_animals"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@color/background"
tools:context="kidsbook.jok.kidsbook.Animals">

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/ads_text"
    android:weightSum=".9"
    android:id="@+id/animalsPage1"
    android:visibility="visible">

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum=".9">

        <Button
            android:background="@drawable/cat"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/catSounds"
            android:layout_weight=".3"/>

        <Button
            android:background="@drawable/dog"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/dogSounds"
            android:layout_weight=".3"/>

        <Button
            android:background="@drawable/chicken"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/chickenSounds"
            android:layout_weight=".3"/>
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum=".9">

        <Button
            android:background="@drawable/horse"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/horseSounds"
            android:layout_weight=".3"/>

        <Button
            android:background="@drawable/frog"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/frogSounds"
            android:layout_weight=".3"/>

        <Button
            android:background="@drawable/pig"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/pigSounds"
            android:layout_weight=".3"/>
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum=".9">

        <Button
            android:background="@drawable/cock"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/cockSounds"
            android:layout_weight=".3"/>

        <Button
            android:background="@drawable/donkey"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/donkeySounds"
            android:layout_weight=".3"/>

        <Button
            android:background="@drawable/sheep"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/sheepSounds"
            android:layout_weight=".3"/>
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="end"
        android:weightSum="1">

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight=".22"
            android:id="@+id/nextButtonAnimalsTo2"
            android:background="@drawable/next_arrow"
            android:onClick="toPage2from1"/>
    </TableRow>

</TableLayout>

<TextView
    android:text="@string/ads"
    android:layout_gravity="center"
    android:layout_width="match_parent"
    android:minHeight="50dp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:textSize="20sp"
    android:id="@+id/ads_text"
    android:layout_alignParentBottom="true"/>

</RelativeLayout>
</code>```

Any suggestions and help would be highly appreciated and thank you all in advance.

答:
Try this layout: use a Linearlayout instead of Relativelayout and manage layout weight and weightsum properly to divide the screen.

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_animals"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/color_white"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:weightSum="5">

    <TableLayout
        android:id="@+id/animalsPage1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_above="@+id/ads_text"
        android:layout_weight="4"
        android:visibility="visible"
        android:weightSum="4">

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:weightSum="3">

            <Button
                android:id="@+id/catSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />

            <Button
                android:id="@+id/dogSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />

            <Button
                android:id="@+id/chickenSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:weightSum="3">

            <Button
                android:id="@+id/horseSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />

            <Button
                android:id="@+id/frogSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />

            <Button
                android:id="@+id/pigSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:weightSum="3">

            <Button
                android:id="@+id/cockSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />

            <Button
                android:id="@+id/donkeySounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />

            <Button
                android:id="@+id/sheepSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="end"
            android:weightSum="3">

            <Button
                android:id="@+id/nextButtonAnimalsTo2"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher"
                android:onClick="toPage2from1" />
        </TableRow>

    </TableLayout>

    <TextView
        android:id="@+id/ads_text"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_alignParentBottom="true"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:gravity="center"
        android:text="Your TEXT"
        android:textColor="#000000"
        android:textSize="20sp" />

</LinearLayout>
</code>```

output:

Body:
I have created a table in which i want to display 9 animals and a next arrow button. Each row has 3 animals, so that's 3 rows for the animals and one last row for the next arrow button. My problem is that on different screen sizes, the rows don't shrink equally but only the last row does having as a result, the next arrow button to disappear.

This is how it looks on a Nexus 4

And that's how it looks an a smaller screen that has a 3.2" size

And here is my XML code

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_animals"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@color/background"
tools:context="kidsbook.jok.kidsbook.Animals">

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/ads_text"
    android:weightSum=".9"
    android:id="@+id/animalsPage1"
    android:visibility="visible">

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum=".9">

        <Button
            android:background="@drawable/cat"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/catSounds"
            android:layout_weight=".3"/>

        <Button
            android:background="@drawable/dog"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/dogSounds"
            android:layout_weight=".3"/>

        <Button
            android:background="@drawable/chicken"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/chickenSounds"
            android:layout_weight=".3"/>
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum=".9">

        <Button
            android:background="@drawable/horse"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/horseSounds"
            android:layout_weight=".3"/>

        <Button
            android:background="@drawable/frog"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/frogSounds"
            android:layout_weight=".3"/>

        <Button
            android:background="@drawable/pig"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/pigSounds"
            android:layout_weight=".3"/>
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum=".9">

        <Button
            android:background="@drawable/cock"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/cockSounds"
            android:layout_weight=".3"/>

        <Button
            android:background="@drawable/donkey"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/donkeySounds"
            android:layout_weight=".3"/>

        <Button
            android:background="@drawable/sheep"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:id="@+id/sheepSounds"
            android:layout_weight=".3"/>
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="end"
        android:weightSum="1">

        <Button
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight=".22"
            android:id="@+id/nextButtonAnimalsTo2"
            android:background="@drawable/next_arrow"
            android:onClick="toPage2from1"/>
    </TableRow>

</TableLayout>

<TextView
    android:text="@string/ads"
    android:layout_gravity="center"
    android:layout_width="match_parent"
    android:minHeight="50dp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:textSize="20sp"
    android:id="@+id/ads_text"
    android:layout_alignParentBottom="true"/>

</RelativeLayout>

Any suggestions and help would be highly appreciated and thank you all in advance.

Body:
Try this layout: use a Linearlayout instead of Relativelayout and manage layout weight and weightsum properly to divide the screen.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_animals"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/color_white"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:weightSum="5">

    <TableLayout
        android:id="@+id/animalsPage1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_above="@+id/ads_text"
        android:layout_weight="4"
        android:visibility="visible"
        android:weightSum="4">

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:weightSum="3">

            <Button
                android:id="@+id/catSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />

            <Button
                android:id="@+id/dogSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />

            <Button
                android:id="@+id/chickenSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:weightSum="3">

            <Button
                android:id="@+id/horseSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />

            <Button
                android:id="@+id/frogSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />

            <Button
                android:id="@+id/pigSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:weightSum="3">

            <Button
                android:id="@+id/cockSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />

            <Button
                android:id="@+id/donkeySounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />

            <Button
                android:id="@+id/sheepSounds"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher" />
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="end"
            android:weightSum="3">

            <Button
                android:id="@+id/nextButtonAnimalsTo2"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@mipmap/ic_launcher"
                android:onClick="toPage2from1" />
        </TableRow>

    </TableLayout>

    <TextView
        android:id="@+id/ads_text"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_alignParentBottom="true"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:gravity="center"
        android:text="Your TEXT"
        android:textColor="#000000"
        android:textSize="20sp" />

</LinearLayout>

output:


问:
How to add animation to hamburger menu Bootstrap 4?
I am working on a website where I'd like to add an animation to my static navbar from Bootstrap. I want the 3 horizontal bars to change to an X when the button is toggled on mobile viewport.

Note: I am using Bootstrap 4, not 3. Some BS3 classes don't work in BS4

This is what I am trying to accomplish: example. However, I've found multiple tutorials but I am struggling with it. The reason for this is that all those tutorials are based on BS3. BS3 uses the navbar-toggle-class, but BS4 uses the navbar-toggler-class. It's major difference, since the BS4-version contains a viewbox in css:

```<code>.navbar-toggler {
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(0, 0, 0, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");
    border-color: rgba(0,0,0,.1);
}
</code>```

And in the bootstrap.min.css the navbar-toggler-class is being used for 11 times. So if I modify this class, it will (probably) break.

```<code>HTML of menu:
<div class="container">
        <div class="row hidden-lg-up">
            <div class="wrapper-right">
                <a href="#"><img src="img/placeholders/225x50.png" alt="Logo Company Mobile" class="mobile-only" /></a>
            </div>
        </div>
        <div class="row">
            <nav class="navbar navbar-light navbar-full">
                <button class="navbar-toggler hidden-lg-up" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"></button>
                <div class="collapse navbar-toggleable-md" id="navbarResponsive">
                    <a class="navbar-brand vc-parent" href="#">
                        <img src="img/placeholders/250x50.png" alt="Logo Company Desktop" class="img-fluid desktop-only" />
                    </a>
                    <ul class="nav navbar-nav navbar-right">
                        <li class="nav-item active align-middle">
                            <a class="nav-link" href="#">Home</a>
                        </li>
                        <li class="nav-item align-middle">
                            <a class="nav-link" href="#">Item</a>
                        </li>
                        <li class="nav-item align-middle">
                            <a class="nav-link" href="#">Item</a>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>
    </div>
</code>```

Could anyone point me in the right direction?

答:
Change .navbar-toggler-icon background when menu is opened to </p>

```<code>background-image:url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='white' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8l20 16M4 24L24 8'/%3E%3C/svg%3E");
</code>```

Body:
I am working on a website where I'd like to add an animation to my static navbar from Bootstrap. I want the 3 horizontal bars to change to an X when the button is toggled on mobile viewport.

Note: I am using Bootstrap 4, not 3. Some BS3 classes don't work in BS4

This is what I am trying to accomplish: example. However, I've found multiple tutorials but I am struggling with it. The reason for this is that all those tutorials are based on BS3. BS3 uses the navbar-toggle-class, but BS4 uses the navbar-toggler-class. It's major difference, since the BS4-version contains a viewbox in css:

.navbar-toggler {
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(0, 0, 0, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");
    border-color: rgba(0,0,0,.1);
}

And in the bootstrap.min.css the navbar-toggler-class is being used for 11 times. So if I modify this class, it will (probably) break.

HTML of menu:

                <button class="navbar-toggler hidden-lg-up" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"></button>

                            Home

                            Item

                            Item

Could anyone point me in the right direction?

Body:
Change .navbar-toggler-icon background when menu is opened to

background-image:url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='white' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8l20 16M4 24L24 8'/%3E%3C/svg%3E");


问:
How would you optimize log4net debugging when using log4net.async?
I started using log4net.async to log using a separate thread but the performance hasn't improved as much as I had anticipated initially and I understand the reason for that being that some of the strings we are logging are very long because they describe properties of a message that is received.

So for example, we could do:

```<code>theLogger.Debug(msg.ToString());
</code>```

When the "ToString()" method is called it could generate a really long string representing a message and it might take awhile to actually generate it (slow deserialization, etc.). Although it is important for me to log the message I would prefer to "stringify" the message on a separate thread rather than the currently running thread so that my currently running thread can continue processing. How would I make log4net evaluate the "ToString()" result or "stringify" the message object on a separate thread?

答:
If you want to defer the string creation to a later point in time (potentially in a separate thread) you could create a wrapper that accepts a Func<object, string> that will be invoked only when needed. That wrapper could then also do the dispatch to a separate thread.

In addition, I would recomment to perform some benchmarks on your current string operations and the overhead of dispatching to a separate thread with Func invokcation.

Body:
I started using log4net.async to log using a separate thread but the performance hasn't improved as much as I had anticipated initially and I understand the reason for that being that some of the strings we are logging are very long because they describe properties of a message that is received.

So for example, we could do:

theLogger.Debug(msg.ToString());

When the "ToString()" method is called it could generate a really long string representing a message and it might take awhile to actually generate it (slow deserialization, etc.). Although it is important for me to log the message I would prefer to "stringify" the message on a separate thread rather than the currently running thread so that my currently running thread can continue processing. How would I make log4net evaluate the "ToString()" result or "stringify" the message object on a separate thread?


问:
Send commands from file to a server - robotframework
I have a question related to RobotFramework, more exactly reading a file, grep it for different commands, add them to a dictionary and then send them commands to a server.

Let me show you what do I have now.

I have the second function called Send commands from file to server

```<code>Send commands from file to server
    [Arguments]  ${COMMANDS_FILE}
    ${FILE_CONTENT}=  Get File  ${COMMANDS_FILE}
    @{LINES}=  Split to Lines  ${FILE_CONTENT}
    : FOR  ${line}  IN  @{LINES}
    \  Send command  ${line}
</code>```

Send command is a keyword that works fine, just sends commands to the server.

The commands file looks something like this (commands.txt):

```<code>  VAL1;VAL2;VAL3;
  VAL1;VAL4;VAL5;
  VAL6;VAL7;VAL8
  VAL6;VAL7;VAL8
</code>```

So as you can see VAL1 is the same on both rows.

How can I get VAL1 and save it somewhere (dict or list) and then run all commands from file that contains VAL1?

答:
You have to further split each line - on the ;, and check is the first command the one you look for. Here's how based on your code:

```<code>Send commands from file to server
    [Arguments]  ${COMMANDS_FILE}
    ${FILE_CONTENT}=  Get File  ${COMMANDS_FILE}

    @{LINES}=  Split to Lines  ${FILE_CONTENT}
    ${commands to run}=     Create List  # will store only the commands you want to run
    :FOR    ${line}  IN  @{LINES}
        \   ${members}=      Split String     ${line}     separator=;    # each command in the line is a list member now
        \   Run Keyword If      $members[0] == 'VAL1'       Append To List      ${commands to run}      ${line}

    :FOR    ${command_line}     IN      @{commands to run}
    \   Send Command  ${command_line}
</code>```

Body:
I have a question related to RobotFramework, more exactly reading a file, grep it for different commands, add them to a dictionary and then send them commands to a server.

Let me show you what do I have now.

I have the second function called Send commands from file to server

Send commands from file to server
    [Arguments]  ${COMMANDS_FILE}
    ${FILE_CONTENT}=  Get File  ${COMMANDS_FILE}
    @{LINES}=  Split to Lines  ${FILE_CONTENT}
    : FOR  ${line}  IN  @{LINES}
    \  Send command  ${line}

Send command is a keyword that works fine, just sends commands to the server.

The commands file looks something like this (commands.txt):

  VAL1;VAL2;VAL3;
  VAL1;VAL4;VAL5;
  VAL6;VAL7;VAL8
  VAL6;VAL7;VAL8

So as you can see VAL1 is the same on both rows.

How can I get VAL1 and save it somewhere (dict or list) and then run all commands from file that contains VAL1?

Body:
You have to further split each line - on the ;, and check is the first command the one you look for. Here's how based on your code:

Send commands from file to server
    [Arguments]  ${COMMANDS_FILE}
    ${FILE_CONTENT}=  Get File  ${COMMANDS_FILE}

    @{LINES}=  Split to Lines  ${FILE_CONTENT}
    ${commands to run}=     Create List  # will store only the commands you want to run
    :FOR    ${line}  IN  @{LINES}
        \   ${members}=      Split String     ${line}     separator=;    # each command in the line is a list member now
        \   Run Keyword If      $members[0] == 'VAL1'       Append To List      ${commands to run}      ${line}

    :FOR    ${command_line}     IN      @{commands to run}
    \   Send Command  ${command_line}


问:
Broken image but path is correct
My file directory

This is a picture of my file directory. When I try to add the image to my index file with the proper path, I keep getting an error telling me the image is not found. The image is there and this doesnt make sense... What could be a possible issue with it besides the path?

答:
Try this

```<code><img src="/logo.png" alt="logo"/>
</code>```

instead of

```<code><img src="logo.png" alt="logo"/>
</code>```

just add "/" before the logo.png like /logo.png

Title: Broken image but path is correct

Body:
Try this

<img src="/logo.png" alt="logo"/>

instead of

<img src="logo.png" alt="logo"/>

just add "/" before the logo.png like /logo.png


问:
How to make a background responsive not only vertically or horizontally but both?
I want to create a login page which has a picture background.
I like this login portal office login page so it's a reference to me. I noticed that on office login page, picture is not affected from vertically or horizontally resize but if i change from the corner it's resizing.

I've tried to change width and height attributes with several types (like; auto, % or vh) but i could'nt find the correct settings for that.

What is the magic behind this? Is there any javascript activities that i missed?
Any ideas?

答:
Use background-size and background-position at the same time to get that:</p>

```<code>background-size: cover;
background-attachment: fixed;
</code>```

Body:
Use background-size and background-position at the same time to get that:

background-size: cover;
background-attachment: fixed;


问:
How to specify path in .config file relative path to folder?
I have folder "NuGetPackages". I need to access only the folder on my computer is OK but on server is different folder structure where the project is store
what i use on my computer absolute path:

C:\workspace\HUD\02_Development\04_Tools\NuGetServer\NuGetPackages

What should I write in the config file to make sure the path is ..\NuGetPackages expanded relative to the config file rather the working?
 directory?

I can't change the app I can only change the config file.
I have also try "~/NuGetPackages" but didn't work.

答:
In short, you can't do exactly what you're trying to do.

If you can't change any of the code, your only real option is to use config transforms. You can have your *.Debug.config use your local path, and then your *.Release.config (or whatever your published build configuration is), and use the server's path.

Here are some docs on doing config transforms: https://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx


问:
Powershell exit status
what's the powershell equivalent of simply:

```<code>bash test.sh
</code>```

I'd like to call a powershell script (from outside a powershell environment) and be able to get a return value of 0 if it executed successfully, and otherwise a non-zero value if either:

the powershell executable can't be found or executed

the script test.ps1 can't be found or executed (insufficient permissions, ...)

the script test.ps1 can be read and executed but returns a non zero value

And then, how to access this return value, which in linux would be

```<code>echo $?
</code>```

答:
In cmd you can use the %ERRORLEVEL% variable to check for any error code returned by the last command. If this was incorrect or not found this will be different from zero.
This will already take care of the first 2 cases, where powershell.exe is not found or the script can't be found.

To return an errorcode from a powershell script use the exit <errorcode> statement.

You can check this in PS using the $LASTEXITCODE variable.
To return this into your calling batch process, you can use the following structure:

```<code>powershell.exe -noprofile -command ". c:\t\returnCode.ps1 ; exit $LASTEXITCODE "
if %errorlevel%==0 (echo "yep") else (echo "nope")
</code>```

Where the returncode.ps1 script is like:

```<code># do stuff
exit 1234
</code>```

Title: Powershell exit status

Body:
what's the powershell equivalent of simply:

bash test.sh

I'd like to call a powershell script (from outside a powershell environment) and be able to get a return value of 0 if it executed successfully, and otherwise a non-zero value if either:

the powershell executable can't be found or executed

the script test.ps1 can't be found or executed (insufficient permissions, ...)

the script test.ps1 can be read and executed but returns a non zero value

And then, how to access this return value, which in linux would be

echo $?

Body:
In cmd you can use the %ERRORLEVEL% variable to check for any error code returned by the last command. If this was incorrect or not found this will be different from zero.
This will already take care of the first 2 cases, where powershell.exe is not found or the script can't be found.

To return an errorcode from a powershell script use the exit <errorcode> statement.

You can check this in PS using the $LASTEXITCODE variable.
To return this into your calling batch process, you can use the following structure:

powershell.exe -noprofile -command ". c:\t\returnCode.ps1 ; exit $LASTEXITCODE "
if %errorlevel%==0 (echo "yep") else (echo "nope")

Where the returncode.ps1 script is like:

# do stuff
exit 1234