GAM - Splines at selected covariate values

Question: I am trying to answer a biology question regarding the antibody kinetics with one or two major breakpoints at 21 days and three months. It is possible for me to use linear splines using GLM framework, but I am wondering if it is possible to do so in GAM but to have non-linear splines.
K argument does the splines according to data. Can I specify K at selected covariate values?
Answer: One approach would be to use an explicit parameterized spline function, and fix, rather than estimate, the specific value(s) of the predictor variable where the spline(s) sits.
For a simple example, I like to call $\max(x_i - \theta,0)$ a 'hinge function', because if I build a model with it like $y_i = \beta_0 + \beta_x x_i + \beta_{cx}\max(x_i - \theta,0)+\varepsilon_i$ what I get is a simple linear regression for values of $x\le \theta$, and then the slope of that linear regression changes by $\beta_{cx}$ for values of $x>\theta$. This works because $\max(x_i - \theta,0)$ is a variable with values equal to zero at or below $\theta$, and values that increase by exactly 1 unit for every 1 unit $x$ increases by thereafter. Keep in mind that the value of $\theta$—like $\beta_0$, $\beta_x$, etc.—is a parameter which is estimated. You might prefer 'broken stick' or some other term to 'hinge'. :)
However, we do not actually have to estimate $\theta$!
Consider instead using $y_i = \beta_0 + \beta_x x_i + \beta_{cx}\max(x_i - C,0)+\varepsilon_i$, where $C$ is some arbitrary constant—such as a theorized or known value in some biological or ecological process. We still get a simple line with a change in slope at the value $x=C$, but now we fix $C$.
Finally, the hinge function as I have described it is pretty bare bones, and there are reasons to find it distasteful (e.g., it's not smooth, and maybe you, or your estimator, care about things like differentability). You could ensmoothen it by squaring it, although that's still a pretty particular functional form, and there are other spline functions which we can be explicit about. Thus, we can be explicit about our spline functions, and explicitly fix their locations, rather than estimate them, or algorithmically "spread" them out. Our ability to do this in practice will depend on both the flexibility of a particular software implementation, and on our understanding of spline function specification.
Comment: I can definitely try different smoothing functions on your suggested "hinge" function.


Jquery Help - OnClick send Title to Clipboard

Question: I am new to JavaScript/jQuery.
I have the below lines as part of a table I am dynamically creating from a DB Query.  My End goal is a jQuery function that when the span is clicked will send the contents of the title attribute of that span to the Clipboard, but so far I can't even seem to find the value, all I am getting is undefined when I click on any of the span/columns.

    False
    False
    False
    False
    False
    False

Comment: You can refer to this http://stackoverflow.com/q/22581345/3580410
Answer: You need to remove the onClick attribute from your span tags and set up an event listener as shown below. Note: you need a selector for the jQuery on method so I also added a class name (here called "clickable", but could be anything) to the table row element.
More information about the jQuery on method can be found here:
http://api.jquery.com/on/

function copyToClipboard() {
    var str = $(this).attr('title');
    console.log(str);
}

$(document).ready(function () {
    $('.clickable').on('click', 'span', copyToClipboard);
});

        False
        False
        False
        False
        False
        False


Why can't I identify major and minor chords?

Question: I am playing violin for 6/7 years now and doing ABRSM grade 7 this year.
Problem is I still can't identify chords. Sad/Happy feeling doesn't work for me even a bit.
Because of this, I can't identify whether a chord is major or minor and at least can't tune the violin by playing two strings simultaneously as professionals do.
I normally can play songs by ear, so I don't think I am tone deaf.
This is a huge barrier in my music career. What do you think my problem is and how to solve it?
Comment: Sad/happy doesn't work for many people, don't let that discourage you. But listening is a skill as much as playing is; it has to be practiced. If you have trouble tuning your violin by ear, start by practicing to recognize intervals; then move on to identifying chords later.
Comment: @piiperi i can hear the difference. But I can't say which is which without hearing the other one.
Comment: Can you identify chords via their intervals if they're arpeggiated, like C - E - G, sound any different than C - Eb - G?
Comment: Yuo don't need to identify any major & minor chords to tune a violin.
Comment: @JohnWu sometimes I do hear the dissonance. But I don't know which string caused it and whether it is flat or sharp.
Comment: Do you know a pianist, or guitarist? Here's my advice. Buy in some of their favourite drinks/snacks. Invite them over (or go to a place with a piano) and ask them to throw chords at you. Try to identify, guess, they'll tell you if it's major or minor. Rinse. Repeat. Play around with it (inversions, extended chords etc). Enjoy spending time with someone you like, trying to learn the sounds of chords. Just a relaxed evening with some chord-based trial and error.
Comment: @AJFaraday Alternatively, if you don't have friends, you might find the software package "GNU Solfege" helpful. It's not quite as good as friends, but you can use it more often.
Comment: Another programme that you might find helpful, if you can read at least some German, is [audite PLUS](https://www.capella-software.com/de/index.cfm/produkte/audite-plus/info-audite-plus/) by the German company [Capella](https://www.capella-software.com/us/). Though many of their programmes are available [in English](https://www.capella-software.com/us/index.cfm/products/), this is unfortunately apparently not. You can practice recognising tunes, intervals, chords, scales and tuning systems and tailor exercises to suit you.
Comment: *can't tune the violin by playing two strings simultaneously* Is this accurate? You can't tell if a perfect fifth is out of tune? You don't hear beating or dissonance? Trying to understand.
Comment: So how do you play in tune? And if you don't, how did you pass grade 6?
Comment: @user207421 when it comes to individual notes most of the times I can recognize whether I am flat or sharp. Problem is with two or more simultaneously.
Comment: Flat or sharp with reference to what? There is no such thing as flat or sharp in isolation. If you can play in tune you can tune your violin, by definition, and major and minor triads have nothing to do with that.
Comment: @user207421 - I think it's safe to assume the flat/sharp reference is A440, often with 12TET, but maybe with some just or Pythagorean intonation thrown in.
Answer: This may be helpful. Start by learning to hear the difference between major and minor thirds. Find four songs, one that begins with a rising major third, one with a rising minor third, one with a falling major third and one with a falling minor third. Then you can match an interval that you hear with one of those. So, for example, "Dixieland" begins with a falling minor third, and the Marine Corps Hymn has a rising major third. "Swing Low, Sweet Chariot" has a falling major third, and "Greensleeves" has a rising minor third.
There are plenty of sites like this one out there with more songs that you can use. The point is that it often helps to learn the intervals of songs that you already know, so you can put a name to a sound, so to speak.
Once you put the intervals together in your head, you can put them together into chords. Minor chords have a minor third on the bottom and a major third on the top, while major chords have a major third on the bottom and a minor third on the top. Get the intervals, and you should see that the chords fall into place in your head fairly quickly.
Answer: Hearing the major and minor thirds is a good first step.  It should be fairly easy to get intervals.  Can you do this?  If you cannot do 2 note intervals then chords will be very difficult.  Once you get triads in root inversion (1, 3, 5) you will want to be able to identify inversions.  The major triad has a major third (1 to 3) followed by a minor third (3 to 5).  So playing a 1st inversion (3, 5, 1) can fool beginners.  The key to hearing this as a maj 1st inversion rather than a minor triad is that you should hear the 4th on top (5 to 8 (octave of 1)).  So, intervals are very important here.  Using "feeling" doesn't make any sense.  This is subjective, I think minor is happy.  You need to learn systematically how to dissect the combination of notes into intervals and hear the "pieces of the chord".  If you are tying to test yourself on whole chords without first doing intervals in sequence and together you may have not developed some basic hearing skills.  If you can afford it try getting a software package like EarMaster.  This has a set of exercises that increase in difficulty from identifying the notes of the major scale relative to 1, relative to 8 (i.e. ascending and descending), then arbitrary placement with a key, intervals, arpeggios, and full chords.  It grades you and recommends going back if you can't score above a certain level.  I think it has modes and chords with a lot of extensions too.  There may be free open source versions of this but it wasn't that expensive a few years ago.  Band in a Box also has an ear training video game that covers a lot of things.  It tries to increase you speed at identifying intervals, chords, and modes.
In short, get your interval recognition well developed first then learn to dissect larger chords.  Learn to arppegiate the chord in your head once you hear it.  That will help you identify the intervals.
Answer: I realize that conservatories set great store by music theory classes, including ear training.  However, it is quite possible for a person to progress well and be successful with one's instrument, without excelling in those classes.  I am such a person.  I was a music performance major.  I did well in my instrument, graduated "with distinction" and got a full-time orchestra job (overseas) after graduation.  But I struggled to get C's in my required music theory classes, and the ear training exercises were especially hard for me.  So my answer to you is, please don't feel like a failure if you have trouble with those exercises.  You play a melodic instrument.  An inability to do well on ear training quizzes will not be a deal breaker for you in the long term.
In fact, my cello professor at Indiana University told me to do the bare minimum of work for my theory classes.  She advised me "to pass the theory classes with a D."
To tune your strings:
For the short term, I suggest you use an electronic tuner.  Often an electronic metronome will have a tuner built in.  For the longer term, perhaps your teacher can work with you on tuning.
Here are some practical tips I can offer for tuning your violin:

Have a luthier add extra fine tuners.  Typically a violin would have only one fine tuner, on the E string, and you'd be expected to tune the other strings by adjusting the pegs.  (The thinking is that fine tuners sometimes cause a rattle (metallic vibration).  However, if the base of the tuner is nice and tight against the tailpiece, you should be able to eliminate rattle.)  For a student who is not feeling confident with tuning, having the fine tuners can be quite helpful.
Use "peg dope" on your pegs so that they turn easily, without any slipping.  If you are not sure how to put it on, ask your teacher, or a more advanced student, or a luthier, to help you.
Actually, let me back up a step.  Have your teacher or a luthier check your instrument and your strings.  If something is not right with your instrument, for example your bridge is warped, or a string is "out of true," it can be impossible to get the instrument properly in tune.
Here is a tuning trick: let's say you are playing an open double-stop, for example the A and the D strings together.  Let's say you are not sure if your fifth is perfect ("in tune").  Put your index finger on the A string at the nut.  You will be in what I could call "zero-th position".  Go ahead and put weight on that finger.  Because you are in zero-th position, the pitch will not change when you do this.  Now, roll your finger gradually to bend the note a tiny bit higher in pitch.  This will make the interval between the two notes you are playing simultaneously LARGER.  Let your ear tell you whether things got better or worse as you did this bending.  If it got better, that means you need to lower the D string with the fine tuner.  If it got worse, try a similar procedure, but this time putting your finger at the nut on the D string.  If this results in improvement, that means you need to raise the D string with the fine tuner.  Repeat this procedure until both bending experiments lead you to conclude that no change gives you the most satisfying result.
Play an open G, and then an A on the G string (first finger in first position), using a slow, legato style in full voice.  Then play an open A, same style.  This should give you a perfect octave.  (Octaves are easier to tune than fifths.)  You're not just looking for it to sound like a perfect octave.  You also want to listen for the sympathetic vibration of the A string while you are still playing that first-finger-A-on-the-G-string.  If the two strings are in tune with each other, and if your hand shape knows exactly where to place your finger, the sympathetic vibration will show you the two strings are in tune with each other.  And the lack of a sympathetic vibration would suggest that the two strings are not in tune with each other.
You can follow the same procedure with an open D, followed by a fingered E (first position on the D string), and then the open E.
Note this trick doesn't work as well on a really cheap student instrument.
Comment: Hey, another IU Music alum. :) I was at IUSB in the days when Fritz Magg was the main cello prof down in Bloomington. I was the other way around, struggled to perform, had little difficulty with theory and ear training. Needless to say, I wound up with an IT career. LOL
Comment: @BobRodes - What years were you there?  (If you care to say.) Fritz Magg was there for a long stretch of time.  What instrument?  Did you ever think about doing theory or an education degree instead?
Comment: Ear training isn't really theory.   It's what music is. Acoustics.  The degree to which it matters depends on what type of career you choose to pursue.  Conversely your strengths may determine your career path.
Comment: @ggcg - I was just asking because I wondered if Bob had an interest in studying theory or some other non-performance major.
Comment: @aparente001 I don't mind. I was there from 74-83. Piano, studied mostly with John Owings. Also some time with Sasha Korsantia, one of Toradze's students, after I graduated. I got a BS in Music with a concentration in foreign languages. (Sort of performance lite; one recital instead of two, for example.) I got as far as one class in education. We all sat in a circle and defined learning (after some discussion, of course) as  "an interpersonal contract between student and teacher" (the definition in the book, of course) withdrew from the program and went into the BS program. Young hothead. :)
Comment: @BobRodes - I took one music ed class too -- conducting.  I was a disaster.  It was rather disappointing.  Now here's the funny part -- we coincided.  I was there for three years, starting in fall 74.  I graduated in spring, 1977.  (I transferred after doing two years at a community college.)
Comment: @aparente001 Cool! You were down in Bloomington, though, right?
Comment: @BobRodes - Oh, sorry, I didn't notice the SB.  I didn't know other campuses of IU had music departments.  Live and learn.
Comment: @aparente001 Yeah, IUSB actually has a very strong piano department. Here's an article about Alexander Toradze, who retired in 2017: https://arts.iusb.edu/aspire-news/2017/january/toradze-leaves-a-legacy-at-iu-south-bend.html
Comment: @BobRodes - Ah, I didn't know.  But what would that be like, to be in a piano cocoon?
Comment: @aparente001 If by "piano cocoon" you mean that IUSB was exclusively piano, that wouldn't be correct. Lutz Rath was the cello professor when I was there, a member of a very capable quartet in residence, the International String Quartet. [Here's](https://www.youtube.com/watch?v=apepX--09b8) a recording of theirs on youtube. (Chihiro Kudo, Machie's husband, passed away about 10 years ago and was replaced by Louis de Froment at first violin.)
Comment: @BobRodes - Live and learn!
Answer: This is really two separate questions:

Tuning by ear:  Violin strings are a perfect fifth apart, which has a very "open" sound because the sound waves match up.  If they are close, but not quite in tune, you will hear "beats" when you play the strings together, which is a repetitive regular warble as the sound waves go in and out of sync. The closer you are to the right note, the faster the beats will happen.  When they go away, you are in tune.
Learning to recognize chords:  If you can play by ear, appeggiate the chord, and then see which one you are playing. For instance, if it is an a-minor chord you'll be using a c natural, if an A-Major chord, you'll be using a c#.  Over time, you'll be able to recognize the sound without going through all the steps.
Answer: I would give the same advice as Bob: try to sing a wellknown minor or major song to the given chord.
Make a selection of only 4 songs: 2 with an up-beat of a fourth in each mode.
The song that fits will give you the answer.
You can even try to make the test with only one song:
HAPPY BIRTHDAY TO YOU or A GROOVY KIND OF LOVE, FRERE  JACQUES
(if one fits it's a major triad, if not it will be certainly minor)
Now you can make the control-test by a minor song (scale or minor triad)
like
the Themes of alla Turca, Moldau, Lady in Black, El Condor Pasa
If you know Grieg "PEER GYNT"
make this test with
In the Hall of the Mountain King (minor)
Morning Mood (major)
Take care with the Moldau (Smetana) and In the Hall of the Mountain King (Grieg): Both tunes are modulating to major, but maybe that just this modulation to the related key will help you to hear and learn the difference for identifying the different modes.
Maybe this link can help you too:
https://www.hearandplay.com/main/major-and-minor-modes
Comment: Thus Spake Zarathustra is an excellent one to listen to!
Comment: "Peer Gynt" is such a good advice! Brilliant!
Answer: If you can hear a difference between minor and major third intervals, but can't identify and remember which one is which, you can learn to recognize them, but you have to make the difference mean something for you. It has to be important and meaningful and make an "emotional" effect on you, as if your life and happiness depended on it or something. ;) I think this has to do with how different people learn things like languages: for many it's impossible to memorize and identify the meanings of foreign words, but once they get to real-life situations where the difference has concrete consequences, they start to remember.
Turn the perspective around: instead of just observing, start producing. Play major and minor intervals and chords in situations where it counts. Accompany songs with chords and play melodies by ear. Translate the question "what interval is this" into "what would I have to play to make it sound like what I'm hearing". Ear training isn't only listening, it's playing and listening, learning to understand the whole feedback loop: what I do and what it sounds like.
Comment: Say I can identify major thirds and minor thirds. But major chord has both of these intervals within it. So how will it support me with identifying the chords?
Comment: @LasithaYapa start accompanying songs with chords and playing melodies by ear and you will notice! :) You relate everything to the chord's root note, and the tonal center of the key. But I think this is not a logical/theoretical exercise. You have to start doing it in practice. You can't really get a person to walk or ride a bicycle through any amount of theoretical explaining, the person has to practice it. A coach/trainer can only give suggestions about what to do and what to focus on. So, pay attention to the chord root notes and the tonal center i.e. tonic i.e. home note.
Comment: @LasithaYapa - you're correct about major and minor triads - they both contain M3 and m3. But not in the same order! Don't rely on a theory fact to get you through. It's always the interval *between root and 3rd* that's more important here. You need to learn to identify root - often the 'home' feeling on the key's I, then take the very next note in the triad - the 3rd. The other 3rd interval doesn't matter a jot here.
Answer: What worked for me was singing over a drone. Put the drone on C for example, and then sing a major scale while plunking the notes out on a piano. Once you get good at it, try and remove the piano. The important thing here is to hear / feel the interval in your body as you sing. Once you get the hang of recognizing the intervals, the chords become much more manageable. Start with 2 notes before you go to 3 :)


How do we calculate the probabillity of a OR b OR c Or d Or e

Question: We all know the formula for the probability of a or b happening.  It is p(a or b ) = p(a) + p(b).  We also all know (maybe) the theorem for p(a or b or c).  (It's on google lol.)  It is p(a or b or c) = p(a) + p(b)  + p
(c) - p(a and b) - p(b and c) - p(a and c) + p(a and b and c).
A more important question that I am trying to figure out is the formula for the p(a or b or c or d or e)  =
Better yet, its there a theorem that we can use to calculate the p(a or b or c or d or e or f ...)?
Comment: https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle
Answer: There is the Inclusion-Exclusion Principle if that is what you are looking at. More formally, in probability space $(\Omega, \boldsymbol{\mathfrak A}, \mathbb P) ,$ if $A_i\in\boldsymbol{\mathfrak A}, ~i\in\{1, \cdots, n\}, ~n\in\mathbb N, $ then
$$\mathbb P\left[\cup_{1\leq i\leq n} A_i\right]= \sum_{1\leq i\leq n} \mathbb P[A_i] -\sum_{1\leq i<j\leq n} P[A_iA_j]+\sum_{1\leq i<j<k\leq n} \mathbb P[A_iA_jA_k]-\cdots+(-1)^n\mathbb P[A_1A_2\cdots A_n].$$ This can be easily shown based on an argument of induction.
Answer: The formula for $P(A\lor B)$ you give is incorrect and is only correct if $A$ and $B$ happen to be disjoint events. The general formula is $P(A\lor B) = P(A) + P(B) - P(A\land B)$, the intuition for this formula being that when you add up $P(A)$ and $P(B)$, you are double counting the states that are part of both $A$ and $B$, hence the need to subtract it out. The formula for $P(A\lor B\lor C)$ works the same way. First, add up $P(A) + P(B) + P(C)$. You will have double counted the states that are part of both $A$ and $B$, part of both $B$ and $C$, or part of both $C$ and $A$. No matter, we just subtract those out. But by doing this subtraction, we will have over-adjusted for states that below to the intersection of all three $A$ and $B$ and $C$, so we need to add this intersection of all three back. Putting this all together gives the formula
$$P(A\lor B\lor C) = P(A) + P(B) + P(C) - P(A\land B) - P(B\land C) - P(A\land C) + P(A\land B\land C)$$
The generalization of this formula is a bit tedious and tricky to write down into a concise formula, but conceptually is no difficult than the argument I have given above. The resulting formula is known as the inclusion-exclusion principle, and it implies that
$$P\left(\bigvee_{i=1}^N A_i \right) = \sum_{k=1}^N (-1)^{n-k} \sum_{S\subseteq \{1,\ldots,N\}} P\left(\bigwedge_{s\in S} A_s\right)$$


axiomatic approach to 3 prisoner problem?

Question: I've decided to start working through Casella and Berger's Statistical Inference. The book introduces probability theory from an axiomatic approach and defines a probability function according to Kolmogorov's Axioms. I would like to prove the well-known solution to the Three Prisoner Problem from an axiomatic approach and I'm a bit confused about how we actually define the probability functions and sample space.
The text doesn't go into much detail in the example given, so I'm hoping I can get some clarity here.
Disclaimers: This is my first time thinking about probability this way. This is the first time I've posted to Stack Exchange. If I'm posting in the wrong place, please let me know :)
The authors give a very short solution to the known Three Prisoner Problem, paraphrased here:

Three prisoners A, B, and C are on death row. One prisoner will be pardoned tomorrow. The warden knows who will be pardoned. Prisoner A asks the warden who will be pardoned, but the warden refuses to tell. So A then asks which of B or C will die tomorrow. The warden says "B will die". The warden thinks he's given no additional information to A about A's own likelihood of being pardoned. Prisoner A thinks their chance of being pardoned has risen to 1/2, given this new information. Who's thinking is correct, the warden or the prisoner?

My thinking and questions:
The known solution is that the warden is correct and I feel I understand this on a logical level. But I can't figure out how to "prove" it on an axiomatic level.
The text starts by stating $p(A)=p(B)=p(C)=1/3$ where A = event A is pardoned, B = event B is pardoned, etc. This makes sense to me, as we can define the function $p$ on the sample space $ S = \{A, B, C\}$.
Then the text says, "Let $W$ denote the event the warden says $B$ will die. A can update his probability of being pardoned to $p(A|W)=p(A\cap W)/p(W)$." This is where I started to get confused.
I understand this equation for $p(A|W)$ is given by definition of conditional probability. But the book doesn't given any indication of how to update the sample space. Am I correct in thinking $p(\cdot)$ and $p(\cdot|W)$ are two different functions, one defined on $S$ and one defined on a new sample space?
It confuses me that $p(A\cap W)$ has any meaning, since $p$ is a function defined on the very simple sample space $ S = \{A, B, C\}$.
Logically, I understand the solution to this problem. But, if I'm going to learn probability from the axioms, I want to understand the specifics of how we define the sample space (well, the sigma-algebra of the sample space) and probability functions for this problem.
My tentative solution would be to define a new sample space $S^* = \{AW_B, AW_C, BW_C, CW_B \}$ where $AW_B$, for example, represents the event that $A$ is pardoned and the warden says $B$ will die.
Then, to define a new probability function $p^*$ on $S^*$, where $p^*(AW_B)=p^*(AW_C)$
By the definition of a probability function: $p^*(AW_B \cup AW_C) = p^*(AW_B) + p^*(AW_C)$
Then, if we could assume $p(A) = p^*(AW_B \cup AW_C)$ we could show $p^*(AW_B) = p^*(AW_C)=1/6$.
But honestly, I'm very confused on how to connect this back to the definition of the conditional probability $P(A|W)$. I guess primarily because I don't understand what initial sample space is being considered for the original definition of $p$. Any guidance on this problem would be greatly appreciated.
Answer: You are right. You have to use a larger probability space to define a $\mathbb{P}\left(A\middle|W\right)$. Because for $W$, the randomness comes additionally from the wardon, which means $W$ doesn't belong to any $\sigma$-algebra generated by subset of $S$ hence not measurable.
To connect your construction to $\mathbb{P}\left(A\middle|W\right)$. Note that $\left(S^{\ast},\mathscr{P}\left(S^{\ast}\right),p^{\ast}\right)$ is a well-defined probability space, where $\mathscr{P}\left(\cdot\right)$ denotes powerset. In addition, using your notation, we have $W=AW_{B}\cup CW_{B}$, $A=AW_{B}\cup AW_{C}$, and $A\cap W=AW_{B}$, hence $A$, $W$, $A\cap W$ are all measurable in this space. Therefore, we can define a valid conditional probability like this
$$p^{\ast}\left(A\middle |W\right)=\frac{p^{\ast}\left(A\cap W\right)}{p^{\ast}\left(W\right)}=\frac{p^{\ast}\left(AW_{B}\right)}{p^{\ast}\left(AW_{B}\right)+p^{\ast}\left(CW_{B}\right)}=\frac{\frac{1}{6}}{\frac{1}{6}+\frac{1}{3}}=\frac{1}{3}=p^{\ast}\left(A\right). $$
Comment: ah ok. this is helpful!


PHP Quiz timer needs to be updated every second which slows down the site

Question: I am building a quiz app in PHP using a MYSQL database of questions.
The app has a timer at the top which needs to maintain the correct timer value when the page

moves to the next question in quiz
The page is refreshed using F5
The page is closed using Alt+F4 or the x button
The back button is clicked

window.unload in javascript does not work for back button, closing of window.
I could not find any other solution, so went for the somewhat incorrect solution to storing the timer value every N seconds. So if user were to do any of above 4 activities, the timer would be off by Maximum N seconds. This requires me to UPDATE a MYSQL table every N seconds using ajax.
In the best case, N=1, which makes the site visibly slower.
N=3 works better, but I am not happy with it.
I use setinterval for running the ajax function every N seconds
Any suggestions here?
PLease suggest alternative methods to achieve my goal which are not database intensive. I am not a DB expert, so this might be trivial.
Short version of question
How do I get control to perform some action (eg, store something in a database) when the Back button is pressed or the page otherwise goes out of focus?
Comment: (The Question seemed clear to me, but the two Answerers (so far) did not seem to understand.  So I added a more specific phrasing.)
Answer: It is unclear what this "timer" does. Does it count down? Count up? What is its purpose? You clearly forgot to explain this.
Let's say it's a countdown timer, telling people how much time they have left to do the quiz. You give them 10 minutes, 600 seconds, and simply subtract one second, every second.
Now you need to keep track of every second, store that number somewhere, and update, what is stored, every second.
What if you stored only the time the quiz started? Say "2022-02-27 15:45:33". Then you know the timer will be down to zero at "2022-02-27 15:55:33". When it is "2022-02-27 15:48:03" you know that 2.5 minutes have passed: 150 seconds. The timer has 450 seconds left.
By using a fixed point in time, stored somewhere, you can compute a relative time, like a countdown timer, without having to store the value of the timer every second.
Answer: One solution to keep accurate track on time is using http-header.
//after 60s it will move automatically to end_test_page
header('Refresh: 60; https://end_test_for_user.php/');

Still, will be some adjustments on logic.
Means:

each form will have an unique id stored in db
so end page will mark the form as used and cannot be open again
header('Refresh: 60; https://end_test_for_user.php?id=123'),
id will be dynamically added
all responses will be track in db (on end_test_php, need just to add a flag for that id. Flag=1 complete)
multiple questions can be bring on front with ajax (only tracking main form status will be enough)


Argument missing after: "-c" vim error after git show

Question: I have been using vim as an editor for vim for a long time now. I set vim as the default editor by:
git config --global core.editor "vim"

But now git show stoped to work. If I call
git show a802fa69:path_to_file/file.cpp

I get the error message
VIM - Vi IMproved 8.1 (2018 May 18, compiled Sep 19 2018 08:30:40)
Argument missing after: "-c"
More info with: "vim -h"

Any ideas? What does Argument missing after: "-c" mean? How can I fix it? It was working previously...
Comment: `git show` doesn't open an editor (at least not for me), it directly prints the diff to the terminal. Only commands like `commit` and `rebase -i` open the configured editor. It might be worthwhile to check the process tree (from git to Vim) including command-line arguments to see what's going on.
Answer: This is not default git show behavior. Check your .gitconfig to see if git show is redefined. You might also check your aliases and .bashrc. It seems like vim is being called by one of these settings with the -c flag, but no command is given. For instance, vim -c will raise the same error.


SAML - Manage User Details in IdP using SSOCircle

Question: I'm setting up Web SSO using the Spring Security SAML extension, and I'm using SSOCircle as my IdP.  Following the Spring Security quick start, I was able to get up and running.  However, I want the IdP to also provide additional user details such as role / organization information.  How/Where does the IdP communicate additional user details?  Does anyone know if we can provide additional information with SSOCircle?
Answer: You can configure SSOCircle IDP to send additional attributes along with the SAML assertion. For example: last name, first name and email address. For specific requirements you should contact SSOCircle directly for a custom setup.


Perform calls in Android Locktask mode

Question: TL;DR How to make a phone call while using Activity.startLockTask()?
I'm trying to setup a restricted environment on an Android device, i.e. what is usually called "Kiosk-Mode".
Official documentation can be found here:
https://developer.android.com/work/cosu.html
The official way of doing this suggest to use Activity.startLockTask.
This works fine until you want to start other apps from within your Activity which is in startLockTask() mode.
Any activity that launches must not start on a new task stack otherwise the system blocks the launch intent, i.e. no Intent.FLAG_ACTIVITY_NEW_TASK.
Some apps can just be launched, other seem to implicitly set this flag, but can be workedaround by using startActivityForResult(...) which seems remove the NEW_TASK flag. For apps that still don't work I could code my own replacement.
The real issue is the call application, which enforces a new task stack. Triggering a call initiated the call, doesn't show the call activity, but also puts a call notification in the status bar (which is not accessible in while using startLockTask().
In contrast to other apps the call app is also one that can't be replaced with a custom app...
DevicePolicyManager.html.setLockTaskPackages() has no effect on this behavior.
Comment: I'm having the same issue. I need a way to make incoming/outgoing calls while in kiosk mode, and couldn't make this work. Did you find a solution?
Comment: we are also facing same issue. we have handle the outgoing call but for incoming call it did not show the incoming call activity
Comment: Solved this yet?
Answer: I tried to make start call intent under locked mode and this line pop up:
    system_process E/ActivityManager: Attempted Lock Task Mode violation mStartActivity=ActivityRecord{56ab302 u0 com.android.server.telecom/.components.UserCallActivity t155}

So I add
    setLockTaskPackages(<ComponentName>,new String[]{getPackageName(),"com.google.android.dialer","com.android.server.telecom"});

Managed to get the dialler out. Of course if I push the home button or back button, there's no way to get the dialler back... the recent button is still locked though. Receiving call works perfectly (all buttons are disabled)
Comment: What happens if you then launch a call from the dialer?
Comment: Sorry, my call intent supplied the phone number directly.
Comment: We need to make sure we talk about the same thing. There is the call activity and the dialer activity. The call activity is what starts when you press "call" from the dailer.
Comment: [link](https://firstname.lastname@example.com/hadifikri/android-example-COSU.git)
Comment: 'Intent callIntent = new Intent(Intent.ACTION_CALL);                callIntent.setData(Uri.parse("tel:" + ""));'
Comment: This launches a call, but can the user then access the call activity, hang up the call or put it on speaker?
Comment: It does launch the call through dialer activity.. So all the controls are there. I mean the standard phone app is at the foreground.
Comment: It launches the call, but can you interact with the call activity? I mean the call activity, the new one that was started by pressing "call", I don't mean the dialer. On the devices I tested it (Samsung S5/Pixel) the call starts but you never see the call activity.
Comment: In the logs it shows as `Recent #0: TaskRecord{46cf2af #7366 A=com.android.incallui U=0 StackId=1 sz=1}`
Comment: Actually I've not tried `com.android.server.telecom` yet, let me test it with that. What device/ROM are you testing this on?
Comment: i tested on samsung galaxy s3 / resurrection remix nougat 7.1.1.  when i tested it, i can interact with the call activity. before i added the last package, indeed the call started but the call activity is inaccessible.
Comment: I've noticed on my phone, when I set device owner using adb, even without launching and locking my app, when I'm using the phone dialer and press call, it does not launch the call activity UI. Going through `setting`->`app`->`Phone`, on `App Info` it says `Phone App`:`No`. Changing it to `Yes` solve the problem. For good measure I even register the google account (after device owner has been set).
Answer: Have you tried this?
setLockTaskPackages(new ComponentName(this, DeviceAdminReceiver.class),new String[]{getPackageName(),"com.google.android.dialer"});

Comment: It doesn't make a difference. The issue is that the call app/activity forces a new task stack, which is exactly what the lockmode prevents, thus hiding the call UI.

Perform calls in Android Locktask mode


Why will $\lim_{z\to \infty} |e^{z^3}|=0$ only if $\mathrm{Re}(z^3) < 0$?

Question: I have come across a question in a textbook "Sketch the region in an Argand diagram where $\lim_{z\to \infty} |e^{z^3}|=0$
The solution in the book begins "This will only be satisfied if $\mathrm{Re}(z^3)$ is negative", without any justification as if it is obvious, but I cannot see why this is the correct condition.
Can anyone explain please? Thank you!
Comment: The modulus of $\exp(z)$ is $\exp(a)$ where $a=\Re(z)$.
Answer: If $z=x+iy$ with $x,y\in\mathbb R$, then
$$|\exp(z)| = |\exp(x+iy)|=|\exp(x)\exp(iy)| = \exp(x)\,.$$
Comment: $\exp(x)$ is the exponential of a real number. If $x\to -\infty$ it goes to $0$, if $x\to \infty$ it goes to $\infty$
Comment: Thank you for the very fast answer! But I'm afraid I still don't see how this leads to it being the correct condition for the required behaviour for $|exp(z^3)|$. I'm just failing to see the line of reasoning from there to the condition in the question. Sorry
Comment: ♂ Ugh I guess I couldn't see the wood for the trees. Thank you for taking the time to explain something so simple to someone who was being very stupid!
Answer: If we denote $z^3=a+ib$, where $a=Re(z^3), b=Im(z^3)$, then $|e^{a+ib}|=|e^ae^{ib}|=|e^a|$. In our case $|e^{a+ib}|=|e^a|\rightarrow 0$ and $e^a$ is a real exponential, so $|e^a|=e^a\rightarrow 0$ for $|a+ib|\rightarrow\infty$ iff $a\rightarrow -\infty$. So we have the necessary and sufficient condition $Re(z^3)\rightarrow-\infty$.
Comment: I just want to add that $|z|\to \infty$ does not imply $Re(z)\to \pm \infty$ or $Im(z)\to \pm \infty$, take $z=t\exp(it)$ with $t\in\mathbb R$ for a counterexample.
Comment: Oh right! I delete the useless row.


Sphere Packing inside a quadratic space

Question: How would you go about calculating the number of uniform spheres that could fit inside a given quadratic surface , say an elliptic paraboloid of a fixed height, given the radius of said spheres and the equation of the quadratic surface?  Assuming two scenarios where the spheres are loosely packed and again when the spheres have the maximum kissing number.
Comment: An elliptic paraboloid is unbounded.  Whichever side you take as the "inside", you shold be able to put infinitely many spheres there.
Comment: @RobertIsrael Good point Ill make an edit
Answer: Since you are asking for a maximal packing the question is likely very hard since the question for how to maximally pack monodisperse spheres in $\mathbb{R}^3$ was open until Hales solved it in 1998:
https://en.wikipedia.org/wiki/Kepler_conjecture

Sphere Packing inside a quadratic space


Binomial coefficient notated by recursive summations

Question: I was considering the number of configurations of elements in a 3-atom adsorbate binding site on a nanoparticle, and I got to wondering how many configurations there would be if there were $k$ atoms in the binding site and $n$ elements that the atoms could be (never mind how realistic or physically-relevant this is, I'm more interested in the math).
Just as an example, for a 3-atom binding site ($k=3$) and 3 elements $A$, $B$, and $C$ ($n=3$), there would be $10$ possible combinations: $$AAA \\ AAB \\ AAC \\ ABB \\ ABC \\ ACC \\ BBB \\ BBC \\ BCC \\ CCC$$
I tried a variety of forms to find a general case and eventually I  found that for $k=2$, the number of configurations of the $k$ atoms would be the $n^{th}$ triangle number. Therefore, for a function $f(n, k) =$<code># of configurations</code>, I found that $$f(n, 2) = \sum_{a=1}^n a = \frac{n(n+1)}{2}$$
I then noticed that for $k=3$, the number of configurations was always the sum of the first $n$ triangle numbers. Therefore, $$f(n, 3) = \sum_{a_1=1}^n \sum_{a_2=1}^{a_1} a_2 = \frac{n(n+1)(n+2)}{6}$$
Just briefly checking $k=4$, it seems to follow the same trend. Therefore it would appear that $$f(n, k) = \sum_{a_1=1}^n \sum_{a_2=1}^{a_1} \sum_{a_3=1}^{a_2} \cdots \sum_{a_{k-1}=1}^{a_{k-2}} a_{k-1} = \frac{(n+(k-1))!}{(n - 1)!\space k!}$$
After thinking myself so clever for finding such a relation without combinatorics, I of course noticed I had derived $\binom{n+k-1}{k}$, but that got me wondering... Maybe I'm just blind or maybe it's the fact that I've never taken a stats class and only ever briefly learned combinations/permutations, but I have never seen binomial coefficient defined in terms of repeated summations. Is this a widely-known fact?
Additionally, how could you write $\binom{n}{k}$ as a series of repeated summations? Using my previous example of $\binom{n+k-1}{k}$ as a reference, it is clear that for $\binom{n+k+x}{k}$, the final sum will be $$\cdots \sum_{a_{k+x}}^{a_{k+x-1}} a_{k+x} = \cdots$$
but I am unsure as for how to proceed when the case is $\binom{n}{k}$ as following the above pattern would leave me with $a_0$ and $a_{-1}$ for the lower and upper bounds respectively which does not really work since the subscript on the lower bound, upper bound, and summand should all be increasing for each additional summation.
Finally, is there a way to collapse all $k-1$ sums into a single summation?
Answer: Multiple summations
Summing using the hockey-stick identity, we have
$$\begin{align}
k=2:\;\;&\sum_{x_1=1}^n x_1& & &=\binom {n+1}2\\
k=3: \;\;&\sum_{x_1=1}^n\sum_{x_2=1}^{x_1}x_2
&&=\sum_{x_1=1}^n\binom {x_1+1}2
&=\binom{n+2}3\\
k=4: \;\;&\sum_{x_1=1}^n\sum_{x_2=1}^{x_1}\sum_{x_3=1}^{x_2}x_3
&=\sum_{x_1=1}^n\sum_{x_2=1}^{x_1}\binom {x_2+1}2
&=\sum_{x_1=1}^{n}\binom{x_1+2}3
&=\binom {n+3}4\\
&&\vdots\\
k=k:\;\;&\sum_{x_1=1}^n\sum_{x_2=1}^{x_1}\sum_{x_3=1}^{x_2}\cdots\sum_{x_{k-1}=1}^{x_{k-2}}x_{k-1}
&&&=\binom {n+k-1}k\end{align}\\
$$
Collapsing the summations
The last cascade of summations may be collapsed by using the following notation:
$$\sum_{x_1=1}^n\sum_{x_2=1}^{x_1}\sum_{x_3=1}^{x_2}\cdots\sum_{x_{k-1}=1}^{x_{k-2}}x_{k-1}=\sum_{1\le x_{k-1}\le x_{k-2}\le\cdots \le x_2\le x_1\le n}x_{k-1}
=\binom {n+k-1}k$$

Note that
$\displaystyle \binom {n+1}2$ are Triangular Numbers,
$\displaystyle \binom {n+2}3$ are Tetrahedral Numbers,
$\displaystyle \binom {n+3}4$ are Pentatope Numbers, and
$\displaystyle \binom {n+r-1}r$  are $r$-simplex Numbers.

To prove the result, it may be easier to index the summations from inside out, i.e.
$$\sum_{x_{k-1}=1}^n\sum_{x_{k-2}=1}^{x_{k-1}}\cdots \sum_{x_2=1}^{x_3}\sum_{x_1=1}^{x_2}x_1$$
Let $\displaystyle f(j)=\binom {x_j+j-1}j$.
Note that
$$\begin{align}
\sum_{x_j=1}^{x_{j+1}} f(j)
&=\sum_{x_j=1}^{x_{j+1}}  \binom {x_j+j-1}j\\
&=\binom {x_{j+1}+j}{j+1}\\
&=\binom {x_{j+1}+\overline{j+1}-1}{\overline{j+1}}\\
&=f(j+1)
\end{align}$$
and that  $f(1)=x_1$.
Hence
$$\begin{align}
&\;\;\;\;\sum_{x_{k-1}=1}^{x_k}\sum_{x_{k-2}=1}^{x_{k-1}}\cdots \sum_{x_3=1}^{x_4}\sum_{x_2=1}^{x_3}\sum_{x_1=1}^{x_2} x_1\\
&=\sum_{x_{k-1}=1}^{x_k}\sum_{x_{k-2}=1}^{x_{k-1}}\cdots \sum_{x_3=1}^{x_4}\sum_{x_2=1}^{x_3}\sum_{x_1=1}^{x_2} f(1)\\
&=\sum_{x_{k-1}=1}^{x_k}\sum_{x_{k-2}=1}^{x_{k-1}}\cdots \sum_{x_3=1}^{x_4}\sum_{x_2=1}^{x_3} f(2)\\
&=\sum_{x_{k-1}=1}^{x_k}\sum_{x_{k-2}=1}^{x_{k-1}}\cdots \sum_{x_3=1}^{x_4} f(3)\\
&=\vdots\\
&=\sum_{x_{k-1}=1}^{x_k} f(k-1)\\
&=f(k)\\
&=\binom {x_k+k-1}k\\
&=\binom {n+k-1}k\qquad\text{if }x_k=n\\
\color{red}{\Rightarrow \sum_{x_{k-1}=1}^n\sum_{x_{k-2}=1}^{x_{k-1}}\cdots \sum_{x_3=1}^{x_4}\sum_{x_2=1}^{x_3}\sum_{x_1=1}^{x_2} x_1}
&\color{red}{=\binom {n+k-1}k}
\end{align}$$
Answer: If you go all the way, you'll write your final summand $a_{k-1} =\sum_{a_k=1}^{a_{k-1}}1$ getting altogether
$$
  f(n, k) = \sum_{a_1=1}^n \sum_{a_2=1}^{a_1} \sum_{a_3=1}^{a_2} \cdots \sum_{a_{k-1}=1}^{a_{k-2}} \sum_{a_k=1}^{a_{k-1}}1
$$
So your nested summations are counting weakly decreasing sequences $n\geq a_1\geq a_2\geq\cdots\geq a_{k-1}\geq a_k\geq 1$. If one represents this as a histogram, namely a column of $a_1$ stacked squares followed by one of $a_2$ squares, and so on terminating with a column of $a_k$ squares, then the shape of the histogram is precisely determined by a path along its top border, starting at $(0,n)$, descending (if necessary) to $(0,a_1)$, then across to $(1,a_1)$, again descending if necessary to $(1,a_2)$, then across, and so on until ending at $(k,1)$. All in all you make $n-1$ descending steps and $k$ steps across, for a total of $n+k-1$ steps in all cases. Among those steps $k$ steps are horizontal (across a column), and they can be chosen in any set of positions, which makes for $ f(n,k)=\binom{n+k-1}k$ possibilities.
Yes, the interpretation of binomial coefficients as counting lattice paths is well known. Indeed the lattice path interpretation is often preferred over the
subsets interpretation. For instance if you count the lattice paths in Pascal's triangle (for a properly aligned lattice) from the root to a given binomial coefficient, then every lattice path must pass through exactly one of the neighbouring coefficients in the row above it, and the total number of lattice paths found is the sum of the two numbers for those two coefficients. It follows that the lattice path counts satisfy Pascal's recurrence, and if you known that these numbers are equal to binomial coefficients, it follows that binomial coefficients also satisfy Pascal's recurrence. Lots of other identities between binomial coefficients can similarly be understood in terms of lattice paths.


Interpreting the Surface Integral over a Vector Field

Question: I have seen the fact that in certain instances, the Surface Integral over a Vector Field gives the quantity of fluid flowing through the surface in unit time (as in here, or in any standard Vector Calculus textbook).
I am having trouble exactly seeing this from the formula. Usually a rate is defined by a derivative, I am unclear on how it emerges from this integral. I hope I am being clear, I would simply like some motivation in how this interpretation comes out of the surface integral. Thanks.
Answer: In the case of which you speak, the surface integral is
$$\int_S \mathbf{v} \cdot \mathbf{n} dS$$
where $\mathbf{v}$ is a velocity of a fluid flowing through $S$.
At each surface element $dS$, the normal component of the velocity provides the time rate you seek.  If $\mathbf{r}$ is the position of an element of fluid that passes through the surface element $dS$, then, at the instant that particle is at that surface element, $\mathbf{v} = d\mathbf{r}/dt$; in this case, across the surface, the surface integral is
$$\frac{d}{dt} \int_S \mathbf{r} \cdot \mathbf{n} dS$$
This integral whose time derivative is taken is the volume of the fluid across the surface; thus, the surface integral in question is the volume flow rate of fluid across the surface $S$.
(I of course assumed that the surface itself is not moving.  This is a pretty big assumption, as moving surfaces appear frequently in physical applications.)
Comment: not sure what you mean when you say "This integral whose time derivative is taken is the volume of the fluid across the surface; thus, the surface integral in question is the volume flow rate of fluid across the surface S." How is that integral the volume? and how does that imply that the surface integral is the flow rate? I'm missing something.
Comment: @Coffee_Table:  The integral is that volume because, for a thin slice of fluid, the volume is the surface times the thickness of the fluid under (through) the surface.  Because the integral is this volume, its derivative is the flow rate.
Comment: I see. and taking $d/dt$ of that integral (the one with $r$) gives the original (the one with $v$)?
Comment: @Coffee_Table: correct.
Answer: If you're asking about $\int \vec{v} \cdot d\vec{S}$, it might be best to think about a flat surface first.  We assign to an infinitesimal "patch" of the surface a vector $d\vec{S}$ which points perpendicular to that "patch" (some people call these "areal (normal) vectors); for a flat surface, all of these point in the same direction.
The vector field described by $\vec {v}$ (or, say, $\vec {v}(x,y,z)$ to make it a function) might represent the "flow" of something.  At each patch on the surface, these "flow" vectors are going to make some angle to each areal vector $d\vec{S}$.  If $\vec{v}$ and $d\vec{S}$ are parallel, the greatest possible amount of flow "outward" through the surface occurs; if they are anti-parallel, the greatest possible "inward" flow occurs there; if they are perpendicular (the flow is "along the surface"), then the flow through the surface at that point is zero; intermediate values are possible for other relative angles.
So the dot product $\vec{v} \cdot d\vec{S}$ gives the amount of flow at each little "patch" of the surface, and can be positive, zero, or negative.  The integral $\int \vec{v} \cdot d\vec{S}$ carried out over the entire surface will give the net flow through the surface; if that sum is positive (negative), the net flow is "outward" ("inward").  An integral value of zero would mean that over the entire surface, there is as much inward as outward flow, so that the net flow is zero.
There is no reason that the full surface has to be flat, since we are integrating all of these infinitesimal patches.  We can as easily make a surface which is a closed spherical shell (like a bubble).  A physical example which uses this is the electric field of a charge.  A single positive electrically-charged particle produces a field $\vec{E}$ which points radially away from the particle.  On a sphere, all of the areal vectors $d\vec{S}$ point perpendicularly outward from the sphere's center in their individual patches.  So the field $\vec{E}$ is aligned everywhere on this "bubble" with every areal vector $d\vec{S}$, and we have $\vec{E} \cdot d\vec{S} = E dS \cos(0) = E dS$ (here, E is the strength of the electric field at the surface of this sphere and has the same value everywhere on it).  The "electric flux" through this spherical shell is then the result of summing E times the total area of all the patches covering the "bubble" of radius R:  $\int \vec{E} \cdot d\vec{S}  =  \int E  dS  =  E \int dS  =  E \cdot 4\pi R^2$, since $4 \pi R^2$ is the surface area of the spherical "bubble" we've chosen.  If the electric charge were negative, the electric field would point toward the charge, giving us an "inward" flux  $\int \vec{E} \cdot d\vec{S}  =  \int -E  dS   =  -E \cdot 4\pi R^2$.  If we place equal amounts of positive and negative charge inside the spherical shell, the net electric flux would add up to zero.
This is a very simple and symmetrical example of a surface integral, but the same principle applies to more complicated vector fields and more complicated (open or closed) surfaces.
Comment: very clear, I like your example with electric fields.
Comment: I am exposing the portion of my education as a physicist.  But a good deal of vector analysis was developed to handle problems with fields representing force or representing flow, so it is convenient to employ such an example.
Answer: let me try to answer you in a very simple way using different kinds of interpretation for the operation which is used in the equation you are asking about
let's start with dot product :-
dot product can be understood from the fact that it get the amount of projected vector field of another vector that's because you are multiplying the magnitude of vector A as example times the cosine of the angle so you are projecting magnitude of A on B
form this face if you take a look at the equation you are asking about you will find that dS is translated into ndS where n is the normal component on the surface you are integrating , so if you thought for a little you will find that the meaning of the surface integral as following :-
at every single point on the surface you take your vector field and project it using dot product on the normal component to the surface and then you are integrating with respect to this surface " and integration is summation of all the magnitudes you already got"
that's why you get amount of fluid going out
Note 1 : you have to keep in mind that this happen for any surface not suppose to be closed one
Note 2 : if we are talking about vector field it will actually be found all over the volume of the surface whether outside it of inside the volume " if it is closed" so you can simply imagine that there is a dotted of imaginary version of your surface and you are projecting your vector field on it


Caused by: java.lang.RuntimeException: com.nimbusds.oauth2.sdk.ParseException: Unexpected type of JSON object member with key "mtls_endpoint_aliases"

Question: I'm running a spring-boot app which acts as a oauth2 resource server and all requests must have a valid jwt. But I'm getting the following error at the application startup.

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webSecurityConfig' defined in file [D:\IdeaProjects\someProject\moduleApp\build\classes\java\main\somePackage\config\WebSecurityConfig.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorizedClientService' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2WebSecurityConfiguration.class]: Unsatisfied dependency expressed through method 'authorizedClientService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRegistrationRepository' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2ClientRegistrationRepositoryConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]: Factory method 'clientRegistrationRepository' threw exception; nested exception is java.lang.IllegalArgumentException: Unable to resolve Configuration with the provided Issuer of "http://localhost:8180/realms/master"
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:227) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1356) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1203) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:408) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:884) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:788) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
... 158 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorizedClientService' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2WebSecurityConfiguration.class]: Unsatisfied dependency expressed through method 'authorizedClientService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRegistrationRepository' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2ClientRegistrationRepositoryConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]: Factory method 'clientRegistrationRepository' threw exception; nested exception is java.lang.IllegalArgumentException: Unable to resolve Configuration with the provided Issuer of "http://localhost:8180/realms/master"
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:538) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:884) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:788) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
... 181 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRegistrationRepository' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2ClientRegistrationRepositoryConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]: Factory method 'clientRegistrationRepository' threw exception; nested exception is java.lang.IllegalArgumentException: Unable to resolve Configuration with the provided Issuer of "http://localhost:8180/realms/master"
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:635) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:884) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:788) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
... 195 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]: Factory method 'clientRegistrationRepository' threw exception; nested exception is java.lang.IllegalArgumentException: Unable to resolve Configuration with the provided Issuer of "http://localhost:8180/realms/master"
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
... 209 common frames omitted
Caused by: java.lang.IllegalArgumentException: Unable to resolve Configuration with the provided Issuer of "http://localhost:8180/realms/master"
at org.springframework.security.oauth2.client.registration.ClientRegistrations.getBuilder(ClientRegistrations.java:204) ~[spring-security-oauth2-client-5.3.5.RELEASE.jar:5.3.5.RELEASE]
at org.springframework.security.oauth2.client.registration.ClientRegistrations.fromIssuerLocation(ClientRegistrations.java:138) ~[spring-security-oauth2-client-5.3.5.RELEASE.jar:5.3.5.RELEASE]
at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter.getBuilderFromIssuerIfPossible(OAuth2ClientPropertiesRegistrationAdapter.java:83) ~[spring-boot-autoconfigure-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter.getClientRegistration(OAuth2ClientPropertiesRegistrationAdapter.java:59) ~[spring-boot-autoconfigure-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter.lambda$getClientRegistrations$0(OAuth2ClientPropertiesRegistrationAdapter.java:53) ~[spring-boot-autoconfigure-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at java.base/java.util.HashMap.forEach(HashMap.java:1337) ~[na:na]
at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(OAuth2ClientPropertiesRegistrationAdapter.java:52) ~[spring-boot-autoconfigure-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientRegistrationRepositoryConfiguration.clientRegistrationRepository(OAuth2ClientRegistrationRepositoryConfiguration.java:49) ~[spring-boot-autoconfigure-2.3.6.RELEASE.jar:2.3.6.RELEASE]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.11.RELEASE.jar:5.2.11.RELEASE]
... 210 common frames omitted
Caused by: java.lang.RuntimeException: com.nimbusds.oauth2.sdk.ParseException: Unexpected type of JSON object member with key "mtls_endpoint_aliases"
at org.springframework.security.oauth2.client.registration.ClientRegistrations.parse(ClientRegistrations.java:216) ~[spring-security-oauth2-client-5.3.5.RELEASE.jar:5.3.5.RELEASE]
at org.springframework.security.oauth2.client.registration.ClientRegistrations.lambda$oidc$0(ClientRegistrations.java:148) ~[spring-security-oauth2-client-5.3.5.RELEASE.jar:5.3.5.RELEASE]
at org.springframework.security.oauth2.client.registration.ClientRegistrations.getBuilder(ClientRegistrations.java:195) ~[spring-security-oauth2-client-5.3.5.RELEASE.jar:5.3.5.RELEASE]
... 222 common frames omitted
Caused by: com.nimbusds.oauth2.sdk.ParseException: Unexpected type of JSON object member with key "mtls_endpoint_aliases"
at com.nimbusds.oauth2.sdk.util.JSONObjectUtils.getGeneric(JSONObjectUtils.java:133) ~[oauth2-oidc-sdk-7.5.jar:7.5]
at com.nimbusds.oauth2.sdk.util.JSONObjectUtils.getJSONObject(JSONObjectUtils.java:829) ~[oauth2-oidc-sdk-7.5.jar:7.5]
at com.nimbusds.oauth2.sdk.as.AuthorizationServerMetadata.parse(AuthorizationServerMetadata.java:1705) ~[oauth2-oidc-sdk-7.5.jar:7.5]
at com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata.parse(OIDCProviderMetadata.java:1203) ~[oauth2-oidc-sdk-7.5.jar:7.5]
at org.springframework.security.oauth2.client.registration.ClientRegistrations.parse(ClientRegistrations.java:214) ~[spring-security-oauth2-client-5.3.5.RELEASE.jar:5.3.5.RELEASE]
... 224 common frames omitted

Process finished with exit code 1
Did not find much on this error when searched online, but what I could gather was that there's a dependency incompatibility with spring-boot-security versions and com.nimbusds:oauth2-oidc-sdk
However when  "com.nimbusds:oauth2-oidc-sdk:9.19" is added as an additional dependency to the project the application starts fine, but returns a 401 UNAUTHORIZED gives the following error in console when an endpoint is triggered

java.lang.NoSuchMethodError: 'net.minidev.json.JSONObject com.nimbusds.jose.Header.toJSONObject()'
at org.springframework.security.oauth2.jwt.NimbusJwtDecoder.createJwt(NimbusJwtDecoder.java:146) ~[spring-security-oauth2-jose-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.oauth2.jwt.NimbusJwtDecoder.decode(NimbusJwtDecoder.java:129) ~[spring-security-oauth2-jose-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider.authenticate(JwtAuthenticationProvider.java:84) ~[spring-security-oauth2-resource-server-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:199) ~[spring-security-core-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationFilter.doFilterInternal(BearerTokenAuthenticationFilter.java:124) ~[spring-security-oauth2-resource-server-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestRedirectFilter.doFilterInternal(OAuth2AuthorizationRequestRedirectFilter.java:160) ~[spring-security-oauth2-client-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:117) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) ~[spring-security-web-5.3.9.RELEASE.jar:5.3.9.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:97) ~[spring-boot-actuator-2.3.12.RELEASE.jar:2.3.12.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.46.jar:9.0.46]
at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]

Any sort of help around this is greatly appreciated.
Answer: I was able to solve this by adding <code>apply plugin: 'io.spring.dependency-management'</code> to my build.gradle file, which imported <code>"com.nimbusds:oauth2-oidc-sdk:9.19"</code> and <code>"com.nimbusds:nimbus-jose-jwt:8.21"</code> in addition to the already existing versions 7.5 and 8.19 respectively, which made the above error at application start up disappear, and then I was able to hit the endpoint without any problems as well.
Comment: Hi @don, I did not specifically use those imports in my implementation directly, but they were required by org.springframework.boot:spring-boot-starter-oauth2-client and org.springframework.boot:spring-boot-starter-oauth2-resource-server(used as transitive dependencies), got automatically imported after adding apply plugin: 'io.spring.dependency-management'
Comment: Hi, I am facing the same issue in a maven project. After the import did you use 1) import com.nimbusds.jose.shaded.json.JSONObject;  OR 2) import net.minidev.json.JSONObject; ? Thanks


Center of a normal subgroup is also a normal subgroup

Question: If $K$ is a normal subgroup of a group $G$, then the center $Z(K)$ of $K$ is also a normal subgroup of $G$.
I want to prove this statement. But without using characteristic subgroups and automorphisms. Since in our course we did not learn yet. I hope there is another proof that only uses conjugation, (normal) subgroups, and center/centralizers.
Comment: You can start from the definition of "center" and definition of "normal subgroup".
Comment: The following might be considered as an abstract duplicate: [If $N$ is a normal subgroup of a group $G$, and $M$ is a characteristic subgroup of $N$, then $M$ is a normal subgroup of G.](https://math.stackexchange.com/a/647066/386889)
Comment: Well it is a good opportunity to learn this convenient notion.Next time please do not just ask. Show some work. https://math.meta.stackexchange.com/questions/9959/how-to-ask-a-good-question
Comment: Thanks @Nobody, but I know that primary stuff. I know Z(G), is a normal subgroup of G.
Comment: Does this answer your question? [Prove that the center of a group is a normal subgroup](https://math.stackexchange.com/questions/66052/prove-that-the-center-of-a-group-is-a-normal-subgroup)
Comment: No. It is not the same question. Please read carefully
Comment: I don't know characteristic subgroups, we didn't learn that in the course. I need a more basic explanation, a different approach.
Comment: Oh, ok. You are right. I am new here, sorry. Also, thanks for the answer. I will do some research
Comment: The approach I gave in my answer is much simpler than what is in the linked post.
Comment: [Prove that: the center of any group is characteristic subgroup .](https://math.stackexchange.com/a/430882/386889)
Answer: Let $z \in Z(H)$ and let $g \in G$. Since $H$ is a normal subgroup of $G$ and $z \in H$, we know that $gzg^{-1} \in H$. We claim that $gzg^{-1} \in Z(H)$. Let $h \in H$. We want to show that $hgzg^{-1}=gzg^{-1}h$. Since $H$ is normal in $G$, we know that $g^{-1}hg=h'$ for some $h' \in H$.
Try to take it from here.
Comment: We have $g^{-1}hg=h'$. Multiply both sides by $g^{-1}$ on the right.
Comment: I guess, I found the answer thanks to you. Showing $hgzg^{−1}=gzg^{−1}h$ is a good simplification. I also used the lemma $gzg^{-1}ghg^{-1} = ghg^{-1}gzg^{-1}$. Which is more critical, I guess. It indicates, after a transformation action on both $h$ and $z$, $z'$ still commutes. Then showing your idea is simple because $ghg^{-1}$ is just another element of $H$.
Comment: I guess, I used unintentionally the concept of automorphism. Am I right? I have not covered that topic yet.
Comment: Did you get your question answered? I didn't see your question until now.


Product of Borel and non-Borel set

Question: It is true that product of Borel and non-Borel sets is non-Borel set?
More precisely, I would like to know if $V $×$ \{1\}$ is Borel, where $V$ is Vitali set.
Answer: It is well known that for a Borel set $M \subset \Bbb{R}^n \times \Bbb{R}^m$ the "sections"
$$
M_x =\{y\in \Bbb{R}^m \mid (x,y)\in M\},\\
M^y =\{x\in \Bbb{R}^n\mid (x,y)\in M\}
$$
are Borel measurable for all $x\in \Bbb{R}^n,y\in \Bbb{R}^m$. To see this, show that the class of all such sets forms a sigma algebra an contains the open sets.
Using this property, it is easy to see that if $M,N$ are nonempty and if $M\times N$ is Borel, then so are $M,N$.
Comment: Thank you. But I still cannot see, if   $M×N$ is Borel or not,  when $M$ is and $N$ is not Borel.
Comment: @compatibilizator: Assume $M \times N$ is Borel. By what I wrote above, you know that $(M \times N)_x$ is Borel for every $x$. Now choose any $x \in M$ then you have $(M \times N)_x = N$, which is not Borel, a contradiction. Hence, $M\times N $ can not be Borel if $N$ is not.

Product of Borel and non-Borel set


Can I apply Barbalat's lemma when the derivative of a function approaches a uniformly continuous function?

Question: Sorry if this is a stupid question, but Barbalat's lemma says that if $f(t)$ approaches a limit as $t$ approaches infinity, and if it's derivative $\dot{f}(t)$ is uniformly continuous, then $\dot{f}$ must approach 0.
I was wondering, if I can show that $\dot{f}$ approaches a uniformly continuous function $g(t)$, for $f(t)$ approaching some limit can I still say that $\dot{f}$ approaches 0 even if it only approaches a uniformly continuous function rather than being one?
I think I have shown that for any $\epsilon>0$, I can show there exists some value $\delta>0$ and some value $T$ such that $|f(x)-f(y)|<\epsilon$ for all $(x,y)>T$ where $|x-y|<\delta$. This seems like it could be used to still state Barbalat's lemma to guarantee convergence past $T$, but I'm not sure. Also, where can I find a proof of Barbalat's lemma? Many thanks.
Answer: Hello Minecraft dirt block! I will refer to the following proof of Barbălat's lemma. Note that the case you mention is a consequence of this general setting by considering $y = f'$. The idea with uniform continuity, as seen in the proof, is that it gives an important estimate: $|y(t)| \geq \frac{\varepsilon}{2}$ for all $t$ with $|t_n - t| \leq \delta_\varepsilon.$ Let's proceed in the same way with the proof and see if we can tinker it to serve our goal. Thus let's assume that $y$ is simply continuous, not necessarily uniformly continuous and approaches a uniformly continuous function $g$ in some way.
We will still proceed by contradiction and deduce the existence of a sequence $(t_n)_{n \in \mathbb{N}}$ that converges to infinity such that $|y(t_n)| \geq \varepsilon$ for all $n$. Eventually passing to a subsequence, we can assume $y(t_n) \geq \varepsilon$ (if necessary, we can replace $y$ by $-y$). Note that the continuation of the proof doesn't work in the same way, but we have that $|y(t_n) - y(t)| \leq |y(t_n) - g(t_n)| + |g(t_n) - g(t)| + |g(t) - y(t)|,$ so if we can control the first and last quantities we would be done. Thus, let's assume that $\lim_{t \to \infty} |y(t) - g(t)| = 0.$ This would mean that there is $M > 0$ such that $|y(t) - g(t)| < \frac{\varepsilon}{6}$ whenever $t > M.$ Once again (eventually passing to a subsequence) we can assume this is true for all of the $t_n$'s. Furthermore, by the uniform continuity of $g,$ we can find $\delta_\varepsilon > 0$ such that $|g(a) - g(b)| < \frac{\varepsilon}{6}$ whenever $|a - b| < \delta_\varepsilon.$ Putting all the pieces together, $|y(t_n) - y(t)| \leq \frac{\varepsilon}{2}$ whenever $|t - t_n| < \delta_\varepsilon$ and all $n \in \mathbb{N}.$ In the same way as in the link provided we deduce that $|y(t)| \geq \frac{\varepsilon}{2}$ for the same values of $t$ as above. Then the conclusion follows in the same way:
$$0\leftarrow|\int_0^{t_n + \delta_\varepsilon} y(t) dt - \int_0^{t_n} y(t) dt| = |\int_{t_n}^{t_n + \delta_\varepsilon} y(t) dt| = \int_{t_n}^{t_n + \delta_\varepsilon} |y(t)| dt \geq \frac{\varepsilon \delta_\varepsilon}{2} > 0,$$
thus reaching a contradiction. I hope this helps.
Comment: Thanks for the comprehensive answer! I think this is pretty much what I ended up doing with the same link you posted.
Answer: I think I got it. I just extended the proof here:
https://planetmath.org/proofofbarbalatslemma
The uniform continuity here is only used to obtain a domain where the difference between the function values is less than a finite value which is determined by the assumed not convergent derivative. So, since I don't need this difference to be vanishing, I think I can just use what I have in the question to extend Barbalat's this proof.
Comment: Oops, someone else already posted the answer.


INDEX rebuild and reorganize based on fragmentation results in SQL Server 2012

Question: I know there are some scripts to detect index fragmentation, and based on the results, REBUILD or REORGANIZE. I have tried with some for SQL Server 2005 without results.
Could you help advise?
Comment: Just [get Ola's stuff](https://ola.hallengren.com/).
Answer: Check out the script provided on TechNet: https://gallery.technet.microsoft.com/scriptcenter/Check-SQL-Server-a-a5758043 that illustrates how to check for fragmented indexes.
<code>SELECT
    OBJECT_NAME(ind.OBJECT_ID) AS TableName,
    ind.name AS IndexName,
    indexstats.index_type_desc AS IndexType,
    indexstats.avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats
INNER JOIN sys.indexes ind
    ON ind.object_id = indexstats.object_id
    AND ind.index_id = indexstats.index_id
WHERE indexstats.avg_fragmentation_in_percent > 30
ORDER BY indexstats.avg_fragmentation_in_percent DESC
</code>
Change the percent from 30 to whatever you are comfortable with. I tend to tolerate up to 30% fragmentation as a starting point. For fragmentation higher than that, I prefer rebuilding more than reorganizing. You can check out Kendra Little/Brent Ozar's blog about rebuild vs. reorg http://www.brentozar.com/archive/2013/09/index-maintenance-sql-server-rebuild-reorganize/


How to show only the comment form, not the comments

Question: Right now in Drupal, at the end of each article, there are the comments which users has put on that article and also the comment form. I just want to have the comment form at the end of each article, I do not want the comments be shown at the end of each article. Does any body know how can I do it?
Answer: Implement hook_node_view() and check for $node->type == 'article' and $view_mode=='full' then unset the comments as follows
unset($node->content['comments']['comments']);


Property 'map' does not exist on type 'Subject<{}>'

Question: So, I've seen multiple other posts about similar problems, but none of the solutions have helped.
I am also doing this development in IntelliJ IDEA 15, not Visual Studio. I am currently on Typescript 2.0.3.
import { Injectable } from '@angular/core';
import { Effect, StateUpdates, toPayload } from '@ngrx/effects';
import { Subject } from 'rxjs/Subject';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/observable/dom/webSocket'
import 'rxjs/add/operator/map';

import { AppState } from '../reducers';
import { NGRXWebSocketService } from '../shared/ngrxWebsocket.service';
import { BASE_URL } from "../shared/ngrxWebsocket.service";

export interface WebsocketMessage {
    data: string
}

@Injectable()
export class WebsocketEffects {

constructor(private updates$:StateUpdates<AppState>,
            private ngrxWebSocketService: NGRXWebSocketService) {
}

@Effect() _recieve$ = this.ngrxWebSocketService.getSubject()
    .map((websocketUpdate: WebsocketMessage) => {
        let message = JSON.parse(websocketUpdate.data);
        return{ type: message.action, payload: message.payload}
    });
}

Edit 1:
Here is this NGRXWebsocketService.
import {Injectable} from '@angular/core';
import {$WebSocket, WebSocketConfig} from 'angular2-websocket/angular2-websocket'

export const BASE_URL = 'ws://' + location.hostname + ':9000/socket';

@Injectable()
export class NGRXWebSocketService {
    private socket: $WebSocket;

    constructor() {
        this.socket = new $WebSocket(BASE_URL);
    }

    public sendRequest(request) {
        return this.socket.send(request);
    }

    public reconnect() {
        this.socket = new $WebSocket(BASE_URL);
    }

    public getSubject() {
        return this.socket.getDataStream();
    }
}

Comment: What happens if you do `getSubject().asObservable().map`?
Comment: @peeskillet

`error TS2339: Property 'map' does not exist on type 'Observable<{}>'.`
Comment: @PaulSwetz I said in my question that I am not using Visual Studio.
Comment: Is it just a problem in the IDE? Or are you getting this when you manually compile?
Comment: I can run the application just fine from within the IDE. I only see this issue when I manually compile.
Comment: Hmm... yea I don't know.
Comment: have you seen [this](http://stackoverflow.com/questions/36947748/angular-2-beta-17-property-map-does-not-exist-on-type-observableresponse?rq=1) ?
Comment: Some questions: What version of RxJS? What do you mean by "manually compile"? Can you include the code for `NGRXWebSocketService`? At the moment, this isn't really a [mcve].
Comment: As @cartant stated, I think we'll need to see your `ngrxWebSocketService` code to solve this. Particularly the `getSubject()` function of that service.
Comment: @A_Singh I have already seen this question and none of the suggestions have helped me.
Comment: @Caleb I added NGRXWebSocketService.
Comment: @cartant I added NGRXWebSocketService.
Comment: @cartant Also, I am using RXJS version 5.0.0-beta.12.
Comment: Does your project use `core-js` or `es6-shim`? Is `typings` in *package.json* `devDependencies`?
Answer: This look like a typing issue during manual compilation.
When compiling within IDE, the IDE may have internal typing configuration, which does not exist in your project settings.

npm install typings -g
Check your package.json dependencies.
es6-shim
If you have es6-shim in dependencies, create typings.json in your project directory:
{
    "globalDependencies": {
        "es6-shim": "registry:dt/es6-shim",
        "node": "registry:dt/node"
    }
}

core-js
If you have core-js in dependencies, create typings.json in your project directory:
{
    "globalDependencies": {
        "core-js": "registry:dt/core-js",
        "node": "registry:dt/node"
    }
}

typings install
Try manual compile.
Answer: In the code in your question, you appear to be doing what's required: you've imported the Subject and you've imported/added the map operator. So it's a bit of a mystery why you are receiving the TypeScript error. However, your recent edit to the question does raise one possibility.
It's apparent that NGRXWebsocketService imports an NPM module: angular2-websocket/angular2-websocket. And that module has a dependency on firstname.lastname@example.com. Note that this is a dependency and not a peerDependency.
It's entirely possible that you have two separate rxjs modules in your node_modules hierarchy: one that's being used in your app (and, therefore in WebsocketEffects) and another that's being used in angular2-websocket/angular2-websocket. If that is the case, TypeScript will consider the type returned by getSubject to differ from the type that you have imported and to which you have added the map operator (despite their both being called Subject).
You can verify whether or not this is actually the case by adding some temporary code to your WebsocketEffects class:
temp() {
    let subject: Subject<any> = this.ngrxWebSocketService.getSubject();
}

If angular2-websocket/angular2-websocket is using a separate rxjs install, you should see an error something like this:
TS2322: Type 'Subject<any>' is not assignable to type 'Subject<any>'.

You can also run the following NPM command to list the rxjs installs that are under your node_modules directory:
npm list rxjs

This potential for multiple rxjs module installations is something that should be addressed by the angular2-websocket/angular2-websocket author. However, if you do have multiple installations, there is something you might be able to do about it (as the rxjs versions are identical). If you uninstall and re-install angular2-websocket/angular2-websocket, it should use the rxjs module that you are using in your app (instead of installing its own).
In fact, all of the dependencies in angular2-websocket/angular2-websocket should be peer dependencies and not dependencies. I would recommend your raising this as an issue.
Answer: Try to import map:
import {map} from 'rxjs/operator/map';

Answer: Looking at the source code for angular2-websocket it looks like getDataStream() returns a subject that emits MessageEvent.
Try this:
@Effect() _receive$ = this.ngrxWebSocketService.getSubject()
  .map((messageEvent: MessageEvent) => {
      let message = JSON.parse(messageEvent.data);
      return { type: message['action'], payload: message['payload'] };
  });

Answer: For RXJS v6 you have to use the pipe() with map().
 this.ngrxWebSocketService.getSubject().pipe(
    map((websocketUpdate: WebsocketMessage) => {
        let message = JSON.parse(websocketUpdate.data);
        return{ type: message.action, payload: message.payload}
    })
 );

Hope this fix will help.
Answer: import 'rxjs/Rx'; should fix all problems
Answer: i try:
import 'rxjs/add/operator/map'

from here:
https://github.com/webmaxru/pwa-workshop-angular/issues/2
and worked fine :)
Answer: https://medium.com/coding-snippets/rxjs-5-5-property-map-does-not-exist
This helped me with the current version of angular and rxjs.
Basically you need to use pipe instead of map,  and call the rxjs map function within the pipe