问:
Pass environment variables to kubernetes at runtime
While using vanilla docker, compose or swarm, I’m able to pass “—add-env FOO=bar” as a Docker cli parameter in order to define a env var value for the container at runtime. However, In kubernetes, I’m only seeing how to hardcore the value in the .yml file at the container spec section.

Can anyone point me how to pass it at runtime? (I.e. pass a env var when using “kubectl apply ...”)

Thanks! Really appreciate any help!

Best regards,

答:
I assume that by "runtime" you actually mean when kubectl create/apply is invoked. No that is not possible.

What you want to do instead is probably run your manifest via some templating engine. The simplest you could do is to pipe your template via sed like cat manifest | sed 's/PLACEHOLDER/VALUE/' into kubectl apply so you can have the ENV defined properly in manifest with a placeholder string that is replaced before it is pushed to kubectl. A bit more advanced solution, and the one I would generally advise, is to get familiar with helm charts where you can for example run helm upgrade my-release --reuse-vars --set my.var=value


来源: stackexchange

问:
Trying to assign a value in a variable and used it in proc in Oracle
i am trying to assign a value in a variable "slno" use it to insert value in table "Par_conn" . but it is giving error while executing the Procedure with parameter.Any help would be appreciated.
Table

```<code>create table PAR_CONN

    (
      CUSTOMER_ID   NUMBER(10) not null,
      CUSTOMER_NAME VARCHAR2(50) not null,
      CITY          VARCHAR2(50)
    )
</code>```

Store Procedure

```<code>CREATE OR REPLACE PROCEDURE sp_insert(CUSTOMER_NAME IN VARCHAR2,CITY IN VARCHAR2)
IS
   Declare  slno number;
BEGIN
    select count(*) into slno from Par_conn;
    insert into Par_conn values(slno,CUSTOMER_NAME,CITY);
    commit;
 END;
</code>```

Executing SP:

```<code>Begin
   sp_insert('ramesh','dispur');
  end;
</code>```

答:
The syntax is wrong. See below comments inline. Not sure what you wanted to achieve but at the first place you need to make all syntatic corrections before implementing any logic.

```<code>CREATE OR REPLACE PROCEDURE sp_insert (CUSTOMER_NAME   IN VARCHAR2,
                                       CITY            IN VARCHAR2)
IS
   ---Declare  slno number; --<this is wrong way of declaration
   slno   NUMBER;
BEGIN
   SELECT COUNT (*) INTO slno FROM Par_conn;

   INSERT INTO Par_conn
        VALUES (slno, CUSTOMER_NAME, CITY);

   COMMIT;
END;
</code>```

Refer here how to create a procedure .
 Procedure

ContentLicense: CC BY-SA 3.0

Body:
i am trying to assign a value in a variable "slno" use it to insert value in table "Par_conn" . but it is giving error while executing the Procedure with parameter.Any help would be appreciated.
Table

create table PAR_CONN

    (
      CUSTOMER_ID   NUMBER(10) not null,
      CUSTOMER_NAME VARCHAR2(50) not null,
      CITY          VARCHAR2(50)
    )

Store Procedure

CREATE OR REPLACE PROCEDURE sp_insert(CUSTOMER_NAME IN VARCHAR2,CITY IN VARCHAR2)
IS
   Declare  slno number;
BEGIN
    select count(*) into slno from Par_conn;
    insert into Par_conn values(slno,CUSTOMER_NAME,CITY);
    commit;
 END;

Executing SP:

Begin
   sp_insert('ramesh','dispur');
  end;

Body:
The syntax is wrong. See below comments inline. Not sure what you wanted to achieve but at the first place you need to make all syntatic corrections before implementing any logic.

CREATE OR REPLACE PROCEDURE sp_insert (CUSTOMER_NAME   IN VARCHAR2,
                                       CITY            IN VARCHAR2)
IS
   ---Declare  slno number; --<this is wrong way of declaration
   slno   NUMBER;
BEGIN
   SELECT COUNT (*) INTO slno FROM Par_conn;

   INSERT INTO Par_conn
        VALUES (slno, CUSTOMER_NAME, CITY);

   COMMIT;
END;

Refer here how to create a procedure .
 Procedure


问:
React Native Relase, Debug apk crashes in physical devices
I followed the facebook documentation on how to generate signed apk exactly. But still I am getting error: undefined is not an object (evaluating 'e.length'
Here is the screenshot

However, the app works fine in Android Emulator with command react-native run-android.
But, I got the issue which was causing the app to crash. It was native-base.
Here is the following code in my App.js:

```<code>import React, { Component } from 'react';
import {Text} from 'react-native';
import { Container, Header, Content, Form,Text, Item, Input, Label, Button }
from 'native-base';
export default class ReactNativeExample extends Component {
constructor(props) {
    super(props);
    this.state = {
        username: '',
        password: ''
    };
    this.doSignIn = this.doSignIn.bind(this);
}

doSignIn() {

let formdata = new FormData();
formdata.append("username", this.state.username)
formdata.append("password", this.state.password)

fetch('http://someweb.com/loginUser',{
method: 'post',
headers: {
'Content-Type': 'multipart/form-data',
},
body: formdata
}).then((response) => response.json())
    .then((responseData) => {
         console.log("Inside responsejson");
         if(responseData.error != true) {
            console.log('You have logged in...');
         }
     }).done();
 }

render() {

return (
  <Container>
    <Header />
    <Content>
      <Form>
        <Item floatingLabel style={{margin: 8}}>
          <Label>Username</Label>
          <Input ref="username" onChangeText={(username) =>
          this.setState({username})}/>
        </Item>
        <Item floatingLabel last style={{margin: 8}}>
          <Label>Password</Label>
          <Input ref="username" onChangeText={(password) =>
          this.setState({password})}/>
        </Item>
         <Button block info style={{margin: 8}} onPress={this.doSignIn}>
        <Text>Login</Text>
      </Button>
      </Form>
    </Content>
  </Container>
  <Text> Hello </Text>
  );
 }
}
</code>```

I want to know what is wrong with the above native-base code that is making the App crash? Is there any way I can make native-base code work?

Thank You.

ReactNative version: 0.50.1

答:
That's because there is import duplicates of Text component

```<code>import { Text } from 'react-native';
import { Container, Header, Content, Form,Text, Item, Input, Label, Button }
from 'native-base';
</code>```

You can import both Text components via as like this

```<code>import { Text as NativeText } from 'react-native';
</code>```

And then use NativeText. Otherwise, do not duplicate your imports.

Body:
I followed the facebook documentation on how to generate signed apk exactly. But still I am getting error: undefined is not an object (evaluating 'e.length'
Here is the screenshot

However, the app works fine in Android Emulator with command react-native run-android.
But, I got the issue which was causing the app to crash. It was native-base.
Here is the following code in my App.js:

import React, { Component } from 'react';
import {Text} from 'react-native';
import { Container, Header, Content, Form,Text, Item, Input, Label, Button }
from 'native-base';
export default class ReactNativeExample extends Component {
constructor(props) {
    super(props);
    this.state = {
        username: '',
        password: ''
    };
    this.doSignIn = this.doSignIn.bind(this);
}

doSignIn() {

let formdata = new FormData();
formdata.append("username", this.state.username)
formdata.append("password", this.state.password)

fetch('http://someweb.com/loginUser',{
method: 'post',
headers: {
'Content-Type': 'multipart/form-data',
},
body: formdata
}).then((response) => response.json())
    .then((responseData) => {
         console.log("Inside responsejson");
         if(responseData.error != true) {
            console.log('You have logged in...');
         }
     }).done();
 }

render() {

return (
  <Container>

    <Content>
      <Form>
        <Item floatingLabel style={{margin: 8}}>
          Username
          <Input ref="username" onChangeText={(username) =>
          this.setState({username})}/>
        </Item>
        <Item floatingLabel last style={{margin: 8}}>
          Password
          <Input ref="username" onChangeText={(password) =>
          this.setState({password})}/>
        </Item>
         <Button block info style={{margin: 8}} onPress={this.doSignIn}>
        <Text>Login</Text>
      </Button>
      </Form>
    </Content>
  </Container>
  <Text> Hello </Text>
  );
 }
}

I want to know what is wrong with the above native-base code that is making the App crash? Is there any way I can make native-base code work?

Thank You.

ReactNative version: 0.50.1

Body:
That's because there is import duplicates of Text component

import { Text } from 'react-native';
import { Container, Header, Content, Form,Text, Item, Input, Label, Button }
from 'native-base';

You can import both Text components via as like this

import { Text as NativeText } from 'react-native';

And then use NativeText. Otherwise, do not duplicate your imports.


问:
Show overlay on image on mobile devices using pure JavaScript
I have a requirement where I need to show overlay on image on mobile devices whenever user touches the image. I am doing it with the code shown below:

document.getElementsByTagName('img')[0].addEventListener('touchstart', function(event){

    let elementExists = document.getElementById('wrapper');
    let Center = document.createElement('div');

    if (!elementExists) {
      let Wrapper = document.createElement('div');
      let parentElement = event.currentTarget.parentElement;
      Wrapper.classList.add('Wrapper');
      Wrapper.id = 'wrapper';

     Center.classList.add('Center');

     parentElement.appendChild(Wrapper);
     Wrapper.appendChild(Center);

      Wrapper.addEventListener('touchend', function(event){
        if (document.getElementById('wrapper')) {
            document.getElementById('wrapper').remove();
        }
      });
    }
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.col-md-6 {
        width: 375px;
        height: 211px;
        margin: 20px;
        position: relative;
    }

        .Wrapper {
        display: table;
        position: absolute;
        background-color: rgba(0, 0, 0, 0.5);
        height: 100% !important;
        width: 100%;
        text-align: center;
        z-index: 1000;
        font-family: arial;
        color: #fff;
        top: 0;
    }

    .Center {
        display: table-cell;
        vertical-align: middle;
    }</code>```

```

The above code works fine, but I have image wrapped in a tag so by default it showing me screen when user touches an image as shown below:

And because of it overlay is not displaying on mobile screen. I would require help how can I fix it.

EDIT:

I am thinking of adding touch swipe event using plain JavaScript but I am not able to do it exactly.
Please let me know if I can get any help!

答: Native behaviour for links on mobile devices works as you explained. It will trigger menu when holding. If you don't need link just remove it like Bojan said.</p>

Body:
I have a requirement where I need to show overlay on image on mobile devices whenever user touches the image. I am doing it with the code shown below:

document.getElementsByTagName('img')[0].addEventListener('touchstart', function(event){

    let elementExists = document.getElementById('wrapper');
    let Center = document.createElement('div');

    if (!elementExists) {
      let Wrapper = document.createElement('div');
      let parentElement = event.currentTarget.parentElement;
      Wrapper.classList.add('Wrapper');
      Wrapper.id = 'wrapper';

     Center.classList.add('Center');

     parentElement.appendChild(Wrapper);
     Wrapper.appendChild(Center);

      Wrapper.addEventListener('touchend', function(event){
        if (document.getElementById('wrapper')) {
            document.getElementById('wrapper').remove();
        }
      });
    }
});

.col-md-6 {
        width: 375px;
        height: 211px;
        margin: 20px;
        position: relative;
    }

        .Wrapper {
        display: table;
        position: absolute;
        background-color: rgba(0, 0, 0, 0.5);
        height: 100% !important;
        width: 100%;
        text-align: center;
        z-index: 1000;
        font-family: arial;
        color: #fff;
        top: 0;
    }

    .Center {
        display: table-cell;
        vertical-align: middle;
    }

The above code works fine, but I have image wrapped in a tag so by default it showing me screen when user touches an image as shown below:

And because of it overlay is not displaying on mobile screen. I would require help how can I fix it.

EDIT:

I am thinking of adding touch swipe event using plain JavaScript but I am not able to do it exactly.
Please let me know if I can get any help!


问:
How to prevent user from navigating away?
In my SAPUI5 application I'm using a sap.tnt.Toolpage as the main layout container. The SideNavigation shows a list of application links and the mainContents is dynamically loaded using the sap.ui.core.routing.Router.

To navigate to a detail page I'm using

```<code>var router = sap.ui.core.UIComponent.getRouterFor(this);
router.navTo("MyDetailRoute", {
    detailItemId: oItem.getBindingContext("oDataSourceName").getProperty("DETAILID")
});
</code>```

This loads a detail view which then binds it's controls to the data from my data source.

The problem arises when I try to remember the user to save his changes back to the server. I basically want to interrup the navigation to aks the user if he'd like to a) Cancel his changes, b) Save his changes or c) Stay on the detail page. While a) and b) are easy to implement, I don't know how to prevent the navigation from happening.

I've tried so far by subscribing to onBeforeHide of my view:

```<code>var view = this.getView();
var that = this;
view.addEventDelegate({
    onBeforeHide: function (evt) {
        var oModel = that.getModel("oDataSourceName");
        if (oModel.hasPendingChanges()) {
            // How to prevent leaving the page?
        }
    }
});
</code>```

Things I've tried that are not working:

evt.preventDefault();

evt.stopPropagation();

throw 'something';

Option 3) actually prevents the navigation but leads to later problems because the URL will change nevertheless...

Does anyone have an idea?

Edit: Thanks to the answer from cschuff I was able to get it working. For anyone who has the same problem in the future:

```<code>// In onInit: Subscribe to onBeforeHide in order to un-register event handler for hashchange

onInit: function () {
    this.getRouter().getRoute("MyDetailRoute").attachPatternMatched(this.onNavigated, this);

    var view = this.getView();
    var that = this;

    view.addEventDelegate({
        onBeforeHide: function (evt) {
            $(window).off('hashchange');
        }
    });
}

// Then in onNavigate stoppen the router, saving the current window location and subscribing to hashchange (only once)
// In hashchange use helper variable m_bSelfURLSetting to prevent the function from running when triggered by URL restore (above)
// In the handler checking for pending changes and either resore the old URL or starting the router again if the user wants to quit or if there are no changes

onNavigated: function (oEvent) {

    this.getRouter().stop();
    this.m_strHref = window.location.href;
    var that = this;

    $(window).off('hashchange').on('hashchange', function (e) {
        if (that.m_bSelfURLSetting) {
            that.m_bSelfURLSetting = false;
            return;
        }

        var oModel = that.getModel("oDataSourceName");
        if (oModel.hasPendingChanges()) {
            var leave = confirm('There are unsaved changes.\r\n\r\nDo you really want to leave the page?');
            if (!leave) {
                // re-set the URL
                that.m_bSelfURLSetting = true;
                window.location.href = that.m_strHref;
            }
            else {
                that.getRouter().initialize(false);
                oModel.resetChanges();
            }
        } else {
            that.getRouter().initialize(false);
        }
    });
}
</code>```

This is definitively not the kind of code one is proud of...

答: Try "onBeforeUnload" event on the window object.</p>

Body:
In my SAPUI5 application I'm using a sap.tnt.Toolpage as the main layout container. The SideNavigation shows a list of application links and the mainContents is dynamically loaded using the sap.ui.core.routing.Router.

To navigate to a detail page I'm using

var router = sap.ui.core.UIComponent.getRouterFor(this);
router.navTo("MyDetailRoute", {
    detailItemId: oItem.getBindingContext("oDataSourceName").getProperty("DETAILID")
});

This loads a detail view which then binds it's controls to the data from my data source.

The problem arises when I try to remember the user to save his changes back to the server. I basically want to interrup the navigation to aks the user if he'd like to a) Cancel his changes, b) Save his changes or c) Stay on the detail page. While a) and b) are easy to implement, I don't know how to prevent the navigation from happening.

I've tried so far by subscribing to onBeforeHide of my view:

var view = this.getView();
var that = this;
view.addEventDelegate({
    onBeforeHide: function (evt) {
        var oModel = that.getModel("oDataSourceName");
        if (oModel.hasPendingChanges()) {
            // How to prevent leaving the page?
        }
    }
});

Things I've tried that are not working:

evt.preventDefault();

evt.stopPropagation();

throw 'something';

Option 3) actually prevents the navigation but leads to later problems because the URL will change nevertheless...

Does anyone have an idea?

Edit: Thanks to the answer from cschuff I was able to get it working. For anyone who has the same problem in the future:

// In onInit: Subscribe to onBeforeHide in order to un-register event handler for hashchange

onInit: function () {
    this.getRouter().getRoute("MyDetailRoute").attachPatternMatched(this.onNavigated, this);

    var view = this.getView();
    var that = this;

    view.addEventDelegate({
        onBeforeHide: function (evt) {
            $(window).off('hashchange');
        }
    });
}

// Then in onNavigate stoppen the router, saving the current window location and subscribing to hashchange (only once)
// In hashchange use helper variable m_bSelfURLSetting to prevent the function from running when triggered by URL restore (above)
// In the handler checking for pending changes and either resore the old URL or starting the router again if the user wants to quit or if there are no changes

onNavigated: function (oEvent) {

    this.getRouter().stop();
    this.m_strHref = window.location.href;
    var that = this;

    $(window).off('hashchange').on('hashchange', function (e) {
        if (that.m_bSelfURLSetting) {
            that.m_bSelfURLSetting = false;
            return;
        }

        var oModel = that.getModel("oDataSourceName");
        if (oModel.hasPendingChanges()) {
            var leave = confirm('There are unsaved changes.\r\n\r\nDo you really want to leave the page?');
            if (!leave) {
                // re-set the URL
                that.m_bSelfURLSetting = true;
                window.location.href = that.m_strHref;
            }
            else {
                that.getRouter().initialize(false);
                oModel.resetChanges();
            }
        } else {
            that.getRouter().initialize(false);
        }
    });
}

This is definitively not the kind of code one is proud of...


问:
how to use nvidia-docker to create service in docker swarm
How do use nvidia-docker to create service in swarm mode of docker operation. I am trying to train a tensorflow model in this swarm network to undergo distributed learning. I found that one way could be to run a swarm network of different containers in different machines and use GPU on each machine to undergo distributed training. If its not possible in swarm mode, Is there any possible way to accomplish the above task?

docker service create --name tensorflow --network overnet saikishor/tfm:test
  azt0tczwkxaqpkh9yaea4laq1

Since --detach=false was not specified, tasks will be created in the background.

In a future release, --detach=false will become the default

but under docker service ls, I have this

ID                  NAME                MODE                REPLICAS            IMAGE                   PORTS

uf6jgp3tm6dp        tensorflow          replicated          0/1                 saikishor/tfm:test

答: As of now, nvidia-docker is not supporting docker swarm. So, there is no possibility now. We need to create an external network to plug them together.</p>


问:
Regexp for a double
I have got this regexp "^[0-9]+\.?[0-9]*$") to match a double number or an integer number in visual C++ but it doesn't seem to work. Any ideas?

This is how I am applying the code:

```<code>if (System::Text::RegularExpressions::Regex::IsMatch(e0, "^[0-9]+\.?[0-9]*$")){
     e0_val = System::Convert::ToDouble(e0);
}
</code>```

答:
the regexp above is not perfect since it accepts "09" which is not a valid number. a better expression would be:

```<code>"^(-?)(0|([1-9][0-9]*))(\\.[0-9]+)?$"
</code>```

where:

```<code>1. is an optional negative sign;
2. is zero or a valid non-zero integer;
4. is the optional fracture part;
</code>```

in theory, the fracture part should be written as "(\.[0-9]*[1-9])?"
instead, because a number must not have tailing zeroes. in practice, the source string might have been created with a fixed number of digits e.g:

```<code>printf("%.1f", x);
</code>```

so it might easily end with a zero character. and, of course, these are all fixed point representations, not the doubles themselves. a double number can
be written as -1.23e-4 as well instead of -0.000123.

ContentLicense: CC BY-SA 4.0

Title: Regexp for a double

Body:
I have got this regexp "^[0-9]+\.?[0-9]*$") to match a double number or an integer number in visual C++ but it doesn't seem to work. Any ideas?

This is how I am applying the code:

if (System::Text::RegularExpressions::Regex::IsMatch(e0, "^[0-9]+\.?[0-9]*$")){
     e0_val = System::Convert::ToDouble(e0);
}

Body:
the regexp above is not perfect since it accepts "09" which is not a valid number. a better expression would be:

"^(-?)(0|([1-9][0-9]*))(\\.[0-9]+)?$"

where:

1. is an optional negative sign;
2. is zero or a valid non-zero integer;
4. is the optional fracture part;

in theory, the fracture part should be written as "(\.[0-9]*[1-9])?"
instead, because a number must not have tailing zeroes. in practice, the source string might have been created with a fixed number of digits e.g:

printf("%.1f", x);

so it might easily end with a zero character. and, of course, these are all fixed point representations, not the doubles themselves. a double number can
be written as -1.23e-4 as well instead of -0.000123.


问:
Angular 4 fire function after server data loaded
How to fire function that requires back end data? My target is to fire getPersons() which depends on getCities() and getCars() with Angular 4.

```<code>export class Person {
  constructor(
    public cities: any[],
    public cars: any[]
  ) { }
}
</code>```

In component I call:

```<code>  public ngOnInit(): void {
    this.getCars();
    this.getCities();
    this.getPersons();
  }
</code>```

EDIT Service:

```<code>  public getCars(): Observable<CarsList> {
    return this.http.get(this.carsUrl)
      .map((res: Response) => res.json())
      .catch((error: Response) => Observable.throw(
        this.errorHandlerService.showError(getCarsError)));
  }
</code>```

Component:

```<code> public getPersons(): void {
    this.personsService.getPersons()
        .subscribe(
          (data) => {
            this.persons = data;
            this.persons .forEach((person, index) => {
              person.carName = this.cars.find((car) => car.id === person.carId).name;
              console.log('error here because this.cars is still undefined')
            }
        )
 }
</code>```

Problem is that getPersons() is fired before getCities() and getCars() are loaded and data depends on it. So this.cities or this.cars objects are null and app crash. How to fire getPersons() when getCities() and getCars() are loaded?
Already tried AfterViewInit with setTimeout workarounds which are not working.

答:
Solved by this way:
Service:

```<code> public async getCars(): Promise<DetailedObjectsList> {
    try {
      const response = await this.http.get(this.carsUrl).toPromise();
      return response.json();
    } catch (e) {
      this.errorHandlerService.showError(carsError);
    }
  }
</code>```

Component:

```<code>  public async getCars() {
    await this.carsService.getCars()
      .then((data) => {
        if (!isNullOrUndefined(data)) {
          this.cars = data.detailedObjects;
        }
      });
  }
</code>```

and most important:

```<code> public ngOnInit(): void {
     this.getCars()
      .then(() => {
        this.getCities()
          .then(() => {
            this.getPersons();
        });
      });
  }
</code>```

I hope that helps for you too.

Body:
How to fire function that requires back end data? My target is to fire getPersons() which depends on getCities() and getCars() with Angular 4.

export class Person {
  constructor(
    public cities: any[],
    public cars: any[]
  ) { }
}

In component I call:

  public ngOnInit(): void {
    this.getCars();
    this.getCities();
    this.getPersons();
  }

EDIT Service:

  public getCars(): Observable<CarsList> {
    return this.http.get(this.carsUrl)
      .map((res: Response) => res.json())
      .catch((error: Response) => Observable.throw(
        this.errorHandlerService.showError(getCarsError)));
  }

Component:

 public getPersons(): void {
    this.personsService.getPersons()
        .subscribe(
          (data) => {
            this.persons = data;
            this.persons .forEach((person, index) => {
              person.carName = this.cars.find((car) => car.id === person.carId).name;
              console.log('error here because this.cars is still undefined')
            }
        )
 }

Problem is that getPersons() is fired before getCities() and getCars() are loaded and data depends on it. So this.cities or this.cars objects are null and app crash. How to fire getPersons() when getCities() and getCars() are loaded?
Already tried AfterViewInit with setTimeout workarounds which are not working.

Body:
Solved by this way:
Service:

 public async getCars(): Promise<DetailedObjectsList> {
    try {
      const response = await this.http.get(this.carsUrl).toPromise();
      return response.json();
    } catch (e) {
      this.errorHandlerService.showError(carsError);
    }
  }

Component:

  public async getCars() {
    await this.carsService.getCars()
      .then((data) => {
        if (!isNullOrUndefined(data)) {
          this.cars = data.detailedObjects;
        }
      });
  }

and most important:

 public ngOnInit(): void {
     this.getCars()
      .then(() => {
        this.getCities()
          .then(() => {
            this.getPersons();
        });
      });
  }

I hope that helps for you too.


问:
Querying for related entities by condition in Symfony(doctrine)
For this question you need to know about 2 entities :

Loan and Charge.  One Loan has Multiple Charges.

So, in my controller, I am querying for each entity and it seems to be lame.

```<code>$query = $this->getDoctrine()
    ->getRepository('AppBundle:Loan')
    ->find($id);

$query1 = $em->createQuery(
'SELECT p
FROM AppBundle:Charge p
WHERE p.loanId = :loanId
AND p.isActive = true
')->setParameter('loanId', $id);
</code>```

I want to transform query1 in smth better, using relationship.

So, from my point of view it must be smth like :

```<code>    foreach($query->getCharges() as $charge) {
     if($charge->getIsActive() == true) {
      //what to put here?
     }
  }
</code>```

If condition passes, how can I obtain the same object that came from DB from my first code?

答:
You can create an extra method on your Loan class that uses ArrayCollections::filter:

```<code>public function getActiveCharges()
{
    return $this->getCharges()->filter(function (Charge $charge) {
        return $charge->getIsActive() === true;

        //or you can omit '=== true'
        return $charge->getIsActive();
    });
}
</code>```

Body:
For this question you need to know about 2 entities :

Loan and Charge.  One Loan has Multiple Charges.

So, in my controller, I am querying for each entity and it seems to be lame.

$query = $this->getDoctrine()
    ->getRepository('AppBundle:Loan')
    ->find($id);

$query1 = $em->createQuery(
'SELECT p
FROM AppBundle:Charge p
WHERE p.loanId = :loanId
AND p.isActive = true
')->setParameter('loanId', $id);

I want to transform query1 in smth better, using relationship.

So, from my point of view it must be smth like :

    foreach($query->getCharges() as $charge) {
     if($charge->getIsActive() == true) {
      //what to put here?
     }
  }

If condition passes, how can I obtain the same object that came from DB from my first code?

Body:
You can create an extra method on your Loan class that uses ArrayCollections::filter:

public function getActiveCharges()
{
    return $this->getCharges()->filter(function (Charge $charge) {
        return $charge->getIsActive() === true;

        //or you can omit '=== true'
        return $charge->getIsActive();
    });
}


问:
IE JQuery ready function not working
Apparently many people have run into this problem, but I have yet to be able to find a solution that works.

I have a bit of code which needs to run once the page has loaded, and so I stuck it inside the following block:

```<code>$(document).ready(function() {
    alert("Running initialization");
    initialize();
});
function checkDivLoaded() {
    if ( $('#footer').length == 0) $.error( 'not ready' );
}
function initialize() {
    try{
        checkDivLoaded();
        ...more code here
    } catch (err) {
        setTimeout(initialize, 200);
    }
}
</code>```

This works fine in all browsers, with the exception of IE. There, the code does not execute at all.

This code is at the lowest point on the page that I can put it (using the Zend Framework and page-specific ready() functions means that there is a limit to how low on the page it can go). I've checked the includes for the js files, which are all being loaded from a local version, and they all have the form

```<code><script type="text/javascript" src=""></script>
</code>```

Any ideas?

NOTE

When I open the debugger in IE, this starts to work correctly.

答:
Using (function($) {})(jQuery); fixed the issue for me.

```<code>(function($) {
  // body code
})(jQuery);
</code>```

Title: IE JQuery ready function not working

Body:
Apparently many people have run into this problem, but I have yet to be able to find a solution that works.

I have a bit of code which needs to run once the page has loaded, and so I stuck it inside the following block:

$(document).ready(function() {
    alert("Running initialization");
    initialize();
});
function checkDivLoaded() {
    if ( $('#footer').length == 0) $.error( 'not ready' );
}
function initialize() {
    try{
        checkDivLoaded();
        ...more code here
    } catch (err) {
        setTimeout(initialize, 200);
    }
}

This works fine in all browsers, with the exception of IE. There, the code does not execute at all.

This code is at the lowest point on the page that I can put it (using the Zend Framework and page-specific ready() functions means that there is a limit to how low on the page it can go). I've checked the includes for the js files, which are all being loaded from a local version, and they all have the form

Any ideas?

NOTE

When I open the debugger in IE, this starts to work correctly.

Body:
Using (function($) {})(jQuery); fixed the issue for me.

(function($) {
  // body code
})(jQuery);


问:
php  how to pass value to another page when click the href? and how to retrieve the value from another page?
How do I pass the value with a href when click href link and go next page? Beside that, on the next page how I retrieve the value?

My code:

```<code>                <?php

            $sql = "SELECT DISTINCT movie.image, movie.name, movie.id
                                FROM movie
                                INNER JOIN movie_genre
                                ON movie.id = movie_genre.movie_id
                                INNER JOIN genre ON genre.id = movie_genre.genre_id
                                INNER JOIN movie_date ON movie_date.movie_id = movie.id
                                ORDER BY timestamp DESC LIMIT 6";

            $res = mysqli_query($conn, $sql);
            if(mysqli_num_rows($res) > 0) {
                while($row = mysqli_fetch_object($res)) {
                    echo '<label class="label1">' . $row->name . '</label><br><br>';
                    echo '<a href="#"><img src="' . $row->image . '" class="poster"></a>';
                    echo '<div class = "section3"><a href="synopsis.php?id="' . $row->id . '" >asd</a>&nbsp &nbsp <a href="">Buy Now</a>';
                }
            }

            ?>
</code>```

答: Using $_GET['id'] you will get value pass from URL</p>

Title: php <a href> how to pass value to another page when click the href? and how to retrieve the value from another page?

Body:
How do I pass the value with a href when click href link and go next page? Beside that, on the next page how I retrieve the value?

My code:

                <?php

            $sql = "SELECT DISTINCT movie.image, movie.name, movie.id
                                FROM movie
                                INNER JOIN movie_genre
                                ON movie.id = movie_genre.movie_id
                                INNER JOIN genre ON genre.id = movie_genre.genre_id
                                INNER JOIN movie_date ON movie_date.movie_id = movie.id
                                ORDER BY timestamp DESC LIMIT 6";

            $res = mysqli_query($conn, $sql);
            if(mysqli_num_rows($res) > 0) {
                while($row = mysqli_fetch_object($res)) {
                    echo '' . $row->name . '

';
                    echo 'image . '" class="poster">';
                    echo '
id . '" >asd&nbsp &nbsp Buy Now';
                }
            }

            ?>


问:
Not getting Firebase database data
I am developing app to display user score that store in firebase database but after running application it won't display data in listview

below is my code:-

```<code>listViewLeaderBoard = (ListView) findViewById(R.id.listView_leader_board);

        reference = FirebaseDatabase.getInstance().getReference("score");

        leaderBoards = new ArrayList<>();

        reference.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                for (DataSnapshot postSnapshot : dataSnapshot.getChildren()){
                    LeaderBoard leaderBoard = postSnapshot.getValue(LeaderBoard.class);
                    leaderBoards.add(0,leaderBoard);
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
        //Collections.sort(leaderBoards);
        CustomLeaderBoardAdapter adapter = new CustomLeaderBoardAdapter(getApplicationContext(),R.layout.leader_board_list_layout,leaderBoards);
        listViewLeaderBoard.setAdapter(adapter);
        adapter.notifyDataSetChanged();
</code>```

Database snapshot:-

Output:-

答:
To solve this, move this line of code:

```<code>List<LeaderBoard> leaderBoards = new ArrayList<>();
</code>```

inside onDataChange() method, otherwise it will always be, due the asynchronous behaviour of this method which is called even before you are trying to add those objects of LeaderBoard class to the list.

Also, leaderBoards.clear(); is no needed anymore. Your code should look something like this:

```<code>DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference scoreRef = rootRef.child("score");
ValueEventListener eventListener = new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        List<String> list = new ArrayList<>();
        for(DataSnapshot ds : dataSnapshot.getChildren()) {
            String imageUrl = ds.child("imageUrl").getValue(String.class);
            String name = ds.child("name").getValue(String.class);
            long score = ds.child("score").getValue(Long.class);
            Log.d("TAG", image + " / " + Urlname + " / " + score);
            list.add(image + " / " + Urlname + " / " + score);
        }
        Log.d("TAG", list);
    }

    @Override
    public void onCancelled(DatabaseError databaseError) {}
};
scoreRef.addListenerForSingleValueEvent(eventListener);
</code>```

Title: Not getting Firebase database data

Body:
I am developing app to display user score that store in firebase database but after running application it won't display data in listview

below is my code:-

listViewLeaderBoard = (ListView) findViewById(R.id.listView_leader_board);

        reference = FirebaseDatabase.getInstance().getReference("score");

        leaderBoards = new ArrayList<>();

        reference.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                for (DataSnapshot postSnapshot : dataSnapshot.getChildren()){
                    LeaderBoard leaderBoard = postSnapshot.getValue(LeaderBoard.class);
                    leaderBoards.add(0,leaderBoard);
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
        //Collections.sort(leaderBoards);
        CustomLeaderBoardAdapter adapter = new CustomLeaderBoardAdapter(getApplicationContext(),R.layout.leader_board_list_layout,leaderBoards);
        listViewLeaderBoard.setAdapter(adapter);
        adapter.notifyDataSetChanged();

Database snapshot:-

Output:-

Body:
To solve this, move this line of code:

List<LeaderBoard> leaderBoards = new ArrayList<>();

inside onDataChange() method, otherwise it will always be, due the asynchronous behaviour of this method which is called even before you are trying to add those objects of LeaderBoard class to the list.

Also, leaderBoards.clear(); is no needed anymore. Your code should look something like this:

DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference scoreRef = rootRef.child("score");
ValueEventListener eventListener = new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        List<String> list = new ArrayList<>();
        for(DataSnapshot ds : dataSnapshot.getChildren()) {
            String imageUrl = ds.child("imageUrl").getValue(String.class);
            String name = ds.child("name").getValue(String.class);
            long score = ds.child("score").getValue(Long.class);
            Log.d("TAG", image + " / " + Urlname + " / " + score);
            list.add(image + " / " + Urlname + " / " + score);
        }
        Log.d("TAG", list);
    }

    @Override
    public void onCancelled(DatabaseError databaseError) {}
};
scoreRef.addListenerForSingleValueEvent(eventListener);


问:
Invalid Identifier for type paramters
I am trying to execute what should be a simple query to get a distance column containing the distance from one SDO_GEOMETRY to another.

My code is as below

```<code>DECLARE query VARCHAR(4000); L_LATITUDE number; L_LONGITUDE number;

BEGIN
IF :P7_USER_POSTCODE IS NOT NULL THEN
    brian.GEOCODE_GM_JSON (:P7_USER_POSTCODE, L_LATITUDE, L_LONGITUDE);
END IF;

query :=     'SELECT
                     S.SPOT_ID,
                     dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
                     IND.SPOT_NAME,
                     IND.SPOT_DESCRIPTION,
                     SPOT.POSTCODE
             FROM SPOT_IMAGES S
             INNER JOIN SURFSPOTINDEX IND ON IND.SPOT_ID = S.SPOT_ID
             INNER JOIN SPOT_LOCATION SPOT ON SPOT.SPOT_ID = IND.SPOT_ID';

IF :P7_SEARCH IS NULL AND :P7_USER_POSTCODE IS NULL THEN
    return query;

ELSIF :P7_SEARCH IS NOT null  AND :P7_USER_POSTCODE IS NULL THEN

    query := query || ' ' ||
          'WHERE CONTAINS(IND.SPOT_DESCRIPTION, :P7_SEARCH, 123) > 0
           OR UPPER(IND.SPOT_NAME) LIKE UPPER(''%'' || :P7_SEARCH || ''%'')
            ';

            RETURN query;

ELSIF :P7_SEARCH IS null  AND :P7_USER_POSTCODE IS NOT NULL THEN

        query :=     'SELECT
                     S.SPOT_ID,
                     dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
                     IND.SPOT_NAME,
                     IND.SPOT_DESCRIPTION,
                     SPOT.POSTCODE,
                     ASDO_GEOM.SDO_DISTANCE(SPOT.LOCATION,
                                          SDO_GEOMETRY(2001,
                                          4326,
                                          SDO_POINT_TYPE(L_LONGITUDE, L_LATITUDE, null),
                                          null,
                                          null)
                     ,0.005, ''unit=mile'')   as DISTANCE
             FROM SPOT_IMAGES S
             INNER JOIN SURFSPOTINDEX IND ON IND.SPOT_ID = S.SPOT_ID
             INNER JOIN SPOT_LOCATION SPOT ON SPOT.SPOT_ID = IND.SPOT_ID
             ORDER BY Distance ASC';

          RETURN query;

END IF;

END;
</code>```

The final else if is where the error occurs.

I get the error

```<code> ORA-00904: "LONGITUDE": invalid identifier
</code>```

I cannot figure out why this is having googled the error code extensively.
The GEOCODE_GM_JSON returns latitude and longitude in the input variables and I have tested this and it is working correctly.

Any help would be appreciated.

Thanks.

答:
You can use DEFINE to use external variables. Then use it as &variable_name in your query.

```<code>DEFINE LATITUDE = 50.5261556;
DEFINE LONGITUDE = -5.5261556;

SELECT
                 S.SPOT_ID,
                 dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
                 IND.SPOT_NAME,
                 IND.SPOT_DESCRIPTION,
                 SPOT.POSTCODE,
                 SDO_GEOM.SDO_DISTANCE(SPOT.LOCATION,
                                          SDO_GEOMETRY(2001,
                                          4326,
                                          SDO_POINT_TYPE(&LATITUDE, &LONGITUDE, null),
                                          null,
                                          null)
                     ,0.005, 'unit=mile')
         FROM SPOT_IMAGES S
         INNER JOIN SURFSPOTINDEX IND ON IND.SPOT_ID = S.SPOT_ID
         INNER JOIN SPOT_LOCATION SPOT ON SPOT.SPOT_ID = IND.SPOT_ID;
</code>```

Title: Invalid Identifier for type paramters

Body:
I am trying to execute what should be a simple query to get a distance column containing the distance from one SDO_GEOMETRY to another.

My code is as below

DECLARE query VARCHAR(4000); L_LATITUDE number; L_LONGITUDE number;

BEGIN
IF :P7_USER_POSTCODE IS NOT NULL THEN
    brian.GEOCODE_GM_JSON (:P7_USER_POSTCODE, L_LATITUDE, L_LONGITUDE);
END IF;

query :=     'SELECT
                     S.SPOT_ID,
                     dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
                     IND.SPOT_NAME,
                     IND.SPOT_DESCRIPTION,
                     SPOT.POSTCODE
             FROM SPOT_IMAGES S
             INNER JOIN SURFSPOTINDEX IND ON IND.SPOT_ID = S.SPOT_ID
             INNER JOIN SPOT_LOCATION SPOT ON SPOT.SPOT_ID = IND.SPOT_ID';

IF :P7_SEARCH IS NULL AND :P7_USER_POSTCODE IS NULL THEN
    return query;

ELSIF :P7_SEARCH IS NOT null  AND :P7_USER_POSTCODE IS NULL THEN

    query := query || ' ' ||
          'WHERE CONTAINS(IND.SPOT_DESCRIPTION, :P7_SEARCH, 123) > 0
           OR UPPER(IND.SPOT_NAME) LIKE UPPER(''%'' || :P7_SEARCH || ''%'')
            ';

            RETURN query;

ELSIF :P7_SEARCH IS null  AND :P7_USER_POSTCODE IS NOT NULL THEN

        query :=     'SELECT
                     S.SPOT_ID,
                     dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
                     IND.SPOT_NAME,
                     IND.SPOT_DESCRIPTION,
                     SPOT.POSTCODE,
                     ASDO_GEOM.SDO_DISTANCE(SPOT.LOCATION,
                                          SDO_GEOMETRY(2001,
                                          4326,
                                          SDO_POINT_TYPE(L_LONGITUDE, L_LATITUDE, null),
                                          null,
                                          null)
                     ,0.005, ''unit=mile'')   as DISTANCE
             FROM SPOT_IMAGES S
             INNER JOIN SURFSPOTINDEX IND ON IND.SPOT_ID = S.SPOT_ID
             INNER JOIN SPOT_LOCATION SPOT ON SPOT.SPOT_ID = IND.SPOT_ID
             ORDER BY Distance ASC';

          RETURN query;

END IF;

END;

The final else if is where the error occurs.

I get the error

 ORA-00904: "LONGITUDE": invalid identifier

I cannot figure out why this is having googled the error code extensively.
The GEOCODE_GM_JSON returns latitude and longitude in the input variables and I have tested this and it is working correctly.

Any help would be appreciated.

Thanks.

Body:
You can use DEFINE to use external variables. Then use it as &variable_name in your query.

DEFINE LATITUDE = 50.5261556;
DEFINE LONGITUDE = -5.5261556;

SELECT
                 S.SPOT_ID,
                 dbms_lob.getlength("THUMBNAIL") "THUMBNAIL",
                 IND.SPOT_NAME,
                 IND.SPOT_DESCRIPTION,
                 SPOT.POSTCODE,
                 SDO_GEOM.SDO_DISTANCE(SPOT.LOCATION,
                                          SDO_GEOMETRY(2001,
                                          4326,
                                          SDO_POINT_TYPE(&LATITUDE, &LONGITUDE, null),
                                          null,
                                          null)
                     ,0.005, 'unit=mile')
         FROM SPOT_IMAGES S
         INNER JOIN SURFSPOTINDEX IND ON IND.SPOT_ID = S.SPOT_ID
         INNER JOIN SPOT_LOCATION SPOT ON SPOT.SPOT_ID = IND.SPOT_ID;


问:
extracting particular number from a line consisting of several numbers using python
As i consists of line having several numbers ,but i need to extract only first 6 digit number

```<code>import re
out=['DOT/R9.4x                 4616542  rtpbuild   x. : 20171111184750 p4 p4burtd review','DOT/dex                 4609974  build      ~. : 20171108044757 p4 p4burtd review']
for item in out:
    line=re.findall(r'\d{7}',item)
    print(line)
</code>```

i'm getting output as:

```<code>['4616542','2017111','1184750']
['4609974','2017110','8044757']
</code>```

but actually i need output of only 1st 7digit number:

```<code>[4616542]
[4609974]
</code>```

i dont need those remaining number which has been divided

答:
It's a list. If you need the first item only, then you need index [0]:

```<code>line=re.findall(r'\d{7}',item)[0]
</code>```

Body:
As i consists of line having several numbers ,but i need to extract only first 6 digit number

import re
out=['DOT/R9.4x                 4616542  rtpbuild   x. : 20171111184750 p4 p4burtd review','DOT/dex                 4609974  build      ~. : 20171108044757 p4 p4burtd review']
for item in out:
    line=re.findall(r'\d{7}',item)
    print(line)

i'm getting output as:

['4616542','2017111','1184750']
['4609974','2017110','8044757']

but actually i need output of only 1st 7digit number:

[4616542]
[4609974]

i dont need those remaining number which has been divided

Body:
It's a list. If you need the first item only, then you need index [0]:

line=re.findall(r'\d{7}',item)[0]


问:
Error while creating react-native app in linux
I have installed node and checked it as the node js docs suggested by doing node -v and npm version  and I got the same expected results as they showed in the docs

But I couldnt run npm install -g react-native-cli

This is the error that I get :

答:
You need to use

```<code>sudo chmod +rwx /usr/lib/node_modules
</code>```

Or run your npm install as sudo but that's never a good idea.

Body:
You need to use

sudo chmod +rwx /usr/lib/node_modules

Or run your npm install as sudo but that's never a good idea.


问:
get the continuous value of week number for the next following year
Can someone help me,
How to get the continuous value of week number for the next following year.
For example 50,51,52,53,54,55,56 ...

Here's my code below:

```<code>now <- as.Date(Sys.time())
dates <- seq(now, now + 900, by = "1 day")
dat <- data.frame(Dates = dates, Week = format(dates, format = "%W"))
dat
</code>```

I want the value continuing to 54,55,56,... instead of starting over from 0,1,2,.. on year change

Thanks

Body:
Can someone help me,
How to get the continuous value of week number for the next following year.
For example 50,51,52,53,54,55,56 ...

Here's my code below:

now <- as.Date(Sys.time())
dates <- seq(now, now + 900, by = "1 day")
dat <- data.frame(Dates = dates, Week = format(dates, format = "%W"))
dat

I want the value continuing to 54,55,56,... instead of starting over from 0,1,2,.. on year change

Thanks

Body:
You can try this

library(lubridate)
library(dplyr)

Dates <- seq(today(), today() + 900, by = "days")
Week  <- week(Dates)
dat   <- data.frame(Dates, Week)

dat %>%
  mutate(
    cumsum = as.integer(cumsum(c(0, diff(Week) != 0))),
    Week_new = case_when(
      year(Dates) %in% year("2017-01-01") ~ Week,
      TRUE                                ~ week(min(Dates)) + cumsum
  )
)

giving you

#        Dates Week cumsum Week_new
#.. ..........   ..      .       ..
#45 2017-12-29   52      6       52
#46 2017-12-30   53      7       53
#47 2017-12-31   53      7       53
#48 2018-01-01    1      8       54
#49 2018-01-02    1      8       54
#50 2018-01-03    1      8       54
#.. ..........    .      .       ..


问:
Why does this JS not work?
I'm trying to calculate the size of 3 elements and if they're greater than the window height, apply another class to a 4 element.

This is what I have so far:

```<code>var limit = $(".logo").height() + $(".nav-items").height() + $(".nav-footer").height();
var win = $(window).height();
    $(document).ready(function(checkHeight) {
        if (limit > win) {
            var element = document.getElementById("sidebar-column");
            element.classList.toggle("red");
    }
});
</code>```

Update:

I would like to apply the check to an existing function - I am VERY NEW to all this, thank you for your patients.

```<code>function aboutUssubNav() {
    var element = document.getElementById("about-us");
    element.classList.toggle("open");
    var element = document.getElementById("about-us-button");
    element.classList.toggle("open");
    // Check Height of Sidebar Elements to position Sidebar Footer
    var limit = $(".logo").height() + $(".nav-items").height() + $(".nav-footer").height();
    var win = $(window).height();
    if (limit > win) {
         var element = document.getElementById("sidebar-column");
         element.classList.toggle("red");
    }
}
</code>```

答:
Just include the variables inside $(document).ready() function.
Something like this:</p>

```<code>    $(document).ready(function() {
        var limit = $(".logo").height() + $(".nav-items").height() + $(".nav-footer").height();
        var win = $(window).height();
        if (limit > win) {
            var element = document.getElementById("sidebar-column");
            element.classList.toggle("red");
        }
    });
</code>```

Title: Why does this JS not work?

Body:
I'm trying to calculate the size of 3 elements and if they're greater than the window height, apply another class to a 4 element.

This is what I have so far:

var limit = $(".logo").height() + $(".nav-items").height() + $(".nav-footer").height();
var win = $(window).height();
    $(document).ready(function(checkHeight) {
        if (limit > win) {
            var element = document.getElementById("sidebar-column");
            element.classList.toggle("red");
    }
});

Update:

I would like to apply the check to an existing function - I am VERY NEW to all this, thank you for your patients.

function aboutUssubNav() {
    var element = document.getElementById("about-us");
    element.classList.toggle("open");
    var element = document.getElementById("about-us-button");
    element.classList.toggle("open");
    // Check Height of Sidebar Elements to position Sidebar Footer
    var limit = $(".logo").height() + $(".nav-items").height() + $(".nav-footer").height();
    var win = $(window).height();
    if (limit > win) {
         var element = document.getElementById("sidebar-column");
         element.classList.toggle("red");
    }
}

Body:
Just include the variables inside $(document).ready() function.
Something like this:

    $(document).ready(function() {
        var limit = $(".logo").height() + $(".nav-items").height() + $(".nav-footer").height();
        var win = $(window).height();
        if (limit > win) {
            var element = document.getElementById("sidebar-column");
            element.classList.toggle("red");
        }
    });


答:
You should use search instead of findall if you are looking for the first occurrence:

```<code>for item in out:
    line=re.search(r'\b\d{7}\b',item)
    print(line.group(0))
</code>```

Notice that re.search returns an SRE_Match object. Another option would be to extract the first value from the list returned by findall.

Edited: Using \b will avoid matching bigger numbers (thanks to @Jean).

Title: extracting particular number from a line consisting of several numbers using python

Body:
You should use search instead of findall if you are looking for the first occurrence:

for item in out:
    line=re.search(r'\b\d{7}\b',item)
    print(line.group(0))

Notice that re.search returns an SRE_Match object. Another option would be to extract the first value from the list returned by findall.

Edited: Using \b will avoid matching bigger numbers (thanks to @Jean).


问:
app:processDebugResources - IllegalArgumentException (no error message)
When build Gradle i get this error message:

```<code>Error:00:29:02.408 [ERROR]   [org.gradle.internal.buildevents.BuildExceptionReporter]
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
 00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:processDebugResources'.
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.lang.IllegalArgumentException (no error message)
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugResources'.
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:32)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:113)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:196)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:193)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:193)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:119)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:102)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:71)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:50)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.runner.RunAsBuildOperationBuildActionRunner$1.execute(RunAsBuildOperationBuildActionRunner.java:43)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.runner.RunAsBuildOperationBuildActionRunner$1.execute(RunAsBuildOperationBuildActionRunner.java:40)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.runner.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:75)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:44)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:29)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:47)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.util.Swapper.swap(Swapper.java:38)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.IllegalArgumentException
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.symbols.Symbol.<init>(Symbol.java:114)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.symbols.SymbolIo.read(SymbolIo.java:79)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:896)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:194)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:82)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 78 more
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
</code>```

I tried rebuild, clean, i hve installed SDK tools.

Here is my Gradle:

```<code>android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
    applicationId "com.example.bolt.skola"
    minSdkVersion 17
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'junit:junit:4.12'
compile 'com.android.support:support-v4:25.2.0'
}
</code>```

答: Make sure that you don't have spaces in your activity name in xml. That was the reason in my case.</p>

Body:
When build Gradle i get this error message:

Error:00:29:02.408 [ERROR]   [org.gradle.internal.buildevents.BuildExceptionReporter]
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
 00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:processDebugResources'.
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.lang.IllegalArgumentException (no error message)
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugResources'.
00:29:02.408 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
00:29:02.409 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:32)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:113)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:196)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:193)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
00:29:02.410 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:193)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:119)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:102)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:71)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:50)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.runner.RunAsBuildOperationBuildActionRunner$1.execute(RunAsBuildOperationBuildActionRunner.java:43)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.runner.RunAsBuildOperationBuildActionRunner$1.execute(RunAsBuildOperationBuildActionRunner.java:40)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.runner.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:75)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:44)
00:29:02.411 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:29)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:47)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.util.Swapper.swap(Swapper.java:38)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
00:29:02.412 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.IllegalArgumentException
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.symbols.Symbol.<init>(Symbol.java:114)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.symbols.SymbolIo.read(SymbolIo.java:79)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:896)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:194)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:82)
00:29:02.413 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 78 more
00:29:02.414 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]

I tried rebuild, clean, i hve installed SDK tools.

Here is my Gradle:

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
    applicationId "com.example.bolt.skola"
    minSdkVersion 17
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'junit:junit:4.12'
compile 'com.android.support:support-v4:25.2.0'
}


问:
How to develop a wordpress site in the root while a static site exists?
Can I have an index2.php file and redirect the htacess file for the meantime?  If so how do I redirect the page for the time being so I can change it later?</p>

答: Much easier to install in a subdirectory like /dev/ and protect the site with a plugin like WordPress › Absolute Privacy « WordPress Plugins and then when it's ready, move it to root: Moving WordPress « WordPress Codex. No need for redirects or vhosts editing.</p>

ContentLicense: CC BY-SA 2.5


答:
```<code>import re
out=['DOT/R9.4x                 4616542  rtpbuild   x. : 20171111184750 p4 p4burtd review','DOT/dex                 4609974  build      ~. : 20171108044757 p4 p4burtd review']
for item in out:
    line=re.findall(r'\d{7}',item)[0]
    print([int(line)])
</code>```


问:
pyspark foreach with arguments
Reading pyspark documentation I know that a foreach is done as:

```<code>def f(x): print(x)
sc.parallelize([1, 2, 3, 4, 5]).foreach(f)
</code>```

But, what if I use a function with several arguments?

An example:

```<code>def f(x,arg1,arg2,arg3):
    print(x*arg1+arg2+arg3)
</code>```

The point is to use something similar this syntax:

```<code>sc.parallelize([1, 2, 3, 4, 5]).foreach(f(arg1=11,arg2=21,arg3=31))
</code>```

答:
You can make a partial function:

```<code><b>from functools import partial</b>

sc.parallelize([1, 2, 3, 4, 5]).foreach(
    <b>partial(</b>f, arg1=11, arg2=21, arg3=31<b>)</b>
 )</code>```

partial takes as input a function and a sequence of unnamed (*args) and named (**kwargs) parameters, and produces a new function that if you call that function will call the original function f, with the unnamed and named parameters already filled in.

Title: pyspark foreach with arguments

Body:
Reading pyspark documentation I know that a foreach is done as:

def f(x): print(x)
sc.parallelize([1, 2, 3, 4, 5]).foreach(f)

But, what if I use a function with several arguments?

An example:

def f(x,arg1,arg2,arg3):
    print(x*arg1+arg2+arg3)

The point is to use something similar this syntax:

sc.parallelize([1, 2, 3, 4, 5]).foreach(f(arg1=11,arg2=21,arg3=31))

Body:
You can make a partial function:

from functools import partial

sc.parallelize([1, 2, 3, 4, 5]).foreach(
    partial(f, arg1=11, arg2=21, arg3=31)
 )

partial takes as input a function and a sequence of unnamed (*args) and named (**kwargs) parameters, and produces a new function that if you call that function will call the original function f, with the unnamed and named parameters already filled in.


问:
Custom pandas groupby on a list of intervals
I have a dataframe df:

```<code>     A    B
0   28  abc
1   29  def
2   30  hij
3   31  hij
4   32  abc
5   28  abc
6   28  abc
7   29  def
8   30  hij
9   28  abc
10  29  klm
11  30  nop
12  28  abc
13  29  xyz

df.dtypes

A    object        # A is a string column as well
B    object
dtype: object
</code>```

I want to use the values from this list to groupby:

```<code>i = np.array([ 3,  5,  6,  9, 12, 14])
</code>```

Basically, all rows in df with index 0, 1, 2 are in the first group, rows with index 3, 4 are in the second group, rows with index 5 are in the third group, and so on.

My end goal is this:

```<code>A              B
28,29,30       abc,def,hij
31,32          hij,abc
28             abc
28,29,30       abc,def,hij
28,29,30       abc,klm,nop
28,29          abc,xyz
</code>```

Solution so far using groupby + pd.cut:

```<code>df.groupby(pd.cut(df.index, bins=np.append([0], i)), as_index=False).agg(','.join)

          A            B
0  29,30,31  def,hij,hij
1     32,28      abc,abc
2        28          abc
3  29,30,28  def,hij,abc
4  29,30,28  klm,nop,abc
5        29          xyz
</code>```

The result is incorrect :-(

How can I do this properly?

答:
You are very close, but use include_lowest=True and right=False in pd.cut because you want 0th index from the bins and then you don't want to include last element each of the bins i.e

```<code>idx = pd.cut(df.index, bins=np.append([0], i),
                      include_lowest=True, right=False)
df.groupby(idx, as_index=False).agg(','.join)
</code>```

```
A              B
28,29,30       abc,def,hij
31,32          hij,abc
28             abc
28,29,30       abc,def,hij
28,29,30       abc,klm,nop
28,29          abc,xyz
```

Body:
I have a dataframe df:

     A    B
0   28  abc
1   29  def
2   30  hij
3   31  hij
4   32  abc
5   28  abc
6   28  abc
7   29  def
8   30  hij
9   28  abc
10  29  klm
11  30  nop
12  28  abc
13  29  xyz

df.dtypes

A    object        # A is a string column as well
B    object
dtype: object

I want to use the values from this list to groupby:

i = np.array([ 3,  5,  6,  9, 12, 14])

Basically, all rows in df with index 0, 1, 2 are in the first group, rows with index 3, 4 are in the second group, rows with index 5 are in the third group, and so on.

My end goal is this:

A              B
28,29,30       abc,def,hij
31,32          hij,abc
28             abc
28,29,30       abc,def,hij
28,29,30       abc,klm,nop
28,29          abc,xyz

Solution so far using groupby + pd.cut:

df.groupby(pd.cut(df.index, bins=np.append([0], i)), as_index=False).agg(','.join)

          A            B
0  29,30,31  def,hij,hij
1     32,28      abc,abc
2        28          abc
3  29,30,28  def,hij,abc
4  29,30,28  klm,nop,abc
5        29          xyz

The result is incorrect :-(

How can I do this properly?

Body:
You are very close, but use include_lowest=True and right=False in pd.cut because you want 0th index from the bins and then you don't want to include last element each of the bins i.e

idx = pd.cut(df.index, bins=np.append([0], i),
                      include_lowest=True, right=False)
df.groupby(idx, as_index=False).agg(','.join)

A              B
28,29,30       abc,def,hij
31,32          hij,abc
28             abc
28,29,30       abc,def,hij
28,29,30       abc,klm,nop
28,29          abc,xyz