问:
own len function with recursion in Go
I'm trying to build simple function to count elements in slice (like len) It must be simple (without additional libs) and with recursion. The problem is when i try to check is slice is empty (is nul).

```<code>package main
import "fmt"

func main() {
  x := []int{1, 2, 3}
  fmt.Println(len2(x))
}
func len2(s []int) int {
  if s == nil {
    return 0
  }
  return 1 + len2(s[1:])
}
</code>```

the result it should be in this example '3'.

It's broken in if s == nil:

```<code>panic: runtime error: slice bounds out of range
</code>```

答:
The following is not a solution with better performance than len but an implementation that does not use any extra libraries and depends on recursion to find length

```<code>func len2(s []int) (count int) {
    defer func() {
        if r := recover(); r != nil {
            count = 0
        }
    }()

    return 1 + len2(s[1:])
}
</code>```

Here is sample code

```<code>package main

import "fmt"

func main() {
    var x []int = nil
    var x1 = []int{1, 2, 3, 4}
    var x2 = []int{}
    var x3 = make([]int, 10, 20)
    fmt.Println(len2(x))
    fmt.Println(len2(x1))
    fmt.Println(len2(x2))
    fmt.Println(len2(x3))
}

func len2(s []int) (count int) {
    defer func() {
        if r := recover(); r != nil {
            count = 0
        }
    }()

    return 1 + len2(s[1:])
}
</code>```

Checkout the same in playground

Title: own len function with recursion in Go

Body:
I'm trying to build simple function to count elements in slice (like len) It must be simple (without additional libs) and with recursion. The problem is when i try to check is slice is empty (is nul).

package main
import "fmt"

func main() {
  x := []int{1, 2, 3}
  fmt.Println(len2(x))
}
func len2(s []int) int {
  if s == nil {
    return 0
  }
  return 1 + len2(s[1:])
}

the result it should be in this example '3'.

It's broken in if s == nil:

panic: runtime error: slice bounds out of range

Body:
The following is not a solution with better performance than len but an implementation that does not use any extra libraries and depends on recursion to find length

func len2(s []int) (count int) {
    defer func() {
        if r := recover(); r != nil {
            count = 0
        }
    }()

    return 1 + len2(s[1:])
}

Here is sample code

package main

import "fmt"

func main() {
    var x []int = nil
    var x1 = []int{1, 2, 3, 4}
    var x2 = []int{}
    var x3 = make([]int, 10, 20)
    fmt.Println(len2(x))
    fmt.Println(len2(x1))
    fmt.Println(len2(x2))
    fmt.Println(len2(x3))
}

func len2(s []int) (count int) {
    defer func() {
        if r := recover(); r != nil {
            count = 0
        }
    }()

    return 1 + len2(s[1:])
}

Checkout the same in playground


来源: stackexchange

问:
libgdx firing event from actor to call another actor
I'm using Scene2D and have 2 actors. When MyActor1 is touched, it should fire an event which should be handled by MyActor2. I've tried several different variants on how to fire and even from MyActor1, but it is still not being handled by MyActor2. The full code is below.

Game class which just forwards to a Screen

```<code>public class MyGdxGame extends Game {
   @Override
   public void create() {
       setScreen(new MyGdxScreen());
   }
}
</code>```

Screen class (empty methods ommited)

```<code>public class MyGdxScreen implements Screen {

   private Stage stage;

   @Override
   public void show() {
       stage = new Stage(new ScreenViewport());
       stage.addActor(new MyActor1());
       stage.addActor(new MyActor2());
       Gdx.input.setInputProcessor(stage);
   }

   @Override
   public void render(float delta) {
       Gdx.gl.glClearColor(1, 1, 1, 1);
       Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

       stage.act(delta);
       stage.draw();
   }

   @Override
   public void dispose() {
       stage.dispose();
   }
}
</code>```

First Actor (fires custom event when touched)

```<code>public class MyActor1 extends Actor {

   private Texture image;

   public MyActor1() {
       this.image = new Texture("badlogic.jpg");

       setPosition(0, 0);
       setBounds(0, 0, image.getWidth(), image.getHeight());
       setTouchable(Touchable.enabled);

       addListener(new InputListener() {
           @Override
           public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
               Gdx.app.log("touched", "First actor touched!");
               MyActor1.this.fire(new ActorTouchedListener.ActorTouchedEvent());
               MyActor1.this.getParent().fire(new ActorTouchedListener.ActorTouchedEvent());
               return true;
           }
       });
   }

   @Override
   public void draw(Batch batch, float parentAlpha) {
       batch.draw(image, 0, 0, image.getWidth(), image.getHeight());
   }
}
</code>```

Second Actor (should handle an Event fired by Actor1)

```<code>public class MyActor2 extends Actor {

   public MyActor2() {
       addListener(new ActorTouchedListener());
   }
}
</code>```

Event listener

```<code>public class ActorTouchedListener implements EventListener {
   @Override
   public boolean handle(Event event) {
       if (event instanceof ActorTouchedEvent) {
           Gdx.app.log("fired", "Second actor got event!");
           return true;
       }
       return false;
   }

public static class ActorTouchedEvent extends Event {
     public ActorTouchedEvent() {
     }
   }
}
</code>```

答:
These two lines do nothing.

```<code>MyActor1.this.fire(new ActorTouchedListener.ActorTouchedEvent());
MyActor1.this.getParent().fire(new ActorTouchedListener.ActorTouchedEvent());
</code>```

To call Actor from another Actor you should create instance of it.

```<code>public class MyActor1 extends Actor {

   private Texture image;
   private Actor actor2; // instance of MyActor2

   public MyActor1(actor2: Actor) {
       this.image = new Texture("badlogic.jpg");
       this.actor2 = actor2;

       setPosition(0, 0);
       setBounds(0, 0, image.getWidth(), image.getHeight());
       setTouchable(Touchable.enabled);

       addListener(new InputListener() {
           @Override
           public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
               Gdx.app.log("touched", "First actor touched!");
               actor2.fire(event);  // Here we fire event on MyActor2
               return true;
           }
       });
   }

   @Override
   public void draw(Batch batch, float parentAlpha) {
       batch.draw(image, 0, 0, image.getWidth(), image.getHeight());
   }
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I'm using Scene2D and have 2 actors. When MyActor1 is touched, it should fire an event which should be handled by MyActor2. I've tried several different variants on how to fire and even from MyActor1, but it is still not being handled by MyActor2. The full code is below.

Game class which just forwards to a Screen

public class MyGdxGame extends Game {
   @Override
   public void create() {
       setScreen(new MyGdxScreen());
   }
}

Screen class (empty methods ommited)

public class MyGdxScreen implements Screen {

   private Stage stage;

   @Override
   public void show() {
       stage = new Stage(new ScreenViewport());
       stage.addActor(new MyActor1());
       stage.addActor(new MyActor2());
       Gdx.input.setInputProcessor(stage);
   }

   @Override
   public void render(float delta) {
       Gdx.gl.glClearColor(1, 1, 1, 1);
       Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

       stage.act(delta);
       stage.draw();
   }

   @Override
   public void dispose() {
       stage.dispose();
   }
}

First Actor (fires custom event when touched)

public class MyActor1 extends Actor {

   private Texture image;

   public MyActor1() {
       this.image = new Texture("badlogic.jpg");

       setPosition(0, 0);
       setBounds(0, 0, image.getWidth(), image.getHeight());
       setTouchable(Touchable.enabled);

       addListener(new InputListener() {
           @Override
           public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
               Gdx.app.log("touched", "First actor touched!");
               MyActor1.this.fire(new ActorTouchedListener.ActorTouchedEvent());
               MyActor1.this.getParent().fire(new ActorTouchedListener.ActorTouchedEvent());
               return true;
           }
       });
   }

   @Override
   public void draw(Batch batch, float parentAlpha) {
       batch.draw(image, 0, 0, image.getWidth(), image.getHeight());
   }
}

Second Actor (should handle an Event fired by Actor1)

public class MyActor2 extends Actor {

   public MyActor2() {
       addListener(new ActorTouchedListener());
   }
}

Event listener

public class ActorTouchedListener implements EventListener {
   @Override
   public boolean handle(Event event) {
       if (event instanceof ActorTouchedEvent) {
           Gdx.app.log("fired", "Second actor got event!");
           return true;
       }
       return false;
   }

public static class ActorTouchedEvent extends Event {
     public ActorTouchedEvent() {
     }
   }
}

Body:
These two lines do nothing.

MyActor1.this.fire(new ActorTouchedListener.ActorTouchedEvent());
MyActor1.this.getParent().fire(new ActorTouchedListener.ActorTouchedEvent());

To call Actor from another Actor you should create instance of it.

public class MyActor1 extends Actor {

   private Texture image;
   private Actor actor2; // instance of MyActor2

   public MyActor1(actor2: Actor) {
       this.image = new Texture("badlogic.jpg");
       this.actor2 = actor2;

       setPosition(0, 0);
       setBounds(0, 0, image.getWidth(), image.getHeight());
       setTouchable(Touchable.enabled);

       addListener(new InputListener() {
           @Override
           public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
               Gdx.app.log("touched", "First actor touched!");
               actor2.fire(event);  // Here we fire event on MyActor2
               return true;
           }
       });
   }

   @Override
   public void draw(Batch batch, float parentAlpha) {
       batch.draw(image, 0, 0, image.getWidth(), image.getHeight());
   }
}


问:
Link doesn't trigger any jquery action through Cucumber, Capybara
The thing is that I have some html page with a little of jquery that when I press the link "Add new booking number" it triggers some Jquery code that appends a new input text to the view, when I test it through the web browser it works, but I have this steps in a cucumber feature:

```<code>1. And I fill in "Booking" with "2FD5623A6"
2. And I follow "Add new booking number"
3. And show me the page
4. And I fill in "Booking 2" with "HGJD8FDU7"
</code>```

the step 4. fails because the booking 2 label isn't generated when clicking the "Add new booking number" link, but with the step 3, when I manually click that link, the new field is correctly generated, so I don't know what's happening

I just solved a problem with capybara and cucumber-rails, I commented the following line

```<code># require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
</code>```

because of this issue https://github.com/jnicklas/capybara/issues/issue/110

My gem versions are:

```<code>Using capybara (0.4.1)  Using
cucumber (0.10.0)  Using
cucumber-rails (0.3.2)
</code>```

Can anyone can help me, please?

答:
Tag your scenario with @javascript if you haven't done so yet.

```<code>@javascript
Scenario: do something AJAXy
  When I click the AJAX link
  …
</code>```

ContentLicense: CC BY-SA 2.5

Body:
The thing is that I have some html page with a little of jquery that when I press the link "Add new booking number" it triggers some Jquery code that appends a new input text to the view, when I test it through the web browser it works, but I have this steps in a cucumber feature:

1. And I fill in "Booking" with "2FD5623A6"
2. And I follow "Add new booking number"
3. And show me the page
4. And I fill in "Booking 2" with "HGJD8FDU7"

the step 4. fails because the booking 2 label isn't generated when clicking the "Add new booking number" link, but with the step 3, when I manually click that link, the new field is correctly generated, so I don't know what's happening

I just solved a problem with capybara and cucumber-rails, I commented the following line

# require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript

because of this issue https://github.com/jnicklas/capybara/issues/issue/110

My gem versions are:

Using capybara (0.4.1)  Using
cucumber (0.10.0)  Using
cucumber-rails (0.3.2)

Can anyone can help me, please?

Body:
Tag your scenario with @javascript if you haven't done so yet.

@javascript
Scenario: do something AJAXy
  When I click the AJAX link
  …


问:
Regular expression to select strings with a character appearing on odd occurences
I'm trying to create a regex that will select words where the quote character appears on odd occurences. And I'm stuck...

Let's say I have these 4 strings :

hello'

pl'pl'op

'heger

qwe'rty

I should get this list in return :

hello'

'heger

qwe'rty

I'm running around in circles and I don't even know if it is possible to do that in a regex. I'm not so good in regex.

Should I just loop on each characters of all the strings, count the amount of quotes and do a modulo operation to check if the number is odd?

答:
You don't need a regular expression. Just check if countMatches return an odd or not

```<code>public class Main {

    public static void main(String[] args) {
        String check = "pl'pl'op";

        System.out.println("Ocurrences: " + StringUtils.countMatches(check, "'"));

    }
}
</code>```

Output: Ocurrences: 2

Body:
You don't need a regular expression. Just check if countMatches return an odd or not

public class Main {

    public static void main(String[] args) {
        String check = "pl'pl'op";

        System.out.println("Ocurrences: " + StringUtils.countMatches(check, "'"));

    }
}

Output: Ocurrences: 2


问:
Fallback method is not being called when rest call is failed by using feign client
I am trying to implement fallback by using Feign client but not getting success.Its a simplest code Please find below.

Main Class

```<code>@SpringBootApplication
@EnableDiscoveryClient
@RestController
@EnableFeignClients
public class EurekaClient1Application {

    @Autowired
    public DiscoveryClient discoveryClient;

    public static void main(String[] args) {
        SpringApplication.run(EurekaClient1Application.class, args);
    }

    @Autowired
    FeingInterface feingInterface;

    @GetMapping("/hi/{name}")
    public String test(@PathVariable String name)
    {
        String h = feingInterface.test(name);

        return h;
    }
}
</code>```

Feign interface

```<code>@FeignClient(name="client22",fallback=FallBack.class)
public interface FeingInterface {

    @GetMapping("/hiname/{name}")
    public String test(@PathVariable("name") String name);

}
</code>```

fallback class

```<code>@Component
class FallBack implements FeingInterface{

    @Override
    public String test(String name) {
        // TODO Auto-generated method stub
        return "fall back methord being called";
    }

}
</code>```

Getting Error in rest client but not from fallback method

"timestamp": 1501950134118,
      "status": 500,
      "error": "Internal Server Error",
      "exception": "java.lang.RuntimeException",
      "message": "com.netflix.client.ClientException: Load balancer does not have available server for client: client22",

To get the fallback method message I passed client22 eureka id which is not there in eureka server. I have stater-feign in pom. Can someone look into this.

答:
Fallbacks are actually not handled by Feign itself, but by a circuit breaker. So, you need to put Hystrix (which is the Netflix circuit breaker) on your classpath and enable it in your application.yml file like this:

```<code>feign:
  hystrix:
    enabled: true
</code>```

If you're using 'cloud:spring-cloud-starter-openfeign' in your build.gradle or pom.xml file, Hystrix should be automatically on your classpath.

Body:
I am trying to implement fallback by using Feign client but not getting success.Its a simplest code Please find below.

Main Class

@SpringBootApplication
@EnableDiscoveryClient
@RestController
@EnableFeignClients
public class EurekaClient1Application {

    @Autowired
    public DiscoveryClient discoveryClient;

    public static void main(String[] args) {
        SpringApplication.run(EurekaClient1Application.class, args);
    }

    @Autowired
    FeingInterface feingInterface;

    @GetMapping("/hi/{name}")
    public String test(@PathVariable String name)
    {
        String h = feingInterface.test(name);

        return h;
    }
}

Feign interface

@FeignClient(name="client22",fallback=FallBack.class)
public interface FeingInterface {

    @GetMapping("/hiname/{name}")
    public String test(@PathVariable("name") String name);

}

fallback class

@Component
class FallBack implements FeingInterface{

    @Override
    public String test(String name) {
        // TODO Auto-generated method stub
        return "fall back methord being called";
    }

}

Getting Error in rest client but not from fallback method

"timestamp": 1501950134118,
      "status": 500,
      "error": "Internal Server Error",
      "exception": "java.lang.RuntimeException",
      "message": "com.netflix.client.ClientException: Load balancer does not have available server for client: client22",

To get the fallback method message I passed client22 eureka id which is not there in eureka server. I have stater-feign in pom. Can someone look into this.

Body:
Fallbacks are actually not handled by Feign itself, but by a circuit breaker. So, you need to put Hystrix (which is the Netflix circuit breaker) on your classpath and enable it in your application.yml file like this:

feign:
  hystrix:
    enabled: true

If you're using 'cloud:spring-cloud-starter-openfeign' in your build.gradle or pom.xml file, Hystrix should be automatically on your classpath.


问:
How to change message of success when adding product to cart in Woocommerce?
Well, the functionality of adding the product to the cart via ajax is 100% working, however a message below appears like this

Well, the code generated is this, automatic whenever the product is added to the cart successfully

```<code><a href="http://www.shopurl.com/cart/" class="added_to_cart wc-forward" title="View Cart">View Cart</a>
</code>```

I want to know how you can edit this particular line

答:
@credited to helgatheviking on her answer here

You can filter the checkout url via woocommerce_get_checkout_url

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

    // Force SSL if needed
    $scheme = ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) ? 'https' : 'http';
    $url = site_url( '/custom-page/', $scheme );

    return $url;
}
add_filter( 'woocommerce_get_checkout_url', 'so_37863005_checkout_url', 10, 2 );
</code>```

Try this unique way

```<code>function text_view_cart_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
    case 'View Cart' :
        $translated_text = __( 'Check On Out', 'woocommerce' );
        break;
}
return $translated_text;
}
add_filter( 'gettext', 'text_view_cart_strings', 20, 3 );
</code>```

Body:
Well, the functionality of adding the product to the cart via ajax is 100% working, however a message below appears like this

Well, the code generated is this, automatic whenever the product is added to the cart successfully

View Cart

I want to know how you can edit this particular line

Body:
@credited to helgatheviking on her answer here

You can filter the checkout url via woocommerce_get_checkout_url

function so_37863005_checkout_url( $url ){

    // Force SSL if needed
    $scheme = ( is_ssl() || 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ) ? 'https' : 'http';
    $url = site_url( '/custom-page/', $scheme );

    return $url;
}
add_filter( 'woocommerce_get_checkout_url', 'so_37863005_checkout_url', 10, 2 );

Try this unique way

function text_view_cart_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
    case 'View Cart' :
        $translated_text = __( 'Check On Out', 'woocommerce' );
        break;
}
return $translated_text;
}
add_filter( 'gettext', 'text_view_cart_strings', 20, 3 );


问:
Spring Web Application - How to get from page controllers to business layer
I am writing a Spring web application in Eclipse. In WEB-INF I have a web.xml file that gives a servlet mapping for a myapp-servlet.xml file.

In myapp-servlet.xml, I have a bean for a page controller. I surmise that the Spring DispatcherServlet instantiates these beans from its own ApplicationContext. When I run my project as a server, it displays the index.jsp file - "hello hello hello".

Now I also surmise that were I to put a submit button that sends post data in this index.jsp file, my page controller would be notified of the HTTP request. However, how can I interact with the rest of my application (the business layer) from the page controller? I am writing an LDAP Directory Lookup application, and once the user inputs a name I want to return an email. So, when the user inputs a name and hits submit, I want to communicate with my LDAP business layer. How can I do this?

One way I have thought of doing this is to add my business objects as properties to the page controller in the myapp-servlet.xml file. However, this seems to integrate the business layer and the controllers far too much for my liking - it means that every controller would need properties for business objects.

Another way I have thought of doing this is to create a kind of factory that all controllers have listed as a property in their XML. Through this factory, the controllers can access business objects; the factory is the interface between the two layers.

These are both custom ideas, and I suspect that there is a pre-made solution. Is there already a method of going about this? (Integrating business layer with web / page controller layer?) Or is it up to the programmer to concoct a custom solution as I outlined above?

Thanks, (and sorry for the long question - hence the bold)

ktm

答:
Your controller needs to somehow hold a reference to your business objects. To fully benefit of Spring, you will want to inject those dependencies into your controller.

This is not tight coupling, especially if those business objects implement an interface and your controller will only know about that interface.

Dependency injection eliminates the need for factories as you will need to know about the service interfaces with our without a factory:

```<code>SomeBusinessServiceInterface service = businessFactory.getBusinessService();
</code>```

But think about it like this: you must somehow get a reference of some service (using that service interface for low coupling) and most likely you need to cache that -- store it as an instance variable. Since you have that anyway, providing a setter does not couple your web and business tier any more than they already are.

If a setter seems unnatural (and it sometimes is) use constructor injection to implement this as classic OO aggregation.

Regarding the application context config, Spring allows you to define a webapp-wide application context defined using a ContextLoaderListener in web.xml. This is usually where all your business bean definitions should reside. Your -servlet.xml application context is bound to the servlet and should usually contain MVC stuff, referencing the beans in the root context as that context automatically becomes the parent of all the -servlet.xml (therefore all the beans there are visible for your servlets).

Body:
Your controller needs to somehow hold a reference to your business objects. To fully benefit of Spring, you will want to inject those dependencies into your controller.

This is not tight coupling, especially if those business objects implement an interface and your controller will only know about that interface.

Dependency injection eliminates the need for factories as you will need to know about the service interfaces with our without a factory:

SomeBusinessServiceInterface service = businessFactory.getBusinessService();

But think about it like this: you must somehow get a reference of some service (using that service interface for low coupling) and most likely you need to cache that -- store it as an instance variable. Since you have that anyway, providing a setter does not couple your web and business tier any more than they already are.

If a setter seems unnatural (and it sometimes is) use constructor injection to implement this as classic OO aggregation.

Regarding the application context config, Spring allows you to define a webapp-wide application context defined using a ContextLoaderListener in web.xml. This is usually where all your business bean definitions should reside. Your -servlet.xml application context is bound to the servlet and should usually contain MVC stuff, referencing the beans in the root context as that context automatically becomes the parent of all the -servlet.xml (therefore all the beans there are visible for your servlets).


问:
Get different tag classes preserving their order using selenium C#
I'm scraping an ePUB bible (which has HTML pages for each chapter) and I want to preserve the order of a few tags that are spread over the HTML page.
All bible chapters are similar and written like this or a variation of this:

```<code><div>
  <p class="p">
  <a class="v">1</a> This is a verse.
  <a class="v">2</a> This is a verse.
  <a class="v">3</a> This is a verse.
  </p>
  <h3 class="s1">This is a pericope</h3>
  <h4 class="r">This is a reference for this pericope.</h4>
  <p class="p">
  <a class="v">4</a> This is a verse.
  <a class="v">5</a> This is a verse.
  </p>
  <p class="p">
  <a class="v">6</a> This is a verse with a quote:
  </p>
  <p class="q">"This is the content</p>
  <p class="q">of a quote;</p>
  <p class="q">or a spoken word."</p>
  <h3 class="s1">This is another pericope</h3>
  ...
</div>
</code>```

Essentially:

```<code><class="v"> is a "a" element with the number of the verse
<class="p"> is a "p" element with a verse or a collection of verses;
<class="q"> is a blockquote;
<class="s1"> is a pericope;
<class="r"> is a reference to a periscope;
</code>```

Getting all p elements can give me quite good results, that was linked to another related question on SO, but is it possible to scrap a page preserving the order of the calls?

For the example above, I would be able to get the elements in order following their classes, so I can re-write in text the content of that chapter as:

1 This is a verse.

2 This is a verse.

3 This is a verse.

This is a pericope.

This is a reference for this pericope.

4 This is a verse.

5 This is a verse.

6 This is a verse with a quote:

"This is the content

of a quote;

or spoken word"

This is another periscope

...

Can't seem to find a way using Selenium, but if there's what would it be?

答:
Try this code block and update me the status :

```<code>IList<IWebElement> elements = driver.FindElements(By.xpath("//*[(self::p) or (self::p and following-sibling::a) or (self::h3) or (self::h4)]"));
foreach (IWebElement element in elements)
{
    string my_text = element.GetAttribute("innerHTML");
    Console.WriteLine(my_text);
}
</code>```

The Output on my console is as :

```<code>1 This is a verse.
2 This is a verse.
3 This is a verse.
This is a pericope
This is a reference for this pericope.
4 This is a verse.
5 This is a verse.
6 This is a verse with a quote:
"This is the content
of a quote;
or a spoken word."
This is another pericope
</code>```

Update :

See the xpath is correct and returning me correct results. Here is the snapshot :

Body:
I'm scraping an ePUB bible (which has HTML pages for each chapter) and I want to preserve the order of a few tags that are spread over the HTML page.
All bible chapters are similar and written like this or a variation of this:

  1 This is a verse.
  2 This is a verse.
  3 This is a verse.

This is a pericope

This is a reference for this pericope.

  4 This is a verse.
  5 This is a verse.

  6 This is a verse with a quote:

"This is the content

of a quote;

or a spoken word."

This is another pericope

  ...

Essentially:

<class="v"> is a "a" element with the number of the verse
<class="p"> is a "p" element with a verse or a collection of verses;
<class="q"> is a blockquote;
<class="s1"> is a pericope;
<class="r"> is a reference to a periscope;

Getting all p elements can give me quite good results, that was linked to another related question on SO, but is it possible to scrap a page preserving the order of the calls?

For the example above, I would be able to get the elements in order following their classes, so I can re-write in text the content of that chapter as:

1 This is a verse.

2 This is a verse.

3 This is a verse.

This is a pericope.

This is a reference for this pericope.

4 This is a verse.

5 This is a verse.

6 This is a verse with a quote:

"This is the content

of a quote;

or spoken word"

This is another periscope

...

Can't seem to find a way using Selenium, but if there's what would it be?

Body:
Try this code block and update me the status :

IList<IWebElement> elements = driver.FindElements(By.xpath("//*[(self::p) or (self::p and following-sibling::a) or (self::h3) or (self::h4)]"));
foreach (IWebElement element in elements)
{
    string my_text = element.GetAttribute("innerHTML");
    Console.WriteLine(my_text);
}

The Output on my console is as :

1 This is a verse.
2 This is a verse.
3 This is a verse.
This is a pericope
This is a reference for this pericope.
4 This is a verse.
5 This is a verse.
6 This is a verse with a quote:
"This is the content
of a quote;
or a spoken word."
This is another pericope

Update :

See the xpath is correct and returning me correct results. Here is the snapshot :


问:
How can I loop over true values in Python
I have a boolean array in python and I want to do a calculation on the cells where the value is 'true'. Currently I am using a nested for loop to go trough all the cells to find the cells with the true values. However, running the program takes a lot of time. I was wondering wether there is a faster way to do this?

```<code>for i in range (0,latstep):
    for j in range (0,lonstep):
        if coastline[i,j] == True:
        ...
</code>```

Thanks for your help!

答:
You can use nested list comprehensions, each comprehension is slightly faster than a generic for-loop on smaller input sizes:</p>

```<code>final_list = [[foo(b) for b in i if b] for i in coastline]
</code>```

Body:
I have a boolean array in python and I want to do a calculation on the cells where the value is 'true'. Currently I am using a nested for loop to go trough all the cells to find the cells with the true values. However, running the program takes a lot of time. I was wondering wether there is a faster way to do this?

for i in range (0,latstep):
    for j in range (0,lonstep):
        if coastline[i,j] == True:
        ...

Thanks for your help!

Body:
You can use nested list comprehensions, each comprehension is slightly faster than a generic for-loop on smaller input sizes:

final_list = [[foo(b) for b in i if b] for i in coastline]


问:
PHP: install mysqlnd_ms fail : make: *** [php_mysqlnd_ms.lo] error 1
I'm installing mysqlnd_ms package for php, but the make command reported an error:

```<code>make: *** [php_mysqlnd_ms.lo] Error 1

ERROR: `make' failed
</code>```

my PHP version:

[root@uoo insFile]# php -v

PHP 5.6.12 (cli) (built: Aug 30 2015 00:04:44)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

my OS:

[root@uoo ~]# cat /etc/centos-release

CentOS Linux release 7.2.1511 (Core)

all php module that has  been installed:

```<code>[root@uoo insFile]# php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
ereg
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
mhash
mysql
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zip
zlib

[Zend Modules]
</code>```

here is my installation process with pecl:

[root@uoo insFile]# pecl install mysqlnd_ms

downloading mysqlnd_ms-1.5.2.tgz ...

Starting to download mysqlnd_ms-1.5.2.tgz (385,916 bytes)

..............................................................................done:
  385,916 bytes

36 source files, building

running: phpize

Configuring for:

PHP Api Version:         20131106

Zend Module Api No:      20131226

Zend Extension Api No:   220131226

building in /tmp/pear/temp/pear-build-rootvgIJMs/mysqlnd_ms-1.5.2

running: /tmp/pear/temp/mysqlnd_ms/configure

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking for a sed that does not truncate output... /usr/bin/sed

checking for cc... cc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether cc accepts -g... yes

checking for cc option to accept ISO C89... none needed

checking how to run the C preprocessor... cc -E

checking for icc... no

checking for suncc... no

checking whether cc understands -c and -o together... yes

checking for system library directory... lib

checking if compiler supports -R... no

checking if compiler supports -Wl,-rpath,... yes

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

checking for PHP prefix... /usr/local/php

checking for PHP includes... -I/usr/local/php/include/php
  -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib

checking for PHP extension directory...
  /usr/local/php/lib/php/extensions/no-debug-zts-20131226

checking for PHP installed headers prefix...
  /usr/local/php/include/php

checking if debug is enabled... no

checking if zts is enabled... no

checking for re2c... no

configure: WARNING: You will need re2c 0.13.4 or later if you want to
  regenerate PHP parsers.

checking for gawk... gawk

checking whether to enable mysqlnd_ms support... yes, shared

checking whether to enable table filter in mysqlnd_ms... no

checking whether to query caching through mysqlnd_qc in mysqlnd_ms...
  no

checking for ld used by cc... /usr/bin/ld

checking if the linker (/usr/bin/ld) is GNU ld... yes

checking for /usr/bin/ld option to reload object files... -r

checking for BSD-compatible nm... /usr/bin/nm -B

checking whether ln -s works... yes

checking how to recognize dependent libraries... pass_all

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking dlfcn.h usability... yes

checking dlfcn.h presence... yes

checking for dlfcn.h... yes

checking the maximum length of command line arguments... 1572864

checking command to parse /usr/bin/nm -B output from cc object... ok

checking for objdir... .libs

checking for ar... ar

checking for ranlib... ranlib

checking for strip... strip

checking if cc supports -fno-rtti -fno-exceptions... no

checking for cc option to produce PIC... -fPIC

checking if cc PIC flag -fPIC works... yes

checking if cc static flag -static works... no

checking if cc supports -c -o file.o... yes

checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports
  shared  libraries... yes

checking whether -lc should be explicitly linked in... no

checking dynamic linker characteristics... GNU/Linux ld.so

checking how to hardcode library paths into programs... immediate

checking whether stripping libraries is possible... yes

checking if libtool supports shared libraries... yes

checking whether to build shared libraries... yes

checking whether to build static libraries... no

creating libtool

appending configuration tag "CXX" to libtool

configure: creating ./config.status

config.status: creating config.h

running: make

/bin/sh /tmp/pear/temp/pear-build-rootr7CW9Q/mysqlnd_ms-1.5.2/libtool
  --mode=compile cc

-I. -I/tmp/pear/temp/mysqlnd_ms -DPHP_ATOM_INC

-I/tmp/pear/temp/pear-build-rootr7CW9Q/mysqlnd_ms-1.5.2/include

-I/tmp/pear/temp/pear-build-rootr7CW9Q/mysqlnd_ms-1.5.2/main

-I/tmp/pear/temp/mysqlnd_ms -I/usr/local/php/include/php

-I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM

-I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext

-I/usr/local/php/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2

-c /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c -o php_mysqlnd_ms.lo

mkdir .libs

cc -I. -I/tmp/pear/temp/mysqlnd_ms -DPHP_ATOM_INC

  -I/tmp/pear/temp/pear-build-rootr7CW9Q/mysqlnd_ms-1.5.2/include     -I/tmp/pear/temp/pear-build-rootr7CW9Q/mysqlnd_ms-1.5.2/main     -I/tmp/pear/temp/mysqlnd_ms -I/usr/local/php/include/php     -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM     -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext     -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2     -c /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c  -fPIC -DPIC -o .libs/php_mysqlnd_ms.o   /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:
  In function ‘zif_mysqlnd_ms_get_last_used_connection’:

/tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:293:2: warning: passing
  argument 2 of ‘zval_to_mysqlnd’ makes integer from pointer without a
  cast [enabled by default]

if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {
  ^    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,

from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
                  /usr/local/php/include/php/ext/mysqlnd/mysqlnd_reverse_api.h:37:18:
  note: expected ‘unsigned int’ but argument is of type ‘void ***’

PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int
  client_api_capabilities, unsigned int * save_client_api_capabilities
  TSRMLS_DC);

^
  /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:293:2: error: too few arguments to function ‘zval_to_mysqlnd’

if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {
  ^    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,

from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
                  /usr/local/php/include/php/ext/mysqlnd/mysqlnd_reverse_api.h:37:18:
  note: declared here

PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int
  client_api_capabilities, unsigned int * save_client_api_capabilities
  TSRMLS_DC);

^
  /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c: In function ‘zif_mysqlnd_ms_get_last_gtid’:

/tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:333:2: warning: passing
  argument 2 of ‘zval_to_mysqlnd’ makes integer from pointer without a
  cast [enabled by default]
  if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {
  ^    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,

from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
                  /usr/local/php/include/php/ext/mysqlnd/mysqlnd_reverse_api.h:37:18:
  note: expected ‘unsigned int’ but argument is of type ‘void ***’

  PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int
  client_api_capabilities, unsigned int * save_client_api_capabilities
  TSRMLS_DC);

^
  /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:333:2: error: too few arguments to function ‘zval_to_mysqlnd’

if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {
   ^    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,

from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:

/usr/local/php/include/php/ext/mysqlnd/mysqlnd_reverse_api.h:37:18:
  note: declared here

PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int
  client_api_capabilities, unsigned int * save_client_api_capabilities
  TSRMLS_DC);

^
  /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:373:3: warning: passing argument 2 of ‘ms_ori  mysqlnd_conn_methods->store_result’
  makes integer from pointer without a cast [enabled▽by default]
   if (!(res = MS_CALL_ORIGINAL_CONN_DATA_METHOD(store_result)(conn TSRMLS_CC))) {
  ^
  /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:373:3: note: expected ‘unsigned int’ but argument is of type ‘void ***’

/tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:373:3: error: too few
  arguments to function ‘ms_orig_mysqlnd_conn_methods->store_result’

/tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c: In function
  ‘zif_mysqlnd_ms_set_qos’:

/tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:506:2: warning: passing
  argument 2 of ‘zval_to_mysqlnd’ makes integer from pointer without a
  cast [enabled by default]
  if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {

^

In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,

from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
                  /usr/local/php/include/php/ext/mysqlnd/mysqlnd_reverse_api.h:37:18:
  note: expected ‘unsigned int’ but argument is of type ‘void ***’

PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int
  client_api_capabilities, unsigned int * save_client_api_capabilities
  TSRMLS_DC);

^

/tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:506:2: error: too few arguments to function ‘zval_to_mysqlnd’

if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {

^

In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,

from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
                  /usr/local/php/include/php/ext/mysqlnd/mysqlnd_reverse_api.h:37:18:
  note: declared here

PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int
  client_api_capabilities, unsigned int * save_client_api_capabilities
  TSRMLS_DC);

^

make: *** [php_mysqlnd_ms.lo] Error 1

ERROR: `make' failed

答:
I have been looking hours and hours on the google finally the Clark's solution worked on cpanel just a bit of tweak

For cpanel I changed the command to:

```<code>svn checkout http://svn.php.net/repository/pecl/mysqlnd_ms/trunk/ && cd trunk && /opt/cpanel/ea-php56/root/usr/bin/phpize && ./configure --with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config && make; make install
</code>```

You also need to create and add the extension name in
/opt/cpanel/ea-php56/root/usr/lib64/php/modules/:

```<code>cd /opt/cpanel/ea-php56/root/usr/lib64/php/modules/
cat >> mysqlnd_ms.ini << EOF
extension=mysqlnd_ms.so
EOF
</code>```

You can see result with php -m.

Body:
I'm installing mysqlnd_ms package for php, but the make command reported an error:

make: *** [php_mysqlnd_ms.lo] Error 1

ERROR: `make' failed

my PHP version:

[root@uoo insFile]# php -v

PHP 5.6.12 (cli) (built: Aug 30 2015 00:04:44)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

my OS:

[root@uoo ~]# cat /etc/centos-release

CentOS Linux release 7.2.1511 (Core)

all php module that has  been installed:

[root@uoo insFile]# php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
ereg
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
mhash
mysql
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zip
zlib

[Zend Modules]

here is my installation process with pecl:

[root@uoo insFile]# pecl install mysqlnd_ms

downloading mysqlnd_ms-1.5.2.tgz ...

Starting to download mysqlnd_ms-1.5.2.tgz (385,916 bytes)

..............................................................................done:
  385,916 bytes

36 source files, building

running: phpize

Configuring for:

PHP Api Version:         20131106

Zend Module Api No:      20131226

Zend Extension Api No:   220131226

building in /tmp/pear/temp/pear-build-rootvgIJMs/mysqlnd_ms-1.5.2

running: /tmp/pear/temp/mysqlnd_ms/configure

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking for a sed that does not truncate output... /usr/bin/sed

checking for cc... cc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether cc accepts -g... yes

checking for cc option to accept ISO C89... none needed

checking how to run the C preprocessor... cc -E

checking for icc... no

checking for suncc... no

checking whether cc understands -c and -o together... yes

checking for system library directory... lib

checking if compiler supports -R... no

checking if compiler supports -Wl,-rpath,... yes

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

checking for PHP prefix... /usr/local/php

checking for PHP includes... -I/usr/local/php/include/php
  -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib

checking for PHP extension directory...
  /usr/local/php/lib/php/extensions/no-debug-zts-20131226

checking for PHP installed headers prefix...
  /usr/local/php/include/php

checking if debug is enabled... no

checking if zts is enabled... no

checking for re2c... no

configure: WARNING: You will need re2c 0.13.4 or later if you want to
  regenerate PHP parsers.

checking for gawk... gawk

checking whether to enable mysqlnd_ms support... yes, shared

checking whether to enable table filter in mysqlnd_ms... no

checking whether to query caching through mysqlnd_qc in mysqlnd_ms...
  no

checking for ld used by cc... /usr/bin/ld

checking if the linker (/usr/bin/ld) is GNU ld... yes

checking for /usr/bin/ld option to reload object files... -r

checking for BSD-compatible nm... /usr/bin/nm -B

checking whether ln -s works... yes

checking how to recognize dependent libraries... pass_all

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking dlfcn.h usability... yes

checking dlfcn.h presence... yes

checking for dlfcn.h... yes

checking the maximum length of command line arguments... 1572864

checking command to parse /usr/bin/nm -B output from cc object... ok

checking for objdir... .libs

checking for ar... ar

checking for ranlib... ranlib

checking for strip... strip

checking if cc supports -fno-rtti -fno-exceptions... no

checking for cc option to produce PIC... -fPIC

checking if cc PIC flag -fPIC works... yes

checking if cc static flag -static works... no

checking if cc supports -c -o file.o... yes

checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports
  shared  libraries... yes

checking whether -lc should be explicitly linked in... no

checking dynamic linker characteristics... GNU/Linux ld.so

checking how to hardcode library paths into programs... immediate

checking whether stripping libraries is possible... yes

checking if libtool supports shared libraries... yes

checking whether to build shared libraries... yes

checking whether to build static libraries... no

creating libtool

appending configuration tag "CXX" to libtool

configure: creating ./config.status

config.status: creating config.h

running: make

/bin/sh /tmp/pear/temp/pear-build-rootr7CW9Q/mysqlnd_ms-1.5.2/libtool
  --mode=compile cc

-I. -I/tmp/pear/temp/mysqlnd_ms -DPHP_ATOM_INC

-I/tmp/pear/temp/pear-build-rootr7CW9Q/mysqlnd_ms-1.5.2/include

-I/tmp/pear/temp/pear-build-rootr7CW9Q/mysqlnd_ms-1.5.2/main

-I/tmp/pear/temp/mysqlnd_ms -I/usr/local/php/include/php

-I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM

-I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext

-I/usr/local/php/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2

-c /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c -o php_mysqlnd_ms.lo

mkdir .libs

cc -I. -I/tmp/pear/temp/mysqlnd_ms -DPHP_ATOM_INC

  -I/tmp/pear/temp/pear-build-rootr7CW9Q/mysqlnd_ms-1.5.2/include     -I/tmp/pear/temp/pear-build-rootr7CW9Q/mysqlnd_ms-1.5.2/main     -I/tmp/pear/temp/mysqlnd_ms -I/usr/local/php/include/php     -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM     -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext     -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2     -c /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c  -fPIC -DPIC -o .libs/php_mysqlnd_ms.o   /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:
  In function ‘zif_mysqlnd_ms_get_last_used_connection’:

/tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:293:2: warning: passing
  argument 2 of ‘zval_to_mysqlnd’ makes integer from pointer without a
  cast [enabled by default]

if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {
  ^    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,

from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
                  /usr/local/php/include/php/ext/mysqlnd/mysqlnd_reverse_api.h:37:18:
  note: expected ‘unsigned int’ but argument is of type ‘void ***’

PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int
  client_api_capabilities, unsigned int * save_client_api_capabilities
  TSRMLS_DC);

^
  /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:293:2: error: too few arguments to function ‘zval_to_mysqlnd’

if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {
  ^    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,

from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
                  /usr/local/php/include/php/ext/mysqlnd/mysqlnd_reverse_api.h:37:18:
  note: declared here

PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int
  client_api_capabilities, unsigned int * save_client_api_capabilities
  TSRMLS_DC);

^
  /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c: In function ‘zif_mysqlnd_ms_get_last_gtid’:

/tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:333:2: warning: passing
  argument 2 of ‘zval_to_mysqlnd’ makes integer from pointer without a
  cast [enabled by default]
  if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {
  ^    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,

from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
                  /usr/local/php/include/php/ext/mysqlnd/mysqlnd_reverse_api.h:37:18:
  note: expected ‘unsigned int’ but argument is of type ‘void ***’

  PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int
  client_api_capabilities, unsigned int * save_client_api_capabilities
  TSRMLS_DC);

^
  /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:333:2: error: too few arguments to function ‘zval_to_mysqlnd’

if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {
   ^    In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,

from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:

/usr/local/php/include/php/ext/mysqlnd/mysqlnd_reverse_api.h:37:18:
  note: declared here

PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int
  client_api_capabilities, unsigned int * save_client_api_capabilities
  TSRMLS_DC);

^
  /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:373:3: warning: passing argument 2 of ‘ms_ori  mysqlnd_conn_methods->store_result’
  makes integer from pointer without a cast [enabled▽by default]
   if (!(res = MS_CALL_ORIGINAL_CONN_DATA_METHOD(store_result)(conn TSRMLS_CC))) {
  ^
  /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:373:3: note: expected ‘unsigned int’ but argument is of type ‘void ***’

/tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:373:3: error: too few
  arguments to function ‘ms_orig_mysqlnd_conn_methods->store_result’

/tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c: In function
  ‘zif_mysqlnd_ms_set_qos’:

/tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:506:2: warning: passing
  argument 2 of ‘zval_to_mysqlnd’ makes integer from pointer without a
  cast [enabled by default]
  if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {

^

In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,

from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
                  /usr/local/php/include/php/ext/mysqlnd/mysqlnd_reverse_api.h:37:18:
  note: expected ‘unsigned int’ but argument is of type ‘void ***’

PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int
  client_api_capabilities, unsigned int * save_client_api_capabilities
  TSRMLS_DC);

^

/tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:506:2: error: too few arguments to function ‘zval_to_mysqlnd’

if (!(proxy_conn = zval_to_mysqlnd(handle TSRMLS_CC))) {

^

In file included from /tmp/pear/temp/mysqlnd_ms/mysqlnd_ms.h:40:0,

from /tmp/pear/temp/mysqlnd_ms/php_mysqlnd_ms.c:34:
                  /usr/local/php/include/php/ext/mysqlnd/mysqlnd_reverse_api.h:37:18:
  note: declared here

PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int
  client_api_capabilities, unsigned int * save_client_api_capabilities
  TSRMLS_DC);

^

make: *** [php_mysqlnd_ms.lo] Error 1

ERROR: `make' failed

Body:
I have been looking hours and hours on the google finally the Clark's solution worked on cpanel just a bit of tweak

For cpanel I changed the command to:

svn checkout http://svn.php.net/repository/pecl/mysqlnd_ms/trunk/ && cd trunk && /opt/cpanel/ea-php56/root/usr/bin/phpize && ./configure --with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config && make; make install

You also need to create and add the extension name in
/opt/cpanel/ea-php56/root/usr/lib64/php/modules/:

cd /opt/cpanel/ea-php56/root/usr/lib64/php/modules/
cat >> mysqlnd_ms.ini << EOF
extension=mysqlnd_ms.so
EOF

You can see result with php -m.


问:
How to know whether the triangle is valid or not by angles?
I want to write a c++ program that finds whether the triangle is valid or not
 here's my code:

```<code>#include <iostream>
using namespace std;
int main () {
    int a,b,c;
    cin>>a>>b>>c;
    if (a+b+c==180)
    cout <<"Yes";
    else
    cout <<"No";
    return 0;
}
</code>```

The user will enter 3 angles e.g 50 30 100 it will print valid Yes, but what if he enters

0 0 180 it will print yes by entering only one angle. that isn't triangle and my program will print yes. What should I do to fix this?

答:
There are two issues that you have to think about in this code. First: are the angles that the user typed in valid (i.e., not negative, not more than 180 degrees, and maybe not 0). Second, once you have decided that the angles are valid, determine whether the three angles can be part of a triangle.

So write two functions: one that gets an angle by prompting for input, checking that the angle is valid, and looping back if it isn't; and one that decides whether three valid angles are a triangle. Then fasten them together with some appropriate glue.

Body:
I want to write a c++ program that finds whether the triangle is valid or not
 here's my code:

#include <iostream>
using namespace std;
int main () {
    int a,b,c;
    cin>>a>>b>>c;
    if (a+b+c==180)
    cout <<"Yes";
    else
    cout <<"No";
    return 0;
}

The user will enter 3 angles e.g 50 30 100 it will print valid Yes, but what if he enters

0 0 180 it will print yes by entering only one angle. that isn't triangle and my program will print yes. What should I do to fix this?


问:
How to write a nice Low-Pass-Filter in Scala
I needed a Low-Pass-Filter in one of my Scala projects and came up with this:

```<code>def filter(numbers: Seq[Double], filterSize: Int): Seq[Double] = {
  assert(filterSize > 0)
  val ringBuffer = new Array[Double](filterSize)
  var ringBufferIndex = 0

  numbers.map(x => {
    // update ring buffer
    ringBuffer(ringBufferIndex) = x

    // increase ring index
    ringBufferIndex += 1
    if (ringBufferIndex == filterSize) {
      ringBufferIndex = 0
    }

    // get avarage
    ringBuffer.foldLeft(0.0)(_ + _) / filterSize
  })
}
</code>```

However, there are some things I don't like about it:

It uses map (nicely functional) but needs a mutable variable (ringBufferIndex - BAD).

It work's on Seq[Double] (which is fine), but returns Seq[Double], which is bad cause it requires the caller to call .toList or whatever he actually uses. I tried using Generics here like this:

def filter\[T <% Seq[Double]](numbers: T, filterSize: Int): T

but that would not compile.

Does anyone have suggestionts how to improve those two issues?

答:
Here is a shorter version that I have come up with to tackle the first problem:

```<code>  def filter(numbers: Seq[Double], filterSize: Int): Seq[Double] = {
    assert(filterSize > 0)
    (0 until numbers.length).map(x => {
      (((x - filterSize) max 0) to x).foldLeft(0.0)((sum, index) => sum + numbers(index)) / filterSize
    })
  }
</code>```

It's downside is the index lookup which could be very bad for things like "List".

OwnerDisplayName: Lemmy

Body:
I needed a Low-Pass-Filter in one of my Scala projects and came up with this:

def filter(numbers: Seq[Double], filterSize: Int): Seq[Double] = {
  assert(filterSize > 0)
  val ringBuffer = new Array[Double](filterSize)
  var ringBufferIndex = 0

  numbers.map(x => {
    // update ring buffer
    ringBuffer(ringBufferIndex) = x

    // increase ring index
    ringBufferIndex += 1
    if (ringBufferIndex == filterSize) {
      ringBufferIndex = 0
    }

    // get avarage
    ringBuffer.foldLeft(0.0)(_ + _) / filterSize
  })
}

However, there are some things I don't like about it:

It uses map (nicely functional) but needs a mutable variable (ringBufferIndex - BAD).

It work's on Seq[Double] (which is fine), but returns Seq[Double], which is bad cause it requires the caller to call .toList or whatever he actually uses. I tried using Generics here like this:

def filter\[T <% Seq[Double]](numbers: T, filterSize: Int): T

but that would not compile.

Does anyone have suggestionts how to improve those two issues?

Body:
Here is a shorter version that I have come up with to tackle the first problem:

  def filter(numbers: Seq[Double], filterSize: Int): Seq[Double] = {
    assert(filterSize > 0)
    (0 until numbers.length).map(x => {
      (((x - filterSize) max 0) to x).foldLeft(0.0)((sum, index) => sum + numbers(index)) / filterSize
    })
  }

It's downside is the index lookup which could be very bad for things like "List".


问:
How to get the word under the cursor in Windows?
I want to create a application which gets the word under the cursor (not only for text fields), but I can't find how to do that. Using OCR is pretty hard. The only thing I've seen working is the Deskperience components. They support a 'native' way, but I they cost a lot. Now I'm trying to figure out what is this 'native' way (maybe somehow of hooking). Any help will be appreciated.

EDIT:
I found a way, but it gets only the whole text of the control. Any idea how to get only the word under the cursor from the whole text?

答: There is an sdk for getting the text using OCR. It's not free but it's quite cheap compared to other products: http://www.screenocr.com/screen-ocr-library-sdk.htm They have an application which provides the same features so you can try the demo too.</p>


问:
Waiting in a redux-saga
I want to introduce a delay in a saga (using redux-saga).

How can I do this?

If redux-saga provides an API, I would also be interested in how to achieve it manually.

```<code>function* save({ payload }) {
    yield put(pending());
    // I want to simply wait (non-blocking) here for say 2 seconds
    yield put(complete());
}
</code>```

答:
Source.</p>

```<code>export function delay(ms, val = true) {
  let timeoutId
  const promise = new Promise(resolve => {
    timeoutId = setTimeout(() => resolve(val), ms)
  })

  promise[CANCEL] = () => clearTimeout(timeoutId)

  return promise
}
</code>```

Title: Waiting in a redux-saga

Body:
I want to introduce a delay in a saga (using redux-saga).

How can I do this?

If redux-saga provides an API, I would also be interested in how to achieve it manually.

function* save({ payload }) {
    yield put(pending());
    // I want to simply wait (non-blocking) here for say 2 seconds
    yield put(complete());
}

Body:
Source.

export function delay(ms, val = true) {
  let timeoutId
  const promise = new Promise(resolve => {
    timeoutId = setTimeout(() => resolve(val), ms)
  })

  promise[CANCEL] = () => clearTimeout(timeoutId)

  return promise
}


问:
TSQL Merge Performance
Scenario:

I have a table with roughly 24 million records.  The table has pricing history related to individual customers and is computed daily.  There are on average 6 million records for each day. Every morning a the price list is generated and a merge statement is ran to reflect the changes in their pricing.

The merge statement begins with the previous day's previous data being inserted into a variable table, that table is then merged into the actual table.  The main problem is that the merge statement takes pretty long.

My real question centers around the performance of using a variable table vs physical table vs temp table. What is the best practice for large merges like this?

答: Temp tables often perform better than table variables for large data sets. Additionally you can put the data into the temp table and then index it. </p>

Title: TSQL Merge Performance


答:
You could achieve that with a promise and a generator function:</p>

```<code>function sleep(sec) {
    return new Promise(resolve => setTimeout(resolve, sec*1000));
}

function* save({ payload }) {
    yield put(pending());
    yield sleep(2); //wait 2 seconds
    yield put(complete());
}
</code>```

Title: Waiting in a redux-saga

Body:
You could achieve that with a promise and a generator function:

function sleep(sec) {
    return new Promise(resolve => setTimeout(resolve, sec*1000));
}

function* save({ payload }) {
    yield put(pending());
    yield sleep(2); //wait 2 seconds
    yield put(complete());
}

ContentLicense: CC BY-SA 4.0


问:
Hyperledger Composer v0.16.0 network start error
I'm trying Hyperledger Composer v0.16.0. According to this procedure, I want to Deploy BNA to Fabric network on cloud. but following error occurs.
Kindly let me know how I can solve it.

command:

```<code>composer network start --card PeerAdmin@myfabric --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile trade-network.bna --file networkadmin.card
</code>```

result:

```<code>tarting business network from archive: trade-network.bna
Business network definition:
    Identifier: trade-network@0.1.13
    Description: Commodities Trading Business Network

Processing these Network Admins:
    userName: admin

✖ Starting business network definition. This may take a minute...
Error: Error trying to instantiate composer runtime. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: chaincode error (status: 500, message: chaincode instantiation policy violated(Failed to authenticate policy))
</code>```

答:
The error 'Error: Error trying to instantiate composer runtime.' Suggests you have not run the composer runtime install command e.g.
composer runtime install -c PeerAdmin@fabric-network -n tutorial-network
Or that the command did not complete successfully.

The other possibility is that your fabric has stopped or is not contactable.

Body:
I'm trying Hyperledger Composer v0.16.0. According to this procedure, I want to Deploy BNA to Fabric network on cloud. but following error occurs.
Kindly let me know how I can solve it.

command:

composer network start --card PeerAdmin@myfabric --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile trade-network.bna --file networkadmin.card

result:

tarting business network from archive: trade-network.bna
Business network definition:
    Identifier: trade-network@0.1.13
    Description: Commodities Trading Business Network

Processing these Network Admins:
    userName: admin

✖ Starting business network definition. This may take a minute...
Error: Error trying to instantiate composer runtime. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: chaincode error (status: 500, message: chaincode instantiation policy violated(Failed to authenticate policy))


问:
Remove part of string but getting the deleted part as result
So, quick question (searched a lot in Google, but only found the answer which produces same response as below):

code:

```<code>var teste = '10/12/2017';
console.log(teste); //returns 10/12/2017
var teste_cut = teste.substr(6,2);
console.log(teste_cut); //returns only 20
</code>```

What I want is 10/12/17. I can't change how the string is created, so I need to change it after getting said string. Does a method for doing this exist, or should I work around with other functions? I'm feeling stupid right now, since it seens to be a fairly obvious answer, but I guess we all get our stupid moments :P

答:
You can use your custom function as -

function formatDate(d)
{
    var month = d.getMonth();
    var day = d.getDate();
    var year = d.getFullYear();

    year = year.toString().substr(2,2);

    month = month + 1;

    month = month + "";

    if (month.length == 1)
    {
        month = "0" + month;
    }

    day = day + "";

    if (day.length == 1)
    {
        day = "0" + day;
    }

    return month + "/" + day + "/" + year;
}

var d = new Date('10/12/2017');
console.log(formatDate(d));```

Body:
So, quick question (searched a lot in Google, but only found the answer which produces same response as below):

code:

var teste = '10/12/2017';
console.log(teste); //returns 10/12/2017
var teste_cut = teste.substr(6,2);
console.log(teste_cut); //returns only 20

What I want is 10/12/17. I can't change how the string is created, so I need to change it after getting said string. Does a method for doing this exist, or should I work around with other functions? I'm feeling stupid right now, since it seens to be a fairly obvious answer, but I guess we all get our stupid moments :P


问:
How to continue row numbering each page in pagination using SQL Server and PHP (foreach method)
I'm trying to add row numbering for data shown, but when i try to go to the next page, the row number is reverting back from 1.

I want the row number is continuously added within the page number like if :

The first page is showing 20 data, the row number is showing 1 ~ 20.

The second page is showing 20 data, the row number is showing 21 ~ 40, not 1 ~ 20

How to handle it ?

This is my getPage function :

```<code><?php
  function getPage($stmt, $pageNum, $rowsPerPage)
  {
   $offset = ($pageNum - 1) * $rowsPerPage;
   $rows = array();
   $i = 0;
      while(($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC, SQLSRV_SCROLL_ABSOLUTE, $offset + $i)) && $i < $rowsPerPage)
      {
         array_push($rows, $row);
         $i++;
      }
    return $rows;
  }
</code>```

This is my script :

```<code> // Display the selected page of data.
 $pageNum = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;
 $page = getPage($stmt, $pageNum, $rowsPerPage);
 $i = $offset + 1;
   foreach($page as $row)
     echo "<tr>
             <td class='text-center'>".$i++."</td>
             <td class='text-center'>".$row[0]."</td>
             <td class='text-center'>$row[1]</td>
             <td class='text-center'>$row[2]</td>
             <td>$row[3]</td>
             <td>$row[7]</td>
             <td>$row[8]</td>
             <td>$row[4]</td>
             <td>$row[5]</td>
             <td>$row[6]</td>
             <td class='text-center'><a href='form-edit-laporan-pelanggar?id=".$row[0]."'><button class='btn btn-sm btn-primary'>Edit</button></a></td>
             <td class='text-center'><a data-href='delete?id=".$row[0]."' data-target='#delete' data-toggle='modal'><button class='btn btn-sm btn-danger'>Del</button></a></td>
           </tr>";

  echo "</table>";
</code>```

答:
Finally i found the answer after unknown hours spend on thinking mode..
Just adding a magic script i create by logic and voila~ it works ! LOL~ xD

Here is the working script :

```<code>$mulai = ($pageNum>1) ? ($pageNum * $rowsPerPage) - $rowsPerPage : 0;

$i = $mulai + 1;
</code>```

Just add and edit the variable from this script before the foreach statement.

Body:
I'm trying to add row numbering for data shown, but when i try to go to the next page, the row number is reverting back from 1.

I want the row number is continuously added within the page number like if :

The first page is showing 20 data, the row number is showing 1 ~ 20.

The second page is showing 20 data, the row number is showing 21 ~ 40, not 1 ~ 20

How to handle it ?

This is my getPage function :

<?php
  function getPage($stmt, $pageNum, $rowsPerPage)
  {
   $offset = ($pageNum - 1) * $rowsPerPage;
   $rows = array();
   $i = 0;
      while(($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC, SQLSRV_SCROLL_ABSOLUTE, $offset + $i)) && $i < $rowsPerPage)
      {
         array_push($rows, $row);
         $i++;
      }
    return $rows;
  }

This is my script :

 // Display the selected page of data.
 $pageNum = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;
 $page = getPage($stmt, $pageNum, $rowsPerPage);
 $i = $offset + 1;
   foreach($page as $row)
     echo "

             ".$i++."
             ".$row[0]."
             $row[1]
             $row[2]
             $row[3]
             $row[7]
             $row[8]
             $row[4]
             $row[5]
             $row[6]
             <button class='btn btn-sm btn-primary'>Edit</button>
             <button class='btn btn-sm btn-danger'>Del</button>

";

  echo "
";

Body:
Finally i found the answer after unknown hours spend on thinking mode..
Just adding a magic script i create by logic and voila~ it works ! LOL~ xD

Here is the working script :

$mulai = ($pageNum>1) ? ($pageNum * $rowsPerPage) - $rowsPerPage : 0;

$i = $mulai + 1;

Just add and edit the variable from this script before the foreach statement.


问:
Strongloop: how do you return an error if Operation Hook fails?
How do you return an error inside an operation hook?

Use case is sending a push notification after saving a new model instance.

I observe the 'after save' event, send the push. If this fails for whatever reason, I want to send a 500 response code. How do I do that?

I am unable to find documentation as to what the ctx object actually is or contains.

```<code>Customer.observe('after save', function(ctx, next) {

  //model saved, but sending push failed for whatever reason, and I want to now send a 500 error back to the user
  //how?  what's inside ctx? how do you send back a response?
  next();
});
</code>```

答:
There is detailed documentation on what ctx actually contains. It can be found in Loopback after-save operation hook docs.

The ctx object has the instance method which returns the model instance that was saved. You can return the error after checking the model instance like so:

```<code>if (ctx.instance) {
  // check if your push operation modified the instance
  // If condition is not met, throw the error
  var error = new Error()
  error.status = 500
  error.message = '...'
  next(error)
}
</code>```

The documentation above covers the properties of the ctx object for the after save hook.

Body:
How do you return an error inside an operation hook?

Use case is sending a push notification after saving a new model instance.

I observe the 'after save' event, send the push. If this fails for whatever reason, I want to send a 500 response code. How do I do that?

I am unable to find documentation as to what the ctx object actually is or contains.

Customer.observe('after save', function(ctx, next) {

  //model saved, but sending push failed for whatever reason, and I want to now send a 500 error back to the user
  //how?  what's inside ctx? how do you send back a response?
  next();
});

Body:
There is detailed documentation on what ctx actually contains. It can be found in Loopback after-save operation hook docs.

The ctx object has the instance method which returns the model instance that was saved. You can return the error after checking the model instance like so:

if (ctx.instance) {
  // check if your push operation modified the instance
  // If condition is not met, throw the error
  var error = new Error()
  error.status = 500
  error.message = '...'
  next(error)
}

The documentation above covers the properties of the ctx object for the after save hook.


问:
Configure theintern for unit testing only
I am trying to configure intern (https://theintern.github.io) for unit testing.

Here is my configuration

```<code>define([ 'intern' ], function (intern) {
  // Return configuration for intern tests
  var config =  {
    basePath: '../',
    loaderOptions: {
      packages: [
                { name: 'app', location: 'app' },
                { name: 'jquery', location: 'bower_components/jquery/dist/jquery' },
                { name: 'underscore', location: 'bower_components/underscore/underscore' },
                { name: 'backbone', location: 'bower_components/backbone/backbone' }
      ]
    },
    suites: [
      'tests/mymodule'
    ],
    excludeInstrumentation: /^(?:tests|node_modules|bower_components|test)\//,
    loaders: {
      'host-node': 'requirejs',
      'host-browser': 'bower_components/requirejs/require.js',
    },
    reporters: [
      {id:'Console'}
    ]

  };
  return config;
});
</code>```

And I am receiving following error

```<code>> intern-runner config=tests/intern

Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
ReferenceError: __cov_YGSj0arNmIBnXUo5NAKQbw is not defined
  at Object.<anonymous>  <node_modules\digdug\NullTunnel.js:9:1>
  at Module._compile  <module.js:570:32>
  at Object.Module._extensions.(anonymous function) [as .js]  <node_modules\istanbul\lib\hook.js:107:24>
  at Module.load  <module.js:487:32>
  at tryModuleLoad  <module.js:446:12>
  at Function.Module._load  <module.js:438:3>
  at Module.require  <module.js:497:17>
  at require  <internal\module.js:20:19>
  at Object.load  <node_modules\intern\browser_modules\dojo\node.ts:56:11>
  at Object.<anonymous>  <node_modules\requirejs\bin\r.js:1347:28>
npm ERR! Test failed.  See above for more details.
</code>```

How can I configure theintern only for unit testing?

答:
From the error it looks like modules in node_modules are being instrumented for code coverage (the bit about "__cov_YGSj0arNmIBnXUo5NAKQbw is not defined" is coverage-related).

Since you're running on Windows, try removing the \/ from the end of excludeInstrumentation:

```<code>excludeInstrumentation: /^(?:tests|node_modules|bower_components|test)/,
</code>```

Body:
I am trying to configure intern (https://theintern.github.io) for unit testing.

Here is my configuration

define([ 'intern' ], function (intern) {
  // Return configuration for intern tests
  var config =  {
    basePath: '../',
    loaderOptions: {
      packages: [
                { name: 'app', location: 'app' },
                { name: 'jquery', location: 'bower_components/jquery/dist/jquery' },
                { name: 'underscore', location: 'bower_components/underscore/underscore' },
                { name: 'backbone', location: 'bower_components/backbone/backbone' }
      ]
    },
    suites: [
      'tests/mymodule'
    ],
    excludeInstrumentation: /^(?:tests|node_modules|bower_components|test)\//,
    loaders: {
      'host-node': 'requirejs',
      'host-browser': 'bower_components/requirejs/require.js',
    },
    reporters: [
      {id:'Console'}
    ]

  };
  return config;
});

And I am receiving following error

> intern-runner config=tests/intern

Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
    at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
    at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
    at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.MemberExpression (C:\repo\\node_modules\escodegen\escodegen.js:1910:28)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
    at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
    at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
ReferenceError: __cov_YGSj0arNmIBnXUo5NAKQbw is not defined
  at Object.<anonymous>  <node_modules\digdug\NullTunnel.js:9:1>
  at Module._compile  <module.js:570:32>
  at Object.Module._extensions.(anonymous function) [as .js]  <node_modules\istanbul\lib\hook.js:107:24>
  at Module.load  <module.js:487:32>
  at tryModuleLoad  <module.js:446:12>
  at Function.Module._load  <module.js:438:3>
  at Module.require  <module.js:497:17>
  at require  <internal\module.js:20:19>
  at Object.load  <node_modules\intern\browser_modules\dojo\node.ts:56:11>
  at Object.<anonymous>  <node_modules\requirejs\bin\r.js:1347:28>
npm ERR! Test failed.  See above for more details.

How can I configure theintern only for unit testing?

Body:
From the error it looks like modules in node_modules are being instrumented for code coverage (the bit about "__cov_YGSj0arNmIBnXUo5NAKQbw is not defined" is coverage-related).

Since you're running on Windows, try removing the \/ from the end of excludeInstrumentation:

excludeInstrumentation: /^(?:tests|node_modules|bower_components|test)/,


问:
Limit number of devices per user in Crashlytics Beta
Can I limit number of devices ( or installations) for a beta user?
I want to set a maximum of 2 devices per user</p>

答: Mike from Fabric here. Currently, it isn't possible to limit the number of devices per tester. </p>


问:
Camera (/dev/video0) dependencies in systemd service Ubuntu 16.04
I need to run some services on boot up which I have successfully accomplished using systemd services. (Lots of answers already available).

Now, one of my service requires access to /dev/video0 while bootup when a certain user is logged in. (I am doing auto login which is working fine).
So how do I check that whether the /dev/video0 is available before starting my systemd service while bootup.

I came across something called udev for doing this, I followed this link
but I am not getting desired output as after editing /lib/udev/rules.d/99-systemd.rules files as mentioned in the link and starting my service manually it's not starting, any help is appreciated.

答:
Finally after struggling for a day I found the answer -
I made a script in /etc/systemd/system which contains

```<code>[Unit]
Description='some description of my file write according to you'
[Service]
Type=forking
ExecStart='path to script'
[Install]
WantedBy=multi-user.target
</code>```

and It executes a script which contains

```<code>#!/bin/bash
modprobe uvcvideo
</code>```

Now after rebooting all the services are running properly
mod probe uvcvideo command check for running video driver and enable it at the time of bootup so that It is available for my systemd process

Thanks

Body:
Finally after struggling for a day I found the answer -
I made a script in /etc/systemd/system which contains

[Unit]
Description='some description of my file write according to you'
[Service]
Type=forking
ExecStart='path to script'
[Install]
WantedBy=multi-user.target

and It executes a script which contains

#!/bin/bash
modprobe uvcvideo

Now after rebooting all the services are running properly
mod probe uvcvideo command check for running video driver and enable it at the time of bootup so that It is available for my systemd process

Thanks