问:
xpath getting data from iframe domXPath php
I am playing around scraping website technique, For ex link, Its always returning empty for description.
The reason is its populated by JS with the following code, How do we go about with these kinds of senarios.

```<code>// Frontend JS
P.when('DynamicIframe').execute(function(DynamicIframe){
    var BookDescriptionIframe = null,
        bookDescEncodedData = "book desc data",
        bookDescriptionAvailableHeight,
        minBookDescriptionInitialHeight = 112,
        options = {},
        iframeId = "bookDesc_iframe";
</code>```

I am using php domxpath as below

```<code>    $file = 'sample.html';
    $dom = new DOMDocument();
    $dom->preserveWhiteSpace = false;
    // I am saving the returned html to a file and reading the file.
    @$dom->loadHTMLFile($file);
    $xpath = new DOMXPath($dom);

    // This xpath works on chrome console, but not here
    // because the content is dynamically created via js
    $desc  = $xpath->query('//*[@id="bookDesc_iframe"]')

</code>```

答:
Everytime when you see these kinds of JavaScript Generated content and especially from big guys like amazon, google, you should immediately think that it would have a graceful degradation implementation.

Meaning it would be done for where Javascript doesn't work like links browser for better browser coverage.

Lookout for  you may find one. and with that you can solve the problem.

Body:
I am playing around scraping website technique, For ex link, Its always returning empty for description.
The reason is its populated by JS with the following code, How do we go about with these kinds of senarios.

// Frontend JS
P.when('DynamicIframe').execute(function(DynamicIframe){
    var BookDescriptionIframe = null,
        bookDescEncodedData = "book desc data",
        bookDescriptionAvailableHeight,
        minBookDescriptionInitialHeight = 112,
        options = {},
        iframeId = "bookDesc_iframe";

I am using php domxpath as below

    $file = 'sample.html';
    $dom = new DOMDocument();
    $dom->preserveWhiteSpace = false;
    // I am saving the returned html to a file and reading the file.
    @$dom->loadHTMLFile($file);
    $xpath = new DOMXPath($dom);

    // This xpath works on chrome console, but not here
    // because the content is dynamically created via js
    $desc  = $xpath->query('//*[@id="bookDesc_iframe"]')

Body:
Everytime when you see these kinds of JavaScript Generated content and especially from big guys like amazon, google, you should immediately think that it would have a graceful degradation implementation.

Meaning it would be done for where Javascript doesn't work like links browser for better browser coverage.

Lookout for <noscript> you may find one. and with that you can solve the problem.


来源: stackexchange

问:
Accessing Java hashmap to get subclass
I am intializing one hashmap which contains key and subclass object.

```<code>@Provides
@Singleton
public Map<Locale, XlsxParserBase> getXlsxParserMap() {
    Map<Locale, XlsxParserBase> xlsxParserMap = Maps.newHashMap();
    xlsxParserMap.put(Locale.US, new com.us.XlsxParser());
    xlsxParserMap.put(Locale.EU, new com.eu.XlsxParser());
    return xlsxParserMap;
}
</code>```

This map gets intialized when the server starts. Now I have a manager class which has the locale. I just want to do

```<code>xlsxParserMap.get(locale).parse();
</code>```

where each subclass has parse implementation and uses common methods from base. When I do this, i am unable to access parse beacause parse method is not present in superclass. Since, map is of type (Locale, XlsxParserBase), I am unable to access child methods from XlsxParserBase reference.

Is there a simpler way to achieve this? I do not want to put instanceOf in manager class. To avoid that, i thought of this map approach. Do experts have some better approach for my problem? Let me know if I am unclear or you need more snippets.

答:
There are some possibilities:

add a parse() method to your XlsxParserBase and make the concrete classes implement/override it in their parse() method.

go with reflection. Retrieve the parse method from the XlsxParserBase class in the map an call this. Method method = obj.getClass().getMethod("parse");  method.invoke(obj);.

create a wrapper (e.g. XlsxParserWrapper) class which contains a parse() method. This method in concretete implementations (e.g. XlsxParserWrapperUS) calls the underlying concrete implementation (e.g. com.us.XlsxParser().parse()).

hassle with instanceof

ContentLicense: CC BY-SA 4.0

Title: Accessing Java hashmap to get subclass

Body:
I am intializing one hashmap which contains key and subclass object.

@Provides
@Singleton
public Map<Locale, XlsxParserBase> getXlsxParserMap() {
    Map<Locale, XlsxParserBase> xlsxParserMap = Maps.newHashMap();
    xlsxParserMap.put(Locale.US, new com.us.XlsxParser());
    xlsxParserMap.put(Locale.EU, new com.eu.XlsxParser());
    return xlsxParserMap;
}

This map gets intialized when the server starts. Now I have a manager class which has the locale. I just want to do

xlsxParserMap.get(locale).parse();

where each subclass has parse implementation and uses common methods from base. When I do this, i am unable to access parse beacause parse method is not present in superclass. Since, map is of type (Locale, XlsxParserBase), I am unable to access child methods from XlsxParserBase reference.

Is there a simpler way to achieve this? I do not want to put instanceOf in manager class. To avoid that, i thought of this map approach. Do experts have some better approach for my problem? Let me know if I am unclear or you need more snippets.


问:
What's an Elmer Cipher
What's an Elmer Cipher? Where can I find a reference on this cipher algorithm?</p>

答: I'm going to guess that it was supposed to be El Gamal. It fits the rest of your description (i.e., it's an asymmetric/public-key cipher).</p>

ContentLicense: CC BY-SA 3.0

Title: What's an Elmer Cipher


问:
How to write multiple queries in one query based on condition in SQL Server?
```<code>SELECT
    [LNMAJORTP], [MainType],
    SUM(x + y - z) [x]
FROM
    [my_table]
WHERE
    state LIKE '%firstCondition%'
GROUP BY
    [LNMAJORTP], [MainType]

SELECT
    [LNMAJORTP], [MainType],
    SUM(x + y - z) [y]
FROM
    [my_table]
WHERE
    state LIKE '%secondCondition%'
GROUP BY
    [LNMAJORTP], [MainType]

SELECT
    [LNMAJORTP], [MainType],
    SUM(x + y - z) [z]
FROM
    [my_table]
WHERE
    state LIKE '%thirdCondition%'
GROUP BY
    [LNMAJORTP], [MainType]
</code>```

How I can change this queries to one query?

答:
If you want to sum your expressions and get results in three different columns ([x], [y] and [z]), use next approach.

```<code>SELECT
    [LNMAJORTP],
    [MainType],
    SUM(CASE WHEN state LIKE '%firstCondition%' THEN x+y-z END) AS [x],
    SUM(CASE WHEN state LIKE '%secondCondition%' THEN x+y-z END) AS [y],
    SUM(CASE WHEN state LIKE '%thirdCondition%' THEN x+y-z END) AS [z]
FROM [my_table]
GROUP BY [LNMAJORTP], [MainType]
</code>```

If you want to sum just one expression (x+y-z in your example), simple OR in WHERE clause should work. The result of the expression will be in one column:

```<code>SELECT
    [LNMAJORTP],
    [MainType],
    SUM(x+y-z) AS [x_y_z]
FROM [my_table]
WHERE state LIKE '%firstCondition%' OR state LIKE '%secondCondition%' OR state LIKE '%thirdCondition%'
GROUP BY [LNMAJORTP], [MainType]
</code>```

Body:
SELECT
    [LNMAJORTP], [MainType],
    SUM(x + y - z) [x]
FROM
    [my_table]
WHERE
    state LIKE '%firstCondition%'
GROUP BY
    [LNMAJORTP], [MainType]

SELECT
    [LNMAJORTP], [MainType],
    SUM(x + y - z) [y]
FROM
    [my_table]
WHERE
    state LIKE '%secondCondition%'
GROUP BY
    [LNMAJORTP], [MainType]

SELECT
    [LNMAJORTP], [MainType],
    SUM(x + y - z) [z]
FROM
    [my_table]
WHERE
    state LIKE '%thirdCondition%'
GROUP BY
    [LNMAJORTP], [MainType]

How I can change this queries to one query?

Body:
If you want to sum your expressions and get results in three different columns ([x], [y] and [z]), use next approach.

SELECT
    [LNMAJORTP],
    [MainType],
    SUM(CASE WHEN state LIKE '%firstCondition%' THEN x+y-z END) AS [x],
    SUM(CASE WHEN state LIKE '%secondCondition%' THEN x+y-z END) AS [y],
    SUM(CASE WHEN state LIKE '%thirdCondition%' THEN x+y-z END) AS [z]
FROM [my_table]
GROUP BY [LNMAJORTP], [MainType]

If you want to sum just one expression (x+y-z in your example), simple OR in WHERE clause should work. The result of the expression will be in one column:

SELECT
    [LNMAJORTP],
    [MainType],
    SUM(x+y-z) AS [x_y_z]
FROM [my_table]
WHERE state LIKE '%firstCondition%' OR state LIKE '%secondCondition%' OR state LIKE '%thirdCondition%'
GROUP BY [LNMAJORTP], [MainType]


问:
how to insert object to Specific index in object array using javascript
I want to insert object Specific index.

I research push and splice but I couldn't find a solution.

```<code>var collection = [ {id:"123"} ,{id:"567"}, {id:"999"} ]
</code>```

The result I'm looking forward to is

result :

```<code>[ {id:"123"} ,{id:"567"}, {id:"1111"}, {id:"999"} ]
</code>```

答:
Use splice:

var collection = [{id:"123"} ,{id:"567"}, {id:"999"}];
collection.splice(2, 0, { id: "1111" });
console.log(collection);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper { max-height: 100% !important; top: auto; }</code>```

Body:
I want to insert object Specific index.

I research push and splice but I couldn't find a solution.

var collection = [ {id:"123"} ,{id:"567"}, {id:"999"} ]

The result I'm looking forward to is

result :

[ {id:"123"} ,{id:"567"}, {id:"1111"}, {id:"999"} ]

Body:
Use splice:

var collection = [{id:"123"} ,{id:"567"}, {id:"999"}];
collection.splice(2, 0, { id: "1111" });
console.log(collection);

.as-console-wrapper { max-height: 100% !important; top: auto; }


问:
Invoke AWS Lambda function only once, at a single specified future time
I want to be able to set a time to invoke an AWS Lambda function, then have that function be invoked then and only then. For example, I want my Lambda function to run at 9:00pm on December 19th, 2017. I don't want it to repeat, I don't want it to invoke now, just at 9:00pm on the 19th.

I understand that CloudWatch provides Scheduled Events, and  I was thinking that when a time to schedule this reminder for is inputted,  a CloudWatch Scheduled Events is created to fire in that amount of time from now (so like if you schedule it at 8:22pm to run at 9pm, it’ll be 38 mins), then it invokes the Lambda function at 9pm which then deletes the CloudWatch Scheduled Event. My issue with this is that when a CloudWatch Scheduled Event is created, it executes right then, then at the specified interval.

Any other ideas would be appreciated, as I can't think of another solution. Thanks in advance!

答:
You can use DynamoDB TTL feature to implement this easily, simply do the following:

1- Put item with TTL, the exact time you want to execute or invoke a lambda function.

2- Configure DynamoDB Streams to trigger a lambda function on item's remove event.

Once the item/record is about to expire, your lambda will be invoked. you don't have to delete or cleanup anything as the item in dynamodb is already gone.

NOTE: However the approach is easy to implement and scales very well, but there's one precaution to mention; using DynamoDB TTL as a scheduling mechanism cannot guarantee exact time precision as there might be a delay. The scheduled tasks are executed couple of minutes behind.


问:
SVG as a CSS Background - Is there ANY way to repeat-x with NO space in between?
In Webkit and Blink-based browsers, SVGs do not tile correctly. There is a space between the images at various zoom levels. There are a number of topics on StackOverflow addressing this, all marked as solved, but those people must not have tested their solutions thoroughly enough.

My SVGs are a perfectly even number of pixels (130 x 24).
They have background-size set to 130px 24px.
They are set to preserveAspectRatio="none".
There is absolutely zero empty space on the edges of the SVG.

Yet, while it looks fine at 100%, there is still a thin space between the SVGs if you zoom in to the right level.

It surprises me this bug has not been reported before, given the widespread recommendations of using SVGs for backgrounds.

Here is the exact SVG:

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
      viewBox="0 0 130 24" xml:space="preserve" preserveAspectRatio="none">

    <path class="st0" d="M0,12c32.5,0,32.5,12,65,12s32.5-12,65-12V0C97.5,0,92.9,12,65,12C32.5,12,20.7,0,0,0"/>
    </svg>```

I can confirm this behavior with other SVGs as well, such as the ones at https://www.heropatterns.com/

Codepen for testing: https://codepen.io/TelFiRE/pen/gJzqaG

The space between the images is usually sub 1 pixel (meaning the line is just a lighter shade of green). It's subtle and may be hard to see if you have a dull monitor.

In asking this question, I'm hoping to understand WHY it is occurring in a way that lets me make lots of repeating SVG backgrounds without issue. It's not just about the one image, so I want to avoid hacky solutions/workarounds if at all possible. For example, chopping 2 pixels off the edge fixes it 99% of the way, but not entirely, and it leaves me wondering what I would do if I actually needed those two pixels. This particular SVG looks okay like that but more complicated patterns would be knocked out of alignment.

答:
This is your svg used as a css background and there are no gaps. I've encoded the svg using this tool

Also please read Optimizing SVGs in data URIs

body{background-image: url("data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 130 24' xml:space='preserve' preserveAspectRatio='none'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%23A5EF8B;%7D %3C/style%3E%3Cpath class='st0' d='M0,12c32.5,0,32.5,12,65,12s32.5-12,65-12V0C97.5,0,92.9,12,65,12C32.5,12,20.7,0,0,0'/%3E%3C/svg%3E%0A");
background-size:130px 24px}```
</div>
</div>
</p>
<h3>UPDATE</h3>
<p>Apparently in Safari there is a gap between the repetitions of the svg background image. In the next example I'm setting the <code>background-size:12vw</code> (or any other multiple of vw) the gaps disappear.</p>
<p>In fact I've simplified the path as well.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{
  background-image: url("data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 6 130 26' width='100%' height='100%'%3E%3Cstyle type='text/css'%3E .st0%7Bstroke:%23A5EF8B; fill:none; stroke-width:12;%7D %3C/style%3E%3Cpath class='st0' d='M-1,12c32.5,0,32.5,12,65,12s32.5-12,69-12'/%3E%3C/svg%3E%0A");
background-size:12vw}</code>```

Body:
In Webkit and Blink-based browsers, SVGs do not tile correctly. There is a space between the images at various zoom levels. There are a number of topics on StackOverflow addressing this, all marked as solved, but those people must not have tested their solutions thoroughly enough.

My SVGs are a perfectly even number of pixels (130 x 24).
They have background-size set to 130px 24px.
They are set to preserveAspectRatio="none".
There is absolutely zero empty space on the edges of the SVG.

Yet, while it looks fine at 100%, there is still a thin space between the SVGs if you zoom in to the right level.

It surprises me this bug has not been reported before, given the widespread recommendations of using SVGs for backgrounds.

Here is the exact SVG:

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
      viewBox="0 0 130 24" xml:space="preserve" preserveAspectRatio="none">

    <path class="st0" d="M0,12c32.5,0,32.5,12,65,12s32.5-12,65-12V0C97.5,0,92.9,12,65,12C32.5,12,20.7,0,0,0"/>
    </svg>

I can confirm this behavior with other SVGs as well, such as the ones at https://www.heropatterns.com/

Codepen for testing: https://codepen.io/TelFiRE/pen/gJzqaG

The space between the images is usually sub 1 pixel (meaning the line is just a lighter shade of green). It's subtle and may be hard to see if you have a dull monitor.

In asking this question, I'm hoping to understand WHY it is occurring in a way that lets me make lots of repeating SVG backgrounds without issue. It's not just about the one image, so I want to avoid hacky solutions/workarounds if at all possible. For example, chopping 2 pixels off the edge fixes it 99% of the way, but not entirely, and it leaves me wondering what I would do if I actually needed those two pixels. This particular SVG looks okay like that but more complicated patterns would be knocked out of alignment.

Body:
This is your svg used as a css background and there are no gaps. I've encoded the svg using this tool

Also please read Optimizing SVGs in data URIs

body{background-image: url("data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 130 24' xml:space='preserve' preserveAspectRatio='none'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%23A5EF8B;%7D %3C/style%3E%3Cpath class='st0' d='M0,12c32.5,0,32.5,12,65,12s32.5-12,65-12V0C97.5,0,92.9,12,65,12C32.5,12,20.7,0,0,0'/%3E%3C/svg%3E%0A");
background-size:130px 24px}

UPDATE

Apparently in Safari there is a gap between the repetitions of the svg background image. In the next example I'm setting the background-size:12vw (or any other multiple of vw) the gaps disappear.

In fact I've simplified the path as well.

body{
  background-image: url("data:image/svg+xml,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 6 130 26' width='100%' height='100%'%3E%3Cstyle type='text/css'%3E .st0%7Bstroke:%23A5EF8B; fill:none; stroke-width:12;%7D %3C/style%3E%3Cpath class='st0' d='M-1,12c32.5,0,32.5,12,65,12s32.5-12,69-12'/%3E%3C/svg%3E%0A");
background-size:12vw}


问:
Trim only the first and last occurrence of a character in a string (PHP)
This is something I could hack together, but I wondered if anybody had a clean solution to my problem. Something that I throw together wont necessarily be very concise or speedy!

I have a string like this ///hello/world///. I need to strip only the first and last slash, none of the others, so that I get a string like this //hello/world//.

PHP's trim isn't quite right right: performing trim($string, '/') will return hello/world.

One thing to note is that the string won't necessarily have any slashes at the beginning or end. Here are a few examples of what I would like to happen to different strings:

```<code>///hello/world/// > //hello/world//
/hello/world/// > hello/world//
hello/world/ > hello/world
</code>```

Thanks in advance for any help!

答:
This function acts as the official trim, except that it only trims once.</p>

```<code>function trim_once($text, $c) {
    $c = preg_quote($c);
    return preg_replace("#^([$c])?(.*?)([$c])?$#", '$2', $text);
}
</code>```

```<code>php > echo trim_once("||1|2|3|*", "*|");
|1|2|3|
php > echo trim_once("//|1|2|3/", "/");
/|1|2|3
</code>```

ContentLicense: CC BY-SA 2.5

Body:
This is something I could hack together, but I wondered if anybody had a clean solution to my problem. Something that I throw together wont necessarily be very concise or speedy!

I have a string like this ///hello/world///. I need to strip only the first and last slash, none of the others, so that I get a string like this //hello/world//.

PHP's trim isn't quite right right: performing trim($string, '/') will return hello/world.

One thing to note is that the string won't necessarily have any slashes at the beginning or end. Here are a few examples of what I would like to happen to different strings:

///hello/world/// > //hello/world//
/hello/world/// > hello/world//
hello/world/ > hello/world

Thanks in advance for any help!

Body:
This function acts as the official trim, except that it only trims once.

function trim_once($text, $c) {
    $c = preg_quote($c);
    return preg_replace("#^([$c])?(.*?)([$c])?$#", '$2', $text);
}

php > echo trim_once("||1|2|3|*", "*|");
|1|2|3|
php > echo trim_once("//|1|2|3/", "/");
/|1|2|3


问:
how to add scroll button on list view?
i have seen one think in android list view there is one small button on right side to scrolling list. like astro provide a right side button to scrolling a list and it visible while scrolling the list and invisible when it ideal.

I dont have idea to how to done this. but i m thinking there is only one property to enable this.

Please provide ans if anybody use that.

Thanks In Advance!

答:
You can set one property in listview that is fastScrollEnabled="true" ..

But right side button is visible only when you have more than 10(appx) number of data in the listview it can not see when you have 5-6 records..

```<code>android:fastScrollEnabled="true"
</code>```

Title: how to add scroll button on list view?

Body:
You can set one property in listview that is fastScrollEnabled="true" ..

But right side button is visible only when you have more than 10(appx) number of data in the listview it can not see when you have 5-6 records..

android:fastScrollEnabled="true"


问:
Unable to use any user in laravel project other than the root
I am a beginner developing an app in Laravel framework. I am facing a problem that only the root user works with my database without the password or the user ''@'host' works. However, when I deploy the app to the server I can not use any of these users

I get the following error, it seems that the Laravel is not reading any user name from .env or database.php file. (as the name of the user is blank here).

SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'itax'

Again it works if I use the user=root and no password or user=''

Here are the configurations of my .env file

```<code>DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=itax
DB_USERNAME=raees
DB_PASSWORD=12345
</code>```

and database.php file

```<code>'mysql' => [
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'itax',
        'username'  => 'raees',
        'password'  => '',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ],
</code>```

Anyone facing the same issue or found any solutions to these problems please share

答:
Found solution with empty username. The username was always blank.

The issue was with MySQL. The SQLSTATE error message is being passed directly from MySQL.

So then I deleted the database and user. Re-created the database in the Databases tab of PhpMyAdmin. And importantly separately added the user and privileges. This fixed the issue.

I could connect from the MySQL client and run migrations.

Body:
I am a beginner developing an app in Laravel framework. I am facing a problem that only the root user works with my database without the password or the user ''@'host' works. However, when I deploy the app to the server I can not use any of these users

I get the following error, it seems that the Laravel is not reading any user name from .env or database.php file. (as the name of the user is blank here).

SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'itax'

Again it works if I use the user=root and no password or user=''

Here are the configurations of my .env file

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=itax
DB_USERNAME=raees
DB_PASSWORD=12345

and database.php file

'mysql' => [
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'itax',
        'username'  => 'raees',
        'password'  => '',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ],

Anyone facing the same issue or found any solutions to these problems please share


答:
You can use splice method of Array
collection.splice(index, value, numberOfElWillBeRemoved, numberOfElWillBeAdded)
For more detail: https://www.w3schools.com/jsref/jsref_splice.asp</p>

Title: how to insert object to Specific index in object array using javascript


答:
You can loop trow array:

```<code>var collection = [{ id: "123" }, { id: "567" }, { id: "999" }];

for(var i = 0; i < collection.length; i++) {
    console.log(collection[i]);
}
</code>```

And change the array length

```<code>collection.length = 4
</code>```

Then replace location of any string.
Just make new same array and replace the var

```<code>var newArray = collection;
collection[3] = newArray[2];
</code>```

Now 2 index is free.

Body:
You can loop trow array:

var collection = [{ id: "123" }, { id: "567" }, { id: "999" }];

for(var i = 0; i < collection.length; i++) {
    console.log(collection[i]);
}

And change the array length

collection.length = 4

Then replace location of any string.
Just make new same array and replace the var

var newArray = collection;
collection[3] = newArray[2];

Now 2 index is free.


问:
Invalid syntax on colon
I'm writing up a program involving speed limit and whatnot with while and if statements. I'm tryna make it so that after outputting the result, it asks if I want to redo the program with a while loop.

I heard that occurs if I have one too many brackets or an open bracket. All my brackets were fine.

ques1 = int(input('What speed is the car travelling? '))
check = ques1

running = True
while running == True:
    if 0 <= check <= 50:
        print('You are clear.')

    if 51 <= check <= 60:
        print('10 demerit points')

    if 61 <= check <= 70:
        print('20 demerit points')

    if 71 <= check <= 80:
        print('30 demerit points')

    if 81 <= check <= 90:
        print('50 demerit points')

    if 91 <= check <= 1000:
        print("100 demerit points")

    dasques = input('Do you want to try again? y/n '):
        if dasques == ('n'):
            running = False

```

<p><strong>Expected output:</strong></p>

```Hoping to get :
50 demerit points
Do you want to try again? y/n
```

but I'm getting

"invalid syntax" with the colon behind:
       [ dasques = input('Do you want to try again? y/n '):]

highlighted in red.

答:
Try this,</p>

```<code>dasques = input('Do you want to try again? : y/n  ') # you can keep ':' inside the string
if dasques == ('n'):
    running = False
</code>```

Title: Invalid syntax on colon

Body:
I'm writing up a program involving speed limit and whatnot with while and if statements. I'm tryna make it so that after outputting the result, it asks if I want to redo the program with a while loop.

I heard that occurs if I have one too many brackets or an open bracket. All my brackets were fine.

ques1 = int(input('What speed is the car travelling? '))
check = ques1

running = True
while running == True:
    if 0 <= check <= 50:
        print('You are clear.')

    if 51 <= check <= 60:
        print('10 demerit points')

    if 61 <= check <= 70:
        print('20 demerit points')

    if 71 <= check <= 80:
        print('30 demerit points')

    if 81 <= check <= 90:
        print('50 demerit points')

    if 91 <= check <= 1000:
        print("100 demerit points")

    dasques = input('Do you want to try again? y/n '):
        if dasques == ('n'):
            running = False

Expected output:

Hoping to get :
50 demerit points
Do you want to try again? y/n

but I'm getting

"invalid syntax" with the colon behind:
       [ dasques = input('Do you want to try again? y/n '):]

highlighted in red.

Body:
Try this,

dasques = input('Do you want to try again? : y/n  ') # you can keep ':' inside the string
if dasques == ('n'):
    running = False


问:
css submenu not appearing
CSS submenu no longer appearing

This was working and I did something to it, I dont know if it is a code problem or a css problem. Forgive me if the post is not formatted correctly,
this is my first time posting at Stackoverflow.

html

```<code>    <nav class='navClass'>
          <ul>
             <li>Home</li>
             <li>Things To Do</li>
               <ul class="sub-menu">
                  <li>Shopping</li>
                  <li>Attractions</li>
                  <li>Outdoor Fun</li>
               </ul>
               </li>
             <li>Places To Stay</li>
             <li>Where to Eat</li>
             <li>Contests</li>
             <li>History</li>
             <li>Events</li>
          </ul>
    </nav>

</code>```

css

```<code>    .navClass > ul{
    background-color: #e56109;
    color:#ffffff;
    margin-top: 0px;
    font-size: 20px;
    font-family: Arial;
}

.navClass > ul li{
    list-style-type: none;
    display: inline-block;
    padding-top: 10px;
    padding-bottom: 10px;
    padding-left: 25px;
    padding-right: 25px;
    position: relative;

}

.navClass > ul li:hover{
    background-color: #212121;
    position: relative;

}

ul.sub-menu{
    position: absolute;
    background-color: #e56109;
    list-style-type: none;
    width: 200px;
    margin-left: -25px;
    padding-bottom: 0px;
    margin-top: 10px;
    opacity: 0;

}

ul.sub-menu li{
    padding-left: 25px;
    padding-top: 5px;
    font-size: 15px;

}

ul.sub-menu li:hover{
    color: #ffffff;
    display: block;

}

.navClass li:hover .sub-menu{
    opacity: 1;

}

</code>```

The sub-menu items need to drop down from the parent item. In this case, the "Things to Do" item.

答:
 .navClass > ul{
    background-color: #e56109;
    color:#ffffff;
    margin-top: 0px;
    font-size: 20px;
    font-family: Arial;
}
.dropdown {
  position: relative;
  display: inline-block;
}
.sub-menu {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  padding: 12px 16px;
  z-index: 1;
}
.dropdown:hover .sub-menu {
  display: block;
  background-color: #000000;
      cursor: pointer;
}

.navClass > ul li:hover{
    background-color: #212121;
    position: relative;

}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><nav class='navClass'>
          <ul class='t'>
             <li class='b'>Home</li>
             <span class="dropdown">
             <li>Things To Do</li>
             <span>
               <ul class="sub-menu">
                  <li>Shopping</li>
                  <li>Attractions</li>
                  <li>Outdoor Fun</li>
              </ul>
             <li>Places To Stay</li>
             <li>Where to Eat</li>
             <li>Contests</li>
             <li>History</li>
             <li>Events</li>
          </ul>
    </nav></code>```

Title: css submenu not appearing

Body:
CSS submenu no longer appearing

This was working and I did something to it, I dont know if it is a code problem or a css problem. Forgive me if the post is not formatted correctly,
this is my first time posting at Stackoverflow.

html

Home

Things To Do

Shopping

Attractions

Outdoor Fun

Places To Stay

Where to Eat

Contests

History

Events

css

    .navClass > ul{
    background-color: #e56109;
    color:#ffffff;
    margin-top: 0px;
    font-size: 20px;
    font-family: Arial;
}

.navClass > ul li{
    list-style-type: none;
    display: inline-block;
    padding-top: 10px;
    padding-bottom: 10px;
    padding-left: 25px;
    padding-right: 25px;
    position: relative;

}

.navClass > ul li:hover{
    background-color: #212121;
    position: relative;

}

ul.sub-menu{
    position: absolute;
    background-color: #e56109;
    list-style-type: none;
    width: 200px;
    margin-left: -25px;
    padding-bottom: 0px;
    margin-top: 10px;
    opacity: 0;

}

ul.sub-menu li{
    padding-left: 25px;
    padding-top: 5px;
    font-size: 15px;

}

ul.sub-menu li:hover{
    color: #ffffff;
    display: block;

}

.navClass li:hover .sub-menu{
    opacity: 1;

}

The sub-menu items need to drop down from the parent item. In this case, the "Things to Do" item.

Body:
 .navClass > ul{
    background-color: #e56109;
    color:#ffffff;
    margin-top: 0px;
    font-size: 20px;
    font-family: Arial;
}
.dropdown {
  position: relative;
  display: inline-block;
}
.sub-menu {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  padding: 12px 16px;
  z-index: 1;
}
.dropdown:hover .sub-menu {
  display: block;
  background-color: #000000;
      cursor: pointer;
}

.navClass > ul li:hover{
    background-color: #212121;
    position: relative;

}

<nav class='navClass'>
          <ul class='t'>
             <li class='b'>Home</li>
             <span class="dropdown">
             <li>Things To Do</li>
             <span>
               <ul class="sub-menu">
                  <li>Shopping</li>
                  <li>Attractions</li>
                  <li>Outdoor Fun</li>
              </ul>
             <li>Places To Stay</li>
             <li>Where to Eat</li>
             <li>Contests</li>
             <li>History</li>
             <li>Events</li>
          </ul>
    </nav>


问:
Autofac Open Generic Decorator with multiple interface causes circular dependency resolving
I have the following interfaces :

```<code>public interface ICommandHandler<T>
{
    void Handle(T command);
}

public class TransactionalCommandHandlerDecorator<T> : ICommandHandler<T>
{
    private readonly ICommandHandler<T> _handler;
    public TransactionalCommandHandlerDecorator(ICommandHandler<T> handler)
    {
        _handler = handler;
    }
    public void Handle(T command)
    {
    }
}
</code>```

and I have a concrete class which implementing two command handlers :

```<code>public class Handler : ICommandHandler<CreateLocation>
                        ,ICommandHandler<ModifyLocation>
{
    public void Handle(CreateLocation command)
    {

    }

    public void Handle(ModifyLocation command)
    {
    }
}
</code>```

and I have a registration as following :

```<code> builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly())
            .AsClosedTypesOf(typeof(ICommandHandler<>))
            .InstancePerLifetimeScope();

    builder.RegisterGenericDecorator(typeof(TransactionalCommandHandlerDecorator<>), typeof(ICommandHandler<>));
</code>```

Resolving 'Handler' class causes autofac to circularly resolving decorater and handler in an infinite loop which causes a StackOverflowException. if I a change 'Handler' to implement only one interface, then it will works without problem.

any idea on how to fix that?

答:
This is a bug and will be addressed in a future release of Autofac. The fix looks like it will require a breaking change to another part of the API so will need to be released as part of v5.0.

In the meantime, one way to work around the issue is creating separate registrations.

var builder = new ContainerBuilder();
builder.RegisterType<Handler>().As<ICommandHandler<CreateLocation>>();
builder.RegisterType<Handler>().As<ICommandHandler<ModifyLocation>>();
builder.RegisterGenericDecorator(typeof(TransactionalCommandHandlerDecorator<>), typeof(ICommandHandler<>));
var container = builder.Build();

var instance = container.Resolve<ICommandHandler<CreateLocation>>();
```

Body:
I have the following interfaces :

public interface ICommandHandler<T>
{
    void Handle(T command);
}

public class TransactionalCommandHandlerDecorator<T> : ICommandHandler<T>
{
    private readonly ICommandHandler<T> _handler;
    public TransactionalCommandHandlerDecorator(ICommandHandler<T> handler)
    {
        _handler = handler;
    }
    public void Handle(T command)
    {
    }
}

and I have a concrete class which implementing two command handlers :

public class Handler : ICommandHandler<CreateLocation>
                        ,ICommandHandler<ModifyLocation>
{
    public void Handle(CreateLocation command)
    {

    }

    public void Handle(ModifyLocation command)
    {
    }
}

and I have a registration as following :

 builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly())
            .AsClosedTypesOf(typeof(ICommandHandler<>))
            .InstancePerLifetimeScope();

    builder.RegisterGenericDecorator(typeof(TransactionalCommandHandlerDecorator<>), typeof(ICommandHandler<>));

Resolving 'Handler' class causes autofac to circularly resolving decorater and handler in an infinite loop which causes a StackOverflowException. if I a change 'Handler' to implement only one interface, then it will works without problem.

any idea on how to fix that?


问:
Pandas map returning all values as NaNs
when mapping target variable, 'diabetes' (False patient has no diabetes, True patient has diabetes) to 0 (False) and 1 (True). All of entries come back as NaNs

I thought may be 'diabetes' isn't a true str and I need to convert to string first. Tried the following code:

```<code>diab_data['diabetes'] = diab_data['diabetes'].astype(str)

diab_data["diabetes"] = diab_data["diabetes"].map({'False':0, 'True':1})
</code>```

I need values below to be either 0 (False) or 1 (True). All values return as NaN

Original Output:

```<code>patient diabetes
0         False
1         True
2         True
3         True
4         False
</code>```

Output after mapping:

```<code>patient diabetes
0         NaN
1         NaN
2         NaN
3         NaN
4         NaN
</code>```

答:
You dont need map for this:

```<code>diab_data["diabetes"].astype(int)
</code>```

Also you are using the bool values as string , use True instead of 'True' for example under map():

```<code>df["diabetes"].map({False:0, True:1})
</code>```

Title: Pandas map returning all values as NaNs

Body:
when mapping target variable, 'diabetes' (False patient has no diabetes, True patient has diabetes) to 0 (False) and 1 (True). All of entries come back as NaNs

I thought may be 'diabetes' isn't a true str and I need to convert to string first. Tried the following code:

diab_data['diabetes'] = diab_data['diabetes'].astype(str)

diab_data["diabetes"] = diab_data["diabetes"].map({'False':0, 'True':1})

I need values below to be either 0 (False) or 1 (True). All values return as NaN

Original Output:

patient diabetes
0         False
1         True
2         True
3         True
4         False

Output after mapping:

patient diabetes
0         NaN
1         NaN
2         NaN
3         NaN
4         NaN

Body:
You dont need map for this:

diab_data["diabetes"].astype(int)

Also you are using the bool values as string , use True instead of 'True' for example under map():

df["diabetes"].map({False:0, True:1})


问:
What does the number following the argument represent?
I was wondering what the number following the argument stands for (In the error message; the number is 1).

I am updating PsychoPy, and it showed the error message. I have searched for a while, but I did not find any explanation about it.

```<code>def onCancel(self, event):
    self.app.updater = None
    self.Close()

def onFileBrowse(self, event):
    self.filename = event.GetString()

def onInstall(self, event):
    if self.currentSelection == self.useLatestBtn:
        info = self.doAutoInstall()
    else:
        info = self.installZipFile(self.filename)
    self.statusMessage.SetLabel(info)
    self.Fit()
</code>```

```<code>Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy3\lib\site-
packages\psychopy\app\connections\updates.py", line 404, in onInstall
    self.statusMessage.SetLabel(info)
TypeError: Control.SetLabel(): argument 1 has unexpected type 'int'
</code>```

答: As @TomKarzes points out in the comments, it's just plain English: argument 1 is referring to the first argument. argument 2 would refer to the second argument and so on.

Body:
I was wondering what the number following the argument stands for (In the error message; the number is 1).

I am updating PsychoPy, and it showed the error message. I have searched for a while, but I did not find any explanation about it.

def onCancel(self, event):
    self.app.updater = None
    self.Close()

def onFileBrowse(self, event):
    self.filename = event.GetString()

def onInstall(self, event):
    if self.currentSelection == self.useLatestBtn:
        info = self.doAutoInstall()
    else:
        info = self.installZipFile(self.filename)
    self.statusMessage.SetLabel(info)
    self.Fit()

Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy3\lib\site-
packages\psychopy\app\connections\updates.py", line 404, in onInstall
    self.statusMessage.SetLabel(info)
TypeError: Control.SetLabel(): argument 1 has unexpected type 'int'


问:
EFcore LazyLoading - What is requested to the database when filtering on a child property
I'm using lazy loading and I'm concerned about performance.

Let's say I have an object A, which contains a list of object B.

I'll retrieve the object A from the database using lazy loading. Which means the list of object B will not be retrieve if I don't access it.

But if I do something like this:

```<code>ObjectA.ObjectsB.Where(b => b.Id == 12);
</code>```

Will it query all the objects B and than filters it, or will it query only the result of the expression ?

答:
Actually you can do it as instructed in this document which is the same as this document for ef core :

```<code>dbContext.Entry(ObjectA)
    .Collection(b => b.ObjectsB)
    .Query()
    .Where(b => b.Id == 12)
    .Load();
</code>```

Then trace it using Sql Profiler and see that it is filtered at database level.

Body:
I'm using lazy loading and I'm concerned about performance.

Let's say I have an object A, which contains a list of object B.

I'll retrieve the object A from the database using lazy loading. Which means the list of object B will not be retrieve if I don't access it.

But if I do something like this:

ObjectA.ObjectsB.Where(b => b.Id == 12);

Will it query all the objects B and than filters it, or will it query only the result of the expression ?

Body:
Actually you can do it as instructed in this document which is the same as this document for ef core :

dbContext.Entry(ObjectA)
    .Collection(b => b.ObjectsB)
    .Query()
    .Where(b => b.Id == 12)
    .Load();

Then trace it using Sql Profiler and see that it is filtered at database level.


问:
Android Web Scraping with a Headless Browser
I have spent a day on researching a library that can be used to accomplish the following:

Retrieve the full contents of a webpage like in the background without rendering result to a view.

The lib should support pages that fires off ajax requests to load some additional result data after the initial HTML has loaded for example.

From the resulting html I need to grab elements in xpath or css selector form.

In future I also possibly need to navigate to a next page (fire off events, submitting buttons/links etc)

Here is what I have tried without success:

Jsoup: Works great but no support for javascript/ajax (so it does not load full page)

Android built in HttpEntity: same problem with javascript/ajax as jsoup

HtmlUnit: Looks exactly what I need but after hours cannot get it to work on Android (Other users failed by trying to load the 12MB+ worth of jar files.  I myself loaded the full source code and referenced it as a project library only to find that things such as Applets and java.awt (used by HtmlUnit) does not exist in Android).

Rhino - I find this very confusing and don't know how to get it working in Android and even if it is what I am looking for.

Selenium Driver: Looks like it can work but you don't have an straightforward way to implement it in a headless way so that you don't have the actual html displayed to a view.

I really want HtmlUnit to work as it seems the best suited for my solution.  Is there any way or at least another library I have missed that is suitable for my needs?

I am currently using Android Studio 0.1.7 and can move to Ellipse if needed.

Thanks in advance!

答: I have taken the implementation mentioned above (injecting JavaScript) and that works for me. All I do is simply set the visibility of the webview to be hidden under other UI elements. I was also thinking of doing the same with selenium. I have used selenium with Chrome in Python and it's great but like you mentioned it is not easy to not show the browser window. But I think it might be possible to just not show the component in Android. I'll have to try.</p>


问:
Make an SVG fill the entire page exactly
I am making a simple single-page application in plain Javascript and want to use a full-page SVG as the graphics foundation.

I would have thought that putting

```<code><svg id="svg" width="100%" height="100%"></svg>
</code>```

in the page body would do the trick. It almost works, but not quite:

the page has a vertical scrollbar (which I wouldn't expect because 100% should not mean "greater than 100%" and therefore there should be nothing to scroll to).

the SVG top-left corner is about 20 pixels into the page (in both dimensions)

the right side of the SVG is truncated -- about 10 pixel columns are blank between the SVG and the scrollbar (that I don't even want nor expect).

To show these problems clearly, I added Javascript code to draw a big bounding rectangle with an X in it after retrieving the SVG client coordinates.

<svg id="svg" width="100%" height="100%"></svg>

```

Any thoughts on what is crufting up the SVG bounds? Perhaps some kind of border defaults or CSS defaults or some wonderful thing like that?

答:
You might need to zero out the default margin and padding in CSS like:</p>

```<code>html, body, * {
     margin: 0;
     padding: 0;
}
</code>```

Body:
I am making a simple single-page application in plain Javascript and want to use a full-page SVG as the graphics foundation.

I would have thought that putting

<svg id="svg" width="100%" height="100%"></svg>

in the page body would do the trick. It almost works, but not quite:

the page has a vertical scrollbar (which I wouldn't expect because 100% should not mean "greater than 100%" and therefore there should be nothing to scroll to).

the SVG top-left corner is about 20 pixels into the page (in both dimensions)

the right side of the SVG is truncated -- about 10 pixel columns are blank between the SVG and the scrollbar (that I don't even want nor expect).

To show these problems clearly, I added Javascript code to draw a big bounding rectangle with an X in it after retrieving the SVG client coordinates.

<svg id="svg" width="100%" height="100%"></svg>

Any thoughts on what is crufting up the SVG bounds? Perhaps some kind of border defaults or CSS defaults or some wonderful thing like that?

Body:
You might need to zero out the default margin and padding in CSS like:

html, body, * {
     margin: 0;
     padding: 0;
}


问:
How to Instantiate new HTMLElement?
I am trying to instantiate new HTMLDivElement in TypeScript

```<code>var elem = new HTMLDivElement();
</code>```

but the browser throws

```<code>Uncaught TypeError: Illegal constructor.
</code>```

The workaround seems to be to use

```<code>var elem = document.createElement('div');
</code>```

but I find this suboptimal for various reasons.

Why can't I instantiate DOM elements directly when there is a new keyword for in in the lib.d.ts?

```<code>declare var HTMLDivElement: {
    prototype: HTMLDivElement;
    new (): HTMLDivElement;
}
</code>```

答:
If you extend HTMLElement or any subclass like HTMLDivElement

You also need to register the custom element

class SampleDiv extends HTMLDivElement{
    constructor(){
       super();
    }
}
customElements.define('sample-div', SampleDiv, { extends: 'div' });
```

See more here:
https://javascript.info/custom-elements

Title: How to Instantiate new HTMLElement?

Body:
I am trying to instantiate new HTMLDivElement in TypeScript

var elem = new HTMLDivElement();

but the browser throws

Uncaught TypeError: Illegal constructor.

The workaround seems to be to use

var elem = document.createElement('div');

but I find this suboptimal for various reasons.

Why can't I instantiate DOM elements directly when there is a new keyword for in in the lib.d.ts?

declare var HTMLDivElement: {
    prototype: HTMLDivElement;
    new (): HTMLDivElement;
}

Body:
If you extend HTMLElement or any subclass like HTMLDivElement

You also need to register the custom element

class SampleDiv extends HTMLDivElement{
    constructor(){
       super();
    }
}
customElements.define('sample-div', SampleDiv, { extends: 'div' });

See more here:
https://javascript.info/custom-elements


问:
during pull request build how does the build definition know to build feature branch
In Azure DevOps I created a branch policy for dev branch and selected a build definition.

in the build definition "Default branch for manual and scheduled builds" is set to Master
and under trigger continuous integration is disabled.

When we do a pull request from feature to dev branch. It seems to take the right branch to build but how does the build definition know which branch to build?

答: because the default branch is the branch that will get used when you manually build the build, not when its triggered.</p>


问:
Accessing Java hashmap to get subclass
I am intializing one hashmap which contains key and subclass object.

```<code>@Provides
@Singleton
public Map<Locale, XlsxParserBase> getXlsxParserMap() {
    Map<Locale, XlsxParserBase> xlsxParserMap = Maps.newHashMap();
    xlsxParserMap.put(Locale.US, new com.us.XlsxParser());
    xlsxParserMap.put(Locale.EU, new com.eu.XlsxParser());
    return xlsxParserMap;
}
</code>```

This map gets intialized when the server starts. Now I have a manager class which has the locale. I just want to do

```<code>xlsxParserMap.get(locale).parse();
</code>```

where each subclass has parse implementation and uses common methods from base. When I do this, i am unable to access parse beacause parse method is not present in superclass. Since, map is of type (Locale, XlsxParserBase), I am unable to access child methods from XlsxParserBase reference.

Is there a simpler way to achieve this? I do not want to put instanceOf in manager class. To avoid that, i thought of this map approach. Do experts have some better approach for my problem? Let me know if I am unclear or you need more snippets.

答:
Create an interface that has a parse() method (and possibly others) and let all subclasses implement the interface. </p>

<p>Then you can have a collection of this interface and the manager class can have a method with that interface as parameter </p>

Title: Accessing Java hashmap to get subclass

Body:
I am intializing one hashmap which contains key and subclass object.

@Provides
@Singleton
public Map<Locale, XlsxParserBase> getXlsxParserMap() {
    Map<Locale, XlsxParserBase> xlsxParserMap = Maps.newHashMap();
    xlsxParserMap.put(Locale.US, new com.us.XlsxParser());
    xlsxParserMap.put(Locale.EU, new com.eu.XlsxParser());
    return xlsxParserMap;
}

This map gets intialized when the server starts. Now I have a manager class which has the locale. I just want to do

xlsxParserMap.get(locale).parse();

where each subclass has parse implementation and uses common methods from base. When I do this, i am unable to access parse beacause parse method is not present in superclass. Since, map is of type (Locale, XlsxParserBase), I am unable to access child methods from XlsxParserBase reference.

Is there a simpler way to achieve this? I do not want to put instanceOf in manager class. To avoid that, i thought of this map approach. Do experts have some better approach for my problem? Let me know if I am unclear or you need more snippets.

Body:
Create an interface that has a parse() method (and possibly others) and let all subclasses implement the interface.

Then you can have a collection of this interface and the manager class can have a method with that interface as parameter


问:
Trying to Remove any non-numbers from an Array
I am trying to get user input and then put this into an array, however, if the user puts in an element that is not a number how can I remove this? I can make an error message show up however the element still goes into the array.</p>

```<code>      var input_array = [];

      var number = prompt('Enter a Number');
      if (isNaN(number)) {
        alert("Please Enter a Number");
      }
      var array = input_array.push(parseInt(number));
</code>```

答:
Just place the push inside an else. Also note that push returns the new length of the array - so array will be 1 in your code.

var input_array = [];

var number = prompt('Enter a Number');
if (isNaN(number)) {
  alert("Please Enter a Number");
} else {
  input_array.push(parseInt(number));
}

console.log(input_array);```

Body:
I am trying to get user input and then put this into an array, however, if the user puts in an element that is not a number how can I remove this? I can make an error message show up however the element still goes into the array.

      var input_array = [];

      var number = prompt('Enter a Number');
      if (isNaN(number)) {
        alert("Please Enter a Number");
      }
      var array = input_array.push(parseInt(number));


问:
Is there a possibility that I'll make the Stripe payment in my app less secured due to wrong implementation?
I am trying to implement stripe in my app, and currently having a bit of a hard time. Like anything else I believe that eventually I'd be able to make it work, but my main concern is that I won't implement it properly, and as a result I'll make the payment less secure that it should be.

Is there a base to my concerns? The last thing I want is to compromise my users credit cards.

I am trying to use the standard implementation and collect the card details with their card input widget.

答:
I don't think security should be a concern, that's what stripe is for. Improper implementation won't make it less secure. You just won't get the right response.

FYI - https://stripe.com/docs/security/stripe
https://stripe.com/docs/security

As long as you follow the official documentation, you are good to go.


问:
RegEx - Time Validation ((h)h:mm)
```<code>/^\d{1,2}[:][0-5][0-9]$/
</code>```

is what I have. this limits minutes to 00-59. It does not, however, limit hours to between 0 and 12. For similarity and uniformity I would like to do this with RegEx alone if possible.

Further-more I would like the first digit to be optional. i.e. 09:30 accepted as well as 9:30. I played around with ranges, but something out of range is always acceptable.

答:
For folks looking for 24h format matching,

hh:mm:ss or h:mm:ss :

```<code>status = /^(2[0-3]|[0-1]?[\d]):[0-5][\d]:[0-5][\d]$/.test(timestr)
</code>```

hh:mm or h:mm :

```<code>status = /^(2[0-3]|[0-1]?[\d]):[0-5][\d]$/.test(timestr)
</code>```

This site is great for testing out: https://www.regexpal.com/

Addedum: Explanation for completeness:

^ : start of string, $ : end of string. So we put the expression in a ^..$ block to ensure there's nothing outside of our pattern.

(2[0-3]|[0-1]?[\d]) : translates to 2[0-3] OR [0-1]?[\d]

2[0-3] : 20, 21, 22, 23

[0-1]?[\d] : 0 or 1 or nothing (?) followed by any single digit(\d). So, this works for numbers from 0 to 19.

: just that character

[0-5][\d] : number from 00 to 59. Note: this won't tolerate single-digit in the mm place.

Title: RegEx - Time Validation ((h)h:mm)

Body:
/^\d{1,2}[:][0-5][0-9]$/

is what I have. this limits minutes to 00-59. It does not, however, limit hours to between 0 and 12. For similarity and uniformity I would like to do this with RegEx alone if possible.

Further-more I would like the first digit to be optional. i.e. 09:30 accepted as well as 9:30. I played around with ranges, but something out of range is always acceptable.

Body:
For folks looking for 24h format matching,

hh:mm:ss or h:mm:ss :

status = /^(2[0-3]|[0-1]?[\d]):[0-5][\d]:[0-5][\d]$/.test(timestr)

hh:mm or h:mm :

status = /^(2[0-3]|[0-1]?[\d]):[0-5][\d]$/.test(timestr)

This site is great for testing out: https://www.regexpal.com/

Addedum: Explanation for completeness:

^ : start of string, $ : end of string. So we put the expression in a ^..$ block to ensure there's nothing outside of our pattern.

(2[0-3]|[0-1]?[\d]) : translates to 2[0-3] OR [0-1]?[\d]

2[0-3] : 20, 21, 22, 23

[0-1]?[\d] : 0 or 1 or nothing (?) followed by any single digit(\d). So, this works for numbers from 0 to 19.

: just that character

[0-5][\d] : number from 00 to 59. Note: this won't tolerate single-digit in the mm place.


问:
Google App Engine PHP 7.2 using app.yaml while on localhost?
I'm trying to migrate my Google App Engine app from PHP 5.5 to PHP 7.2.

I've created a router script as my app's entrypoint which is what does the work of all of the urlhandlers that used to be in my app.yaml. I'm starting the local server as described in the above migration document, by just starting php's built-in web server.

But it occurs to me that when I'm running this on localhost for testing purposes that my app.yaml is never even being read by the application.

This means that my app on localhost isn't going to behave like it will when pushed to the Google App Engine and that's rather frightening. It means that all of the work I do on localhost might not work at all once I push it out to the world.

Am I missing something in how I'm supposed to be developing and testing for PHP 7.2 on Google App Engine? This can't be Google's real intention for development, right?

答:
dev_appserver.py is not supported with the PHP 7.2 runtime. To test your application and run it locally, you must download and install PHP 7.2 and set up a web server.

https://cloud.google.com/appengine/docs/standard/php7/php-differences

I don't think you can run it locally and that sucks. I am trying to use Docker to build a local devevelopment and test environment. This seems to make it impossible. :-(


问:
I want to change backcolor every 1 second in winform using timer
I want to change backgroundcolor every 1 second using timer in winform. For example Red -> SystemColors.Control -> red -> SystemColors.Control ->..

I have menuitem in mainUI. So when I click this control, I want to see automatically changing of mainUI's background color.

Here is code what I wrote. what should I change in this code?

```<code>private void RadMenuItem9_Click(object sender, EventArgs e)
{
    System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
    timer.Enabled = true;
    timer.Interval = 2000;
    timer.Tick += new EventHandler(Timer1_Tick);
    timer.Start();
}

private void Timer1_Tick(object sender, EventArgs e)
{
    BackColor = Color.Red;
    Thread.Sleep(1000);
    BackColor = SystemColors.Control;
}
</code>```

答: You need to make logic for switching colors. Here since you want to change between two colors you can check the current color and switch to the other. You can’t use Sleep since that will block the UI thread and no changes will be shown on screen while the thread is blocked.

Body:
I want to change backgroundcolor every 1 second using timer in winform. For example Red -> SystemColors.Control -> red -> SystemColors.Control ->..

I have menuitem in mainUI. So when I click this control, I want to see automatically changing of mainUI's background color.

Here is code what I wrote. what should I change in this code?

private void RadMenuItem9_Click(object sender, EventArgs e)
{
    System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
    timer.Enabled = true;
    timer.Interval = 2000;
    timer.Tick += new EventHandler(Timer1_Tick);
    timer.Start();
}

private void Timer1_Tick(object sender, EventArgs e)
{
    BackColor = Color.Red;
    Thread.Sleep(1000);
    BackColor = SystemColors.Control;
}


问:
Exception while starting Weblogic Managed Server
I tried to start Weblogic managed server and I'm getting the exception below:

```<code>Apr 11, 2011 10:08:16 PM PDT> <Error> <oracle.bam.adc.dse.common.DataSourceFactory> <BEA-000000> <[12] Exception occurred in method DataSourceFactory.getDataSource(jdbc/oracle/bam/adc)
Exception: javax.naming.NameNotFoundException: While trying to lookup 'jdbc.oracle.bam/adc' didn't find subcontext 'oracle'. Resolved 'jdbc'; remaining name 'oracle/bam/adc'
  at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
  at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
  at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
  at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
  at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
  at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
  at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:411)
  at javax.naming.InitialContext.lookup(InitialContext.java:392)
  at oracle.bam.adc.dse.common.DataSourceFactory.getDataSource(DataSourceFactory.java:132)
  at oracle.bam.adc.dse.common.DataSourceFactory.getDataSource(DataSourceFactory.java:105)
  at oracle.bam.adc.dse.common.StorageEngineFactory.startup(StorageEngineFactory.java:109)
  at oracle.bam.adc.kernel.server.DataStoreServer.startup(DataStoreServer.java:234)
  at oracle.bam.adc.kernel.server.ADCService.startService(ADCService.java:83)
  at oracle.bam.server.BamServer$ServiceEntry$1.run(BamServer.java:1716)
  at java.security.AccessController.doPrivileged(Native Method)
  at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
  at oracle.security.jps.internal.jaas.AccActionExecutor.execute(AccActionExecutor.java:47)
  at oracle.security.jps.internal.jaas.CascadeActionExecutor$SubjectPrivilegedExceptionAction.run(CascadeActionExecutor.java:79)
  at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
  at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
  at weblogic.security.Security.runAs(Security.java:61)
  at oracle.security.jps.wls.jaas.WlsActionExecutor.execute(WlsActionExecutor.java:48)
  at oracle.security.jps.internal.jaas.CascadeActionExecutor.execute(CascadeActionExecutor.java:52)
  at oracle.bam.common.security.authentication.BamPrivilegedExceptionAction.execute(BamPrivilegedExceptionAction.java:153)
  at oracle.bam.common.security.authentication.BamPrivilegedExceptionAction.execute(BamPrivilegedExceptionAction.java:121)
  at oracle.bam.server.BamServer$ServiceEntry.start(BamServer.java:1722)
  at oracle.bam.server.BamServer.init(BamServer.java:272)
  at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
  at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
  at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
  at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
  at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
  at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
  at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
  at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)
  at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)
  at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)
  at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153)
  at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
  at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
  at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
  at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
  at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
  at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
  at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
  at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
  at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
  at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636)
  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
  at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
  at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)
  at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
  at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
  at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)
  at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)
  at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)
  at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:200)
  at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
  at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:261)
  at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:246)
  at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
  at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
  at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:180)
  at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:96)
  at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
  at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
  at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
>
<Apr 11, 2011 10:08:16 PM PDT> <Error> <HTTP> <BEA-101216> <Servlet: "BamServer" failed to preload on startup in Web application: "/oracle/bam".
java.lang.Exception: BAM data store server failed to start.
        at oracle.bam.adc.kernel.server.DataStoreServer.startup(DataStoreServer.java:323)
        at oracle.bam.adc.kernel.server.ADCService.startService(ADCService.java:83)
        at oracle.bam.server.BamServer$ServiceEntry$1.run(BamServer.java:1716)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
        Truncated. see log file for complete stacktrace
Caused By: javax.naming.NameNotFoundException: While trying to lookup 'jdbc.oracle.bam/adc' didn't find subcontext 'oracle'. Resolved 'jdbc'; remaining name 'oracle/bam/adc'
        at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
        at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
        at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
        Truncated. see log file for complete stacktrace
>
<Apr 11, 2011 10:08:16 PM PDT> <Error> <Deployer> <BEA-149231> <Unable to set the activation state to true for the application 'oracle-bam [Version=11.1.1]'.
weblogic.application.ModuleException: [HTTP:101216]Servlet: "BamServer" failed to preload on startup in Web application: "/oracle/bam".
java.lang.Exception: BAM data store server failed to start.
        at oracle.bam.adc.kernel.server.DataStoreServer.startup(DataStoreServer.java:323)
        at oracle.bam.adc.kernel.server.ADCService.startService(ADCService.java:83)
        at oracle.bam.server.BamServer$ServiceEntry$1.run(BamServer.java:1716)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
        at oracle.security.jps.internal.jaas.AccActionExecutor.execute(AccActionExecutor.java:47)
        at oracle.security.jps.internal.jaas.CascadeActionExecutor$SubjectPrivilegedExceptionAction.run(CascadeActionExecutor.java:79)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
        at weblogic.security.Security.runAs(Security.java:61)
        at oracle.security.jps.wls.jaas.WlsActionExecutor.execute(WlsActionExecutor.java:48)
        at oracle.security.jps.internal.jaas.CascadeActionExecutor.execute(CascadeActionExecutor.java:52)
        at oracle.bam.common.security.authentication.BamPrivilegedExceptionAction.execute(BamPrivilegedExceptionAction.java:153)
        at oracle.bam.common.security.authentication.BamPrivilegedExceptionAction.execute(BamPrivilegedExceptionAction.java:121)
        at oracle.bam.server.BamServer$ServiceEntry.start(BamServer.java:1722)
        at oracle.bam.server.BamServer.init(BamServer.java:272)
        at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
        at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
        at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
        at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
        at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)
        at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)
        at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)
        at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153)
        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
        at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
        at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
        at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
        at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
        at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
        at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)
        at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
        at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
        at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)
        at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)
        at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)
        at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:200)
        at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
        at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:261)
        at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:246)
        at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
        at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
        at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:180)
        at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:96)
        at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
Caused by: javax.naming.NameNotFoundException: While trying to lookup 'jdbc.oracle.bam/adc' didn't find subcontext 'oracle'. Resolved 'jdbc'; remaining name 'oracle/bam/adc'
        at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
        at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
        at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
        at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
        at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:411)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at oracle.bam.adc.dse.common.DataSourceFactory.getDataSource(DataSourceFactory.java:132)
        at oracle.bam.adc.dse.common.DataSourceFactory.getDataSource(DataSourceFactory.java:105)
        at oracle.bam.adc.dse.common.StorageEngineFactory.startup(StorageEngineFactory.java:109)
        at oracle.bam.adc.kernel.server.DataStoreServer.startup(DataStoreServer.java:234)
        ... 57 more

        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1510)
        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
        Truncated. see log file for complete stacktrace
Caused By: javax.naming.NameNotFoundException: While trying to lookup 'jdbc.oracle.bam/adc' didn't find subcontext 'oracle'. Resolved 'jdbc'; remaining name 'oracle/bam/adc'
        at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
        at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
        at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
        Truncated. see log file for complete stacktrace
>
<Apr 11, 2011 10:08:16 PM PDT> <Notice> <Log Management> <BEA-170027> <The Server has established connection with the Domain level Diagnostic Service successfully.>
<Apr 11, 2011 10:08:17 PM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN>
<Apr 11, 2011 10:08:17 PM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING>
<Apr 11, 2011 10:08:17 PM PDT> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on 127.0.0.1:9001 for protocols iiop, iiop, t3, t3, ldap, ldap, snmp, snmp, http, http.>
<Apr 11, 2011 10:08:17 PM PDT> <Notice> <Server> <BEA-002613> <Channel "Default[2]" is now listening on 0:0:0:0:0:0:0:1:9001 for protocols iiop, t3, ldap, snmp, http.>
<Apr 11, 2011 10:08:17 PM PDT> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 10.152.105.211:9001 for protocols iiop, t3, ldap, snmp, http.>
<Apr 11, 2011 10:08:17 PM PDT> <Notice> <WebLogicServer> <BEA-000332> <Started WebLogic Managed Server "ManagedServer" for domain "bpms_poc_domain" running in Development Mode>
<Apr 11, 2011 10:08:30 PM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING>
<Apr 11, 2011 10:08:30 PM PDT> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>
</code>```

Due to this exception, my Oracle-BAM service doesn't start. I need to start the same.

Can someone give me pointers?

Regards,
Arvind K

答:
JDBC/JNDI ISSUE, undeply app and reconfigure it from console, also check required jars are in platform/domain lib folder

hopefully this will helps

Body:
I tried to start Weblogic managed server and I'm getting the exception below:

Apr 11, 2011 10:08:16 PM PDT> <Error> <oracle.bam.adc.dse.common.DataSourceFactory> <BEA-000000> <[12] Exception occurred in method DataSourceFactory.getDataSource(jdbc/oracle/bam/adc)
Exception: javax.naming.NameNotFoundException: While trying to lookup 'jdbc.oracle.bam/adc' didn't find subcontext 'oracle'. Resolved 'jdbc'; remaining name 'oracle/bam/adc'
  at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
  at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
  at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
  at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
  at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
  at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
  at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:411)
  at javax.naming.InitialContext.lookup(InitialContext.java:392)
  at oracle.bam.adc.dse.common.DataSourceFactory.getDataSource(DataSourceFactory.java:132)
  at oracle.bam.adc.dse.common.DataSourceFactory.getDataSource(DataSourceFactory.java:105)
  at oracle.bam.adc.dse.common.StorageEngineFactory.startup(StorageEngineFactory.java:109)
  at oracle.bam.adc.kernel.server.DataStoreServer.startup(DataStoreServer.java:234)
  at oracle.bam.adc.kernel.server.ADCService.startService(ADCService.java:83)
  at oracle.bam.server.BamServer$ServiceEntry$1.run(BamServer.java:1716)
  at java.security.AccessController.doPrivileged(Native Method)
  at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
  at oracle.security.jps.internal.jaas.AccActionExecutor.execute(AccActionExecutor.java:47)
  at oracle.security.jps.internal.jaas.CascadeActionExecutor$SubjectPrivilegedExceptionAction.run(CascadeActionExecutor.java:79)
  at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
  at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
  at weblogic.security.Security.runAs(Security.java:61)
  at oracle.security.jps.wls.jaas.WlsActionExecutor.execute(WlsActionExecutor.java:48)
  at oracle.security.jps.internal.jaas.CascadeActionExecutor.execute(CascadeActionExecutor.java:52)
  at oracle.bam.common.security.authentication.BamPrivilegedExceptionAction.execute(BamPrivilegedExceptionAction.java:153)
  at oracle.bam.common.security.authentication.BamPrivilegedExceptionAction.execute(BamPrivilegedExceptionAction.java:121)
  at oracle.bam.server.BamServer$ServiceEntry.start(BamServer.java:1722)
  at oracle.bam.server.BamServer.init(BamServer.java:272)
  at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
  at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
  at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
  at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
  at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
  at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
  at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
  at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)
  at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)
  at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)
  at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153)
  at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
  at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
  at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
  at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
  at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
  at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
  at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
  at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
  at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
  at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636)
  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
  at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
  at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)
  at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
  at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
  at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)
  at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)
  at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)
  at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:200)
  at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
  at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:261)
  at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:246)
  at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
  at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
  at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:180)
  at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:96)
  at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
  at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
  at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
>
<Apr 11, 2011 10:08:16 PM PDT> <Error> <HTTP> <BEA-101216> <Servlet: "BamServer" failed to preload on startup in Web application: "/oracle/bam".
java.lang.Exception: BAM data store server failed to start.
        at oracle.bam.adc.kernel.server.DataStoreServer.startup(DataStoreServer.java:323)
        at oracle.bam.adc.kernel.server.ADCService.startService(ADCService.java:83)
        at oracle.bam.server.BamServer$ServiceEntry$1.run(BamServer.java:1716)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
        Truncated. see log file for complete stacktrace
Caused By: javax.naming.NameNotFoundException: While trying to lookup 'jdbc.oracle.bam/adc' didn't find subcontext 'oracle'. Resolved 'jdbc'; remaining name 'oracle/bam/adc'
        at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
        at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
        at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
        Truncated. see log file for complete stacktrace
>
<Apr 11, 2011 10:08:16 PM PDT> <Error> <Deployer> <BEA-149231> <Unable to set the activation state to true for the application 'oracle-bam [Version=11.1.1]'.
weblogic.application.ModuleException: [HTTP:101216]Servlet: "BamServer" failed to preload on startup in Web application: "/oracle/bam".
java.lang.Exception: BAM data store server failed to start.
        at oracle.bam.adc.kernel.server.DataStoreServer.startup(DataStoreServer.java:323)
        at oracle.bam.adc.kernel.server.ADCService.startService(ADCService.java:83)
        at oracle.bam.server.BamServer$ServiceEntry$1.run(BamServer.java:1716)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
        at oracle.security.jps.internal.jaas.AccActionExecutor.execute(AccActionExecutor.java:47)
        at oracle.security.jps.internal.jaas.CascadeActionExecutor$SubjectPrivilegedExceptionAction.run(CascadeActionExecutor.java:79)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
        at weblogic.security.Security.runAs(Security.java:61)
        at oracle.security.jps.wls.jaas.WlsActionExecutor.execute(WlsActionExecutor.java:48)
        at oracle.security.jps.internal.jaas.CascadeActionExecutor.execute(CascadeActionExecutor.java:52)
        at oracle.bam.common.security.authentication.BamPrivilegedExceptionAction.execute(BamPrivilegedExceptionAction.java:153)
        at oracle.bam.common.security.authentication.BamPrivilegedExceptionAction.execute(BamPrivilegedExceptionAction.java:121)
        at oracle.bam.server.BamServer$ServiceEntry.start(BamServer.java:1722)
        at oracle.bam.server.BamServer.init(BamServer.java:272)
        at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
        at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
        at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
        at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
        at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)
        at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)
        at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)
        at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153)
        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
        at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
        at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
        at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
        at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
        at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
        at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)
        at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
        at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
        at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)
        at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)
        at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)
        at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:200)
        at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
        at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:261)
        at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:246)
        at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
        at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
        at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:180)
        at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:96)
        at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
Caused by: javax.naming.NameNotFoundException: While trying to lookup 'jdbc.oracle.bam/adc' didn't find subcontext 'oracle'. Resolved 'jdbc'; remaining name 'oracle/bam/adc'
        at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
        at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
        at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
        at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
        at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:411)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at oracle.bam.adc.dse.common.DataSourceFactory.getDataSource(DataSourceFactory.java:132)
        at oracle.bam.adc.dse.common.DataSourceFactory.getDataSource(DataSourceFactory.java:105)
        at oracle.bam.adc.dse.common.StorageEngineFactory.startup(StorageEngineFactory.java:109)
        at oracle.bam.adc.kernel.server.DataStoreServer.startup(DataStoreServer.java:234)
        ... 57 more

        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1510)
        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
        Truncated. see log file for complete stacktrace
Caused By: javax.naming.NameNotFoundException: While trying to lookup 'jdbc.oracle.bam/adc' didn't find subcontext 'oracle'. Resolved 'jdbc'; remaining name 'oracle/bam/adc'
        at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
        at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
        at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
        at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
        Truncated. see log file for complete stacktrace
>
<Apr 11, 2011 10:08:16 PM PDT> <Notice> <Log Management> <BEA-170027> <The Server has established connection with the Domain level Diagnostic Service successfully.>
<Apr 11, 2011 10:08:17 PM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN>
<Apr 11, 2011 10:08:17 PM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING>
<Apr 11, 2011 10:08:17 PM PDT> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on 127.0.0.1:9001 for protocols iiop, iiop, t3, t3, ldap, ldap, snmp, snmp, http, http.>
<Apr 11, 2011 10:08:17 PM PDT> <Notice> <Server> <BEA-002613> <Channel "Default[2]" is now listening on 0:0:0:0:0:0:0:1:9001 for protocols iiop, t3, ldap, snmp, http.>
<Apr 11, 2011 10:08:17 PM PDT> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 10.152.105.211:9001 for protocols iiop, t3, ldap, snmp, http.>
<Apr 11, 2011 10:08:17 PM PDT> <Notice> <WebLogicServer> <BEA-000332> <Started WebLogic Managed Server "ManagedServer" for domain "bpms_poc_domain" running in Development Mode>
<Apr 11, 2011 10:08:30 PM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING>
<Apr 11, 2011 10:08:30 PM PDT> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>

Due to this exception, my Oracle-BAM service doesn't start. I need to start the same.

Can someone give me pointers?

Regards,
Arvind K


问:
refactoring a class to be more efficient
i'm trying to refactor a class that i guess has several memory and runtime inefficiencies and bugs.
can you help me with that or remark my assumptions?

(for example

1.
i understand that the tostring method can use stringBuilder instead of strings concatinations...

2.also i guess it's better to use hashtable instead of list in order to getch the results from m_strings in o(1) instead of o(n) (in remove_string_method)

can you help me in approving it more??
i'm also not sure regarding those casting...
thanks

```<code>public class SomeClass
{
  private Date m_time;
  private String m_name;
  private List<Long> m_numbers;
  private List<String> m_strings;

  public MyClass(Date time, String name, List<Long> numbers, List<String> strings) {
        m_time = time; m_name = name; m_numbers = numbers; m_strings = strings;
  }

  public boolean equals(Object obj) {
     if (obj instanceof MyClass) {
        return m_name.equals(((MyClass)obj).m_name);
     }
     return false;
  }

public String toString() {
   String out = m_name;
   for (long item : m_numbers) {
      out += " " + item;
   }
   return out;
}

public void removeString(String str) {
    for (int i = 0; i < m_strings.size(); i++) {
      if (m_strings.get(i).equals(str)) {
        m_strings.remove(i);
      }
   }
}

public boolean containsNumber(long number) {
    for (long num : m_numbers) {
     if (num == number) {
       return true;
     }
    }
return false;
}

public boolean isHistoric() {
    return m_time.before(new Date());
}
}
</code>```

答:
Start with naming: avoid Hungarian notation, so throw away all the m_ prefixes!

And yes, when looking up contained elements is a frequent task, then you obviously use a Set implementation, like HashSet. That would help with both data sets, names and numbers!

Body:
i'm trying to refactor a class that i guess has several memory and runtime inefficiencies and bugs.
can you help me with that or remark my assumptions?

(for example

1.
i understand that the tostring method can use stringBuilder instead of strings concatinations...

2.also i guess it's better to use hashtable instead of list in order to getch the results from m_strings in o(1) instead of o(n) (in remove_string_method)

can you help me in approving it more??
i'm also not sure regarding those casting...
thanks

public class SomeClass
{
  private Date m_time;
  private String m_name;
  private List<Long> m_numbers;
  private List<String> m_strings;

  public MyClass(Date time, String name, List<Long> numbers, List<String> strings) {
        m_time = time; m_name = name; m_numbers = numbers; m_strings = strings;
  }

  public boolean equals(Object obj) {
     if (obj instanceof MyClass) {
        return m_name.equals(((MyClass)obj).m_name);
     }
     return false;
  }

public String toString() {
   String out = m_name;
   for (long item : m_numbers) {
      out += " " + item;
   }
   return out;
}

public void removeString(String str) {
    for (int i = 0; i < m_strings.size(); i++) {
      if (m_strings.get(i).equals(str)) {
        m_strings.remove(i);
      }
   }
}

public boolean containsNumber(long number) {
    for (long num : m_numbers) {
     if (num == number) {
       return true;
     }
    }
return false;
}

public boolean isHistoric() {
    return m_time.before(new Date());
}
}