问:
BATCH: How can I copy files to directory based on file name
I've got quite a lot of files I am trying to archive for the company I work for. I am a little familiar with Batch scripts, but I do not quite understand enough to fully get what I am after.

I am trying to copy some files based on the beginning of their file name into folders on our NAS. The files are 7z files and their structure is going to be like so:

5476 BMW Handle-A.7z

5487 Chevy-Imp.7z

5986 Honda Lid-Upper.7z

etc.

The file structure works like this: the four numbers at the beginning is our company job number. On our NAS we have an archive directory with folders in it like this:

_5000-5999

_6000-6999

And inside of those folders are folders that will contain 250 archive files each. They are formatted like this:

_5000-5249

_5250-5499

_5500-5749

_5750-5999

I am looking to create a Batch file that I can drag these 7z files onto and it will read the first four numbers of the file name, and copy it to the proper folder on our NAS.

So for instance the files:

5476 BMW Handle-A.7z

5487 Chevy-Imp.7z

Would copy into

\nas01\archive\ _5000-5999\ _5250-5499

etc.

The main code I was messing with was this:

```<code>@echo off
for /f "delims=" %%i in ('dir /b /a-d *.7z') do (
set "filename1=%%~i"
setlocal enabledelayedexpansion
set "folder1=!filename1:~0,4!"
mkdir "!folder1!" 2>nul
copy "!filename1!" "!folder1!" >nul
)
</code>```

What is not working for me is this line:

```<code>set "folder1=!filename1:~0,4!"
</code>```

How can I create some sort of variable to check the file name, create the folders if necessary and copy it to the correct folder? I would appreciate any help on this!

-Dustin

答:
Thanks to some help from commenters, I was able to figure it out. I was having a problem with how to structure the script, but I got it!

```<code>@echo off
for /f "delims=" %%i in ('dir /b /a-d *.7z') do (
set "filename=%%~i"
setlocal enabledelayedexpansion
set "folder1=!filename:~0,4!"
set "subfolder1=_!folder1:~0,1!000-!folder1:~0,1!999"
set "firstdigit=!filename:~0,1!"
set "parent=\\nas01\The_Archives"

REM CONDITIONAL STATEMENTS
IF !folder1! GEQ !firstdigit!000 IF !folder1! LEQ !firstdigit!249 SET "subfolder2=_!firstdigit!000-!firstdigit!249"
IF !folder1! GEQ !firstdigit!250 IF !folder1! LEQ !firstdigit!499 SET "subfolder2=_!firstdigit!250-!firstdigit!499"
IF !folder1! GEQ !firstdigit!500 IF !folder1! LEQ !firstdigit!749 SET "subfolder2=_!firstdigit!500-!firstdigit!749"
IF !folder1! GEQ !firstdigit!750 IF !folder1! LEQ !firstdigit!999 SET "subfolder2=_!firstdigit!750-!firstdigit!999"

mkdir "!parent!\!subfolder1!\!subfolder2!" 2>nul
copy "!filename!" "!parent!\!subfolder1!\!subfolder2!" >nul
)
</code>```

I learned more about Batch today, so it was a day well spent!

Is there a way I can make this to where you just click and drag the files into this Batch script instead of grabbing all of the 7z files in the folder?

Body:
I've got quite a lot of files I am trying to archive for the company I work for. I am a little familiar with Batch scripts, but I do not quite understand enough to fully get what I am after.

I am trying to copy some files based on the beginning of their file name into folders on our NAS. The files are 7z files and their structure is going to be like so:

5476 BMW Handle-A.7z

5487 Chevy-Imp.7z

5986 Honda Lid-Upper.7z

etc.

The file structure works like this: the four numbers at the beginning is our company job number. On our NAS we have an archive directory with folders in it like this:

_5000-5999

_6000-6999

And inside of those folders are folders that will contain 250 archive files each. They are formatted like this:

_5000-5249

_5250-5499

_5500-5749

_5750-5999

I am looking to create a Batch file that I can drag these 7z files onto and it will read the first four numbers of the file name, and copy it to the proper folder on our NAS.

So for instance the files:

5476 BMW Handle-A.7z

5487 Chevy-Imp.7z

Would copy into

\nas01\archive\ _5000-5999\ _5250-5499

etc.

The main code I was messing with was this:

@echo off
for /f "delims=" %%i in ('dir /b /a-d *.7z') do (
set "filename1=%%~i"
setlocal enabledelayedexpansion
set "folder1=!filename1:~0,4!"
mkdir "!folder1!" 2>nul
copy "!filename1!" "!folder1!" >nul
)

What is not working for me is this line:

set "folder1=!filename1:~0,4!"

How can I create some sort of variable to check the file name, create the folders if necessary and copy it to the correct folder? I would appreciate any help on this!

-Dustin

Body:
Thanks to some help from commenters, I was able to figure it out. I was having a problem with how to structure the script, but I got it!

@echo off
for /f "delims=" %%i in ('dir /b /a-d *.7z') do (
set "filename=%%~i"
setlocal enabledelayedexpansion
set "folder1=!filename:~0,4!"
set "subfolder1=_!folder1:~0,1!000-!folder1:~0,1!999"
set "firstdigit=!filename:~0,1!"
set "parent=\\nas01\The_Archives"

REM CONDITIONAL STATEMENTS
IF !folder1! GEQ !firstdigit!000 IF !folder1! LEQ !firstdigit!249 SET "subfolder2=_!firstdigit!000-!firstdigit!249"
IF !folder1! GEQ !firstdigit!250 IF !folder1! LEQ !firstdigit!499 SET "subfolder2=_!firstdigit!250-!firstdigit!499"
IF !folder1! GEQ !firstdigit!500 IF !folder1! LEQ !firstdigit!749 SET "subfolder2=_!firstdigit!500-!firstdigit!749"
IF !folder1! GEQ !firstdigit!750 IF !folder1! LEQ !firstdigit!999 SET "subfolder2=_!firstdigit!750-!firstdigit!999"

mkdir "!parent!\!subfolder1!\!subfolder2!" 2>nul
copy "!filename!" "!parent!\!subfolder1!\!subfolder2!" >nul
)

I learned more about Batch today, so it was a day well spent!

Is there a way I can make this to where you just click and drag the files into this Batch script instead of grabbing all of the 7z files in the folder?


来源: stackexchange

问:
Can I create my own sequence in Hibernate?
Can I create my own sequence in Hibernate, like I have a database sequence and I have to add 2 characters before the sequence?</p>

答:
Try this one. With Date and Calender

```<code> public class StockCodeGenerator
 implements IdentifierGenerator
 {
 private static Logger log = Logger.getLogger(StockCodeGenerator.class);

 public StockCodeGenerator() {}

 public int generateCustId()
 {
 Random random = new Random();
 return random.nextInt(100);
 }

 public Serializable generate(SessionImplementor session, Object object)
 throws HibernateException
 {
 String prefix = "Custom_String";
 Connection connection = session.connection();
 System.out.println(session.connection());

 Date date = new Date();

 Calendar calendar = Calendar.getInstance();
 return prefix + "_" + generateCustId() + "_" + calendar.get(1);
 }
 }
</code>```

And then use it in your @GenericGenerator annotation

```<code>@Id
@GenericGenerator(name="seq_id",strategy="com.mvc.StockCodeGenerator.
StockCodeGenerator")
@GeneratedValue(generator="seq_id")
</code>```

ContentLicense: CC BY-SA 2.5

Body:
Try this one. With Date and Calender

 public class StockCodeGenerator
 implements IdentifierGenerator
 {
 private static Logger log = Logger.getLogger(StockCodeGenerator.class);

 public StockCodeGenerator() {}

 public int generateCustId()
 {
 Random random = new Random();
 return random.nextInt(100);
 }

 public Serializable generate(SessionImplementor session, Object object)
 throws HibernateException
 {
 String prefix = "Custom_String";
 Connection connection = session.connection();
 System.out.println(session.connection());

 Date date = new Date();

 Calendar calendar = Calendar.getInstance();
 return prefix + "_" + generateCustId() + "_" + calendar.get(1);
 }
 }

And then use it in your @GenericGenerator annotation

@Id
@GenericGenerator(name="seq_id",strategy="com.mvc.StockCodeGenerator.
StockCodeGenerator")
@GeneratedValue(generator="seq_id")

ContentLicense: CC BY-SA 3.0


问:
Spring @Entity Annotation findById
I have the below Student entity, trying to make a REST API for this.

```<code>@Entity
public class Student {
    @Id
    private int id;
    private String name;
    private String email;
    private List<Course> enrolledCourses;

    public Student() {
        // default constructor
    }

    // getters and setters
}
</code>```

When using @RestController, I am able to do @GetMapping("/api/students) and the page returns all the student's JSON. However when I try @GetMapping("/api/students/{id}") and specify @PathVariable the page returns something but all the fields are null. Anyone know what's the problem?

EDIT:

```<code>@RestController
public class StudentRestController {

    @Autowired
    private StudentService studentService;

    @GetMapping("/api/students")
    public List<Student> getAllStudents() {
        return studentService.getAllStudents();
    }

    @GetMapping("/api/students/{id}")
    public Student getStudentById(@PathVariable int id) {
        return studentService.getStudentById(id);
    }
}
</code>```

The StudentService gets from the StudentRepository which gets from PostgreSQL database. But the StudentRepository here uses JdbcTemplate to fetch from database instead of extending CrudRepository or JpaRepository, I'm not sure if that might be the problem. I'm using code passed to me from my team. Here's the repo method findById, using ResultSetExtractor and RowMapper.

```<code>public Student findById(int id) {
        String selectSQL = "SELECT s.id as s_id, s.name as s_name, " +
            "s.email as s_email, " +
            "c1.id as c1_id, c1.name as c1_name, c1.alias as c1_alias, " +
            "c2.id as c2_id, c2.name as c2_name, c2.alias as c2_alias," +
            "c3.id as c3_id, c3.name as c3_name, c3.alias as c3_alias," +
            "c4.id as c4_id, c4.name as c4_name, c4.alias as c4_alias " +
            "FROM students s " +
            "JOIN courses c1 ON s.course1_id = c1.id " +
            "JOIN courses c2 ON s.course2_id = c2.id " +
            "JOIN courses c3 ON s.course3_id = c3.id " +
            "JOIN courses c4 ON s.course4_id = c4.id " +
            "WHERE s.id = ?";

    return (Student) jdbcTemplate.queryForObject(selectSQL, new Object[]{id},
            new BeanPropertyRowMapper(Student.class));
}
</code>```

EDIT2:

I created a custom StudentRowMapper and StudentResultSetExtractor, now there's another error, Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: student, for columns: [org.hibernate.mapping.Column(enrolled_courses)]. Do I use @OneToMany?

EDIT3:

Using @OneToMany worked. Thanks.

答:
Your BeanPropertyRowMapper cannot find fields. You rename them in your SQL.
So BeanPropertyRowMapper tries to find field id but your query returns s_id
so nothing is set in the Student class.

Change SQL to return exactly the same column names as columns used in Student class.

Create a separate POJO instead of Student and add the fields you need. Check the POJO fields has corresponding column names in the SQL to be filled properly.

Title: Spring @Entity Annotation findById

Body:
I have the below Student entity, trying to make a REST API for this.

@Entity
public class Student {
    @Id
    private int id;
    private String name;
    private String email;
    private List<Course> enrolledCourses;

    public Student() {
        // default constructor
    }

    // getters and setters
}

When using @RestController, I am able to do @GetMapping("/api/students) and the page returns all the student's JSON. However when I try @GetMapping("/api/students/{id}") and specify @PathVariable the page returns something but all the fields are null. Anyone know what's the problem?

EDIT:

@RestController
public class StudentRestController {

    @Autowired
    private StudentService studentService;

    @GetMapping("/api/students")
    public List<Student> getAllStudents() {
        return studentService.getAllStudents();
    }

    @GetMapping("/api/students/{id}")
    public Student getStudentById(@PathVariable int id) {
        return studentService.getStudentById(id);
    }
}

The StudentService gets from the StudentRepository which gets from PostgreSQL database. But the StudentRepository here uses JdbcTemplate to fetch from database instead of extending CrudRepository or JpaRepository, I'm not sure if that might be the problem. I'm using code passed to me from my team. Here's the repo method findById, using ResultSetExtractor and RowMapper.

public Student findById(int id) {
        String selectSQL = "SELECT s.id as s_id, s.name as s_name, " +
            "s.email as s_email, " +
            "c1.id as c1_id, c1.name as c1_name, c1.alias as c1_alias, " +
            "c2.id as c2_id, c2.name as c2_name, c2.alias as c2_alias," +
            "c3.id as c3_id, c3.name as c3_name, c3.alias as c3_alias," +
            "c4.id as c4_id, c4.name as c4_name, c4.alias as c4_alias " +
            "FROM students s " +
            "JOIN courses c1 ON s.course1_id = c1.id " +
            "JOIN courses c2 ON s.course2_id = c2.id " +
            "JOIN courses c3 ON s.course3_id = c3.id " +
            "JOIN courses c4 ON s.course4_id = c4.id " +
            "WHERE s.id = ?";

    return (Student) jdbcTemplate.queryForObject(selectSQL, new Object[]{id},
            new BeanPropertyRowMapper(Student.class));
}

EDIT2:

I created a custom StudentRowMapper and StudentResultSetExtractor, now there's another error, Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: student, for columns: [org.hibernate.mapping.Column(enrolled_courses)]. Do I use @OneToMany?

EDIT3:

Using @OneToMany worked. Thanks.


问:
Apache Camel Infinite Loop on error
I'm having a problem with an infinite loop in Apache Camel (2.15.2). The route shown below works fine under normal conditions. However, in some rare cases, an infinite loop is created which consumes all CPU. I'm not sure what causes this, but I have a feeling it's related to when the remote application producing messages on the route is shutting down.

Code to configure the route (using RouteBuilder):

```<code>@Override
public void configure() throws Exception {
    errorHandler(deadLetterChannel(
        "file:messages/myRoute?fileName=${date:now:yyyyMMdd-HHmm-ssSSS}.xml")
        .useOriginalMessage()
        .maximumRedeliveries(10)
        .delayPattern("1:5000");
    onException(java.net.ConnectException.class).handled(true);

    fromF("myEndpoint")
        .routeId("myRoute")
        .bean(messageHandler, "process");
}
</code>```

The bean handling the message:

```<code>public void process(final String message) {
    final MyMessage message = (MyMessage) marshaller.getXStream().fromXML(message);
    ...some processing...
    producer.sendBody("anotherEndpoint", marshaller.getXStream().toXML(message));
}
</code>```

I've made several thread dumps and they all show stuff similar to this:

```<code>at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:56)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:56)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1206)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1190)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1061)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1052)
at com.example.message.MessageHandler.process(MessageHandler.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:408)
at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:279)
at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:252)
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:171)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:103)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:746)
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:684)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:651)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:315)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:253)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1164)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1156)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1053)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
</code>```

Perhaps my errorHandler and/or onException are incorrect? Thank you!

答: The infinite loop may be related to a concurrency issue in the underlying x-stream library. See https://github.com/x-stream/xstream/issues/2 and the related issues.</p>

Title: Apache Camel Infinite Loop on error

Body:
I'm having a problem with an infinite loop in Apache Camel (2.15.2). The route shown below works fine under normal conditions. However, in some rare cases, an infinite loop is created which consumes all CPU. I'm not sure what causes this, but I have a feeling it's related to when the remote application producing messages on the route is shutting down.

Code to configure the route (using RouteBuilder):

@Override
public void configure() throws Exception {
    errorHandler(deadLetterChannel(
        "file:messages/myRoute?fileName=${date:now:yyyyMMdd-HHmm-ssSSS}.xml")
        .useOriginalMessage()
        .maximumRedeliveries(10)
        .delayPattern("1:5000");
    onException(java.net.ConnectException.class).handled(true);

    fromF("myEndpoint")
        .routeId("myRoute")
        .bean(messageHandler, "process");
}

The bean handling the message:

public void process(final String message) {
    final MyMessage message = (MyMessage) marshaller.getXStream().fromXML(message);
    ...some processing...
    producer.sendBody("anotherEndpoint", marshaller.getXStream().toXML(message));
}

I've made several thread dumps and they all show stuff similar to this:

at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:56)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:56)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1206)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1190)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1061)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1052)
at com.example.message.MessageHandler.process(MessageHandler.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:408)
at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:279)
at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:252)
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:171)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:103)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:746)
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:684)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:651)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:315)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:253)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1164)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1156)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1053)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

Perhaps my errorHandler and/or onException are incorrect? Thank you!


问:
Angular 2 get element by dynamic id
How can I get/update value of element with dynamic id?

```<code><input type="text" class="form-control" id="{{'lat' + ind}}" formControlName="lat">
</code>```

I can't use ngAfterViewInit() {} because I need to update dynamic input after server responce

```<code>this.someService.getData().subscribe(
                  (response) => {this.data = response.json()
                                 this.lon = this.data.x;
                                 this.lat = this.data.y;
                                 this.ind = this.data.ind;
                                // UPDATE MY 'lat+ind' and 'lon+ind' HERE
                  },
                  (error) => console.log('ERROR: ' + error)
          );
</code>```

答:
```<code>this.someService.getData().subscribe(
    (response) => {
                     this.ngZone.run(function() {
                       this.data = response.json()
                       this.lon = this.data.x;
                       this.lat = this.data.y;
                       this.ind = this.data.ind;
                     };)
                  },
(error) => console.log('ERROR: ' + error)
);
</code>```

Note: you have to import NgZone and inject it at your constructor.

You need to do this because your view is not updated after you receive your response from your service. My code above will revive your view and publish updated values to your ID.

Your template gets published in the beginning when your lat and ind are still undefined. Then when you make your service call and you get a response, you must tell angular to update your view with the new values.

Note: You can also use ChangeDetectorRef.detectChanges() to do this

Title: Angular 2 get element by dynamic id

Body:
How can I get/update value of element with dynamic id?

<input type="text" class="form-control" id="{{'lat' + ind}}" formControlName="lat">

I can't use ngAfterViewInit() {} because I need to update dynamic input after server responce

this.someService.getData().subscribe(
                  (response) => {this.data = response.json()
                                 this.lon = this.data.x;
                                 this.lat = this.data.y;
                                 this.ind = this.data.ind;
                                // UPDATE MY 'lat+ind' and 'lon+ind' HERE
                  },
                  (error) => console.log('ERROR: ' + error)
          );

Body:
this.someService.getData().subscribe(
    (response) => {
                     this.ngZone.run(function() {
                       this.data = response.json()
                       this.lon = this.data.x;
                       this.lat = this.data.y;
                       this.ind = this.data.ind;
                     };)
                  },
(error) => console.log('ERROR: ' + error)
);

Note: you have to import NgZone and inject it at your constructor.

You need to do this because your view is not updated after you receive your response from your service. My code above will revive your view and publish updated values to your ID.

Your template gets published in the beginning when your lat and ind are still undefined. Then when you make your service call and you get a response, you must tell angular to update your view with the new values.

Note: You can also use ChangeDetectorRef.detectChanges() to do this


问:
Validation expression in asp.net
How to disallow use of double quotes " in a textbox

答:
You haven't specified if you're using webforms or MVC, so I'm gonna throw a couple things a'cha.

First off, here's the Regex you'll use in either situation.  ^[^\"]*$

First for WebForms

```<code><asp:TextBox runat="server" id="TextBox1" />
<asp:RegularExpressionValidator runat="server" id="Regex1" controltovalidate="TextBox1" validationexpression="^[^\"]*$" errormessage="Nope!" />
<!-- This will give you client AND server side validation capabilities-->
</code>```

To ensure you're valid on the SERVER SIDE, you add this to your form submit method

```<code>If Page.IsValid Then
    ''# submit the form
Else
    ''# your form was not entered properly.
    ''# Even if the user disables Javascript, we're gonna catch them here
End If
</code>```

In MVC you should definitely use DataAnnotations on your ViewModel

NOTE: DataAnnotations can also be use for WebForms if you're planning on doing a lot of repeat ctrl + C and ctrl + V

```<code>''# fix SO code coloring
''# this is in the view model
<RegularExpression("^[^\"]*$", ErrorMessage:="Nope")>
Public Property TextBox1 As String ''# don't actually call it TextBox1 of course
</code>```

And in your controller "Post" action, you wanna add the following

```<code>If ModelState.IsValid Then
    ''# submit the form
Else
    ''# your form was not entered properly.
    ''# Even if the user disables Javascript, we're gonna catch them here
End If
</code>```

Title: Validation expression in asp.net

Body:
You haven't specified if you're using webforms or MVC, so I'm gonna throw a couple things a'cha.

First off, here's the Regex you'll use in either situation.  ^[^\"]*$

First for WebForms

<asp:TextBox runat="server" id="TextBox1" />
<asp:RegularExpressionValidator runat="server" id="Regex1" controltovalidate="TextBox1" validationexpression="^[^\"]*$" errormessage="Nope!" />
<!-- This will give you client AND server side validation capabilities-->

To ensure you're valid on the SERVER SIDE, you add this to your form submit method

If Page.IsValid Then
    ''# submit the form
Else
    ''# your form was not entered properly.
    ''# Even if the user disables Javascript, we're gonna catch them here
End If

In MVC you should definitely use DataAnnotations on your ViewModel

NOTE: DataAnnotations can also be use for WebForms if you're planning on doing a lot of repeat ctrl + C and ctrl + V

''# fix SO code coloring
''# this is in the view model
<RegularExpression("^[^\"]*$", ErrorMessage:="Nope")>
Public Property TextBox1 As String ''# don't actually call it TextBox1 of course

And in your controller "Post" action, you wanna add the following

If ModelState.IsValid Then
    ''# submit the form
Else
    ''# your form was not entered properly.
    ''# Even if the user disables Javascript, we're gonna catch them here
End If


问:
Replace array key value
I want to replace array values (1, 2, 3 and 4) to corresponding text

```<code>1 = OK;
2 = nOK;
3 = Warning;
4 = Other
</code>```

Here is some code:

```<code>$status = $row['status'];
</code>```

(I stored $status text in mysql row 1,2,3,4,1,2,4,4,1, etc)

```<code>$myarray = array($status);
foreach($myarray as $key => $val)
{
    print_r($val);
}
</code>```

Output of this is:

```<code>Array ( [0] => 2 [1] => 3 [2] => 1 [3] => 4 [4] => 1 [5] => 1 [6] => 3 [7] => 4 [8] => 1 [9] => 2 )
</code>```

How to do this? Thanks!

答:
You can use str_replace for this.

Str_replace accepts arrays and means you don't have to loop.

```<code>$repl =  array(1 =>"OK", 2 => "nOK", 3 => "Warning", 4 => "Other");

$myarray = array(1,2,3,4);

$new = str_replace($myarray,$repl, $myarray);

var_dump($new);
</code>```

https://3v4l.org/tgL1q

Title: Replace array key value

Body:
I want to replace array values (1, 2, 3 and 4) to corresponding text

1 = OK;
2 = nOK;
3 = Warning;
4 = Other

Here is some code:

$status = $row['status'];

(I stored $status text in mysql row 1,2,3,4,1,2,4,4,1, etc)

$myarray = array($status);
foreach($myarray as $key => $val)
{
    print_r($val);
}

Output of this is:

Array ( [0] => 2 [1] => 3 [2] => 1 [3] => 4 [4] => 1 [5] => 1 [6] => 3 [7] => 4 [8] => 1 [9] => 2 )

How to do this? Thanks!

Body:
You can use str_replace for this.

Str_replace accepts arrays and means you don't have to loop.

$repl =  array(1 =>"OK", 2 => "nOK", 3 => "Warning", 4 => "Other");

$myarray = array(1,2,3,4);

$new = str_replace($myarray,$repl, $myarray);

var_dump($new);

https://3v4l.org/tgL1q


问:
Interrupt UrlConnection on back presss
In my Android Application I have two activities: Main and Articles. My application starts with Main. In Articles I am showing Images which are downloaded from server.

Here is the code to download the images from server:

```<code>public class SyncImage extends AsyncTask<Void, Void, Bitmap> {
private String url;
private URLConnection connection;

public SyncImage(String url) {
        this.url = url;
    }

@Override
    protected Bitmap doInBackground(Void... voids) {
        Bitmap img;
        try {
            URL source = new URL(url);
            connection = source.openConnection();
            Handler.addUrlConnection(connection);
            connection.setConnectTimeout(10000);
            connection.setReadTimeout(10000);
            connection.connect();
            img = BitmapFactory.decodeStream(connection.getInputStream());
            return img;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return null;
    }
}
</code>```

Articles activity

```<code>private void downloadImages(ArrayList<String> images) {
        for (String image : images) {
            SyncImage sync = new SyncImage(image);
            sync.execute();
            // Rest of the code
        }
    }
</code>```

What I want that if user press back button to go back to Main Screen, all UrlConnection objects should cancel/stop their executions.

I can cancel the SyncImage object using sync.cancel(true), but it will only stop AsyncTask object, not the URLConnection object in process.

So, how to cancel the ongoing execution UrlConnection objects on Back Press?

答:
Make Connection and SyncImage class variable and then try to disconnect connection as follows :

```<code>@Override
public void onBackPressed() {
    connection.close();
    connection.disconnect();
    SyncImages.cancel(true);
    finish();
  }
</code>```

Title: Interrupt UrlConnection on back presss

Body:
In my Android Application I have two activities: Main and Articles. My application starts with Main. In Articles I am showing Images which are downloaded from server.

Here is the code to download the images from server:

public class SyncImage extends AsyncTask<Void, Void, Bitmap> {
private String url;
private URLConnection connection;

public SyncImage(String url) {
        this.url = url;
    }

@Override
    protected Bitmap doInBackground(Void... voids) {
        Bitmap img;
        try {
            URL source = new URL(url);
            connection = source.openConnection();
            Handler.addUrlConnection(connection);
            connection.setConnectTimeout(10000);
            connection.setReadTimeout(10000);
            connection.connect();
            img = BitmapFactory.decodeStream(connection.getInputStream());
            return img;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return null;
    }
}

Articles activity

private void downloadImages(ArrayList<String> images) {
        for (String image : images) {
            SyncImage sync = new SyncImage(image);
            sync.execute();
            // Rest of the code
        }
    }

What I want that if user press back button to go back to Main Screen, all UrlConnection objects should cancel/stop their executions.

I can cancel the SyncImage object using sync.cancel(true), but it will only stop AsyncTask object, not the URLConnection object in process.

So, how to cancel the ongoing execution UrlConnection objects on Back Press?

Body:
Make Connection and SyncImage class variable and then try to disconnect connection as follows :

@Override
public void onBackPressed() {
    connection.close();
    connection.disconnect();
    SyncImages.cancel(true);
    finish();
  }


问:
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

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:
Here is a mixed base R- stringr - data.table approach.

library(stringr)
library(data.table)
aa = aa = 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))
aa = aa[aa$V1 !="",]
a1 = str_trim(aa$V1)

cc  = str_split_fixed(aa$V1, "\\?|~", 2)
cc2 = apply(cc, 2, str_extract_all, "\\d+\\.\\d+", simplify = T)
cc2 = apply(cc2, 2, as.numeric)
cc2 = cbind(cc2, as.character(aa$V2))

range_col = list()
for(i in 1:nrow(cc2)){
  range_col[[i]] = data.table(V1 = seq(cc2[i,1], cc2[i,2], by = 0.01),
                              V2 = cc2[i, 3])
}
rr = rbindlist(range_col)

which results in

      V1  V2
 1: 1.01 CTH
 2: 1.02 CTH
 3: 1.03 CTH
 4: 1.04 CTH
 5: 1.05 CTH
 6: 1.06 CTH
 7: 2.01 CTH
 8: 2.02 CTH
 9: 2.03 CTH
10: 2.04 CTH
11: 2.05 CTH
12: 2.06 CTH
13: 2.07 CTH
14: 2.08 CTH
15: 2.09 CTH
16: 2.10 CTH
17: 3.01 CTH
18: 3.02 CTH
19: 3.03 CTH
20: 3.04 CTH
21: 3.05 CTH
22: 3.06 CTH
23: 3.07 CTH
24: 4.01  WO
25: 4.02  WO
26: 4.03  WO
27: 4.04  WO
28: 4.05  WO
29: 4.06  WO
30: 4.07  WO
31: 4.08  WO
32: 4.09  WO
33: 4.10  WO


答:
Here is a complete batch code for this task using mainly arithmetic expressions and string concatenations to determine the target folder path for each *.7z file in source folder, or alternatively for each file of which name is passed via an argument to the batch file.

```<code>@echo off
setlocal EnableExtensions DisableDelayedExpansion

rem Source path is the directory of the batch file ending with a backslash.
set "SourcePath=%~dp0"
rem Target path is a UNC path also ending with a backslash.
set "TargetPath=\\nas01\archive\"

rem Run subroutine ProcessFile for each *.7z file in source folder
rem if not at least 1 file was specified on command line to process.
rem Otherwise process the files of which names are passed as arguments
rem to this batch file on starting it.
if "%~1" == "" (
    for %%I in ("%SourcePath%*.7z") do call :ProcessFile "%%I"
) else (
    for %%I in (%*) do call :ProcessFile "%%~I"
)

rem Restore previous environment and exit this batch file.
endlocal
goto :EOF

rem The subroutine ProcessFile determines the target folders based on
rem first part of the file name separated with one or more spaces from
rem rest of the file name which should be a positive integer number.

rem File names not starting with a valid number are copied (or moved)
rem to the folder _0000-0249\_0000-0249 in specified target folder.

rem For file numbers less than 1000 an extra code is added to copy (or move)
rem those files into folders also having at least 4 digit numbers in name.

:ProcessFile
for /F %%J in ("%~n1") do set "FileNumber=%%J"
set /A FolderNumber1=(FileNumber / 1000) * 1000
set /A FolderNumber2=FolderNumber1 + 999

set /A FolderNumber3=FileNumber - FolderNumber1
if %FolderNumber3% LSS 250 (
    set "FolderNumber3=%FolderNumber1%"
    set /A FolderNumber4=FolderNumber1 + 249
    goto BuildFolderPath
)
if %FolderNumber3% LSS 500 (
    set /A FolderNumber3=FolderNumber1 + 250
    set /A FolderNumber4=FolderNumber1 + 499
    goto BuildFolderPath
)
if %FolderNumber3% LSS 750 (
    set /A FolderNumber3=FolderNumber1 + 500
    set /A FolderNumber4=FolderNumber1 + 749
    goto BuildFolderPath
)
set /A FolderNumber3=FolderNumber1 + 750
set "FolderNumber4=%FolderNumber2%"

:BuildFolderPath
if %FolderNumber1% == 0 (
    set "FolderNumber1=0000"
    set "FolderNumber2=0%FolderNumber2%"
    set "FolderNumber4=0%FolderNumber4%"
    if %FolderNumber3% == 0 (
        set "FolderNumber3=0000"
    ) else (
        set "FolderNumber3=0%FolderNumber3%"
    )
)
set "TargetFolder=%TargetPath%_%FolderNumber1%-%FolderNumber2%\_%FolderNumber3%-%FolderNumber4%"

mkdir "%TargetFolder%" 2>nul
copy /Y "%~1" "%TargetFolder%\" >nul
rem move /Y "%~1" "%TargetFolder%\" >nul
goto :EOF
</code>```

A subroutine is used instead of doing everything within FOR loop as this makes the task much easier to code because of GOTO can be used in the subroutine. And with a subroutine it is not necessary to use delayed environment variable expansion which is helpful in case of a *.7z file ever contains an exclamation mark.

The main advantage of this solution: it works with numbers in range 0 to 2147482999 in file name.

For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.

call /?

copy /?

echo /?

endlocal /?

for /?

goto /?

if /?

mkdir /?

move /?

rem /?

setlocal /?

Read also the Microsoft article about Using Command Redirection Operators explaining >nul and 2>nul used to redirect success and error messages to device NUL to suppress them.

Title: BATCH: How can I copy files to directory based on file name

Body:
Here is a complete batch code for this task using mainly arithmetic expressions and string concatenations to determine the target folder path for each *.7z file in source folder, or alternatively for each file of which name is passed via an argument to the batch file.

@echo off
setlocal EnableExtensions DisableDelayedExpansion

rem Source path is the directory of the batch file ending with a backslash.
set "SourcePath=%~dp0"
rem Target path is a UNC path also ending with a backslash.
set "TargetPath=\\nas01\archive\"

rem Run subroutine ProcessFile for each *.7z file in source folder
rem if not at least 1 file was specified on command line to process.
rem Otherwise process the files of which names are passed as arguments
rem to this batch file on starting it.
if "%~1" == "" (
    for %%I in ("%SourcePath%*.7z") do call :ProcessFile "%%I"
) else (
    for %%I in (%*) do call :ProcessFile "%%~I"
)

rem Restore previous environment and exit this batch file.
endlocal
goto :EOF

rem The subroutine ProcessFile determines the target folders based on
rem first part of the file name separated with one or more spaces from
rem rest of the file name which should be a positive integer number.

rem File names not starting with a valid number are copied (or moved)
rem to the folder _0000-0249\_0000-0249 in specified target folder.

rem For file numbers less than 1000 an extra code is added to copy (or move)
rem those files into folders also having at least 4 digit numbers in name.

:ProcessFile
for /F %%J in ("%~n1") do set "FileNumber=%%J"
set /A FolderNumber1=(FileNumber / 1000) * 1000
set /A FolderNumber2=FolderNumber1 + 999

set /A FolderNumber3=FileNumber - FolderNumber1
if %FolderNumber3% LSS 250 (
    set "FolderNumber3=%FolderNumber1%"
    set /A FolderNumber4=FolderNumber1 + 249
    goto BuildFolderPath
)
if %FolderNumber3% LSS 500 (
    set /A FolderNumber3=FolderNumber1 + 250
    set /A FolderNumber4=FolderNumber1 + 499
    goto BuildFolderPath
)
if %FolderNumber3% LSS 750 (
    set /A FolderNumber3=FolderNumber1 + 500
    set /A FolderNumber4=FolderNumber1 + 749
    goto BuildFolderPath
)
set /A FolderNumber3=FolderNumber1 + 750
set "FolderNumber4=%FolderNumber2%"

:BuildFolderPath
if %FolderNumber1% == 0 (
    set "FolderNumber1=0000"
    set "FolderNumber2=0%FolderNumber2%"
    set "FolderNumber4=0%FolderNumber4%"
    if %FolderNumber3% == 0 (
        set "FolderNumber3=0000"
    ) else (
        set "FolderNumber3=0%FolderNumber3%"
    )
)
set "TargetFolder=%TargetPath%_%FolderNumber1%-%FolderNumber2%\_%FolderNumber3%-%FolderNumber4%"

mkdir "%TargetFolder%" 2>nul
copy /Y "%~1" "%TargetFolder%\" >nul
rem move /Y "%~1" "%TargetFolder%\" >nul
goto :EOF

A subroutine is used instead of doing everything within FOR loop as this makes the task much easier to code because of GOTO can be used in the subroutine. And with a subroutine it is not necessary to use delayed environment variable expansion which is helpful in case of a *.7z file ever contains an exclamation mark.

The main advantage of this solution: it works with numbers in range 0 to 2147482999 in file name.

For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.

call /?

copy /?

echo /?

endlocal /?

for /?

goto /?

if /?

mkdir /?

move /?

rem /?

setlocal /?

Read also the Microsoft article about Using Command Redirection Operators explaining >nul and 2>nul used to redirect success and error messages to device NUL to suppress them.


问:
Blackberry: WebBitmapField center image
http://www.coderholic.com/blackberry-webbitmapfield/

This is a great script for grabbing an image from the web for a Blackberry App. Now I would like to know how to center the returned image. I have tried everything.

This portion of code seems to return the image:

byte[] dataArray = data.getBytes();

bitmap = EncodedImage.createEncodedImage(dataArray, 0,

dataArray.length);

setImage(bitmap);

This displays the image:

getimage = new WebBitmapField("http://");
add (getimage);

Where can I put FIELD_HCENTER to center this thing.
Please show sample code. Thanks!!

答:
If you insist on using this WebBitmapField, then you'll need to add a new constructor so that style bits can be passed to the BitmapField:</p>

```<code>public class WebBitmapField extends BitmapField implements WebDataCallback
{
    ...
    public WebBitmapField(String url, long style)
    {
        super(style);
        try
        {
            Util.getWebData(url, this);
        }
        catch (Exception e) {}
    }

    public WebBitmapField(String url)
    {
        this(url, 0L);
    }
    ...
}
</code>```

Title: Blackberry: WebBitmapField center image

Body:
If you insist on using this WebBitmapField, then you'll need to add a new constructor so that style bits can be passed to the BitmapField:

public class WebBitmapField extends BitmapField implements WebDataCallback
{
    ...
    public WebBitmapField(String url, long style)
    {
        super(style);
        try
        {
            Util.getWebData(url, this);
        }
        catch (Exception e) {}
    }

    public WebBitmapField(String url)
    {
        this(url, 0L);
    }
    ...
}


问:
flex spacer automatic grow
I'm trying to make tournament brackets with flexbox.

A flashscore example is here

But I can't make gaps between second row. my codepen

.brackets {
  display: flex;
  flex-direction: row;
}

.round {
  display: flex;
  flex-direction: column;
  margin-right: 31px;
  justify-content: center;
}
.round__item-wrapper {
  width: 200px;
  height: 60px;
  -webkit-border-radius: 6px;
  -moz-border-radius: 6px;
  border-radius: 6px;
  border: 1px solid #ea1312;
}
.round__item-spacer {
  min-height: 15px;
  flex-grow: 1;
}
.round__game {
  display: flex;
  flex-direction: column;
  position: relative;
  justify-content: center;
}
.round__game-spacer {
  flex-grow: 1;
}
.round__game-spacer:first-child, .round__game-spacer:last-child {
  flex-grow: 0.5;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="brackets mt-3">
    <div class="round">
        <div class="round__game-spacer"> </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-spacer"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game-spacer"> </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-spacer"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game-spacer"> </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-spacer"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game-spacer"> </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-spacer"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game-spacer"> </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game-spacer"> </div>
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-spacer"></div>
                <div class="round__item-wrapper"></div>
            </div>
            <div class="round__game-spacer"> </div>
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-spacer"></div>
                <div class="round__item-wrapper"></div>
            </div>
            <div class="round__game-spacer"> </div>
          </div>
    </div>
</div></code>```

The main difficulity is that I don't know how many participants will be there

How can I do that?

答:
But I can't make gaps between second row

You could use flex: 1 on .round__game, and they will stretch and fill their parents, and then, with justify-content: center you get this

Note 1: I removed all the "space" elements, as they are not needed. If you will need a gap/gutter somewhere, use margins instead.

The main difficulity is that I don't know how many participants will
  be there

I doubled up the initial row, so you can see this work w/o knowing how many participants.

Updated codepen

Stack snippet

.brackets {
  display: flex;
}

.round {
  display: flex;
  flex-direction: column;
  margin-right: 15px;
}
.round__item-wrapper {
  width: 120px;
  height: 20px;
  -webkit-border-radius: 6px;
  -moz-border-radius: 6px;
  border-radius: 6px;
  border: 1px solid #ea1312;
}
.round__game {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.round:first-child .round__game {
  margin: 5px 0;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="brackets mt-3">
    <div class="round">
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-wrapper"></div>
            </div>
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-wrapper"></div>
            </div>
          </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-wrapper"></div>
            </div>
          </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game">
                <div class="round__item-wrapper"></div>
            </div>
          </div>
    </div>
</div></code>```

And with justify-content: space-around you get this

Updated codepen 2

Stack snippet 2

.brackets {
  display: flex;
}

.round {
  display: flex;
  flex-direction: column;
  margin-right: 15px;
}
.round__item-wrapper {
  width: 120px;
  height: 20px;
  -webkit-border-radius: 6px;
  -moz-border-radius: 6px;
  border-radius: 6px;
  border: 1px solid #ea1312;
}
.round__game {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.round:first-child .round__game {
  margin: 5px 0;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="brackets mt-3">
    <div class="round">
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-wrapper"></div>
            </div>
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-wrapper"></div>
            </div>
          </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-wrapper"></div>
            </div>
          </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game">
                <div class="round__item-wrapper"></div>
            </div>
          </div>
    </div>
</div></code>```

Title: flex spacer automatic grow

Body:
I'm trying to make tournament brackets with flexbox.

A flashscore example is here

But I can't make gaps between second row. my codepen

.brackets {
  display: flex;
  flex-direction: row;
}

.round {
  display: flex;
  flex-direction: column;
  margin-right: 31px;
  justify-content: center;
}
.round__item-wrapper {
  width: 200px;
  height: 60px;
  -webkit-border-radius: 6px;
  -moz-border-radius: 6px;
  border-radius: 6px;
  border: 1px solid #ea1312;
}
.round__item-spacer {
  min-height: 15px;
  flex-grow: 1;
}
.round__game {
  display: flex;
  flex-direction: column;
  position: relative;
  justify-content: center;
}
.round__game-spacer {
  flex-grow: 1;
}
.round__game-spacer:first-child, .round__game-spacer:last-child {
  flex-grow: 0.5;
}

The main difficulity is that I don't know how many participants will be there

How can I do that?

Body:
But I can't make gaps between second row

You could use flex: 1 on .round__game, and they will stretch and fill their parents, and then, with justify-content: center you get this

Note 1: I removed all the "space" elements, as they are not needed. If you will need a gap/gutter somewhere, use margins instead.

The main difficulity is that I don't know how many participants will
  be there

I doubled up the initial row, so you can see this work w/o knowing how many participants.

Updated codepen

Stack snippet

.brackets {
  display: flex;
}

.round {
  display: flex;
  flex-direction: column;
  margin-right: 15px;
}
.round__item-wrapper {
  width: 120px;
  height: 20px;
  -webkit-border-radius: 6px;
  -moz-border-radius: 6px;
  border-radius: 6px;
  border: 1px solid #ea1312;
}
.round__game {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.round:first-child .round__game {
  margin: 5px 0;
}

<div class="brackets mt-3">
    <div class="round">
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-wrapper"></div>
            </div>
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-wrapper"></div>
            </div>
          </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-wrapper"></div>
            </div>
          </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game">
                <div class="round__item-wrapper"></div>
            </div>
          </div>
    </div>
</div>

And with justify-content: space-around you get this

Updated codepen 2

Stack snippet 2

.brackets {
  display: flex;
}

.round {
  display: flex;
  flex-direction: column;
  margin-right: 15px;
}
.round__item-wrapper {
  width: 120px;
  height: 20px;
  -webkit-border-radius: 6px;
  -moz-border-radius: 6px;
  border-radius: 6px;
  border: 1px solid #ea1312;
}
.round__game {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.round:first-child .round__game {
  margin: 5px 0;
}

<div class="brackets mt-3">
    <div class="round">
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
        <div class="round__game">
            <div class="round__item-wrapper"></div>
            <div class="round__item-wrapper"></div>
        </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-wrapper"></div>
            </div>
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-wrapper"></div>
            </div>
          </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game">
                <div class="round__item-wrapper"></div>
                <div class="round__item-wrapper"></div>
            </div>
          </div>
    </div>
    <div class="round">
        <div class="round__game">
            <div class="round__game">
                <div class="round__item-wrapper"></div>
            </div>
          </div>
    </div>
</div>


问:
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.

答:
This will do the job, without a new column:</p>

```<code>SELECT *, (likes/(likes+dislikes))*5 AS rank FROM tableName order by rank DESC
</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:
This will do the job, without a new column:

SELECT *, (likes/(likes+dislikes))*5 AS rank FROM tableName order by rank DESC


问:
I am getting and error as - Module ''selenium-webdriver'' has no exported member 'Promise', while trying to run protractor tests in webstorm
Below is the error I am facing.. the same code is working when I compile it to JavaScript here "compile Typescript to JavaScript". I would like to execute it without generating the JavaScript files. Below is the code snippet.

```<code>getIndusElem(): Promise<string> {
    return element(by.id('industry')).getText()
  }
</code>```

Thanks in advance for your help...

```<code>[15:10:39] I/launcher - Running 1 instances of WebDriver
[15:10:39] I/direct - Using ChromeDriver directly...
[15:10:45] E/launcher - Error: TSError: ⨯ Unable to compile TypeScript
e2e\app.po.ts (2,10): Module '"C:/Venkat/new/test/solaris/node_modules/@types/selenium-webdriver/index"' has no exported member 'Promise'. (2305)
    at getOutput (C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:307:15)
    at C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:336:16
    at Object.compile (C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:496:11)
    at Module.m._compile (C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:392:43)
    at Module._extensions..js (module.js:646:10)
    at Object.require.extensions.(anonymous function) [as .ts] (C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:395:12)
    at Module.load (C:\Venkat\new\test\solaris\node_modules\coffee-script\lib\coffee-script\register.js:45:36)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Venkat\new\test\solaris\e2e\context_selector.e2e-spec.ts:2:1)
    at Module._compile (module.js:635:30)
    at Module.m._compile (C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:392:23)
    at Module._extensions..js (module.js:646:10)
    at Object.require.extensions.(anonymous function) [as .ts] (C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:395:12)
    at Module.load (C:\Venkat\new\test\solaris\node_modules\coffee-script\lib\coffee-script\register.js:45:36)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at C:\Venkat\new\test\solaris\node_modules\jasmine\lib\jasmine.js:93:5
    at Array.forEach (<anonymous>)
    at Jasmine.loadSpecs (C:\Venkat\new\test\solaris\node_modules\jasmine\lib\jasmine.js:92:18)
    at Jasmine.execute (C:\Venkat\new\test\solaris\node_modules\jasmine\lib\jasmine.js:197:8)
    at C:\Venkat\new\test\solaris\node_modules\protractor\built\frameworks\jasmine.js:132:15
    at Function.promise (C:\Venkat\new\test\solaris\node_modules\protractor\node_modules\q\q.js:682:9)
    at C:\Venkat\new\test\solaris\node_modules\protractor\built\frameworks\jasmine.js:104:14
</code>```

Here are my devDependencies..

```<code>"devDependencies": {
    "@angular/cli": "1.5.0-rc.3",
    "@angular/compiler-cli": "^5.0.0-rc.6",
    "@angular/language-service": "^5.0.0-rc.6",
    "@compodoc/compodoc": "^1.0.4",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "angular-split": "^0.2.7",
    "archiver": "2.0.0",
    "codelyzer": "~3.2.0",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "normalize.css": "^7.0.0",
    "primeng": "^5.0.0",
    "protractor": "~5.1.2",
    "quill": "^1.3.4",
    "sync-request": "4.0.3",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~2.4.2"
  }
</code>```

答: It worked by adding the below checks in config file. hope it will be helpfull for someone. "skipLibCheck": true, "noStrictGenericChecks": true.

Body:
Below is the error I am facing.. the same code is working when I compile it to JavaScript here "compile Typescript to JavaScript". I would like to execute it without generating the JavaScript files. Below is the code snippet.

getIndusElem(): Promise<string> {
    return element(by.id('industry')).getText()
  }

Thanks in advance for your help...

[15:10:39] I/launcher - Running 1 instances of WebDriver
[15:10:39] I/direct - Using ChromeDriver directly...
[15:10:45] E/launcher - Error: TSError: ⨯ Unable to compile TypeScript
e2e\app.po.ts (2,10): Module '"C:/Venkat/new/test/solaris/node_modules/@types/selenium-webdriver/index"' has no exported member 'Promise'. (2305)
    at getOutput (C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:307:15)
    at C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:336:16
    at Object.compile (C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:496:11)
    at Module.m._compile (C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:392:43)
    at Module._extensions..js (module.js:646:10)
    at Object.require.extensions.(anonymous function) [as .ts] (C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:395:12)
    at Module.load (C:\Venkat\new\test\solaris\node_modules\coffee-script\lib\coffee-script\register.js:45:36)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Venkat\new\test\solaris\e2e\context_selector.e2e-spec.ts:2:1)
    at Module._compile (module.js:635:30)
    at Module.m._compile (C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:392:23)
    at Module._extensions..js (module.js:646:10)
    at Object.require.extensions.(anonymous function) [as .ts] (C:\Venkat\new\test\solaris\node_modules\ts-node\src\index.ts:395:12)
    at Module.load (C:\Venkat\new\test\solaris\node_modules\coffee-script\lib\coffee-script\register.js:45:36)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at C:\Venkat\new\test\solaris\node_modules\jasmine\lib\jasmine.js:93:5
    at Array.forEach (<anonymous>)
    at Jasmine.loadSpecs (C:\Venkat\new\test\solaris\node_modules\jasmine\lib\jasmine.js:92:18)
    at Jasmine.execute (C:\Venkat\new\test\solaris\node_modules\jasmine\lib\jasmine.js:197:8)
    at C:\Venkat\new\test\solaris\node_modules\protractor\built\frameworks\jasmine.js:132:15
    at Function.promise (C:\Venkat\new\test\solaris\node_modules\protractor\node_modules\q\q.js:682:9)
    at C:\Venkat\new\test\solaris\node_modules\protractor\built\frameworks\jasmine.js:104:14

Here are my devDependencies..

"devDependencies": {
    "@angular/cli": "1.5.0-rc.3",
    "@angular/compiler-cli": "^5.0.0-rc.6",
    "@angular/language-service": "^5.0.0-rc.6",
    "@compodoc/compodoc": "^1.0.4",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "angular-split": "^0.2.7",
    "archiver": "2.0.0",
    "codelyzer": "~3.2.0",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "normalize.css": "^7.0.0",
    "primeng": "^5.0.0",
    "protractor": "~5.1.2",
    "quill": "^1.3.4",
    "sync-request": "4.0.3",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~2.4.2"
  }


问:
Can we give the test data, without labelling them?
I came across this snippet in the Tensorflow documentation, MNIST For ML Beginners.

```<code>eval_data = mnist.test.images  # Returns np.array
eval_labels = np.asarray(mnist.test.labels, dtype=np.int32)
</code>```

Now, I want to feed my own test images, without labelling them and would like the model to predict the labels, how do I achieve this?

答:
Yes you can, but it would not be deep learning instead it would be clustering. ( Ex: K means Clustering )

Basic idea is like the following:

Create two placeholders for input and centroids

Decide a distance metric

Create graph

feed only dataset to run the graph

Body:
I came across this snippet in the Tensorflow documentation, MNIST For ML Beginners.

eval_data = mnist.test.images  # Returns np.array
eval_labels = np.asarray(mnist.test.labels, dtype=np.int32)

Now, I want to feed my own test images, without labelling them and would like the model to predict the labels, how do I achieve this?


问:
Socket get disconnected randomly
Client Socket randomly disconnects because of a ping timeout

At the server side, I am listening the disconnected event.

Output:

Socket disconnected because of ping timeout

```<code>socket.on('disconnect', function (reason) {
    console.log('Socket disconnected because of ' + reason);
});
</code>```

答:
Due to the inactivity it throws that error.

If server not able to communicate the Client particular interval of time which is ping interval time.

Ref: https://socket.io/docs/server-api/

pingTimeout (Number): how many ms without a pong packet to consider the connection closed (60000)
pingInterval (Number): how many ms before sending a new ping packet (25000).

Those two parameters will impact the delay before a client knows the server is not available anymore. For example, if the underlying TCP connection is not closed properly due to a network issue, a client may have to wait up to pingTimeout + pingInterval ms before getting a disconnect event.

Title: Socket get disconnected randomly

Body:
Client Socket randomly disconnects because of a ping timeout

At the server side, I am listening the disconnected event.

Output:

Socket disconnected because of ping timeout

socket.on('disconnect', function (reason) {
    console.log('Socket disconnected because of ' + reason);
});


问:
graphics.h for microsoft visual studio community 2017
I have been including the graphics.h in the header folder of vs project, but for some reason, it still says "No such file directory". I watched one of the videos and I saw that I need to get graphics.lib and I have no idea where the .lib file is since I searched everywhere for it. Can you please help me?</p>

答:
You need to download the WinBGIm graphics library onto your machine (preferably to the desktop, where you can easily access it):

For Visual Studio 2005:     BGI.zip
For Visual Studio 2008:     BGI2008.zip
For Visual Studio 2010:     BGI2010.zip
ref:http://www.cs.colorado.edu/~main/bgi/visual/

ContentLicense: CC BY-SA 4.0


问:
Libraries must use the exact same versions specification
I have created a project with :

```<code>compileSdkVersion 27
buildToolsVersion '27.0.2'
</code>```

on dependecies I have this code:

```<code>dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    //    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    //        exclude group: 'com.android.support', module: 'support-annotations'
    //    })
    compile 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.android.support:recyclerview-v7:27.0.2'
    compile 'com.android.support:support-annotations:27.0.2'
   compile 'com.android.support:support-vector-drawable:27.0.2'
    compile 'com.android.support:design:27.0.2'
    compile 'com.android.support:support-v4:27.0.2'
    compile 'com.github.Kunzisoft:Android-SwitchDateTimePicker:1.4'
    compile 'com.eminayar.panterdialog:panter-dialog:0.0.2.1'
    compile 'com.github.polok:clicknumberpicker:0.1.2'
    compile 'com.roughike:bottom-bar:2.1.1'
    compile 'com.github.HotBitmapGG:RingProgressBar:V1.2.2'
    compile 'com.anjlab.android.iab.v3:library:1.0.44'
    compile 'com.google.android.gms:play-services-ads:11.6.2'
    compile 'com.github.10uroi:ToastOX:1.0.1'
    compile 'com.yarolegovich:lovely-dialog:1.0.4'
    testCompile 'junit:junit:4.12'
}
</code>```

I have error on 'com.android.support:appcompat-v7:27.0.2' and it says:

All com.android.support libraries must use the exact same version
  specification (mixing versions can lead to runtime crashes). Found
  versions 27.0.2, 24.2.1. Examples include
  com.android.support:animated-vector-drawable:27.0.2 and
  com.android.support:percent:24.2.1

I've run gradlew -q dependencies app:dependencies --configuration compile
and this is the result:

How can I change it to 27 ?

ATTENTION! I haven't used compile com.android.support:percent:24.2.1 it imports from com.github.polok:clicknumberpicker:0.1.2

答:
Change-

```<code>com.android.support:percent:24.2.1
</code>```

to-

```<code>com.android.support:percent:27.0.2
</code>```

Body:
I have created a project with :

compileSdkVersion 27
buildToolsVersion '27.0.2'

on dependecies I have this code:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    //    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    //        exclude group: 'com.android.support', module: 'support-annotations'
    //    })
    compile 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.android.support:recyclerview-v7:27.0.2'
    compile 'com.android.support:support-annotations:27.0.2'
   compile 'com.android.support:support-vector-drawable:27.0.2'
    compile 'com.android.support:design:27.0.2'
    compile 'com.android.support:support-v4:27.0.2'
    compile 'com.github.Kunzisoft:Android-SwitchDateTimePicker:1.4'
    compile 'com.eminayar.panterdialog:panter-dialog:0.0.2.1'
    compile 'com.github.polok:clicknumberpicker:0.1.2'
    compile 'com.roughike:bottom-bar:2.1.1'
    compile 'com.github.HotBitmapGG:RingProgressBar:V1.2.2'
    compile 'com.anjlab.android.iab.v3:library:1.0.44'
    compile 'com.google.android.gms:play-services-ads:11.6.2'
    compile 'com.github.10uroi:ToastOX:1.0.1'
    compile 'com.yarolegovich:lovely-dialog:1.0.4'
    testCompile 'junit:junit:4.12'
}

I have error on 'com.android.support:appcompat-v7:27.0.2' and it says:

All com.android.support libraries must use the exact same version
  specification (mixing versions can lead to runtime crashes). Found
  versions 27.0.2, 24.2.1. Examples include
  com.android.support:animated-vector-drawable:27.0.2 and
  com.android.support:percent:24.2.1

I've run gradlew -q dependencies app:dependencies --configuration compile
and this is the result:

How can I change it to 27 ?

ATTENTION! I haven't used compile com.android.support:percent:24.2.1 it imports from com.github.polok:clicknumberpicker:0.1.2

Body:
Change-

com.android.support:percent:24.2.1

to-

com.android.support:percent:27.0.2


问:
Can't BeautifulSoup show me the content of the website?
I want to scrape the contents of a website, using the library called BeautifulSoup.

Code:

```<code>from bs4 import BeautifulSoup
from urllib.request import urlopen
html_http_response = urlopen("http://www.airlinequality.com/airport-reviews/jeddah-airport/")
data = html_http_response.read()
soup = BeautifulSoup(data, "html.parser")
print(soup.prettify())
</code>```

Output:

```<code><html style="height:100%">
 <head>
  <meta content="NOINDEX, NOFOLLOW" name="ROBOTS"/>
  <meta content="telephone=no" name="format-detection"/>
  <meta content="initial-scale=1.0" name="viewport"/>
  <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
 </head>
 <body style="margin:0px;height:100%">
  <iframe frameborder="0" height="100%" marginheight="0px" marginwidth="0px" src="/_Incapsula_Resource?CWUDNSAI=9&xinfo=9-57435048-0%200NNN%20RT%281512733380259%202%29%20q%280%20-1%20-1%20-1%29%20r%280%20-1%29%20B12%284%2c315%2c0%29%20U19&incident_id=466002040110357581-305794245507288265&edet=12&cinfo=04000000" width="100%">
   Request unsuccessful. Incapsula incident ID: 466002040110357581-305794245507288265
  </iframe>
 </body>
</html>
</code>```

The body contains an iFrame balise instead of the content shown when inspecting the content from the browser.

答:
The data you are looking for , don't exist yet cause this page has Java Jenerated Data. You must study on selenium library and you will find it ( it's rather easy).
This means that the data you want only created when you actually load the page and click e.g. search button.(keep in mind that in iframes first you must select them).</p>

Body:
I want to scrape the contents of a website, using the library called BeautifulSoup.

Code:

from bs4 import BeautifulSoup
from urllib.request import urlopen
html_http_response = urlopen("http://www.airlinequality.com/airport-reviews/jeddah-airport/")
data = html_http_response.read()
soup = BeautifulSoup(data, "html.parser")
print(soup.prettify())

Output:

  <meta content="NOINDEX, NOFOLLOW" name="ROBOTS"/>
  <meta content="telephone=no" name="format-detection"/>
  <meta content="initial-scale=1.0" name="viewport"/>
  <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>

   Request unsuccessful. Incapsula incident ID: 466002040110357581-305794245507288265

The body contains an iFrame balise instead of the content shown when inspecting the content from the browser.


答:
Does POINT(-105.542221069336 39.2369068303763) give you what you expect?

If so it seems likely the terms are reversed from what you are expecting.

Title: DbGeography's FromText throwing error in c#

Body:
I am using System.Data.Entity.Spatial.DbGeography.FromText() method to convert the Google map geographical json data to DbGeography data type to save it into SQL database. Sometimes its throwing the error

"24201: Latitude values must be between -90 and 90 degrees."

Following are the polygon points which I have drawn on United States and its throwing error while conversion:

POLYGON(( 40.6806380252146 -106.8310546875, 40.6639728763869 -93.7353515625, 34.8318411498286 -93.27392578125, 37.9788450404971 -97.84423828125, 35.3890499669117 -98.96484375, 38.3244204270065 -100.43701171875, 35.3173663292379 -102.48046875, 38.5481654230466 -103.60107421875, 35.5143431343182 -104.9853515625, 37.7880813841205 -105.93017578125, 36.6155276313492 -111.26953125, 38.8397076135451 -107.7978515625, 38.685509760012 -111.24755859375, 40.111688665596 -108.74267578125, 38.8568201347436 -105.79833984375, 40.6806380252146 -106.8310546875))

Even its throwing error with below points:

POINT(39.2369068303763 -105.542221069336)


问:
How to animate triangle vertices in a-frame
I am trying to animate an individual vertex of a triangle primitive in a-frame using the animation tag and am having some strange results

In one case, If I try to animate as I would expect to, changing the x,y,z values like so...

```<code><a-triangle
        vertex-a="-1 1 -5"
        vertex-b="-1 1 -10"
        vertex-c="4 1 -10"
        color="blue"
        material="side: double">
            <a-animation
                attribute="vertex-b"
                from="-1 1 -10"
                to="-1 5 -10"
                dur="4000"
                >
            </a-animation>
    </a-triangle>
</code>```

Fiddle https://jsfiddle.net/k7fbmo9k/

...I get the following error

'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is
  NaN. The "position" attribute is likely to have NaN values.'

However, If I only offer a single value like so..

```<code>   <a-triangle
        vertex-a="-1 1 -5"
        vertex-b="-1 1 -10"
        vertex-c="4 1 -10"
        color="blue"
        material="side: double">
            <a-animation
                attribute="vertex-b"
                from="1"
                to="5"
                dur="4000"
                >
            </a-animation>
    </a-triangle>
</code>```

Fiddle https://jsfiddle.net/k7fbmo9k/1/

..it seems to 'work' as in no errors and there is animation but I have no control over it.

Am I doing something wrong?

Thanks for any advice as ever

答:
I have a solution. Using the animation component https://www.npmjs.com/package/aframe-animation-component
the vertices will animate as expected. See example below</p>

```<code> <a-triangle
        vertex-a="-1 1 -5"
        vertex-b="-1 1 -10"
        vertex-c="4 1 -10"
        color="blue"
        material="side: double"
        animation="property: vertex-b; to: -1 5 -10; dur: 1000">
    </a-triangle>
</code>```

Body:
I am trying to animate an individual vertex of a triangle primitive in a-frame using the animation tag and am having some strange results

In one case, If I try to animate as I would expect to, changing the x,y,z values like so...

Fiddle https://jsfiddle.net/k7fbmo9k/

...I get the following error

'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is
  NaN. The "position" attribute is likely to have NaN values.'

However, If I only offer a single value like so..

Fiddle https://jsfiddle.net/k7fbmo9k/1/

..it seems to 'work' as in no errors and there is animation but I have no control over it.

Am I doing something wrong?

Thanks for any advice as ever

Body:
I have a solution. Using the animation component https://www.npmjs.com/package/aframe-animation-component
the vertices will animate as expected. See example below

 <a-triangle
        vertex-a="-1 1 -5"
        vertex-b="-1 1 -10"
        vertex-c="4 1 -10"
        color="blue"
        material="side: double"
        animation="property: vertex-b; to: -1 5 -10; dur: 1000">
    </a-triangle>


问:
Using hops and join against datasets, how to get the highest value of a certain property. DTL
I'm running hops against a dataset in sesam and my output is as the example below, my problem is that need a join where i only end up with the property with the highest priority. </p>

```<code>[{
    "id": "AAA",
    "priority": 10
  }, {
    "id": "AAB",
    "priority": 7
  }]
</code>```

答:
You can also solve this with the "max" function:

```<code>{
  "_id": "sort-by-prop",
  "type": "pipe",
  "source": {
    "type": "embedded",
    "entities": [{
      "_id": "foo",
      "bar": [{
        "id": "AAA",
        "priority": 10
      }, {
        "id": "AAB",
        "priority": 5
      }]
    }]
  },
  "transform": {
    "type": "dtl",
    "rules": {
      "default": [
        ["copy", "_id"],
        ["add", "foo",
          ["path", "id",
            ["max", "_.priority", "_S.bar"]
          ]
        ]
      ]
    }
  }
}
</code>```

The result will be:

```<code>[
  {
    "_id": "foo",
    "foo": "AAA"
  }
]
</code>```

Body:
I'm running hops against a dataset in sesam and my output is as the example below, my problem is that need a join where i only end up with the property with the highest priority.

[{
    "id": "AAA",
    "priority": 10
  }, {
    "id": "AAB",
    "priority": 7
  }]

Body:
You can also solve this with the "max" function:

{
  "_id": "sort-by-prop",
  "type": "pipe",
  "source": {
    "type": "embedded",
    "entities": [{
      "_id": "foo",
      "bar": [{
        "id": "AAA",
        "priority": 10
      }, {
        "id": "AAB",
        "priority": 5
      }]
    }]
  },
  "transform": {
    "type": "dtl",
    "rules": {
      "default": [
        ["copy", "_id"],
        ["add", "foo",
          ["path", "id",
            ["max", "_.priority", "_S.bar"]
          ]
        ]
      ]
    }
  }
}

The result will be:

[
  {
    "_id": "foo",
    "foo": "AAA"
  }
]


问:
Grey Shadow on Wordpress menu
Good morning everyone!

I'm creating a website using a Wordpress theme and my Menus have a grey shadow that I cannot remove.
Grey shadow on menu

The same issue happens when I place the mouse in the other "categories".

I already looked into google and tried to change the custom CSS to the following:

```<code>    #menu-barra-superior.nav.navbar-nav {
       background-color: #B40404;
       text-shadow: none !important;
    }

    .navbar-default .navbar-nav > li > a {
       color: #FFBF00;
       text-shadow: none !important;
    }

    .dropdown-menu > li > a {
       color: #FFBF00;
       text-shadow: none !important;
    }

    .navbar-default .navbar-nav > .active > a {
       color: #FFBF00;
       text-shadow: none !important;
    }
</code>```

(I added the text-shadow: none !important), but this doesn't seem to work.

Could anyone help me? Thanks in advance!

答:
Try:

```<code>box-shadow: none;
</code>```

Instead of text-shadow

```<code>menu-barra-superior.nav.navbar-nav {
  background-color: #B40404;
  box-shadow: none !important;
}

.navbar-default .navbar-nav > li > a {
  color: #FFBF00;
  box-shadow: none !important;
}

.dropdown-menu > li > a {
  color: #FFBF00;
  box-shadow: none !important;

}

.navbar-default .navbar-nav > .active > a {
  color: #FFBF00;
  box-shadow: none !important;

}
</code>```

Title: Grey Shadow on Wordpress menu

Body:
Good morning everyone!

I'm creating a website using a Wordpress theme and my Menus have a grey shadow that I cannot remove.
Grey shadow on menu

The same issue happens when I place the mouse in the other "categories".

I already looked into google and tried to change the custom CSS to the following:

    #menu-barra-superior.nav.navbar-nav {
       background-color: #B40404;
       text-shadow: none !important;
    }

    .navbar-default .navbar-nav > li > a {
       color: #FFBF00;
       text-shadow: none !important;
    }

    .dropdown-menu > li > a {
       color: #FFBF00;
       text-shadow: none !important;
    }

    .navbar-default .navbar-nav > .active > a {
       color: #FFBF00;
       text-shadow: none !important;
    }

(I added the text-shadow: none !important), but this doesn't seem to work.

Could anyone help me? Thanks in advance!

Body:
Try:

box-shadow: none;

Instead of text-shadow

menu-barra-superior.nav.navbar-nav {
  background-color: #B40404;
  box-shadow: none !important;
}

.navbar-default .navbar-nav > li > a {
  color: #FFBF00;
  box-shadow: none !important;
}

.dropdown-menu > li > a {
  color: #FFBF00;
  box-shadow: none !important;

}

.navbar-default .navbar-nav > .active > a {
  color: #FFBF00;
  box-shadow: none !important;

}


问:
ora-01841 full year must be between 4713 and 9999 and not be 0
I have been working on a query that is making me go crazy because I couldn't seem to understand the error message: my query is:

```<code>SELECT  MYTABLE." ID ",

  NVL(max(TO_DATE(TO_CHAR(ADD_MONTHS(MYTABLE." XISSU_DT " ,MYTABLE." XTNR "), 'DD/MM/YYYY'),'DD/MM/YYYY')),  TO_DATE(SYSDATE , 'DD/MM/YYYY') )  MAXLASTINSDATE,

   TO_DATE(SYSDATE , 'DD/MM/YYYY'),

      (TO_CHAR (TO_DATE(SYSDATE , 'DD/MM/YYYY')
           - TO_DATE(NVL(max(TO_DATE(TO_CHAR(ADD_MONTHS(MYTABLE." XISSU_DT " ,MYTABLE." XTNR "), 'DD/MM/YYYY'),'DD/MM/YYYY')),  TO_DATE(SYSDATE , 'DD/MM/YYYY') ) , 'DD/MM/YYYY')) * -1) MaturityPeriod

     FROM MYTABLE
where
MYTABLE." STATUS " = 'A'
group by MYTABLE." ID "
</code>```

the Error I have been getting is:

```<code>ora-01841 full year must be between 4713 and 9999 and not be 0
</code>```

Your help is really appreciated!

答:
TO_DATE(TO_CHAR(datevalue, 'DD/MM/YYYY'),'DD/MM/YYYY') is removing any time component which is effectively the same as: TRUNC( datevalue ).

Then TO_DATE(SYSDATE , 'DD/MM/YYYY') is probably where your error lies as TO_DATE( stringvalue, format_model ) takes a string as the first argument so you are effectively doing:

```<code>TO_DATE(
  TO_CHAR(
    SYSDATE,
    ( SELECT value FROM NLS_SESSION_PARAMETERS WHERE parameter = 'NLS_DATE_FORMAT' )
  ),
  'DD/MM/YYYY'
)
</code>```

It doesn't make sense as SYSDATE is already of the DATE data type so you don't need to use TO_DATE with it.

Finally, TO_CHAR(SYSDATE - datevalue)*-1 Why are you converting it to a string then multiplying it by a number when you can just do:

```<code>(SYSDATE - datevalue)*-1
</code>```

But you don't even need the *-1 as you can just swap the terms around:

```<code>(datevalue - SYSDATE)
</code>```

Tidying it all up you want something like:

```<code>SELECT  MYTABLE." ID ",
        NVL(
          MAX( TRUNC( ADD_MONTHS(MYTABLE." XISSU_DT " ,MYTABLE." XTNR ") ) ),
          SYSDATE
        ) MAXLASTINSDATE,
        SYSDATE,
        ( NVL(
            MAX( TRUNC( ADD_MONTHS(MYTABLE." XISSU_DT " ,MYTABLE." XTNR ") ) ),
            SYSDATE
          )
          - SYSDATE
        ) AS MaturityPeriod
FROM   MYTABLE
where  MYTABLE." STATUS " = 'A'
group by MYTABLE." ID "
</code>```

Body:
I have been working on a query that is making me go crazy because I couldn't seem to understand the error message: my query is:

SELECT  MYTABLE." ID ",

  NVL(max(TO_DATE(TO_CHAR(ADD_MONTHS(MYTABLE." XISSU_DT " ,MYTABLE." XTNR "), 'DD/MM/YYYY'),'DD/MM/YYYY')),  TO_DATE(SYSDATE , 'DD/MM/YYYY') )  MAXLASTINSDATE,

   TO_DATE(SYSDATE , 'DD/MM/YYYY'),

      (TO_CHAR (TO_DATE(SYSDATE , 'DD/MM/YYYY')
           - TO_DATE(NVL(max(TO_DATE(TO_CHAR(ADD_MONTHS(MYTABLE." XISSU_DT " ,MYTABLE." XTNR "), 'DD/MM/YYYY'),'DD/MM/YYYY')),  TO_DATE(SYSDATE , 'DD/MM/YYYY') ) , 'DD/MM/YYYY')) * -1) MaturityPeriod

     FROM MYTABLE
where
MYTABLE." STATUS " = 'A'
group by MYTABLE." ID "

the Error I have been getting is:

ora-01841 full year must be between 4713 and 9999 and not be 0

Your help is really appreciated!

Body:
TO_DATE(TO_CHAR(datevalue, 'DD/MM/YYYY'),'DD/MM/YYYY') is removing any time component which is effectively the same as: TRUNC( datevalue ).

Then TO_DATE(SYSDATE , 'DD/MM/YYYY') is probably where your error lies as TO_DATE( stringvalue, format_model ) takes a string as the first argument so you are effectively doing:

TO_DATE(
  TO_CHAR(
    SYSDATE,
    ( SELECT value FROM NLS_SESSION_PARAMETERS WHERE parameter = 'NLS_DATE_FORMAT' )
  ),
  'DD/MM/YYYY'
)

It doesn't make sense as SYSDATE is already of the DATE data type so you don't need to use TO_DATE with it.

Finally, TO_CHAR(SYSDATE - datevalue)*-1 Why are you converting it to a string then multiplying it by a number when you can just do:

(SYSDATE - datevalue)*-1

But you don't even need the *-1 as you can just swap the terms around:

(datevalue - SYSDATE)

Tidying it all up you want something like:

SELECT  MYTABLE." ID ",
        NVL(
          MAX( TRUNC( ADD_MONTHS(MYTABLE." XISSU_DT " ,MYTABLE." XTNR ") ) ),
          SYSDATE
        ) MAXLASTINSDATE,
        SYSDATE,
        ( NVL(
            MAX( TRUNC( ADD_MONTHS(MYTABLE." XISSU_DT " ,MYTABLE." XTNR ") ) ),
            SYSDATE
          )
          - SYSDATE
        ) AS MaturityPeriod
FROM   MYTABLE
where  MYTABLE." STATUS " = 'A'
group by MYTABLE." ID "