问:
how to get specific characters between others in a string with jquery?
Having a string such like this one:

```<code>var str = "https://www.portalinmobiliario.com/venta/departamento/vitacura-metropolitana/6579-parque-arboleda-nva";
</code>```

I need to be able to only get "6579" number from that string, because it is an ID I need to use. In fact,
this ID is always located between that last "/" and the next "-" that follows.

So considering that the url is dynamic but this "ID" is always between these two characters "/" and "-", I have to be able to always get the ID.

Any Idea how could I solve this?

I tried with this but

```<code>var id = str.lastIndexOf('/');
</code>```

答:
Take your var id and substr your original String</p>

```<code>var index = str.lastIndexOf('/');
var id = str.substr(index+1,4);
</code>```

Body:
Having a string such like this one:

var str = "https://www.portalinmobiliario.com/venta/departamento/vitacura-metropolitana/6579-parque-arboleda-nva";

I need to be able to only get "6579" number from that string, because it is an ID I need to use. In fact,
this ID is always located between that last "/" and the next "-" that follows.

So considering that the url is dynamic but this "ID" is always between these two characters "/" and "-", I have to be able to always get the ID.

Any Idea how could I solve this?

I tried with this but

var id = str.lastIndexOf('/');

Body:
Take your var id and substr your original String

var index = str.lastIndexOf('/');
var id = str.substr(index+1,4);


来源: stackexchange

问:
Split html between two divs?
I have two divs. Both are 400 px height. User enters text in WYSIWYG editor.
I need to split this HTML text in a way that div #1 is filled first and when it's full (no more text will fit) I need to start appending to another div.

It it was plain text I would split it on newlines and then line by line I would copy to div #1 and, when it's full, to #div 2.
But since it's HTML I don't know how to split it.

I cannot use CSS columns because I need different styles for each column.

答:
if you want news paper kind of layout you can simply use column-count css property

.parent-div{
  column-count:2;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="parent-div">
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius.
</div></code>```

ContentLicense: CC BY-SA 3.0

Title: Split html between two divs?

Body:
if you want news paper kind of layout you can simply use column-count css property

.parent-div{
  column-count:2;
}

<div class="parent-div">
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius.
</div>

ContentLicense: CC BY-SA 4.0


问:
Wait for Observable to Complete Inside of Array.Map
I have an array of objects in which one of the keys includes a customer id.

```<code>const customerArray = [{ customerId: 123, ...}, { customerId: 456, ...}];
</code>```

I want to iterate through this array and make an api call to get further details about this customer from a separate endpoint.

```<code>const mapped = customerArray
  .map(customer => ({
    customerId: customer.customerId,
    rating: this.productService(customer.customerId)
               .pipe(map(rating => rating))}));
</code>```

My expectation is that I would then have an array that includes an object with the following shape:

```<code>{
  customerId: number,
  rating: number
}
</code>```

Instead, I end up with:

```<code>{
  customerId: number,
  rating: Observable
}
</code>```

My productService call returns on observable and is used elsewhere in the app successfully. I need to have my map wait for the call to complete on the rating key before mapping to the next item in the array.

答:
If I understand it right, you have to iterate through an array, make an http request to an endpoint for each element of the array, and fill each element of the array with the data returned by the endpoint.
So, if this is the case, you may try mergeMap like this

```<code>const myObs = from(customerArray).pipe(
  mergeMap(customer => {
    return this.productService(customer.customerId).pipe(
      map(rating => ({customerId: customer.customerId, rating}))
    )
  })
)
</code>```

If you subscribe to myObs you should get a stream of objects in the shape you are looking for, i.e.

```<code>{
  customerId: number,
  rating: number
}
</code>```

mergeMap, previously known as flatMap, allows you to flatten a stream of Observables. In other words, if you iterate through an array to generate an array of Observables, which should be your case, mergeMap allows you to extract the values inside the Observables generated.

Body:
I have an array of objects in which one of the keys includes a customer id.

const customerArray = [{ customerId: 123, ...}, { customerId: 456, ...}];

I want to iterate through this array and make an api call to get further details about this customer from a separate endpoint.

const mapped = customerArray
  .map(customer => ({
    customerId: customer.customerId,
    rating: this.productService(customer.customerId)
               .pipe(map(rating => rating))}));

My expectation is that I would then have an array that includes an object with the following shape:

{
  customerId: number,
  rating: number
}

Instead, I end up with:

{
  customerId: number,
  rating: Observable
}

My productService call returns on observable and is used elsewhere in the app successfully. I need to have my map wait for the call to complete on the rating key before mapping to the next item in the array.

Body:
If I understand it right, you have to iterate through an array, make an http request to an endpoint for each element of the array, and fill each element of the array with the data returned by the endpoint.
So, if this is the case, you may try mergeMap like this

const myObs = from(customerArray).pipe(
  mergeMap(customer => {
    return this.productService(customer.customerId).pipe(
      map(rating => ({customerId: customer.customerId, rating}))
    )
  })
)

If you subscribe to myObs you should get a stream of objects in the shape you are looking for, i.e.

{
  customerId: number,
  rating: number
}

mergeMap, previously known as flatMap, allows you to flatten a stream of Observables. In other words, if you iterate through an array to generate an array of Observables, which should be your case, mergeMap allows you to extract the values inside the Observables generated.


问:
Checking some columns for specific values before insert/update using a trigger
I have a database FOO with several columns, among those I have one column "Url". I need to write a trigger before insert/update that will check the Url columns whether the newer value matches any existing values, i.e. "hello" except some predefined value. That means if "hello" is inserted or updated multiple times no error will happen otherwise it will check for duplicity. And if it finds some aborts the insertion update. This will also return some code so that my script calling for the insertion/update will know a failure has occurred. I know there might be other workarounds but I will need to have it this way. I am pretty new to SQL.

```<code>Foo {
    Url
}
</code>```

Here is the algorithm

```<code>Before update insert
if new value of Url is not "hello1" o "hello 2"
    check if new value of Url already exists in Foo.Url if so abort otherwise allow update/insert
     return something if aborted/success
</code>```

答:
If you are using SQL Server 2008 or newer version you can use MERGE as well, the syntax is like the following :</p>

```<code>MERGE [TableName] AS TARGET
USING ( SELECT @UrlName ) AS SOURCE (UrlName) ON SOURCE.UrlName = TARGET.UrlName
WHEN MATCHED THEN
UPDATE SET ...
WHEN NOT MATCHED THEN INSERT ()
VALUES ();
</code>```

Body:
I have a database FOO with several columns, among those I have one column "Url". I need to write a trigger before insert/update that will check the Url columns whether the newer value matches any existing values, i.e. "hello" except some predefined value. That means if "hello" is inserted or updated multiple times no error will happen otherwise it will check for duplicity. And if it finds some aborts the insertion update. This will also return some code so that my script calling for the insertion/update will know a failure has occurred. I know there might be other workarounds but I will need to have it this way. I am pretty new to SQL.

Foo {
    Url
}

Here is the algorithm

Before update insert
if new value of Url is not "hello1" o "hello 2"
    check if new value of Url already exists in Foo.Url if so abort otherwise allow update/insert
     return something if aborted/success

Body:
If you are using SQL Server 2008 or newer version you can use MERGE as well, the syntax is like the following :

MERGE [TableName] AS TARGET
USING ( SELECT @UrlName ) AS SOURCE (UrlName) ON SOURCE.UrlName = TARGET.UrlName
WHEN MATCHED THEN
UPDATE SET ...
WHEN NOT MATCHED THEN INSERT ()
VALUES ();


问:
R, Format date on X axis using ggplot
After aggregating, "filtering" and parsing a column with date and hours by using as.Date, also transforming it by using melt function, my data looks like this:

```<code>DATE    variable value
1 13-09-20  Billete_50 20405
2 14-09-20  Billete_50 19808
3 13-09-20 Billete_100 27787
4 14-09-20 Billete_100 20361
5 13-09-20       Total 48192
6 14-09-20       Total 40169
</code>```

I want a linear graph to show the data, but it looks like this:

It's in spanish, I'm sorry, but the date is almost the same, it may say only September (Sep), but it is showing October, January, April, July, then back to October.

This is my ggplot line:

```<code>ggplot(plotCajero1Melted, aes(x=DATE, y=value, col=variable)) + geom_line() +xlab("Fecha") +ylab("Saldo") +ggtitle("Cajero 1")
</code>```

What should I do? It's something with the date? I was thinking in the year, it is represented in a short way, probably it is making ggplot to have a weird behavior, or maybe a ggplot option that i'm missing?

答:
You're right, your date format is not read as it should be (it seems to be read as Year-Month-Day).

You can modify the date format for example by using the function dmy from lubridate package to indicate r to read the date as Day-Month-Year:

library(lubridate)
df$DATE <- dmy(df$DATE)

ggplot(df, aes(x = DATE, y = value, color = variable))+
  geom_line()
```

Is it what you are looking for ?

Title: R, Format date on X axis using ggplot

Body:
After aggregating, "filtering" and parsing a column with date and hours by using as.Date, also transforming it by using melt function, my data looks like this:

DATE    variable value
1 13-09-20  Billete_50 20405
2 14-09-20  Billete_50 19808
3 13-09-20 Billete_100 27787
4 14-09-20 Billete_100 20361
5 13-09-20       Total 48192
6 14-09-20       Total 40169

I want a linear graph to show the data, but it looks like this:

It's in spanish, I'm sorry, but the date is almost the same, it may say only September (Sep), but it is showing October, January, April, July, then back to October.

This is my ggplot line:

ggplot(plotCajero1Melted, aes(x=DATE, y=value, col=variable)) + geom_line() +xlab("Fecha") +ylab("Saldo") +ggtitle("Cajero 1")

What should I do? It's something with the date? I was thinking in the year, it is represented in a short way, probably it is making ggplot to have a weird behavior, or maybe a ggplot option that i'm missing?

Body:
You're right, your date format is not read as it should be (it seems to be read as Year-Month-Day).

You can modify the date format for example by using the function dmy from lubridate package to indicate r to read the date as Day-Month-Year:

library(lubridate)
df$DATE <- dmy(df$DATE)

ggplot(df, aes(x = DATE, y = value, color = variable))+
  geom_line()

Is it what you are looking for ?


问:
VS Code: How to change text color of selected text?
I am trying to change the selected text of highlighted text in VS Code. There are 3 ways I can select text.

My current editor settings are:

```<code>    "workbench.colorCustomizations": {
        "editor.selectionHighlightBackground": "#e8fc37",
        "editor.wordHighlightBackground": "#e8fc37",
    },
</code>```

(1) When I first click or select a string of text,then hiting CMD+d, I can select the next occurrences of a string of text:

(2) But if I try to select the text by first searching for it in the same file(CMD+f), then selecting the next occurrences (pressing CMD+d), the color doesn't highlight. The text does in fact highlight, but it's very difficult to tell. You can only really tell by looking in the gutter where the line numbers are.

(3) When I use the Search command (searching among all files; CMD+Shift+f), and I click on one of the search results, even though it clearly tells me what line the text is one, I can't easily tell where in the line the text is being highlighted. This is tricky when the line is longer or filled special characters.

In all these cases, I would like to have the selected text, whether I'm selecting it by using CMD+d or clicking on a result in a search side bar to have the text be dark gray in the foreground, and yellow in the background. I have been able to achieve the background color change, but don't know the editor key for any of the foreground texts.

How can I get selected text to be yellow in the background (which I have done) with dark gray text?

答:
I finally found a decent solution. Check out 123Dev's response. I just copied the Border key and values and I'm happy enough with it.</p>

```<code>"workbench.colorCustomizations": {
    // Totally Transparent
    "editor.selectionHighlightBackground": "#ffffff00",
    "editor.findMatchHighlightBackground": "#ffffff00",
    // Borders
    "editor.findMatchBorder": "#ffff00",
    "editor.findMatchHighlightBorder": "#ff0000",
    "editor.selectionHighlightBorder": "#ffffff",
    "editor.lineHighlightBorder": "#272727",
    // Selection
    "editor.selectionBackground": "#771835",
    "editor.wordHighlightBackground": "#771835",
    // Misc
    "editorCursor.foreground": "#00ff00",
    "editor.lineHighlightBackground": "#181818",
    "editor.findMatchBackground": "#000000",
    // Debugger
    "statusBar.debuggingBackground": "#410d18",
    "statusBar.debuggingForeground": "#dddddd"
}
</code>```

Body:
I am trying to change the selected text of highlighted text in VS Code. There are 3 ways I can select text.

My current editor settings are:

    "workbench.colorCustomizations": {
        "editor.selectionHighlightBackground": "#e8fc37",
        "editor.wordHighlightBackground": "#e8fc37",
    },

(1) When I first click or select a string of text,then hiting CMD+d, I can select the next occurrences of a string of text:

(2) But if I try to select the text by first searching for it in the same file(CMD+f), then selecting the next occurrences (pressing CMD+d), the color doesn't highlight. The text does in fact highlight, but it's very difficult to tell. You can only really tell by looking in the gutter where the line numbers are.

(3) When I use the Search command (searching among all files; CMD+Shift+f), and I click on one of the search results, even though it clearly tells me what line the text is one, I can't easily tell where in the line the text is being highlighted. This is tricky when the line is longer or filled special characters.

In all these cases, I would like to have the selected text, whether I'm selecting it by using CMD+d or clicking on a result in a search side bar to have the text be dark gray in the foreground, and yellow in the background. I have been able to achieve the background color change, but don't know the editor key for any of the foreground texts.

How can I get selected text to be yellow in the background (which I have done) with dark gray text?

Body:
I finally found a decent solution. Check out 123Dev's response. I just copied the Border key and values and I'm happy enough with it.

"workbench.colorCustomizations": {
    // Totally Transparent
    "editor.selectionHighlightBackground": "#ffffff00",
    "editor.findMatchHighlightBackground": "#ffffff00",
    // Borders
    "editor.findMatchBorder": "#ffff00",
    "editor.findMatchHighlightBorder": "#ff0000",
    "editor.selectionHighlightBorder": "#ffffff",
    "editor.lineHighlightBorder": "#272727",
    // Selection
    "editor.selectionBackground": "#771835",
    "editor.wordHighlightBackground": "#771835",
    // Misc
    "editorCursor.foreground": "#00ff00",
    "editor.lineHighlightBackground": "#181818",
    "editor.findMatchBackground": "#000000",
    // Debugger
    "statusBar.debuggingBackground": "#410d18",
    "statusBar.debuggingForeground": "#dddddd"
}


问:
is there a way to write a clojure function that destructures a map and returns any portion of the map?
I would like to write a function that accepts a specific structure of a map and returns (prints out) any portion of the map I want. Is this possible?

I haven't been successful so far. The following below are the functions I wrote to print portion a, b and c of the map but i seem to be missing some logic in this whole thing.

The test map is {:nums {:test number?}}. My true goal is to return the test value i.e number? or whichever value the user wishes to test e.g symbol? or vector?. This is why I have chosen to use this method.

I wish to understand the logic that's why I have chosen to return all the parts of the map i.e a, b, c.

Thanks.

```<code>(defn des [mapp]
  (let [[a [b c]] [mapp]]
    (println (str a)))
  )
=> #'user/des
(des {:nums {:test number?}})
{:nums {:test #object[clojure.core$number_QMARK_ 0x1089d00e "clojure.core$number_QMARK_@1089d00e"]}}
=> nil

(defn des [mapp]
  (let [[a [b c]] [mapp]]
    (println (str b)))
  )
=> #'user/des
(des {:nums {:test number?}})

=> nil

(defn des [mapp]
  (let [[a [b c]] [mapp]]
    (println (str c)))
  )
=> #'user/des
(des {:nums {:test number?}})

=> nil
</code>```

答:
```<code>(defn des [mapp]
  (let [m mapp
          {x :nums y :vects z :syms} m
          {a :test} x
          {b :test} y
          {c :test} z
          ]
    (println x)
    (println y)
    (println z)
    (println a)
    (println b)
    (println c)
    )
  )
=> #'user/des

(des {:nums {:test number?}})
{:test #object[clojure.core$number_QMARK_ 0x48c86e76 clojure.core$number_QMARK_@48c86e76]}
nil
nil
#object[clojure.core$number_QMARK_ 0x48c86e76 clojure.core$number_QMARK_@48c86e76]
nil
nil
=> nil

(des {:nums {:test number?}, :vects {:test vector?} :syms {:test symbol?}})
{:test #object[clojure.core$number_QMARK_ 0x48c86e76 clojure.core$number_QMARK_@48c86e76]}
{:test #object[clojure.core$vector_QMARK___5399 0x17d504aa clojure.core$vector_QMARK___5399@17d504aa]}
{:test #object[clojure.core$symbol_QMARK_ 0x4593ff34 clojure.core$symbol_QMARK_@4593ff34]}
#object[clojure.core$number_QMARK_ 0x48c86e76 clojure.core$number_QMARK_@48c86e76]
#object[clojure.core$vector_QMARK___5399 0x17d504aa clojure.core$vector_QMARK___5399@17d504aa]
#object[clojure.core$symbol_QMARK_ 0x4593ff34 clojure.core$symbol_QMARK_@4593ff34]
=> nil
</code>```

Body:
I would like to write a function that accepts a specific structure of a map and returns (prints out) any portion of the map I want. Is this possible?

I haven't been successful so far. The following below are the functions I wrote to print portion a, b and c of the map but i seem to be missing some logic in this whole thing.

The test map is {:nums {:test number?}}. My true goal is to return the test value i.e number? or whichever value the user wishes to test e.g symbol? or vector?. This is why I have chosen to use this method.

I wish to understand the logic that's why I have chosen to return all the parts of the map i.e a, b, c.

Thanks.

(defn des [mapp]
  (let [[a [b c]] [mapp]]
    (println (str a)))
  )
=> #'user/des
(des {:nums {:test number?}})
{:nums {:test #object[clojure.core$number_QMARK_ 0x1089d00e "clojure.core$number_QMARK_@1089d00e"]}}
=> nil

(defn des [mapp]
  (let [[a [b c]] [mapp]]
    (println (str b)))
  )
=> #'user/des
(des {:nums {:test number?}})

=> nil

(defn des [mapp]
  (let [[a [b c]] [mapp]]
    (println (str c)))
  )
=> #'user/des
(des {:nums {:test number?}})

=> nil


问:
How to use data for more than one UIPickerView using didSelectRow
Got a problem, cannot figure out how to use data from more than UIPickerView using didSelectRow method.

Problem is that components and rows are not separate, is there any chance to use separate rows and components?

Im trying to change label.text to some data from arrays, but it changes in other arrays even when im changing one pickerview.

```<code>func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        resultLabel1.text = "\(pickerData![component][row]) \(timeNumber[row - 1]) \(timePickerData[row - 1])"

      //    print(component)
      //  print(unitsPickerView.selectedRow(inComponent: component))
      //  print(pickerData![component][row])

    }
</code>```

答:
You can you an if statement inside didSelectRow to check which UIPickerView is currently being used, then take actions accordingly. Something like:</p>

```<code>func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        if pickerView == unitsPickerView {
            // do stuff
        } else {
            // do some other stuff
        }
    }
</code>```

Body:
Got a problem, cannot figure out how to use data from more than UIPickerView using didSelectRow method.

Problem is that components and rows are not separate, is there any chance to use separate rows and components?

Im trying to change label.text to some data from arrays, but it changes in other arrays even when im changing one pickerview.

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        resultLabel1.text = "\(pickerData![component][row]) \(timeNumber[row - 1]) \(timePickerData[row - 1])"

      //    print(component)
      //  print(unitsPickerView.selectedRow(inComponent: component))
      //  print(pickerData![component][row])

    }

Body:
You can you an if statement inside didSelectRow to check which UIPickerView is currently being used, then take actions accordingly. Something like:

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        if pickerView == unitsPickerView {
            // do stuff
        } else {
            // do some other stuff
        }
    }


问:
How do modern compilers use mmx/3dnow/sse instructions?
I've been reading up on the x86 instruction set extensions, and they only seem useful in some quite specific circumstances (eg HADDPD - (Horizontal-Add-Packed-Double) in SSE3). These require a certain register layout that needs to be either deliberately set up, or occur from the series of instructions before it. How often do general-purpose compilers like gcc actually use these instructions (or a subset thereof), or are they mainly to be used in hand-coded assembler? How does the compiler detect where it is appropriate to use SIMD instructions?</p>

答:
I have seen gcc use sse to zero out a default std::string object. Not a particularly powerful use of sse, but it exists. In most cases, though you will have to write your own.

I know this because I had allowed the stack to become unaligned and it crashed, otherwise I probably wouldn't have noticed!

ContentLicense: CC BY-SA 2.5


问:
When will Thread.Abort() not actually abort?
So you read the title, when will Thread.Abort() not actually abort? I've heard lots of people say that its a dangerous command and that it is never guaranteed to work, but ive never actually been able to reproduce that. It's always worked for me..

Is there any specific situations that might cause Thread.Abort() to fail consistantly?

答: There is also a situation where the Thread.Abort() call does not fail, but the thread does not terminate.  The ThreadAbortException that is thrown can be caught by the thread itself.  If it does and then calls Thread.ResetAbort() within the catch handler, the ThreadAbortException will not be rethrown at the end of the catch block.</p>


问:
Can't Download PyQt5 on Python
I'm using Pycharm and when i try to download pyqt5 package, I'm getting an error like this.

```<code>  Failed building wheel for PyQt5-sip
  Running setup.py clean for PyQt5-sip
Failed to build PyQt5-sip
Could not build wheels for PyQt5-sip which use PEP 517 and cannot be installed directly
</code>```

What could be the problem ?

答:
You have to upgrade pip and then install pyqt5:</p>

```<code>python3 -m pip install --upgrade pip
python3 -m pip install pyqt5
</code>```

Title: Can't Download PyQt5 on Python

Body:
I'm using Pycharm and when i try to download pyqt5 package, I'm getting an error like this.

  Failed building wheel for PyQt5-sip
  Running setup.py clean for PyQt5-sip
Failed to build PyQt5-sip
Could not build wheels for PyQt5-sip which use PEP 517 and cannot be installed directly

What could be the problem ?

Body:
You have to upgrade pip and then install pyqt5:

python3 -m pip install --upgrade pip
python3 -m pip install pyqt5


问:
Generate unique string for each db object
I have a model where I need to create a UNIQUE string for each object in the db.

I've made a function to generate the string, but I can create an object using the django admin once, and then the second time it will error out and say that the value is not unique.

What can I do so Django just generates a new string if the previous one was used already?

models.py

```<code>def randomword(length):
   letters = string.ascii_lowercase
   return ''.join(random.choice(letters) for i in range(length))

class Refferal(models.Model):
    email = models.EmailField(max_length=254, unique=True)
    coupon = models.CharField(default=randomword(4), primary_key=True, editable=False, max_length=4)
    count = models.IntegerField(default=0)
</code>```

Log output from when I try to create the second object using the admin
The above exception was the direct cause of the following exception:

```<code>Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py", line 607, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/sites.py", line 231, in inner
    return view(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1638, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
  File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1522, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1565, in _changeform_view
    self.save_model(request, new_object, form, not add)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1081, in save_model
    obj.save()
  File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 746, in save
    force_update=force_update, update_fields=update_fields)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 784, in save_base
    force_update, using, update_fields,
  File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 887, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 926, in _do_insert
    using=using, raw=raw,
  File "/usr/local/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1204, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1384, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "index_refferal_coupon_a6e4bc31_pk"
DETAIL:  Key (coupon)=(vtgs) already exists.
</code>```

答:
You here will evaluate eagerly the call randomword(4), and set the result of that function call as default value. You can however pass a callable:

```<code>def randomword(length):
   letters = string.ascii_lowercase
   return ''.join(random.choice(letters) for i in range(length))

def <b>random4</b>():
    return randomword(4)

class Refferal(models.Model):
    email = models.EmailField(max_length=254, unique=True)
    coupon = models.CharField(default=<b>random4</b>, primary_key=True, editable=False, max_length=4)
    count = models.IntegerField(default=0)</code>```

Note that we do not call the function. We only pass a reference to the function.

That being said, it might be better to use Django's UUIDField [Django-doc]. This is made to store and generate random UUIDs, which are likely better sources of random strings.

Body:
I have a model where I need to create a UNIQUE string for each object in the db.

I've made a function to generate the string, but I can create an object using the django admin once, and then the second time it will error out and say that the value is not unique.

What can I do so Django just generates a new string if the previous one was used already?

models.py

def randomword(length):
   letters = string.ascii_lowercase
   return ''.join(random.choice(letters) for i in range(length))

class Refferal(models.Model):
    email = models.EmailField(max_length=254, unique=True)
    coupon = models.CharField(default=randomword(4), primary_key=True, editable=False, max_length=4)
    count = models.IntegerField(default=0)

Log output from when I try to create the second object using the admin
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py", line 607, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/sites.py", line 231, in inner
    return view(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1638, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
  File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1522, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1565, in _changeform_view
    self.save_model(request, new_object, form, not add)
  File "/usr/local/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1081, in save_model
    obj.save()
  File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 746, in save
    force_update=force_update, update_fields=update_fields)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 784, in save_base
    force_update, using, update_fields,
  File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 887, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 926, in _do_insert
    using=using, raw=raw,
  File "/usr/local/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1204, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1384, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "index_refferal_coupon_a6e4bc31_pk"
DETAIL:  Key (coupon)=(vtgs) already exists.

Body:
You here will evaluate eagerly the call randomword(4), and set the result of that function call as default value. You can however pass a callable:

def randomword(length):
   letters = string.ascii_lowercase
   return ''.join(random.choice(letters) for i in range(length))

def random4():
    return randomword(4)

class Refferal(models.Model):
    email = models.EmailField(max_length=254, unique=True)
    coupon = models.CharField(default=random4, primary_key=True, editable=False, max_length=4)
    count = models.IntegerField(default=0)

Note that we do not call the function. We only pass a reference to the function.

That being said, it might be better to use Django's UUIDField [Django-doc]. This is made to store and generate random UUIDs, which are likely better sources of random strings.


问:
Remove scripts from html string using regex
I want to remove

but this won't:

How can I update the regex to fix this?

答:
try this regex

```<code>/<script.*?>.*?<\/script>/igm
</code>```

https://stackoverflow.com/a/15816902/5812095

Body:
try this regex

/<script.*?>.*?<\/script>/igm

https://stackoverflow.com/a/15816902/5812095


问:
Get multiline text from textarea with Selenium VBA
I need to get multiline text from textarea element of web-page. I see in Chrome developer tool that text I need is stored in value property of textarea.
I marked it on screenshot

Below is fragment of page source:

```<code><div id="team1">
 <div id="lineupsPanel1" style="display: block;">
  <textarea id="lineupsField1" placeholder="Enter text for analyze here"></textarea>
  <button onclick="viewLineupsInTable(1,1)" title="Process text" style="cursor: pointer; font-weight: bold; color: red; padding: 3px 6px; margin: 0px 4px
  0px 0px;">Process</button>
</code>```

I try below code to get text from value property

Set WebElemTextBox = Chrome.FindElementById("lineupsField1")
If Not (WebElemTextBox Is Nothing) Then
    TextVar = WebElemTextBox.value
End If
```

But so TextVar gets only first line of stored text (on screenshot example

 value: "Next items are not found:↵↵Pam-pam↵↵Next items are found:↵↵Monitor"

But TextVar gets only "Next items are not found:" ).

How to get full multiline text?

I also found some answers to use something like

TextVar = WebElemTextBox.getAttribute("value")

But I get
"Run-time error: 438. Object doesn't support this property or method"
on that string while testing.

UPDATE. I figured out the problem myself:

When you watch value of the variable by moving cursor to it - then for string variable is showing only first line of text without any mark (three dots or something else). We should use Watch Window instead to not to be cheated.
So method TextVar = WebElemTextBox.value works well.

答:
If possible posting the HTML would be helpful, but I'll try answering it anyway.

First Check your element Id for each line you wish to make into a string, I'm assuming they are sequential. Something like "lineupsField1", "lineupsField2", lineupsField3" etc.

If so you can loop through and append these values to a string. Ex:

```<code>For i = 1 to 10
    Set WebElemTextBox = Chrome.FindElementById("lineupsField" & i)
    If Not (WebElemTextBox Is Nothing) Then
        TextVar = TextVar & WebElemTextBox.value
    End If
Next
</code>```

If the element Id's are not in sequential order than instead of looping just append till you reach your goal. Ex:

```<code>Set WebElemTextBox = Chrome.FindElementById("lineupsField1")
    If Not (WebElemTextBox Is Nothing) Then
        TextVar = TextVar & WebElemTextBox.value
    End If

Set WebElemTextBox = Chrome.FindElementById("Element2")
    If Not (WebElemTextBox Is Nothing) Then
        TextVar = TextVar & WebElemTextBox.value
    End If
</code>```

As far as the other method you showed:

```<code>TextVar = WebElement.getAttribute("value")
</code>```

I wouldn't recommend going down this path as you are likely going to create more work for yourself parsing through all the values in the HTML.

Body:
I need to get multiline text from textarea element of web-page. I see in Chrome developer tool that text I need is stored in value property of textarea.
I marked it on screenshot

Below is fragment of page source:

  <textarea id="lineupsField1" placeholder="Enter text for analyze here"></textarea>
  <button onclick="viewLineupsInTable(1,1)" title="Process text" style="cursor: pointer; font-weight: bold; color: red; padding: 3px 6px; margin: 0px 4px
  0px 0px;">Process</button>

I try below code to get text from value property

Set WebElemTextBox = Chrome.FindElementById("lineupsField1")
If Not (WebElemTextBox Is Nothing) Then
    TextVar = WebElemTextBox.value
End If

But so TextVar gets only first line of stored text (on screenshot example

 value: "Next items are not found:↵↵Pam-pam↵↵Next items are found:↵↵Monitor"

But TextVar gets only "Next items are not found:" ).

How to get full multiline text?

I also found some answers to use something like

TextVar = WebElemTextBox.getAttribute("value")

But I get
"Run-time error: 438. Object doesn't support this property or method"
on that string while testing.

UPDATE. I figured out the problem myself:

When you watch value of the variable by moving cursor to it - then for string variable is showing only first line of text without any mark (three dots or something else). We should use Watch Window instead to not to be cheated.
So method TextVar = WebElemTextBox.value works well.

Body:
If possible posting the HTML would be helpful, but I'll try answering it anyway.

First Check your element Id for each line you wish to make into a string, I'm assuming they are sequential. Something like "lineupsField1", "lineupsField2", lineupsField3" etc.

If so you can loop through and append these values to a string. Ex:

For i = 1 to 10
    Set WebElemTextBox = Chrome.FindElementById("lineupsField" & i)
    If Not (WebElemTextBox Is Nothing) Then
        TextVar = TextVar & WebElemTextBox.value
    End If
Next

If the element Id's are not in sequential order than instead of looping just append till you reach your goal. Ex:

Set WebElemTextBox = Chrome.FindElementById("lineupsField1")
    If Not (WebElemTextBox Is Nothing) Then
        TextVar = TextVar & WebElemTextBox.value
    End If

Set WebElemTextBox = Chrome.FindElementById("Element2")
    If Not (WebElemTextBox Is Nothing) Then
        TextVar = TextVar & WebElemTextBox.value
    End If

As far as the other method you showed:

TextVar = WebElement.getAttribute("value")

I wouldn't recommend going down this path as you are likely going to create more work for yourself parsing through all the values in the HTML.


问:
is there any way to convert string with hypen into integer in java(Android sdk)
I am trying below code to convert string into Int but it is showing exception

```<code>String ID = "37f6c80-2d5-44c-82f-0001a40cf4"
int boardid = Integer.parseInt(ID);
</code>```

Exception is :

```<code>java.lang.NumberFormatException: For input string:
</code>```

I can handle exception by writing it in try and catch, but the problem is there any way I can convert it into int?

答:
You could use Long object type but not int for this data:

```<code>public Long numberify(String number) {
    Long result = Long.parseLong(number.replaceAll("[a-zA-Z|-]", ""));
    return result;
}
</code>```

Body:
I am trying below code to convert string into Int but it is showing exception

String ID = "37f6c80-2d5-44c-82f-0001a40cf4"
int boardid = Integer.parseInt(ID);

Exception is :

java.lang.NumberFormatException: For input string:

I can handle exception by writing it in try and catch, but the problem is there any way I can convert it into int?

Body:
You could use Long object type but not int for this data:

public Long numberify(String number) {
    Long result = Long.parseLong(number.replaceAll("[a-zA-Z|-]", ""));
    return result;
}


问:
Boxplots/histograms for multiple variables in R
I have a big dataset with +100 observation and 68 variables.
I was wondering whether there might be a way to generate plots and histograms for all those variables at once without having to write down the code for a boxplot/histogram one by one, and save them in a folder as pns or in a pdf.

possibly I'd like to have more than one plot on the same page (i know you can do that using "par")

I know is probably a simple piece of coding but it would be really helpful for me.
Thank you

Ok I think an example could be the data from the iris dataset:

"Sepal.Length Sepal.Width Petal.Length Petal.Width Species

1          5.1         3.5          1.4         0.2  setosa

2          4.9         3.0          1.4         0.2  setosa

3          4.7         3.2          1.3         0.2  setosa

4          4.6         3.1          1.5         0.2  setosa

5          5.0         3.6          1.4         0.2  setosa

6          5.4         3.9          1.7         0.4  setosa"

But instead of having just "Sepal.Length Sepal.Width Petal.Length Petal.Width " as observed variables, I  have 68 of them.
My interest is to check normality distribution for the sample on all my 68 variables and boxplot . I know how to create boxplots and histogram variable per variable, but that would take a lot of time and I  imagine there must be a way to do it at once, probably using a loop or a %>% ?

答:
Take a look at the DataExplorer, skimr and inspectdf packages. They all produce summaries like the one you want. These articles give an overview:

https://www.littlemissdata.com/blog/simple-eda

https://www.littlemissdata.com/blog/inspectdf


问:
Failed to introspect Class [org.keycloak.adapters.springboot.KeycloakAutoConfiguration]
I'm trying to work with KeyCloak for creating an SSO application and found a startup app but I'm facing errors with my POM file and I tried to do Clean maven and Install and it got build successfully. I have used latest version of each debency in my POM file. Please advice on what could be the reason for these errors :

POM File :

```<code><modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung.keycloak</groupId>
<artifactId>spring-boot-keycloak</artifactId>
<version>0.0.1</version>
<name>spring-boot-keycloak</name>
<packaging>jar</packaging>
<description>This is a simple application demonstrating integration between Keycloak and Spring Boot.</description>

<parent>
    <groupId>com.baeldung</groupId>
    <artifactId>parent-boot-1</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>../parent-boot-1</relativePath>
</parent>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.keycloak.bom</groupId>
            <artifactId>keycloak-adapter-bom</artifactId>
            <version>${keycloak-adapter-bom.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.keycloak</groupId>
        <artifactId>keycloak-spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<properties>
    <keycloak-adapter-bom.version>3.3.0.Final</keycloak-adapter-bom.version>
</properties>
</code>```

the errors i'm getting when I run the code :

```<code>    Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
2019-12-21 21:46:12.107  INFO 5076 --- [           main] sa.gov.saip.scanner.ScannerApplication   : Starting ScannerApplication on saip-ddrees with PID 5076 (started by ddrees in C:\Users\ddrees\Documents\New folder\E.Services)
2019-12-21 21:46:12.115 DEBUG 5076 --- [           main] sa.gov.saip.scanner.ScannerApplication   : Running with Spring Boot v2.2.2.RELEASE, Spring v5.2.2.RELEASE
2019-12-21 21:46:12.116  INFO 5076 --- [           main] sa.gov.saip.scanner.ScannerApplication   : No active profile set, falling back to default profiles: default
2019-12-21 21:46:14.620 ERROR 5076 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration.mbeanExporter
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:184) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:337) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:242) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at sa.gov.saip.scanner.ScannerApplication.main(ScannerApplication.java:10) ~[classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.keycloak.adapters.springboot.KeycloakAutoConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@2626b418]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:358) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:414) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$2(AbstractAutowireCapableBeanFactory.java:743) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705) ~[na:na]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:742) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:681) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:649) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1604) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:520) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:491) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:230) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:223) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:213) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:167) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:142) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    ... 17 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/EmbeddedServletContainerCustomizer
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3167) ~[na:na]
    at java.base/java.lang.Class.getDeclaredMethods(Class.java:2310) ~[na:na]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    ... 33 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
    ... 37 common frames omitted

2019-12-21 21:46:14.628  WARN 5076 --- [           main] o.s.boot.SpringApplication               : Unable to close ApplicationContext

java.lang.IllegalStateException: Failed to introspect Class [org.keycloak.adapters.springboot.KeycloakAutoConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@2626b418]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:358) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:414) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$2(AbstractAutowireCapableBeanFactory.java:743) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705) ~[na:na]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:742) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:681) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:649) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1604) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:520) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:491) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:613) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:605) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1242) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.getExitCodeFromMappedException(SpringApplication.java:869) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.getExitCodeFromException(SpringApplication.java:857) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.handleExitCode(SpringApplication.java:844) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:795) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at sa.gov.saip.scanner.ScannerApplication.main(ScannerApplication.java:10) ~[classes/:na]
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/EmbeddedServletContainerCustomizer
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3167) ~[na:na]
    at java.base/java.lang.Class.getDeclaredMethods(Class.java:2310) ~[na:na]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    ... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
    ... 25 common frames omitted

Process finished with exit code 1
</code>```

答:
This particular problem was solved for me when I changed the dependency management entry to this:</p>

```<code>         <dependency>
            <groupId>org.keycloak.bom</groupId>
            <artifactId>keycloak-adapter-bom</artifactId>
            <version>9.0.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
</code>```

Body:
I'm trying to work with KeyCloak for creating an SSO application and found a startup app but I'm facing errors with my POM file and I tried to do Clean maven and Install and it got build successfully. I have used latest version of each debency in my POM file. Please advice on what could be the reason for these errors :

POM File :

<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung.keycloak</groupId>
<artifactId>spring-boot-keycloak</artifactId>
<version>0.0.1</version>
<name>spring-boot-keycloak</name>
<packaging>jar</packaging>
<description>This is a simple application demonstrating integration between Keycloak and Spring Boot.</description>

<parent>
    <groupId>com.baeldung</groupId>
    <artifactId>parent-boot-1</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>../parent-boot-1</relativePath>
</parent>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.keycloak.bom</groupId>
            <artifactId>keycloak-adapter-bom</artifactId>
            <version>${keycloak-adapter-bom.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.keycloak</groupId>
        <artifactId>keycloak-spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<properties>
    <keycloak-adapter-bom.version>3.3.0.Final</keycloak-adapter-bom.version>
</properties>

the errors i'm getting when I run the code :

    Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
2019-12-21 21:46:12.107  INFO 5076 --- [           main] sa.gov.saip.scanner.ScannerApplication   : Starting ScannerApplication on saip-ddrees with PID 5076 (started by ddrees in C:\Users\ddrees\Documents\New folder\E.Services)
2019-12-21 21:46:12.115 DEBUG 5076 --- [           main] sa.gov.saip.scanner.ScannerApplication   : Running with Spring Boot v2.2.2.RELEASE, Spring v5.2.2.RELEASE
2019-12-21 21:46:12.116  INFO 5076 --- [           main] sa.gov.saip.scanner.ScannerApplication   : No active profile set, falling back to default profiles: default
2019-12-21 21:46:14.620 ERROR 5076 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration.mbeanExporter
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:184) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:337) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:242) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at sa.gov.saip.scanner.ScannerApplication.main(ScannerApplication.java:10) ~[classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.keycloak.adapters.springboot.KeycloakAutoConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@2626b418]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:358) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:414) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$2(AbstractAutowireCapableBeanFactory.java:743) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705) ~[na:na]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:742) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:681) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:649) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1604) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:520) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:491) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:230) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:223) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:213) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:167) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:142) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    ... 17 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/EmbeddedServletContainerCustomizer
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3167) ~[na:na]
    at java.base/java.lang.Class.getDeclaredMethods(Class.java:2310) ~[na:na]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    ... 33 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
    ... 37 common frames omitted

2019-12-21 21:46:14.628  WARN 5076 --- [           main] o.s.boot.SpringApplication               : Unable to close ApplicationContext

java.lang.IllegalStateException: Failed to introspect Class [org.keycloak.adapters.springboot.KeycloakAutoConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@2626b418]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:358) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:414) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$2(AbstractAutowireCapableBeanFactory.java:743) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705) ~[na:na]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:742) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:681) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:649) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1604) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:520) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:491) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:613) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:605) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1242) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.getExitCodeFromMappedException(SpringApplication.java:869) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.getExitCodeFromException(SpringApplication.java:857) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.handleExitCode(SpringApplication.java:844) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:795) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at sa.gov.saip.scanner.ScannerApplication.main(ScannerApplication.java:10) ~[classes/:na]
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/EmbeddedServletContainerCustomizer
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3167) ~[na:na]
    at java.base/java.lang.Class.getDeclaredMethods(Class.java:2310) ~[na:na]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    ... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
    ... 25 common frames omitted

Process finished with exit code 1

Body:
This particular problem was solved for me when I changed the dependency management entry to this:

         <dependency>
            <groupId>org.keycloak.bom</groupId>
            <artifactId>keycloak-adapter-bom</artifactId>
            <version>9.0.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>


问:
Webscraping with http shows "Web page blocked"
I am trying to scrape http website using proxies and when I am trying to extract text, it shows as "Web page Blocked". How could I avoid this error?

My code is as follows

```<code>url = "http://campanulaceae.myspecies.info/"

proxy_dict = {
          'http'  : "174.138.54.49:8080",
          'https' : "174.138.54.49:8080"
        }

page = requests.get(url, proxies=proxy_dict)
soup = BeautifulSoup(page.text,'html.parser')
print(soup)

</code>```

I get below output when I am trying to output text from the website.

```<code><html>
<head>
<title>Web Page Blocked</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<meta content="NO-CACHE" http-equiv="PRAGMA"/>
<meta content="initial-scale=1.0" name="viewport"/>
........
<body bgcolor="#e7e8e9">
<div id="content">
<h1>Web Page Blocked</h1>
<p>Access to the web page you were trying to visit has been blocked in accordance with company policy. Please contact your system administrator if you believe this is in error.</p>

</code>```

答:
Because you did not specify a user-agent for the request headers.
Quite often, sites block requests that come from robot-like sources.
Try it like this:

headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36'}

page = requests.get(url, headers=headers, proxies=proxy_dict)
```

Body:
I am trying to scrape http website using proxies and when I am trying to extract text, it shows as "Web page Blocked". How could I avoid this error?

My code is as follows

url = "http://campanulaceae.myspecies.info/"

proxy_dict = {
          'http'  : "174.138.54.49:8080",
          'https' : "174.138.54.49:8080"
        }

page = requests.get(url, proxies=proxy_dict)
soup = BeautifulSoup(page.text,'html.parser')
print(soup)

I get below output when I am trying to output text from the website.

<title>Web Page Blocked</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<meta content="NO-CACHE" http-equiv="PRAGMA"/>
<meta content="initial-scale=1.0" name="viewport"/>
........

Web Page Blocked

Access to the web page you were trying to visit has been blocked in accordance with company policy. Please contact your system administrator if you believe this is in error.


问:
Argon2 is difficult to get working with Angular 8 on MacOS: actually not working at all
I am working with:

MacOS Mojave

Angular 8

node v12.12.0

npm v6.13.4

and trying to make Argon2 to work in my Angular 8 app.

In order to use Argon2 it is required to install gcc and node-gyp globally.
I did install them as indicated on the npm pages of Argon2. GCC v9 was installed. But, I had repeatedly problems executing:

```<code>CXX=g++-9 npm install
</code>```

I kept getting errors about stdlib++ . I tried using Apple's CLang++ and got a successful build with:

```<code>CXX=clang++ npm install
</code>```

I imported argon2 in my angular project in order to do password hashing and verification. Hashing seems to be working well (no errors) but as soon as I import argon2.verify() and use it in my code (by making a verify-call) I will get an error when trying to execute npm run start. Just trying to start the httpserver secured (ssl/tls) with corresponding private key and certificate.

The error I get is some mysterious error:

```<code>ERROR in ./node_modules/node-gyp-build/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/[username-deleted]/WebstormProjects/my-app/node_modules/node-gyp-build'
</code>```

I have seen comments and complaints on probably similar problems on internet and people referring to some adjustment in a Webpack config file but at this point I dont have this config file in my project. I tried other versions of node-gyp-build but not resolved.
Apparently argon2.hash() (its usage) is working without causing problems, but as soon as I introduce argon2.verify() in my code and run my app with npm run start I get the above error.

Any one with similar problem and how this problem was resolved?

答:
I had the same issue and fixed it by installing the Xcode Command Line Tools:

xcode-select --install

npm upgrade

npm install argon2 --save-dev

Hope it helps.

Body:
I am working with:

MacOS Mojave

Angular 8

node v12.12.0

npm v6.13.4

and trying to make Argon2 to work in my Angular 8 app.

In order to use Argon2 it is required to install gcc and node-gyp globally.
I did install them as indicated on the npm pages of Argon2. GCC v9 was installed. But, I had repeatedly problems executing:

CXX=g++-9 npm install

I kept getting errors about stdlib++ . I tried using Apple's CLang++ and got a successful build with:

CXX=clang++ npm install

I imported argon2 in my angular project in order to do password hashing and verification. Hashing seems to be working well (no errors) but as soon as I import argon2.verify() and use it in my code (by making a verify-call) I will get an error when trying to execute npm run start. Just trying to start the httpserver secured (ssl/tls) with corresponding private key and certificate.

The error I get is some mysterious error:

ERROR in ./node_modules/node-gyp-build/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/[username-deleted]/WebstormProjects/my-app/node_modules/node-gyp-build'

I have seen comments and complaints on probably similar problems on internet and people referring to some adjustment in a Webpack config file but at this point I dont have this config file in my project. I tried other versions of node-gyp-build but not resolved.
Apparently argon2.hash() (its usage) is working without causing problems, but as soon as I introduce argon2.verify() in my code and run my app with npm run start I get the above error.

Any one with similar problem and how this problem was resolved?


问:
Pandas apply operation on each pair of rows
Same value is repeating in the dataframe column while calculating the distance between langitude and longitude . I have created a dynamic column for finding the distance between every source to destination but all the values of each column is repeating.

```<code>for a,b,x in zip(df.Longitude,df.Latitude,df.index):
    for c,d in zip(df.Longitude,df.Latitude):
        df['distance_'+str(x)]=haversine(a,b,c,d)
</code>```

suppose this is the dataframe

```<code>  index   name   lat     long

    0      a     74.299104  31.481188

    1      b     74.351619  39.481188

    2      c     73.351619  39.481188
</code>```

now i want the expected result like this

```<code>  index   name   lat          long     distanceA      distanceB     distanceC

    0      a     74.299104  31.481188      0             4.5          2.4

    1      b     74.351619  39.481188     5.7             0           5.8

    2      c     73.351619  39.481188     3.8            1.3           0
</code>```

答:
You can try something like this using a self-join to get all combinations:

```<code>df_m = df.assign(key=1).merge(df.assign(key=1), on='key', suffixes=('','_y'))
df_m['distance'] = df_m.apply(lambda x: haversine((x.lat, x.long),(x.lat_y, x.long_y),
                                                   unit=Unit.MILES),
                              axis=1)
df_mat = (df_m.set_index(df.columns.to_list()+['name_y'])['distance']
              .unstack()
              .add_prefix('distance')
              .reset_index())

df.merge(df_mat)
</code>```

Output:

```<code>  name        lat       long   distancea   distanceb   distancec
0    a  74.299104  31.481188    0.000000  149.269583  167.150147
1    b  74.351619  39.481188  149.269583    0.000000   69.093420
2    c  73.351619  39.481188  167.150147   69.093420    0.000000
</code>```

Body:
Same value is repeating in the dataframe column while calculating the distance between langitude and longitude . I have created a dynamic column for finding the distance between every source to destination but all the values of each column is repeating.

for a,b,x in zip(df.Longitude,df.Latitude,df.index):
    for c,d in zip(df.Longitude,df.Latitude):
        df['distance_'+str(x)]=haversine(a,b,c,d)

suppose this is the dataframe

  index   name   lat     long

    0      a     74.299104  31.481188

    1      b     74.351619  39.481188

    2      c     73.351619  39.481188

now i want the expected result like this

  index   name   lat          long     distanceA      distanceB     distanceC

    0      a     74.299104  31.481188      0             4.5          2.4

    1      b     74.351619  39.481188     5.7             0           5.8

    2      c     73.351619  39.481188     3.8            1.3           0

Body:
You can try something like this using a self-join to get all combinations:

df_m = df.assign(key=1).merge(df.assign(key=1), on='key', suffixes=('','_y'))
df_m['distance'] = df_m.apply(lambda x: haversine((x.lat, x.long),(x.lat_y, x.long_y),
                                                   unit=Unit.MILES),
                              axis=1)
df_mat = (df_m.set_index(df.columns.to_list()+['name_y'])['distance']
              .unstack()
              .add_prefix('distance')
              .reset_index())

df.merge(df_mat)

Output:

  name        lat       long   distancea   distanceb   distancec
0    a  74.299104  31.481188    0.000000  149.269583  167.150147
1    b  74.351619  39.481188  149.269583    0.000000   69.093420
2    c  73.351619  39.481188  167.150147   69.093420    0.000000


问:
Query to Snowflake database isn't working because no active warehouse is selected
I'm able to successfully connect to the Snowflake database via R but I'm having trouble getting the data because no active warehouse is selected. Below is the error message:

No active warehouse selected in the current session. Select an active warehouse with the 'use warehouse' command.

Here is my code I'm using.

```<code>  con <- DBI::dbConnect(
    odbc::odbc(),
    UID    = user,
    PWD    = pass,
    Server = host,
    Warehouse = 'YOUR_WAREHOUSE_NAME',
    Driver = "SnowflakeDSIIDriver",
    Role = role,
    Database = database,
    Autthenticator = "external browser"
  )

dbGetQuery(con, "SELECT * FROM MY_TABLE LIMIT 100")
</code>```

I've based my connection and query from this thread on RStudio Community but I'm not having any luck. I've also tried using the 'use warehouse MY_WAREHOUSE' command in my query without any luck.

Note: I can connect successfully and query data via Python so I think this is an R specific issue.

答:
Seems like an R bug IMHO if the python equivalent code is fine

Your role can have a default warehouse assigned, perhaps it is blank and requires it need be specified upon connection; and a bug in the R code is stopping it from being set?

Body:
I'm able to successfully connect to the Snowflake database via R but I'm having trouble getting the data because no active warehouse is selected. Below is the error message:

No active warehouse selected in the current session. Select an active warehouse with the 'use warehouse' command.

Here is my code I'm using.

  con <- DBI::dbConnect(
    odbc::odbc(),
    UID    = user,
    PWD    = pass,
    Server = host,
    Warehouse = 'YOUR_WAREHOUSE_NAME',
    Driver = "SnowflakeDSIIDriver",
    Role = role,
    Database = database,
    Autthenticator = "external browser"
  )

dbGetQuery(con, "SELECT * FROM MY_TABLE LIMIT 100")

I've based my connection and query from this thread on RStudio Community but I'm not having any luck. I've also tried using the 'use warehouse MY_WAREHOUSE' command in my query without any luck.

Note: I can connect successfully and query data via Python so I think this is an R specific issue.


问:
How to use a function member of an object from an array passed to a function by pointer?
So here are 2 functions I am working on :

```<code>void Ville::sous_la_moyenne( int moyenne, Tableau<Quartier>* quartiersSousMoyenne )
{
    for( int i = 0; i < nbQuartiers_; i++ )
    {
        if( quartiers_[i].get_revenuMoyen() < moyenne )
        {
            quartiersSousMoyenne->ajouter( quartiers_[i] );
        }
    }
}

void Ville::afficher_quartier_sous_moy( Tableau<Quartier>* quartiersSousMoyenne )
{
    for( int i = 0; i < quartiersSousMoyenne->taille(); i++ )
    {
        cout << quartiersSousMoyenne[i]->get_nom() << " Revenu moyen:"
        << quartiersSousMoyenne[i]->set_revenuMoyen() << endl;
    }
}
</code>```

This doesn't work :
- quartiersSousMoyenne[i]->get_nom()
- quartiersSousMoyenne[i]->set_revenuMoyen()

I tried :
- quartiersSousMoyenne[i].get_nom()
- *( quartiersSousMoyenne[i] ).get_nom()
- *quartiersSousMoyenne[i].get_nom()
- *(quartiersSousMoyenne + i).get_nom()

It says: "No member named 'set_revenuMoyen' in 'Tableau'"

If you see in the first function, named sous_la_moyenne, there is an instance of Tableau named quartiers_. I access its element with [i] and I then use the function get_revenuMoyen() which is a function of the class Quartier.

I would like now to do the same thing but for a pointer of Tableau... if that's even possible.

I successfully make it work w/o pointer, but I don't want to make a copy of an object.

P.S. Don't try to understand the meaning of the variables names... I speak french :D. Tableau means array though - This one's important.

答:
Actually TheArquitect gave me a good advice. He said it's better to use & (reference), instead of * (pointer) to pass an object.

It works like this :

```<code>void Ville::afficher_quartier_sous_moy( Tableau<Quartier>& quartiersSousMoyenne )
{
    for( int i = 0; i < quartiersSousMoyenne.taille(); i++ )
    {
        cout << quartiersSousMoyenne[i].get_nom() << " Revenu moyen:"
        << quartiersSousMoyenne[i].get_revenuMoyen() << endl;
    }
}
</code>```

I consider the case solved.

Body:
So here are 2 functions I am working on :

void Ville::sous_la_moyenne( int moyenne, Tableau<Quartier>* quartiersSousMoyenne )
{
    for( int i = 0; i < nbQuartiers_; i++ )
    {
        if( quartiers_[i].get_revenuMoyen() < moyenne )
        {
            quartiersSousMoyenne->ajouter( quartiers_[i] );
        }
    }
}

void Ville::afficher_quartier_sous_moy( Tableau<Quartier>* quartiersSousMoyenne )
{
    for( int i = 0; i < quartiersSousMoyenne->taille(); i++ )
    {
        cout << quartiersSousMoyenne[i]->get_nom() << " Revenu moyen:"
        << quartiersSousMoyenne[i]->set_revenuMoyen() << endl;
    }
}

This doesn't work :
- quartiersSousMoyenne[i]->get_nom()
- quartiersSousMoyenne[i]->set_revenuMoyen()

I tried :
- quartiersSousMoyenne[i].get_nom()
- *( quartiersSousMoyenne[i] ).get_nom()
- *quartiersSousMoyenne[i].get_nom()
- *(quartiersSousMoyenne + i).get_nom()

It says: "No member named 'set_revenuMoyen' in 'Tableau'"

If you see in the first function, named sous_la_moyenne, there is an instance of Tableau named quartiers_. I access its element with [i] and I then use the function get_revenuMoyen() which is a function of the class Quartier.

I would like now to do the same thing but for a pointer of Tableau... if that's even possible.

I successfully make it work w/o pointer, but I don't want to make a copy of an object.

P.S. Don't try to understand the meaning of the variables names... I speak french :D. Tableau means array though - This one's important.

Body:
Actually TheArquitect gave me a good advice. He said it's better to use & (reference), instead of * (pointer) to pass an object.

It works like this :

void Ville::afficher_quartier_sous_moy( Tableau<Quartier>& quartiersSousMoyenne )
{
    for( int i = 0; i < quartiersSousMoyenne.taille(); i++ )
    {
        cout << quartiersSousMoyenne[i].get_nom() << " Revenu moyen:"
        << quartiersSousMoyenne[i].get_revenuMoyen() << endl;
    }
}

I consider the case solved.


答:
Since the result is mirrored along the diagonal, you can cut the iterations in half:</p>

```<code>res = pd.DataFrame(index=df['name'], columns=df['name'])

for idx1 in df.index:
    for idx2 in df.index[idx1+1:]:
         name1, lat1, lon1 = df.loc[idx1, ['name', 'lat', 'long']]
         name2, lat2, lon2 = df.loc[idx2, ['name', 'lat', 'long']]

         res.loc[name1, name2] = haversine(lat1, lon1, lat2, lon2)

res = res.add(res.T, fill_value=0)  # res is upper triangular
</code>```

Title: Pandas apply operation on each pair of rows

Body:
Since the result is mirrored along the diagonal, you can cut the iterations in half:

res = pd.DataFrame(index=df['name'], columns=df['name'])

for idx1 in df.index:
    for idx2 in df.index[idx1+1:]:
         name1, lat1, lon1 = df.loc[idx1, ['name', 'lat', 'long']]
         name2, lat2, lon2 = df.loc[idx2, ['name', 'lat', 'long']]

         res.loc[name1, name2] = haversine(lat1, lon1, lat2, lon2)

res = res.add(res.T, fill_value=0)  # res is upper triangular