问:
Javascript compare arrays to mark occurrences of a specific element
I have an array that contains n arrays that hold a car information (color, company) as follows:

el[0] -> color value

el[1] -> company value

My goal is to show for how many car companies a color can be found.

For example this array

```<code>var array = [
  ['red', 'Ford'],
  ['blue', 'Ford'],
  ['green', 'Ford'],
  ['red', 'Ford'],
  ['red', 'Renault'],
  ['blue', 'Renault'],
  ['green', 'Opel'],
  ['red', 'Opel']
];
</code>```

Should be changed as follows:

```<code> result = [
  ['red', 'Ford', '3: Ford, Renault, Opel'],
  ['blue', 'Ford', '2: Ford, Renault'],
  ['green', 'Ford', '2: Ford, Open'],
  ['red', 'Renault', '3: Ford, Renault, Opel'],
  ['blue', 'Renault', '2: Ford, Renault'],
  ['green', 'Opel', '2: Ford, Opel'],
  ['red', 'Opel', '3: Ford, Renault, Opel']
 ];
</code>```

Explanation:

There are 3 companies having the red color: Ford, Renault, Opel

There are 2 companies having the blue color: Ford, Renault

There are 2 companies having the green color: Ford, Opel

This is how I think it can be solved, but I'm not sure if it's the right approach:

1. Loop through each array and filter the color to get all companies that apply to it

2. Loop through the filter response and remove the duplicates

3. Loop again through the main array and assign the result from step 2 to the corresponding array that has the filtered color

答:
var array = [
  ['red', 'Ford'],
  ['blue', 'Ford'],
  ['green', 'Ford'],
  ['red', 'Ford'],
  ['red', 'Renault'],
  ['blue', 'Renault'],
  ['green', 'Opel'],
  ['red', 'Opel']
];

const res = array.map(set => {
  const newSet = set;
  const same = array.filter(compareSet => set[0] === compareSet[0])
    .map(compareSet => compareSet[1])
    .filter((make, i, arr) => arr.indexOf(make) === i);
  newSet.push(`${same.length} ${same.join(', ')}`);
  return newSet;
});

document.body.innerHTML = JSON.stringify(res).split('],[').join('],
[');```

Body:
I have an array that contains n arrays that hold a car information (color, company) as follows:

el[0] -> color value

el[1] -> company value

My goal is to show for how many car companies a color can be found.

For example this array

var array = [
  ['red', 'Ford'],
  ['blue', 'Ford'],
  ['green', 'Ford'],
  ['red', 'Ford'],
  ['red', 'Renault'],
  ['blue', 'Renault'],
  ['green', 'Opel'],
  ['red', 'Opel']
];

Should be changed as follows:

 result = [
  ['red', 'Ford', '3: Ford, Renault, Opel'],
  ['blue', 'Ford', '2: Ford, Renault'],
  ['green', 'Ford', '2: Ford, Open'],
  ['red', 'Renault', '3: Ford, Renault, Opel'],
  ['blue', 'Renault', '2: Ford, Renault'],
  ['green', 'Opel', '2: Ford, Opel'],
  ['red', 'Opel', '3: Ford, Renault, Opel']
 ];

Explanation:

There are 3 companies having the red color: Ford, Renault, Opel

There are 2 companies having the blue color: Ford, Renault

There are 2 companies having the green color: Ford, Opel

This is how I think it can be solved, but I'm not sure if it's the right approach:

1. Loop through each array and filter the color to get all companies that apply to it

2. Loop through the filter response and remove the duplicates

3. Loop again through the main array and assign the result from step 2 to the corresponding array that has the filtered color

Body:
var array = [
  ['red', 'Ford'],
  ['blue', 'Ford'],
  ['green', 'Ford'],
  ['red', 'Ford'],
  ['red', 'Renault'],
  ['blue', 'Renault'],
  ['green', 'Opel'],
  ['red', 'Opel']
];

const res = array.map(set => {
  const newSet = set;
  const same = array.filter(compareSet => set[0] === compareSet[0])
    .map(compareSet => compareSet[1])
    .filter((make, i, arr) => arr.indexOf(make) === i);
  newSet.push(`${same.length} ${same.join(', ')}`);
  return newSet;
});

document.body.innerHTML = JSON.stringify(res).split('],[').join('], <br/>[');


来源: stackexchange

问:
JPA save BigDecimal as integer in Database
I have this field in the database:

```<code>ITEMCOST    NUMERIC (13)    DEFAULT 0  NOT NULL
</code>```

In JAVA, the field in the Entity is defined like this:

```<code>@Column(name = "ITEMCOST")
private BigDecimal itemCost;
</code>```

The values are stored in the database as integer. Where the last two digits are the decimal values. like this:

DB 100 means 1.00

DB 250  means 2.50

etc

What I want is when I read the Entity the value is loaded like that.
If the value in the database is 357 the BigDeciamal should have the value  "3.57". And when I save that entity, the value should be converted again as INT.

答:
Like the comments say you should use an Attribute converter.

Please find a description here https://www.thoughts-on-java.org/jpa-21-how-to-implement-type-converter/

It could look like this:

```<code>@Converter
public class BigDecimalConverter implements AttributeConverter<BigDecimal, Long> {

  @Override
  public Long convertToDatabaseColumn(BigDecimal value) {
    if (value == null) {
        return null;
    } else {
        return value.multiply(BigDecimal.valueOf(100)).longValue();
    }
  }

  @Override
  public BigDecimal convertToEntityAttribute(Long value) {
    if (value == null) {
        return null;
    } else {
        return new BigDecimal(value).divide(BigDecimal.valueOf(100));
    }
  }
}
</code>```

Then you can use it in your entity

```<code>@Convert(converter = BigDecimalConverter.class)
@Column(name = "ITEMCOST")
private BigDecimal itemCost;
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have this field in the database:

ITEMCOST    NUMERIC (13)    DEFAULT 0  NOT NULL

In JAVA, the field in the Entity is defined like this:

@Column(name = "ITEMCOST")
private BigDecimal itemCost;

The values are stored in the database as integer. Where the last two digits are the decimal values. like this:

DB 100 means 1.00

DB 250  means 2.50

etc

What I want is when I read the Entity the value is loaded like that.
If the value in the database is 357 the BigDeciamal should have the value  "3.57". And when I save that entity, the value should be converted again as INT.

Body:
Like the comments say you should use an Attribute converter.

Please find a description here https://www.thoughts-on-java.org/jpa-21-how-to-implement-type-converter/

It could look like this:

@Converter
public class BigDecimalConverter implements AttributeConverter<BigDecimal, Long> {

  @Override
  public Long convertToDatabaseColumn(BigDecimal value) {
    if (value == null) {
        return null;
    } else {
        return value.multiply(BigDecimal.valueOf(100)).longValue();
    }
  }

  @Override
  public BigDecimal convertToEntityAttribute(Long value) {
    if (value == null) {
        return null;
    } else {
        return new BigDecimal(value).divide(BigDecimal.valueOf(100));
    }
  }
}

Then you can use it in your entity

@Convert(converter = BigDecimalConverter.class)
@Column(name = "ITEMCOST")
private BigDecimal itemCost;


问:
PHP memory_limit -1 does not work, seems to be 6GB
On a non production system I export data from a Magento shop using PHP script on CLI. Even if I use this settings

```<code>php -i | grep memory_limit
memory_limit => -1 => -1
</code>```

or (for testing, if "-1" is a problem)

```<code>php -i | grep memory_limit
memory_limit => 9000M => 9000M
</code>```

in my /etc/php/7.0/cli/php.ini, I get the following error:

Fatal error: Allowed memory size of 6290000000 bytes exhausted (tried to allocate 232422 bytes)

Memory of the system using command "top":

```<code>KiB Mem : 20561176 total,  8667804 free,  7096968 used,  4796404 buff/cache
KiB Swap:  4190204 total,  4067004 free,   123200 used. 13050308 avail Mem
</code>```

How can I increase the memory limit to really unlimited?

Exists other settings I don't know?

答:
There was a hard coded </p>

```<code>ini_set('memory_limit', '6000M');
</code>```

<p>in the Magento code. Sorry for my question. </p>

Body:
On a non production system I export data from a Magento shop using PHP script on CLI. Even if I use this settings

php -i | grep memory_limit
memory_limit => -1 => -1

or (for testing, if "-1" is a problem)

php -i | grep memory_limit
memory_limit => 9000M => 9000M

in my /etc/php/7.0/cli/php.ini, I get the following error:

Fatal error: Allowed memory size of 6290000000 bytes exhausted (tried to allocate 232422 bytes)

Memory of the system using command "top":

KiB Mem : 20561176 total,  8667804 free,  7096968 used,  4796404 buff/cache
KiB Swap:  4190204 total,  4067004 free,   123200 used. 13050308 avail Mem

How can I increase the memory limit to really unlimited?

Exists other settings I don't know?

Body:
There was a hard coded

ini_set('memory_limit', '6000M');

in the Magento code. Sorry for my question.


问:
Wordpress ACF get_field( ) not returning value
I am using the advanced custom field plugin for Wordpress. I am having difficulty displaying a field on my page.

Basically I've created a field group and assigned id's to the members of that group. I then use the get_field('field_name') function to store the value of this field in a variable and echo it on the screen. However this is returning false.

I've also tried using the_field('field_name') but this returns null. I then read somewhere If you are trying to access a field outside of the Wordpress loop you must pass the post id as a parameter to the get_field()/the_field() methods.

I've tried that and still the same result...Does anyone have any idea as to what is the problem?

This is my code:

```<code><?php get_header();
      $postID = get_the_ID();
      the_field('the-title', $postID); //Nothing being returned...
      die();
?>
</code>```

答: If you're using WP_Query() before using get_field(), you need to reset the query using wp_reset_query() function. I hope it'll solve this issue.

Body:
I am using the advanced custom field plugin for Wordpress. I am having difficulty displaying a field on my page.

Basically I've created a field group and assigned id's to the members of that group. I then use the get_field('field_name') function to store the value of this field in a variable and echo it on the screen. However this is returning false.

I've also tried using the_field('field_name') but this returns null. I then read somewhere If you are trying to access a field outside of the Wordpress loop you must pass the post id as a parameter to the get_field()/the_field() methods.

I've tried that and still the same result...Does anyone have any idea as to what is the problem?

This is my code:

<?php get_header();
      $postID = get_the_ID();
      the_field('the-title', $postID); //Nothing being returned...
      die();
?>


问:
How to set grid kendo fields condionnally?
I have a kendo grid with columns like below:

```<code> columns: [
        {
          title: 'Solde Débiteur',
          field: 'sold', // if sold > 0
          filterable: { cell: { operator: 'eq', showOperators: false } }
        },
        {
          title: 'Solde Créditeur',
          field: 'sold', // if sold < 0
          filterable: { cell: { operator: 'eq', showOperators: false } }
        }
]
</code>```

how can populate my grid anf set sold in first column if it is positive and in the second if negative?

thanks in advance.

答:
You can use template to fill column conditionally. For example:

```<code> columns: [
        {
          title: 'Solde Débiteur',
          field: 'sold', // if sold > 0
          filterable: { cell: { operator: 'eq', showOperators: false } },
          template: "<div>#= sold > 0 ? sold :0 #</div>" //if sold > 0 return sold else 0
        },
        {
          title: 'Solde Créditeur',
          field: 'sold', // if sold < 0
          filterable: { cell: { operator: 'eq', showOperators: false } }
          template: "<div>#= sold < 0 ? sold :0 #</div>" // if sold < 0 return sold else 0
        }
]
</code>```

Body:
I have a kendo grid with columns like below:

 columns: [
        {
          title: 'Solde Débiteur',
          field: 'sold', // if sold > 0
          filterable: { cell: { operator: 'eq', showOperators: false } }
        },
        {
          title: 'Solde Créditeur',
          field: 'sold', // if sold < 0
          filterable: { cell: { operator: 'eq', showOperators: false } }
        }
]

how can populate my grid anf set sold in first column if it is positive and in the second if negative?

thanks in advance.

Body:
You can use template to fill column conditionally. For example:

 columns: [
        {
          title: 'Solde Débiteur',
          field: 'sold', // if sold > 0
          filterable: { cell: { operator: 'eq', showOperators: false } },
          template: "<div>#= sold > 0 ? sold :0 #</div>" //if sold > 0 return sold else 0
        },
        {
          title: 'Solde Créditeur',
          field: 'sold', // if sold < 0
          filterable: { cell: { operator: 'eq', showOperators: false } }
          template: "<div>#= sold < 0 ? sold :0 #</div>" // if sold < 0 return sold else 0
        }
]


问:
Getting DOM of object user clicks on
Ok people can make a list on my website by pushing the ADD button. the code to do this is as follows (using jquery):

```<code><script type="text/javascript">
 function voegToe(){
 $('#sortable1').append("<li class='ui-state-default'>" + $('#product').html() + $('#eiwit').html() + " <button id='voegtoe' class='zoek' type='button' onClick='deleteObject();'>del</button></li>");
 }
</script>
</code>```

so pushing the button adds a LI element in the UL#sortable1 which also has a delete button in it. Now I want to make an event that when the users clicks the delete button of a certain list item, that list items is removed from the list.

How can I do this? because now when a list is made, all the li id's or classes are the same, so I can't use that to specify which element should be removed. So how can I say: delete only the LI of which the delete button was pressed?

```<code>    <script type="text/javascript">
     function voegToe(){
      $('??????').remove();
     }
    </script>
</code>```

答:
Using jQuery 1.4.2+:

```<code>$('#sortable1').delegate('button', 'click', function() {
    $(this).parent().remove();
});
</code>```

By the way, you shouldn't have duplicate IDs, but rather you should use another class instead. Elements can be part of multiple classes; the class HTML attribute is a space-separated list.

ContentLicense: CC BY-SA 2.5

Title: Getting DOM of object user clicks on

Body:
Ok people can make a list on my website by pushing the ADD button. the code to do this is as follows (using jquery):

so pushing the button adds a LI element in the UL#sortable1 which also has a delete button in it. Now I want to make an event that when the users clicks the delete button of a certain list item, that list items is removed from the list.

How can I do this? because now when a list is made, all the li id's or classes are the same, so I can't use that to specify which element should be removed. So how can I say: delete only the LI of which the delete button was pressed?

Body:
Using jQuery 1.4.2+:

$('#sortable1').delegate('button', 'click', function() {
    $(this).parent().remove();
});

By the way, you shouldn't have duplicate IDs, but rather you should use another class instead. Elements can be part of multiple classes; the class HTML attribute is a space-separated list.


问:
Using Xamarin.Forms with Native pages (Xamarin.iOS, UWP)
I already have a solution which consist of Xamarin.iOS and UWP. We have multiple views (Pages) in both platforms. We are using MvvmCross, so we have a common code (PCL) which consists of Viewmodels, business logic etc. Also, we have separate views (Pages) for both Xamarin.iOS and UWP.

Now I want to add Xamarin.Forms support for native pages of both projects so that we have same views for both Xamarin.iOS and UWP. We need the support of navigation (from Native to Xamarin.Forms & vice versa). I am navigating through MvvmCross navigation service.

For instance,
I have FirstFormView in Xamarin.Forms project.
I have SecondFormView in Native project (can be Xamarin.iOS or UWP).
I have ThirdFormView in Xamarin.Froms project.

I have navigated to FirstFormView (which is staring page of my application)
Now I want to go to SecondFormView (which is in native project).
And from SecondFormView  I need to go to ThirdFormView which is again in Xamarin.Forms

Is it possible to do it MvvmCross? If yes, then what steps should we follow to achieve our desired goal.

Thanks in advance.

Regards,

答:
This is possible through the Forms presenters. Take a look at the playground: https://github.com/MvvmCross/MvvmCross/tree/develop/TestProjects/Playground/Playground.Forms.Droid

Here the views are all Forms, but 1 or 2 are in Native. By using the same solution you should be able to do this.


问:
React Bootstrap Checkbox in Nav -> NavItem does not rerender on click
I have a peculiar problem with using a Nav and NavItem with a Checkbox from React Bootstrap. The thing is that if I click directly on the checkbox and not the NavItem button the checkbox will not re-render correctly but my state has updated.

Example: Given the code below I render the component and click directly on the checkbox. In this case showMap will be set to false since we set it to true in the constructor but the checkbox will still be checked in the html view. If I however click on the NavItem but not directly on the checkbox both the state showMap is updated correctly as well as the view.

https://react-bootstrap.github.io/components.html#navs

```<code>import * as React from "react";
import * as ReactDOM from "react-dom";
import { LinkContainer } from 'react-router-bootstrap';
import { Col, Nav, NavItem, Checkbox } from "react-bootstrap";

interface IProps {

}

interface IState {
    showMap: boolean
}

export class Menu extends React.Component<IProps, IState> {
    constructor(props: any) {
        super(props);
        this.state = {
            showMap: true
        }
    }

    toggleCheckbox = (event: any) => {
        event.preventDefault();
        this.setState({ showMap: !this.state.showMap });
    }

    render() {
        return (
            <div>
                <Nav bsStyle="tabs" activeKey="1">
                    <LinkContainer to="/test">
                        <NavItem eventKey="1">Test</NavItem>
                    </LinkContainer>
                    <LinkContainer to="/test2">
                        <NavItem eventKey="2">Test2</NavItem>
                    </LinkContainer>
                    <NavItem eventKey="3" onClick={this.toggleCheckbox}><Checkbox name="showMap" inline checked={this.state.showMap} readOnly >
                    Show Map </Checkbox></NavItem>
                </Nav>
            </div>
        )
    }
}
</code>```

Update:

Tried it like this as well, still the same result:

```<code>import * as React from "react";
import * as ReactDOM from "react-dom";
import { LinkContainer } from 'react-router-bootstrap';
import { Navbar, Nav, NavItem, Checkbox } from "react-bootstrap";

interface IProps {

}

interface IState {
    showMap: boolean
}

export class Menu extends React.Component<IProps, IState> {
    constructor(props: any) {
        super(props);
        this.state = {
            showMap: true
        }
    }

    toggleCheckbox = (event: any) => {
        event.preventDefault();
        this.setState({ showMap: !this.state.showMap });
    }

    render() {
        return (
            <div>
                <Navbar>
                    <Nav bsStyle="tabs" activeKey="1">
                        <LinkContainer to="/test">
                            <NavItem eventKey="1">Test</NavItem>
                        </LinkContainer>
                        <LinkContainer to="/test2">
                            <NavItem eventKey="2">Test2</NavItem>
                        </LinkContainer>
                        <NavItem eventKey="5" onClick={this.toggleCheckbox}><input type="checkbox" name="showMap"
                            checked={this.state.showMap} readOnly />Show map</NavItem>
                    </Nav>
                   </Navbar>
            </div>
        )
    }
}
</code>```

答:
Created an issue with React Bootstrap here. https://github.com/react-bootstrap/react-bootstrap/issues/2876

They did however think it had to do with React so I created an issue with them https://github.com/facebook/react/issues/11539.

The React team however got to the conclusion this was browser native behavior.

If anyone ends up here this is how I fixed it:

```<code>toggleCheckbox = (event: any) => {
    this.setState({ showMap: !this.state.showMap });
}

const showMapStyle: React.CSSProperties = {
    paddingTop: '15px',
    paddingBottom: '15px',
}

    ...
    </Nav>
    <div onClick={this.toggleCheckbox} role='button' style={showMapStyle}><input type="checkbox" name="showMap"
        checked={this.state.showMap} readOnly />Show map</div>
</Navbar>
</code>```

I also tried with adding a li item inside  but then I got this warning:

React does not recognize the activeKey prop on a DOM element. If you
  intentionally want it to appear in the DOM as a custom attribute,
  spell it as lowercase activekey instead. If you accidentally passed
  it from a parent component, remove it from the DOM element.

https://github.com/react-bootstrap/react-bootstrap/issues/2199

```<code><li onClick={this.toggleCheckbox} role='button' style={showMapStyle}><input type="checkbox" id="showMap" name="showMap"
    checked={this.state.showMap} readOnly />Show map</li>
</code>```

Body:
I have a peculiar problem with using a Nav and NavItem with a Checkbox from React Bootstrap. The thing is that if I click directly on the checkbox and not the NavItem button the checkbox will not re-render correctly but my state has updated.

Example: Given the code below I render the component and click directly on the checkbox. In this case showMap will be set to false since we set it to true in the constructor but the checkbox will still be checked in the html view. If I however click on the NavItem but not directly on the checkbox both the state showMap is updated correctly as well as the view.

https://react-bootstrap.github.io/components.html#navs

import * as React from "react";
import * as ReactDOM from "react-dom";
import { LinkContainer } from 'react-router-bootstrap';
import { Col, Nav, NavItem, Checkbox } from "react-bootstrap";

interface IProps {

}

interface IState {
    showMap: boolean
}

export class Menu extends React.Component<IProps, IState> {
    constructor(props: any) {
        super(props);
        this.state = {
            showMap: true
        }
    }

    toggleCheckbox = (event: any) => {
        event.preventDefault();
        this.setState({ showMap: !this.state.showMap });
    }

    render() {
        return (

                    <LinkContainer to="/test">
                        <NavItem eventKey="1">Test</NavItem>
                    </LinkContainer>
                    <LinkContainer to="/test2">
                        <NavItem eventKey="2">Test2</NavItem>
                    </LinkContainer>
                    <NavItem eventKey="3" onClick={this.toggleCheckbox}><Checkbox name="showMap" inline checked={this.state.showMap} readOnly >
                    Show Map </Checkbox></NavItem>

        )
    }
}

Update:

Tried it like this as well, still the same result:

import * as React from "react";
import * as ReactDOM from "react-dom";
import { LinkContainer } from 'react-router-bootstrap';
import { Navbar, Nav, NavItem, Checkbox } from "react-bootstrap";

interface IProps {

}

interface IState {
    showMap: boolean
}

export class Menu extends React.Component<IProps, IState> {
    constructor(props: any) {
        super(props);
        this.state = {
            showMap: true
        }
    }

    toggleCheckbox = (event: any) => {
        event.preventDefault();
        this.setState({ showMap: !this.state.showMap });
    }

    render() {
        return (

                <Navbar>

                        <LinkContainer to="/test">
                            <NavItem eventKey="1">Test</NavItem>
                        </LinkContainer>
                        <LinkContainer to="/test2">
                            <NavItem eventKey="2">Test2</NavItem>
                        </LinkContainer>
                        <NavItem eventKey="5" onClick={this.toggleCheckbox}><input type="checkbox" name="showMap"
                            checked={this.state.showMap} readOnly />Show map</NavItem>

                   </Navbar>

        )
    }
}

Body:
Created an issue with React Bootstrap here. https://github.com/react-bootstrap/react-bootstrap/issues/2876

They did however think it had to do with React so I created an issue with them https://github.com/facebook/react/issues/11539.

The React team however got to the conclusion this was browser native behavior.

If anyone ends up here this is how I fixed it:

toggleCheckbox = (event: any) => {
    this.setState({ showMap: !this.state.showMap });
}

const showMapStyle: React.CSSProperties = {
    paddingTop: '15px',
    paddingBottom: '15px',
}

    ...
    </Nav>
    <div onClick={this.toggleCheckbox} role='button' style={showMapStyle}><input type="checkbox" name="showMap"
        checked={this.state.showMap} readOnly />Show map</div>
</Navbar>

I also tried with adding a li item inside <Nav> but then I got this warning:

React does not recognize the activeKey prop on a DOM element. If you
  intentionally want it to appear in the DOM as a custom attribute,
  spell it as lowercase activekey instead. If you accidentally passed
  it from a parent component, remove it from the DOM element.

https://github.com/react-bootstrap/react-bootstrap/issues/2199

<li onClick={this.toggleCheckbox} role='button' style={showMapStyle}><input type="checkbox" id="showMap" name="showMap"
    checked={this.state.showMap} readOnly />Show map</li>


问:
Sails.js Data undefined
I'm trying to create function named Edit function and update function to update items in the database bying using sails.js but its said Length it can't read property of undefined. I'm kinda stuck here, please help.

This is a picture of Edit and Update functions

This is an error result that I got when I click on Edit button

<!DOCTYPE html>

 <title>Edit Item | Make4You</title>
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">

Edit Item

 <form method="post" action="/item/update?id=<%= items.id %>">

   Title
   <input type="text" name="title" class="form-control" value="<%= items.title %>">
   Category
   <select name="category_id">
   <% for (var j=0; j<categories.length; j++){ %>
   <option value="<% if(items[i].category_id == categories[j].id){ %>"><%= categories[j].name %></option>
   <% } %>
   <% } %>
   </select>
   Description
   <input type="text" name="description" class="form-control" value="<%= items.description %>">
   Width
   <input type="text" name="width" class="form-control" value="<%= items.width %>">
   Height
   <input type="text" name="height" class="form-control" value="<%= items.height %>">
   Price
   <input type="price" name="price" class="form-control" value="<%= items.price %>">

  <input type="submit" value="submit">
 </form>

```

答:
In your edit method, it looks like you are trying to fetch both an Item and a Category using the same id (req.param('id'))... you probably mean to either pass in two different ids, or use a category id attached to the fetched Item or something...

Also, you have a little confusion between find and findOne. find will always return an array of results, possibly empty. findOne will return a single object if found, or undefined if not:

```<code>Category.find({id: category_id}).exec(function(err, results) {
    // results is an array, possibly empty
});

Category.findOne({id: category_id}).exec(function(err, results) {
    // results is either a model or undefined
});
</code>```

From the error returned from your view, it looks like maybe you want the array. And remember that checking for empty results (undefined or a zero-length array) is a distict check from looking at the err parameter - empty results are not an error.

Title: Sails.js Data undefined

Body:
In your edit method, it looks like you are trying to fetch both an Item and a Category using the same id (req.param('id'))... you probably mean to either pass in two different ids, or use a category id attached to the fetched Item or something...

Also, you have a little confusion between find and findOne. find will always return an array of results, possibly empty. findOne will return a single object if found, or undefined if not:

Category.find({id: category_id}).exec(function(err, results) {
    // results is an array, possibly empty
});

Category.findOne({id: category_id}).exec(function(err, results) {
    // results is either a model or undefined
});

From the error returned from your view, it looks like maybe you want the array. And remember that checking for empty results (undefined or a zero-length array) is a distict check from looking at the err parameter - empty results are not an error.


问:
Dynamically opening modal with different content on button click
i am trying to develop angular2 application. I have 9 buttons in each of the card footers on a page. Clicking on any button or anchor tag should open the modal of bootstrap but it has to have different content for every click. The template for modal has to be the same except the content has to be different for every button clicked. Right now the modal opens on every button with the same template and content. How to associate ID with button so that click results in same modal template but different content.

Here's my code in sample.component.html

```<code>           <div class="row">
     <div class="col-md-4">
            <div class="card">
                <div class="card-content">
                    <div class="card-header-orange">
                       <h1 class="card-heading">Card Header Blue</h1>
                    </div>
                    <div class="card-body">
                      <p class="card-p">
                            There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour,
                            or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there
                            isn't anything embarrassing hidden in the middle of text.

                        </p>
                    </div><br>
                    <div class="card-footer">
                  <button (click)="openModal(template)" class="btn btn-primary">Learn More</button>
                </div>

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

    <div class="col-md-4">
            <div class="card">
                <div class="card-content">
                    <div class="card-header-orange">
                       <h1 class="card-heading">Card Header Blue</h1>
                    </div>
                    <div class="card-body">
                      <p class="card-p">
                            There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour,
                            or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there
                            isn't anything embarrassing hidden in the middle of text.

                        </p>
                    </div><br>
                    <div class="card-footer">
                  <button (click)="openModal(template)" class="btn btn-primary">Learn More</button>
                </div>

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

      <div class="col-md-4">
            <div class="card">
                <div class="card-content">
                    <div class="card-header-orange">
                       <h1 class="card-heading">Card Header Blue</h1>
                    </div>
                    <div class="card-body">
                      <p class="card-p">
                            There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour.
                        </p>
                    </div><br>
                    <div class="card-footer">
                     <button (click)="openModal(template)" class="btn btn-primary">Learn More</button>
                    </div>

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

Here is my modal template:

```<code>      <ng-template #template>
     <div class="modal-header">
    <h4 class="modal-title pull-left">Modal</h4>
       <button type="button" class="close pull-right" aria-label="Close"   (click)="modalRef.hide()">
        <span aria-hidden="true">×</span>
    </button>
   </div>
 <div class="modal-body">
This is a modal.
 </div>
</code>```

答:
You could try out the ng-content feature. You can use it as reference:- https://blog.angular-university.io/angular-ng-content/

If you use ng-content to dynamically change the content of the modal body, then your modal would look something like this:-

modal.component.html :-

```<code><div class="modal">
<div class="modal-dialog">
    <div class="modal-header">
        <span class="close-modal" (click)="closeModal()">x</span>
        <ng-content select="[modal-header]"></ng-content>
    </div>

    <div class="modal-content-container">
        <br>
        <br>
        <ng-content select="[modal-body]"></ng-content>
    </div>
</div>

<div class="overlay" (click)="closeModal()"></div>
</code>```

and the call to the modal component should be like:-

abc.component.html:-

```<code><modal >
<div modal-header>
    <h3>Instance</h3>
</div>
<div modal-body>
    "Your Template"
</div>
</code>```

This is one way or else you could also use another way which is of dynamic component loader, which is more of a pro way to code. You can check for reference here:- https://angular.io/guide/dynamic-component-loader

Using component loader, we can dynamically load any component template into modal according to options.

If you opt to use the component loader then your modal would like :-

```<code><div class="modal">

<div class="modal-dialog" *ngIf="(selectors$ | async).state">

    <div class="modal-header">
         <span class="close-modal" (click)="closeModal()">x</span>
    </div>

    <div class="modal-content-container">
         <ng-container component-loader [config]="selectors.component" [payload]="selectors.data"></ng-container>
    </div>
</div>

<div class="modal-overlay" (click)="closeModal()" *ngIf="(selectors$ | async).state"></div>
</code>```

in this component loader is the directive which dynamically load different component according to the input recieved. The modal.component.ts file would be like:-

@Component({
        selector: 'modal',
        templateUrl: './modal.component.html',
   })

export class ModalComponent{
       @Input selectors: Observable;
       constructor( )
   }

The selectors would be an object like this :-
selectors = {
component: "Name of the component to be dynamically loaded",
data: "Any data to be passed to the dynamically loaded component as input"
}

Body:
i am trying to develop angular2 application. I have 9 buttons in each of the card footers on a page. Clicking on any button or anchor tag should open the modal of bootstrap but it has to have different content for every click. The template for modal has to be the same except the content has to be different for every button clicked. Right now the modal opens on every button with the same template and content. How to associate ID with button so that click results in same modal template but different content.

Here's my code in sample.component.html

Card Header Blue

                            There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour,
                            or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there
                            isn't anything embarrassing hidden in the middle of text.

                  <button (click)="openModal(template)" class="btn btn-primary">Learn More</button>

Card Header Blue

                            There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour,
                            or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there
                            isn't anything embarrassing hidden in the middle of text.

                  <button (click)="openModal(template)" class="btn btn-primary">Learn More</button>

Card Header Blue

                            There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour.

                     <button (click)="openModal(template)" class="btn btn-primary">Learn More</button>

Here is my modal template:

      <ng-template #template>

Modal

       <button type="button" class="close pull-right" aria-label="Close"   (click)="modalRef.hide()">
        ×
    </button>

This is a modal.

Body:
You could try out the ng-content feature. You can use it as reference:- https://blog.angular-university.io/angular-ng-content/

If you use ng-content to dynamically change the content of the modal body, then your modal would look something like this:-

modal.component.html :-

<div class="modal">
<div class="modal-dialog">
    <div class="modal-header">
        <span class="close-modal" (click)="closeModal()">x</span>
        <ng-content select="[modal-header]"></ng-content>
    </div>

    <div class="modal-content-container">
        <br>
        <br>
        <ng-content select="[modal-body]"></ng-content>
    </div>
</div>

<div class="overlay" (click)="closeModal()"></div>

and the call to the modal component should be like:-

abc.component.html:-

<modal >
<div modal-header>
    <h3>Instance</h3>
</div>
<div modal-body>
    "Your Template"
</div>

This is one way or else you could also use another way which is of dynamic component loader, which is more of a pro way to code. You can check for reference here:- https://angular.io/guide/dynamic-component-loader

Using component loader, we can dynamically load any component template into modal according to options.

If you opt to use the component loader then your modal would like :-

<div class="modal">

<div class="modal-dialog" *ngIf="(selectors$ | async).state">

    <div class="modal-header">
         <span class="close-modal" (click)="closeModal()">x</span>
    </div>

    <div class="modal-content-container">
         <ng-container component-loader [config]="selectors.component" [payload]="selectors.data"></ng-container>
    </div>
</div>

<div class="modal-overlay" (click)="closeModal()" *ngIf="(selectors$ | async).state"></div>

in this component loader is the directive which dynamically load different component according to the input recieved. The modal.component.ts file would be like:-

@Component({
        selector: 'modal',
        templateUrl: './modal.component.html',
   })

export class ModalComponent{
       @Input selectors: Observable;
       constructor( )
   }

The selectors would be an object like this :-
selectors = {
component: "Name of the component to be dynamically loaded",
data: "Any data to be passed to the dynamically loaded component as input"
}


问:
Css. Doesn't work text-overflow: ellipsis
I have something like this:

```<code><div>
  <span>
    text text text text text text
  </span>
</div>

div{
  width:100px;
  border: 1px solid black;
  line-height: 12px;
  height: 16px;
  position: relative;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

span{
  position: absolute;
  overflow: hidden;
  text-overflow: ellipsis;
}
</code>```

And ellipsis doesn't work.
I do not necessarily need to use position: absolute, but as result I should have text, that doesn't expand div and truncated width ellipsis.

P.S. Width for div is included for sample, in reality div width is unknown.

答:
Try adding width: 100% to your span:

div{
  width:100px;
  border: 1px solid black;
  line-height: 12px;
  height: 16px;
  position: relative;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

span{
  position: absolute;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
  <span>
    text text text text text text
  </span>
</div></code>```

Body:
I have something like this:

    text text text text text text

div{
  width:100px;
  border: 1px solid black;
  line-height: 12px;
  height: 16px;
  position: relative;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

span{
  position: absolute;
  overflow: hidden;
  text-overflow: ellipsis;
}

And ellipsis doesn't work.
I do not necessarily need to use position: absolute, but as result I should have text, that doesn't expand div and truncated width ellipsis.

P.S. Width for div is included for sample, in reality div width is unknown.

Body:
Try adding width: 100% to your span:

div{
  width:100px;
  border: 1px solid black;
  line-height: 12px;
  height: 16px;
  position: relative;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

span{
  position: absolute;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

<div>
  <span>
    text text text text text text
  </span>
</div>


问:
Retrieving URL data when Content-Range is sent in PHP
There's many options available for downloading a URL in PHP - but I'm stuck.

I've looked through all the ones I know, but none seem to pay attention to partial content headers.

I'm trying to retrieve a URL that gives the following header:
HTTP/1.1 206 Partial Content
Content-Range:   bytes 0-100000/631723

As you can see it dishes out the file in 100,000 byte chunks.

Trouble is, when I use any method in PHP, ie file_get_contents, fopen, or even cURL, none of these continue on after receiving the first 100,000 bytes.

End result, I have a 100,000 byte file.

What I need is to get the PHP script to grab all the data, in the example above, all 631,723 bytes.

How can I do this?

答:
If you're getting a 206 Partial Content response, then you must have included a Range header field indicating the desired range in your request:

e.g.

```<code>GET /2390/2253727548_a413c88ab3_s.jpg HTTP/1.1
Host: farm3.static.flickr.com
Range: bytes=0-999
</code>```

or there's a proxy somewhere that is breaking the requests into a series of range requests

EDIT

As a resolution, you might want to try sending a series of requests using the Get Range, then stitching them all together as you get each response

EDIT 2

If there is a proxy that's breaking the request so that you get a series of responses, you're probably only processing the first. You might be able to use the CURLOPT_WRITEFUNCTION to register a callback that is called whenever each data response is received, and which could then manage the stitching back together of the various chunks.

Body:
If you're getting a 206 Partial Content response, then you must have included a Range header field indicating the desired range in your request:

e.g.

GET /2390/2253727548_a413c88ab3_s.jpg HTTP/1.1
Host: farm3.static.flickr.com
Range: bytes=0-999

or there's a proxy somewhere that is breaking the requests into a series of range requests

EDIT

As a resolution, you might want to try sending a series of requests using the Get Range, then stitching them all together as you get each response

EDIT 2

If there is a proxy that's breaking the request so that you get a series of responses, you're probably only processing the first. You might be able to use the CURLOPT_WRITEFUNCTION to register a callback that is called whenever each data response is received, and which could then manage the stitching back together of the various chunks.


问:
Error at launch app
When I launch app sometimes I get this error and sometimes no:

```<code>2017-11-10 14:00:37.119701+0000 XXX[768:176399] [DYGLInitPlatform] connection to host has failed: Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"
2017-11-10 14:00:37.123363+0000 XXX[768:176399] aborting: platform initialization failed
(lldb)
</code>```

What can cause this problem ?

答:
In my case, the error was related to Launch Screen, most likely it was corrupt.

Deleting the launch screen under General Tab, fixed the issue.

Title: Error at launch app

Body:
When I launch app sometimes I get this error and sometimes no:

2017-11-10 14:00:37.119701+0000 XXX[768:176399] [DYGLInitPlatform] connection to host has failed: Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"
2017-11-10 14:00:37.123363+0000 XXX[768:176399] aborting: platform initialization failed
(lldb)

What can cause this problem ?


问:
Database Date: How to auto increment the date automatically in a table?
I created a Database called DatesOfYear

```<code> CREATE TABLE DATESOFYEAR
 (
 MyName varchar(15),
 MyDate date
 );
</code>```

and i inserted a value in it

```<code> INSERT INTO DATESOFYEAR VALUES ('FName','1-JAN-2017');
</code>```

The output is

```<code> MYNAME     MYDATE
 FName      1-JAN-2017
</code>```

How do i increment the MyDate from 1-JAN-2017 up until the end of year which is 31-DEC-2017, the output that i want to see is

```<code> MYNAME     MYDATE
 FName      1-JAN-2017
 ....          ....
 FName      31-DEC-2017
</code>```

答:
You could make a loop and add rows in the database until you reach the end of the year. On each insert, you increment the previous date by 1 day.</p>

```<code>DECLARE @my_previous_date DATE = '1-JAN-2017',
        @my_date DATE = DATEADD(d,1, @my_previous_date);

WHILE @my_date <= '31-DEC-2017'
    BEGIN
    INSERT INTO DATESOFYEAR VALUES ('FName', DATEADD(d,1, @my_date));
    @my_date = DATEADD(d,1, @my_date);
END;
</code>```

Body:
I created a Database called DatesOfYear

 CREATE TABLE DATESOFYEAR
 (
 MyName varchar(15),
 MyDate date
 );

and i inserted a value in it

 INSERT INTO DATESOFYEAR VALUES ('FName','1-JAN-2017');

The output is

 MYNAME     MYDATE
 FName      1-JAN-2017

How do i increment the MyDate from 1-JAN-2017 up until the end of year which is 31-DEC-2017, the output that i want to see is

 MYNAME     MYDATE
 FName      1-JAN-2017
 ....          ....
 FName      31-DEC-2017

Body:
You could make a loop and add rows in the database until you reach the end of the year. On each insert, you increment the previous date by 1 day.

DECLARE @my_previous_date DATE = '1-JAN-2017',
        @my_date DATE = DATEADD(d,1, @my_previous_date);

WHILE @my_date <= '31-DEC-2017'
    BEGIN
    INSERT INTO DATESOFYEAR VALUES ('FName', DATEADD(d,1, @my_date));
    @my_date = DATEADD(d,1, @my_date);
END;


问:
Comma is causing unwanted string split
I have an array of data sent from my database - Once received, I save it in shared preferences - here is my getter:

```<code>public List getAnswerStringEdit() {
        return answer_edit;
    }
</code>```

I save it as so:

```<code>editor.putString(Constants.ANSWER_EDIT,resp.getAnswer().getAnswerStringEdit().toString().trim());
</code>```

Then retrieve it here:

```<code>String answerString = pref.getString(Constants.ANSWER_EDIT, "").trim();
        answerString = answerString.substring(1, answerString.length() - 1).trim();
        String[] array = answerString.split(",");
</code>```

Finally, I access the array as so:

```<code>et_answer1_edit.append(array[0]);
</code>```

My problem is this - Say I add a questions which has a comma in the middle of it, like -

Question 1- "Why is this broke, I don't know?"

Currently, when I retrieve my question, the string is getting split, even though there are quotation marks around the whole question/answer- So in the example above, in position 0 in the array, I should have:

"Why is this broke, I don't know?"

However, instead I am getting in position 0:

Why is this broke - then position 1 as: I don't know

I know this sounds daft because clearly, I am calling for the split to happen on the comma, but I expect that at the end of the whole string object, not in the middle of it.

The retrieved JSON is as follows:

```<code>{
    "result": "success",
    "message": "Answer Has Been Selected",
    "answer": {
        "answer_edit": ["Why is this broke, I don't know?", "What is your favorite song, because I want to know"]
    }
}
</code>```

Any help/advice that can help me to understand what is causing this, would be really appreciated.

答:
Try this

```<code>JSONObject jsonObject = new JSONObject("your json response");

try
  {
      JSONObject data = jsonObject.getJSONObject("answer");

      JSONArray jsonArray = data.getJSONArray("answer_edit");
      Log.e("=>", "" + jsonArray);

      for (int i = 0; i < jsonArray.length(); i++)
      {
         String value = jsonArray.getString(i);

         String[] parts = value.split(Pattern.quote(","));

          for (int j=0; j<parts.length; j++)
          {
            Log.e("Answer String ", "=" + parts[j]);
          }
     }
  } catch (JSONException e) {
      e.printStackTrace();
  }
</code>```

OUTPUT

```<code>E/=>: ["Why is this broke, I don't know?","What is your favorite song, because I want to know"]
E/Answer String: =Why is this broke
E/Answer String: = I don't know?
E/Answer String: =What is your favorite song
E/Answer String: = because I want to know
</code>```

Title: Comma is causing unwanted string split

Body:
I have an array of data sent from my database - Once received, I save it in shared preferences - here is my getter:

public List getAnswerStringEdit() {
        return answer_edit;
    }

I save it as so:

editor.putString(Constants.ANSWER_EDIT,resp.getAnswer().getAnswerStringEdit().toString().trim());

Then retrieve it here:

String answerString = pref.getString(Constants.ANSWER_EDIT, "").trim();
        answerString = answerString.substring(1, answerString.length() - 1).trim();
        String[] array = answerString.split(",");

Finally, I access the array as so:

et_answer1_edit.append(array[0]);

My problem is this - Say I add a questions which has a comma in the middle of it, like -

Question 1- "Why is this broke, I don't know?"

Currently, when I retrieve my question, the string is getting split, even though there are quotation marks around the whole question/answer- So in the example above, in position 0 in the array, I should have:

"Why is this broke, I don't know?"

However, instead I am getting in position 0:

Why is this broke - then position 1 as: I don't know

I know this sounds daft because clearly, I am calling for the split to happen on the comma, but I expect that at the end of the whole string object, not in the middle of it.

The retrieved JSON is as follows:

{
    "result": "success",
    "message": "Answer Has Been Selected",
    "answer": {
        "answer_edit": ["Why is this broke, I don't know?", "What is your favorite song, because I want to know"]
    }
}

Any help/advice that can help me to understand what is causing this, would be really appreciated.

Body:
Try this

JSONObject jsonObject = new JSONObject("your json response");

try
  {
      JSONObject data = jsonObject.getJSONObject("answer");

      JSONArray jsonArray = data.getJSONArray("answer_edit");
      Log.e("=>", "" + jsonArray);

      for (int i = 0; i < jsonArray.length(); i++)
      {
         String value = jsonArray.getString(i);

         String[] parts = value.split(Pattern.quote(","));

          for (int j=0; j<parts.length; j++)
          {
            Log.e("Answer String ", "=" + parts[j]);
          }
     }
  } catch (JSONException e) {
      e.printStackTrace();
  }

OUTPUT

E/=>: ["Why is this broke, I don't know?","What is your favorite song, because I want to know"]
E/Answer String: =Why is this broke
E/Answer String: = I don't know?
E/Answer String: =What is your favorite song
E/Answer String: = because I want to know


问:
How to transform into database and label according to the interval with R
I'm trying to transform mass data into database but it seems too cumbersome to make it ordered.

it is example data.

```<code>structure(list(V1 = structure(c(2L, 1L, 1L, 3L, 1L, 4L, 1L, 1L,
1L, 5L), .Label = c("", "01.01 ? 01.06                          ",
"02.01 ? 02.10                          ", "03.01 ? 03.07                          ",
"Chapter 4 (04.01~04.10)"), class = "factor"), V2 = structure(c(2L,
1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 3L), .Label = c("", "CTH", "WO"
), class = "factor")), .Names = c("V1", "V2"), class = "data.frame", row.names = c(NA,
-10L))
</code>```

the result I want to show is like this

```<code>structure(list(V1 = c(1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 2.01,
2.02, 2.03, 2.04, 2.05, 2.06, 2.07, 2.08, 2.09, 2.1, 3.01, 3.02,
3.03, 3.04, 3.05, 3.06, 3.07, 4.01, 4.02, 4.03, 4.04, 4.05, 4.06,
4.07, 4.08, 4.09, 4.1), V2 = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("CTH",
"WO"), class = "factor")), .Names = c("V1", "V2"), class = "data.frame", row.names = c(NA,
-33L))
</code>```

you can find out each cell of row A is comprised kinda interval value. it would be an abbreviation of several cells in database I want to make.

I should labeling those cells as same code of row C - for example, cell of 01.01 - CTH, cell of 01.02 - CTH, cell of 01.03 - CTH, so on till 0.06 is done.

But there are several problems.

how to divide a cell of interval value into 2 variables?

and labeling same code according to the value of the first data of the interval.

the classification indicators of data are chapter, heading and subheading.

And I'd like to if the cell of the interval value just says chapter I, I'd like to label all sub-category data as the code corresponding to interval value.
and organizing a dataframe on the new csv.

Let me know how to deal those problems with R.

thanks for you all

答:
It isn't particularly elegant, but it gets the job done.</p>

```<code>library(dplyr)
library(stringr)
library(purrr)
library(tidyr)
input %>%
  filter(V1 != "") %>%
  mutate(lim = str_extract_all(V1, "\\d{2}\\.\\d{2}"),
         lim = map_chr(lim, paste0, collapse = ",")) %>%
  separate(lim,
           into = c("low", "high"),
           sep = ",") %>%
  separate(low,
           into = c("prefix", "low"),
           sep = "\\.") %>%
  mutate(high = str_replace(hight, "^.+\\.", ""),
         id = row_number()) %>%
  select(id, V2, prefix, low, high) %>%
  split(f = list(.$id)) %>%
  map(.f = function(rdf){
    suffix <- (as.numeric(rdf$low):as.numeric(rdf$high)) / 100
    data.frame(V1 = as.numeric(rdf$prefix) + suffix,
               V2 = rep(rdf$V2, length(suffix)),
               stringsAsFactors = FALSE)
  }) %>%
  bind_rows()
</code>```

Body:
I'm trying to transform mass data into database but it seems too cumbersome to make it ordered.

it is example data.

structure(list(V1 = structure(c(2L, 1L, 1L, 3L, 1L, 4L, 1L, 1L,
1L, 5L), .Label = c("", "01.01 ? 01.06                          ",
"02.01 ? 02.10                          ", "03.01 ? 03.07                          ",
"Chapter 4 (04.01~04.10)"), class = "factor"), V2 = structure(c(2L,
1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 3L), .Label = c("", "CTH", "WO"
), class = "factor")), .Names = c("V1", "V2"), class = "data.frame", row.names = c(NA,
-10L))

the result I want to show is like this

structure(list(V1 = c(1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 2.01,
2.02, 2.03, 2.04, 2.05, 2.06, 2.07, 2.08, 2.09, 2.1, 3.01, 3.02,
3.03, 3.04, 3.05, 3.06, 3.07, 4.01, 4.02, 4.03, 4.04, 4.05, 4.06,
4.07, 4.08, 4.09, 4.1), V2 = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("CTH",
"WO"), class = "factor")), .Names = c("V1", "V2"), class = "data.frame", row.names = c(NA,
-33L))

you can find out each cell of row A is comprised kinda interval value. it would be an abbreviation of several cells in database I want to make.

I should labeling those cells as same code of row C - for example, cell of 01.01 - CTH, cell of 01.02 - CTH, cell of 01.03 - CTH, so on till 0.06 is done.

But there are several problems.

how to divide a cell of interval value into 2 variables?

and labeling same code according to the value of the first data of the interval.

the classification indicators of data are chapter, heading and subheading.

And I'd like to if the cell of the interval value just says chapter I, I'd like to label all sub-category data as the code corresponding to interval value.
and organizing a dataframe on the new csv.

Let me know how to deal those problems with R.

thanks for you all

Body:
It isn't particularly elegant, but it gets the job done.

library(dplyr)
library(stringr)
library(purrr)
library(tidyr)
input %>%
  filter(V1 != "") %>%
  mutate(lim = str_extract_all(V1, "\\d{2}\\.\\d{2}"),
         lim = map_chr(lim, paste0, collapse = ",")) %>%
  separate(lim,
           into = c("low", "high"),
           sep = ",") %>%
  separate(low,
           into = c("prefix", "low"),
           sep = "\\.") %>%
  mutate(high = str_replace(hight, "^.+\\.", ""),
         id = row_number()) %>%
  select(id, V2, prefix, low, high) %>%
  split(f = list(.$id)) %>%
  map(.f = function(rdf){
    suffix <- (as.numeric(rdf$low):as.numeric(rdf$high)) / 100
    data.frame(V1 = as.numeric(rdf$prefix) + suffix,
               V2 = rep(rdf$V2, length(suffix)),
               stringsAsFactors = FALSE)
  }) %>%
  bind_rows()


问:
How to write a custom Leanbacks VerticalGridView in Android TV?
I want to implement a Row from the Details screen of the Leanback library into a customized screen. The row will be the one below. I have already implemented the HorizontalGridView and have managed to get the items to be shown.

My layout:

```<code><android.support.v17.leanback.widget.HorizontalGridView
android:id="@+id/detail_related"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</code>```

My Java:

```<code>RecyclerView.Adapter mAdapter = new SimilarAssetsAdapter();
mBinding.detailRelated.setAdapter(mAdapter);
</code>```

The problem I am encountering is that I cannot focus on any of the items but the focus is on the whole HorizontalGridView. How do I solve this?

答:
The problem in custom view is you need to add the focus change listener in the java code.Add the focus listener inside the adapter to the root view of the adapter items.

Add focusable for the rootview in the oncreate of the adapter items.

```<code>yourView.setFocusable(true);
yourView.setFocusableInTouchMode(true);
</code>```

Then in the onBind add the focuschangeListener.

```<code> yourRootView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
    @Override
    public void onFocusChange(View v, boolean hasFocus) {

        if(hasFocus){
           //focus gained
        }else {
          //focus lost
        }
    }
});
</code>```

Body:
I want to implement a Row from the Details screen of the Leanback library into a customized screen. The row will be the one below. I have already implemented the HorizontalGridView and have managed to get the items to be shown.

My layout:

<android.support.v17.leanback.widget.HorizontalGridView
android:id="@+id/detail_related"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

My Java:

RecyclerView.Adapter mAdapter = new SimilarAssetsAdapter();
mBinding.detailRelated.setAdapter(mAdapter);

The problem I am encountering is that I cannot focus on any of the items but the focus is on the whole HorizontalGridView. How do I solve this?

Body:
The problem in custom view is you need to add the focus change listener in the java code.Add the focus listener inside the adapter to the root view of the adapter items.

Add focusable for the rootview in the oncreate of the adapter items.

yourView.setFocusable(true);
yourView.setFocusableInTouchMode(true);

Then in the onBind add the focuschangeListener.

 yourRootView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
    @Override
    public void onFocusChange(View v, boolean hasFocus) {

        if(hasFocus){
           //focus gained
        }else {
          //focus lost
        }
    }
});


问:
UWP app UI not updating from Device Watcher listener
How to update UI from bluetooth and BLE Device Watcher Listener Events (add, update, remove) in UWP Application.

Currently I'm using Observable Collection which updates UI when add or update collection object it's working fine but, when I jump on other page and come back Observable Collection won't able to update ui.

答: The chances are, that you replace the original instance of the ObservableCollection with a new one when navigating back to the page, which is a common mistake. But it is impossible to say for sure without seeing your code.


问:
How do I use Bash on Windows from the Visual Studio Code integrated terminal?
Visual Studio Code on Windows uses PowerShell by default as the integrated terminal. If you want to use Bash from Visual Studio Code, what steps should be followed?</p>

答:
This, at least for me, will make Visual Studio Code open a new Bash window as an external terminal.

If you want the integrated environment you need to point to the sh.exe file inside the bin folder of your Git installation.

So the configuration should say C:\\<my-git-install>\\bin\\sh.exe.

ContentLicense: CC BY-SA 4.0


问:
Implementing case insensitive In Xtext editor
When i search for solution online i found this.

In above code i thought it will help me to achieve my solution but i dont know how to add the above code in my current mwe2 workflow. i tried what he mentioned but i am getting exception so i thought i was making mistake due to lack xtext knowledge

just for more understanding see my mwe2 workflow

```<code>    language = StandardLanguage {
        name = "com.herzog.pmide.RoutingLineINI"
        fileExtensions = "ini"
        referencedResource = "platform:/resource/com.herzog.pmide.routingline.xtext.model/model/pmrouting.genmodel"
        fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}

        fragment = org.eclipse.xtext.generator.adapter.FragmentAdapter {
            fragment = org.eclipse.xtext.generator.ecore2xtext.FormatterFragment {}
        }

        serializer = {
            generateStub = false
        }
        validator = {
        // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
        }

        formatter = {
            generateStub = true
        }

        scopeProvider = {
            ignoreCase = true
        }
        parserGenerator = {
            options = {
                ignoreCase = true
            }
        }
    }
</code>```

By doing above i am getting exception as below

```<code>0    [main] INFO  text.xtext.generator.XtextGenerator  - Initializing Xtext generator
8    [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'org.eclipse.xtext.common.types.TypesPackage'
476  [main] WARN  lipse.emf.mwe.utils.StandaloneSetup  - Skipping conflicting project ini4j at 'archive:file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.tools.importutility/libs/ini4j-0.5.4.jar!/' and using 'archive:file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.nl/libs/ini4j-0.5.4.jar!/' instead.
707  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.herzog.pmide.routingline.xtext at 'file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.routingline.xtext/'
708  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.herzog.pmide.routingline.xtext.tests at 'file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.routingline.xtext.tests/'
708  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.herzog.pmide.routingline.xtext.ide at 'file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.routingline.xtext.ide/'
709  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.herzog.pmide.routingline.xtext.ui at 'file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.routingline.xtext.ui/'
709  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.herzog.pmide.routingline.xtext.ui.tests at 'file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.routingline.xtext.ui.tests/'
722  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
941  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/Xtext/Xbase/XAnnotations' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
944  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xtype' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
955  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xbase' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
955  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/common/JavaVMTypes' from 'platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel'
967  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://pmrouting/1.0' from 'platform:/resource/com.herzog.pmide.routingline.xtext.model/model/pmrouting.genmodel'
1830 [main] INFO  text.xtext.generator.XtextGenerator  - Generating com.herzog.pmide.RoutingLineINI
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:244:1: rule A_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:246:1: rule B_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:248:1: rule C_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:250:1: rule D_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:254:1: rule M_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:256:1: rule P_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:258:1: rule R_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:260:1: rule S_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:262:1: rule U_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:264:1: rule W_1 redefinition
error(3):  cannot find tokens file ..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\internal\InternalRoutingLineINILexer.tokens
12930 [main] INFO  text.xtext.generator.XtextGenerator  - Generating common infrastructure
12957 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow com.herzog.pmide.GenerateRoutingLineINI:
[ERROR]: GeneratorException: (Element: -UNKNOWN-; Reported by: XtextGenerator)
     org.eclipse.xtext.util.RuntimeIOException: java.io.FileNotFoundException: C:\Users\HUSER02\git\pm-ide_local4\com.herzog.pmide.routingline.xtext\..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\lexer\InternalRoutingLineINILexer.tokens (The system cannot find the file specified)
    at org.eclipse.xtext.generator.JavaIoFileSystemAccess.readBinaryFile(JavaIoFileSystemAccess.java:241)
    at org.eclipse.xtext.generator.AbstractFileSystemAccess2.readBinaryFile(AbstractFileSystemAccess2.java:37)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2$3.getAntlrTokenFile(AbstractAntlrGeneratorFragment2.java:331)
    at org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider.getTokenDefMap(AntlrTokenDefProvider.java:46)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2.cleanupParserTokensFile(AbstractAntlrGeneratorFragment2.java:341)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.runAntlr(XtextAntlrGeneratorFragment2.java:355)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.generateProductionGrammar(XtextAntlrGeneratorFragment2.java:234)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.doGenerate(XtextAntlrGeneratorFragment2.java:167)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2.generate(AbstractAntlrGeneratorFragment2.java:117)
    at org.eclipse.xtext.xtext.generator.CompositeGeneratorFragment2.generate(CompositeGeneratorFragment2.java:48)
    at org.eclipse.xtext.xtext.generator.XtextGenerator.invokeInternal(XtextGenerator.java:202)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
    at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
    at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
    at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: java.io.FileNotFoundException: C:\Users\HUSER02\git\pm-ide_local4\com.herzog.pmide.routingline.xtext\..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\lexer\InternalRoutingLineINILexer.tokens (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at org.eclipse.xtext.generator.JavaIoFileSystemAccess.readBinaryFile(JavaIoFileSystemAccess.java:239)
    ... 20 more

java.lang.RuntimeException: Problems running workflow com.herzog.pmide.GenerateRoutingLineINI:
[ERROR]: GeneratorException: (Element: -UNKNOWN-; Reported by: XtextGenerator)
     org.eclipse.xtext.util.RuntimeIOException: java.io.FileNotFoundException: C:\Users\HUSER02\git\pm-ide_local4\com.herzog.pmide.routingline.xtext\..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\lexer\InternalRoutingLineINILexer.tokens (The system cannot find the file specified)
    at org.eclipse.xtext.generator.JavaIoFileSystemAccess.readBinaryFile(JavaIoFileSystemAccess.java:241)
    at org.eclipse.xtext.generator.AbstractFileSystemAccess2.readBinaryFile(AbstractFileSystemAccess2.java:37)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2$3.getAntlrTokenFile(AbstractAntlrGeneratorFragment2.java:331)
    at org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider.getTokenDefMap(AntlrTokenDefProvider.java:46)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2.cleanupParserTokensFile(AbstractAntlrGeneratorFragment2.java:341)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.runAntlr(XtextAntlrGeneratorFragment2.java:355)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.generateProductionGrammar(XtextAntlrGeneratorFragment2.java:234)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.doGenerate(XtextAntlrGeneratorFragment2.java:167)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2.generate(AbstractAntlrGeneratorFragment2.java:117)
    at org.eclipse.xtext.xtext.generator.CompositeGeneratorFragment2.generate(CompositeGeneratorFragment2.java:48)
    at org.eclipse.xtext.xtext.generator.XtextGenerator.invokeInternal(XtextGenerator.java:202)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
    at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
    at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
    at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: java.io.FileNotFoundException: C:\Users\HUSER02\git\pm-ide_local4\com.herzog.pmide.routingline.xtext\..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\lexer\InternalRoutingLineINILexer.tokens (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at org.eclipse.xtext.generator.JavaIoFileSystemAccess.readBinaryFile(JavaIoFileSystemAccess.java:239)
    ... 20 more

    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:104)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: java.lang.RuntimeException:
[ERROR]: GeneratorException: (Element: -UNKNOWN-; Reported by: XtextGenerator)
     org.eclipse.xtext.util.RuntimeIOException: java.io.FileNotFoundException: C:\Users\HUSER02\git\pm-ide_local4\com.herzog.pmide.routingline.xtext\..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\lexer\InternalRoutingLineINILexer.tokens (The system cannot find the file specified)
    at org.eclipse.xtext.generator.JavaIoFileSystemAccess.readBinaryFile(JavaIoFileSystemAccess.java:241)
    at org.eclipse.xtext.generator.AbstractFileSystemAccess2.readBinaryFile(AbstractFileSystemAccess2.java:37)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2$3.getAntlrTokenFile(AbstractAntlrGeneratorFragment2.java:331)
    at org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider.getTokenDefMap(AntlrTokenDefProvider.java:46)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2.cleanupParserTokensFile(AbstractAntlrGeneratorFragment2.java:341)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.runAntlr(XtextAntlrGeneratorFragment2.java:355)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.generateProductionGrammar(XtextAntlrGeneratorFragment2.java:234)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.doGenerate(XtextAntlrGeneratorFragment2.java:167)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2.generate(AbstractAntlrGeneratorFragment2.java:117)
    at org.eclipse.xtext.xtext.generator.CompositeGeneratorFragment2.generate(CompositeGeneratorFragment2.java:48)
    at org.eclipse.xtext.xtext.generator.XtextGenerator.invokeInternal(XtextGenerator.java:202)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
    at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
    at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
    at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: java.io.FileNotFoundException: C:\Users\HUSER02\git\pm-ide_local4\com.herzog.pmide.routingline.xtext\..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\lexer\InternalRoutingLineINILexer.tokens (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at org.eclipse.xtext.generator.JavaIoFileSystemAccess.readBinaryFile(JavaIoFileSystemAccess.java:239)
    ... 20 more

    at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.handleIssues(Mwe2Bridge.java:56)
    at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:48)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
    at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
    at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
    ... 4 more
</code>```

Thank you for reading my question.

答:
To use case insentive languages with the new workflow use</p>

```<code>    language = StandardLanguage {
        name = "org.xtext.example.mydsl1.MyDsl"
        fileExtensions = "mydsl1"

        serializer = {
            generateStub = false
        }
        validator = {
            // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
        }
        scopeProvider = {
            ignoreCase = true
        }
        parserGenerator = {
            options = {
                ignoreCase = true
            }
        }
    }
</code>```

Body:
When i search for solution online i found this.

In above code i thought it will help me to achieve my solution but i dont know how to add the above code in my current mwe2 workflow. i tried what he mentioned but i am getting exception so i thought i was making mistake due to lack xtext knowledge

just for more understanding see my mwe2 workflow

    language = StandardLanguage {
        name = "com.herzog.pmide.RoutingLineINI"
        fileExtensions = "ini"
        referencedResource = "platform:/resource/com.herzog.pmide.routingline.xtext.model/model/pmrouting.genmodel"
        fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}

        fragment = org.eclipse.xtext.generator.adapter.FragmentAdapter {
            fragment = org.eclipse.xtext.generator.ecore2xtext.FormatterFragment {}
        }

        serializer = {
            generateStub = false
        }
        validator = {
        // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
        }

        formatter = {
            generateStub = true
        }

        scopeProvider = {
            ignoreCase = true
        }
        parserGenerator = {
            options = {
                ignoreCase = true
            }
        }
    }

By doing above i am getting exception as below

0    [main] INFO  text.xtext.generator.XtextGenerator  - Initializing Xtext generator
8    [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Adding generated EPackage 'org.eclipse.xtext.common.types.TypesPackage'
476  [main] WARN  lipse.emf.mwe.utils.StandaloneSetup  - Skipping conflicting project ini4j at 'archive:file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.tools.importutility/libs/ini4j-0.5.4.jar!/' and using 'archive:file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.nl/libs/ini4j-0.5.4.jar!/' instead.
707  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.herzog.pmide.routingline.xtext at 'file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.routingline.xtext/'
708  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.herzog.pmide.routingline.xtext.tests at 'file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.routingline.xtext.tests/'
708  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.herzog.pmide.routingline.xtext.ide at 'file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.routingline.xtext.ide/'
709  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.herzog.pmide.routingline.xtext.ui at 'file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.routingline.xtext.ui/'
709  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Registering project com.herzog.pmide.routingline.xtext.ui.tests at 'file:/C:/Users/HUSER02/git/pm-ide_local4/com.herzog.pmide.routingline.xtext.ui.tests/'
722  [main] INFO  lipse.emf.mwe.utils.StandaloneSetup  - Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
941  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/Xtext/Xbase/XAnnotations' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
944  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xtype' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
955  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xbase' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
955  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://www.eclipse.org/xtext/common/JavaVMTypes' from 'platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel'
967  [main] INFO  clipse.emf.mwe.utils.GenModelHelper  - Registered GenModel 'http://pmrouting/1.0' from 'platform:/resource/com.herzog.pmide.routingline.xtext.model/model/pmrouting.genmodel'
1830 [main] INFO  text.xtext.generator.XtextGenerator  - Generating com.herzog.pmide.RoutingLineINI
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:244:1: rule A_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:246:1: rule B_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:248:1: rule C_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:250:1: rule D_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:254:1: rule M_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:256:1: rule P_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:258:1: rule R_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:260:1: rule S_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:262:1: rule U_1 redefinition
error(101): ../com.herzog.pmide.routingline.xtext/src-gen/com/herzog/pmide/parser/antlr/lexer/InternalRoutingLineINILexer.g:264:1: rule W_1 redefinition
error(3):  cannot find tokens file ..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\internal\InternalRoutingLineINILexer.tokens
12930 [main] INFO  text.xtext.generator.XtextGenerator  - Generating common infrastructure
12957 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow com.herzog.pmide.GenerateRoutingLineINI:
[ERROR]: GeneratorException: (Element: -UNKNOWN-; Reported by: XtextGenerator)
     org.eclipse.xtext.util.RuntimeIOException: java.io.FileNotFoundException: C:\Users\HUSER02\git\pm-ide_local4\com.herzog.pmide.routingline.xtext\..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\lexer\InternalRoutingLineINILexer.tokens (The system cannot find the file specified)
    at org.eclipse.xtext.generator.JavaIoFileSystemAccess.readBinaryFile(JavaIoFileSystemAccess.java:241)
    at org.eclipse.xtext.generator.AbstractFileSystemAccess2.readBinaryFile(AbstractFileSystemAccess2.java:37)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2$3.getAntlrTokenFile(AbstractAntlrGeneratorFragment2.java:331)
    at org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider.getTokenDefMap(AntlrTokenDefProvider.java:46)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2.cleanupParserTokensFile(AbstractAntlrGeneratorFragment2.java:341)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.runAntlr(XtextAntlrGeneratorFragment2.java:355)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.generateProductionGrammar(XtextAntlrGeneratorFragment2.java:234)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.doGenerate(XtextAntlrGeneratorFragment2.java:167)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2.generate(AbstractAntlrGeneratorFragment2.java:117)
    at org.eclipse.xtext.xtext.generator.CompositeGeneratorFragment2.generate(CompositeGeneratorFragment2.java:48)
    at org.eclipse.xtext.xtext.generator.XtextGenerator.invokeInternal(XtextGenerator.java:202)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
    at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
    at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
    at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: java.io.FileNotFoundException: C:\Users\HUSER02\git\pm-ide_local4\com.herzog.pmide.routingline.xtext\..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\lexer\InternalRoutingLineINILexer.tokens (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at org.eclipse.xtext.generator.JavaIoFileSystemAccess.readBinaryFile(JavaIoFileSystemAccess.java:239)
    ... 20 more

java.lang.RuntimeException: Problems running workflow com.herzog.pmide.GenerateRoutingLineINI:
[ERROR]: GeneratorException: (Element: -UNKNOWN-; Reported by: XtextGenerator)
     org.eclipse.xtext.util.RuntimeIOException: java.io.FileNotFoundException: C:\Users\HUSER02\git\pm-ide_local4\com.herzog.pmide.routingline.xtext\..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\lexer\InternalRoutingLineINILexer.tokens (The system cannot find the file specified)
    at org.eclipse.xtext.generator.JavaIoFileSystemAccess.readBinaryFile(JavaIoFileSystemAccess.java:241)
    at org.eclipse.xtext.generator.AbstractFileSystemAccess2.readBinaryFile(AbstractFileSystemAccess2.java:37)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2$3.getAntlrTokenFile(AbstractAntlrGeneratorFragment2.java:331)
    at org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider.getTokenDefMap(AntlrTokenDefProvider.java:46)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2.cleanupParserTokensFile(AbstractAntlrGeneratorFragment2.java:341)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.runAntlr(XtextAntlrGeneratorFragment2.java:355)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.generateProductionGrammar(XtextAntlrGeneratorFragment2.java:234)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.doGenerate(XtextAntlrGeneratorFragment2.java:167)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2.generate(AbstractAntlrGeneratorFragment2.java:117)
    at org.eclipse.xtext.xtext.generator.CompositeGeneratorFragment2.generate(CompositeGeneratorFragment2.java:48)
    at org.eclipse.xtext.xtext.generator.XtextGenerator.invokeInternal(XtextGenerator.java:202)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
    at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
    at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
    at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: java.io.FileNotFoundException: C:\Users\HUSER02\git\pm-ide_local4\com.herzog.pmide.routingline.xtext\..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\lexer\InternalRoutingLineINILexer.tokens (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at org.eclipse.xtext.generator.JavaIoFileSystemAccess.readBinaryFile(JavaIoFileSystemAccess.java:239)
    ... 20 more

    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:104)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: java.lang.RuntimeException:
[ERROR]: GeneratorException: (Element: -UNKNOWN-; Reported by: XtextGenerator)
     org.eclipse.xtext.util.RuntimeIOException: java.io.FileNotFoundException: C:\Users\HUSER02\git\pm-ide_local4\com.herzog.pmide.routingline.xtext\..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\lexer\InternalRoutingLineINILexer.tokens (The system cannot find the file specified)
    at org.eclipse.xtext.generator.JavaIoFileSystemAccess.readBinaryFile(JavaIoFileSystemAccess.java:241)
    at org.eclipse.xtext.generator.AbstractFileSystemAccess2.readBinaryFile(AbstractFileSystemAccess2.java:37)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2$3.getAntlrTokenFile(AbstractAntlrGeneratorFragment2.java:331)
    at org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider.getTokenDefMap(AntlrTokenDefProvider.java:46)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2.cleanupParserTokensFile(AbstractAntlrGeneratorFragment2.java:341)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.runAntlr(XtextAntlrGeneratorFragment2.java:355)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.generateProductionGrammar(XtextAntlrGeneratorFragment2.java:234)
    at org.eclipse.xtext.xtext.generator.parser.antlr.XtextAntlrGeneratorFragment2.doGenerate(XtextAntlrGeneratorFragment2.java:167)
    at org.eclipse.xtext.xtext.generator.parser.antlr.AbstractAntlrGeneratorFragment2.generate(AbstractAntlrGeneratorFragment2.java:117)
    at org.eclipse.xtext.xtext.generator.CompositeGeneratorFragment2.generate(CompositeGeneratorFragment2.java:48)
    at org.eclipse.xtext.xtext.generator.XtextGenerator.invokeInternal(XtextGenerator.java:202)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
    at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
    at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
    at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
Caused by: java.io.FileNotFoundException: C:\Users\HUSER02\git\pm-ide_local4\com.herzog.pmide.routingline.xtext\..\com.herzog.pmide.routingline.xtext\src-gen\com\herzog\pmide\parser\antlr\lexer\InternalRoutingLineINILexer.tokens (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at org.eclipse.xtext.generator.JavaIoFileSystemAccess.readBinaryFile(JavaIoFileSystemAccess.java:239)
    ... 20 more

    at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.handleIssues(Mwe2Bridge.java:56)
    at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:48)
    at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
    at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
    at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
    at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
    ... 4 more

Thank you for reading my question.

Body:
To use case insentive languages with the new workflow use

    language = StandardLanguage {
        name = "org.xtext.example.mydsl1.MyDsl"
        fileExtensions = "mydsl1"

        serializer = {
            generateStub = false
        }
        validator = {
            // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
        }
        scopeProvider = {
            ignoreCase = true
        }
        parserGenerator = {
            options = {
                ignoreCase = true
            }
        }
    }


问:
How to do math formula in the sql query for desc sorting (res.a div res.b)
I have a large mySql table with user given finger up/down ratings. At the moment I have two basic sorting options for table to choose from:

```<code> ['likes desc', 'id desc'],
 ['dislikes desc', 'id desc'],
</code>```

I would like to add 3rd sorting option, that would convert above n/o of likes OR dislikes to one easy 1..5 star rating system with this kind of formula:

```<code>$rank = ($this->getLikes() / ($this->getDislikes() + $this->getLikes()))*5 ;
</code>```

What is the highest performance option to do this math on sql level itself, would it be possible to do sorting for "result.likes div result.dislikes" formula inside the SQl query itself, or should I make a few queries to get a proper output somehow?  I dont want to make a third column for this purpose.

答:
So one thing i assume you can do is get the needed data by applying where clause and use it as tmp table and apply order by on this. Like below</p>

```<code>SELECT * FROM (SELECT * FROM products where name like '%bottle%') tmp ORDER BY (tmp.likes/(tmp.likes+tmp.dislikes))*5;
</code>```

Body:
I have a large mySql table with user given finger up/down ratings. At the moment I have two basic sorting options for table to choose from:

 ['likes desc', 'id desc'],
 ['dislikes desc', 'id desc'],

I would like to add 3rd sorting option, that would convert above n/o of likes OR dislikes to one easy 1..5 star rating system with this kind of formula:

$rank = ($this->getLikes() / ($this->getDislikes() + $this->getLikes()))*5 ;

What is the highest performance option to do this math on sql level itself, would it be possible to do sorting for "result.likes div result.dislikes" formula inside the SQl query itself, or should I make a few queries to get a proper output somehow?  I dont want to make a third column for this purpose.

Body:
So one thing i assume you can do is get the needed data by applying where clause and use it as tmp table and apply order by on this. Like below

SELECT * FROM (SELECT * FROM products where name like '%bottle%') tmp ORDER BY (tmp.likes/(tmp.likes+tmp.dislikes))*5;