Virtual SMTP Server not relaying mail

Question: In our LAN, we have a development box with IIS 7 that has an SMTP Virtual Server installed.  All development applications send outgoing mail to this virtual SMTP server, and it in turn relays the mail to our internal Exchange 2007 server.  Or, at least it used to.  Our network engineer recently replaced our Exchange server with another one, and now the mail is no-longer relaying.
Strangely enough, in our production environment, we have a similar setup.  All outbound mail is sent to a virtual SMTP server (same version of IIS), and that server relays mail to the same Exchange server, only over the Internet.  And outbound mail is working from the production environment.  I've tried mirroring every single setting on our development box, including changing the smart host to the Exchange box's Internet-facing host name, and mail continues to linger in the queue.
The development box is able to successfully resolve the smart host's name, and I can connect to the Exchange server via port 25 from that box just fine.
Being completely unfamiliar with Exchange and weakly familiar with SMTP, I'm clueless as to how to troubleshoot this issue.  The network engineer hasn't been able to figure things out either.  What could be causing this to not work?
Here's my Virtual SMTP Server settings.

Under the delivery tab, Outbound Security dialog of the SMTP server, "Integrated Windows Authentication" is selected, and a valid username & password is entered.  The user name is prefixed by the Windows domain (domain\username).  TLS encryption is selected.
Under the delivery tab's Advanced dialog, we have the following settings:

Masquerade domain: mycompany.com (I've tried removing this to no avail)
Fully-qualified domain name: mycompany.local (I've also tried mycompany.com)
Smart host: myexchangeserver.mycompany.local (I've also tried its public domain name)
The direct delivery and reverse DNS lookup options are disabled

As far as Exchange settings go, I'm not sure what to look for, but I have access to the box and can post its relevant settings if necessary.
Answer: Rather than poking at a black box and wondering why it won't work, install "Network Monitor" or Wireshark on the SMTP relay machine and sniff some SMTP traffic. You'll find out in about 30 seconds why your mail is being rejected. That's going to be your path of least resistance. The box wants to tell you what's wrong, you just need to look.
Your "network engineer" should've reached for the sniffer earlier, IMO. Sniffing the traffic on the wire seems "taboo" to some people, but it's often the best way to get to the bottom of a problem in a human-readable protocol like SMTP.
Comment: I tried doing so earlier and saw no SMTP traffic.  I'll try it again just in case.  However, I suspect that SMTP traffic will continue to not show up since I'm using TLS encryption.  How would encrypted traffic appear?
Comment: Duh! I didn't see that you're using TLS. Can you turn off TLS temporarily to see the plaintext traffic?
Comment: Strange... I see no SMTP traffic on the box through Wireshark, even with TLS disabled.  Very fishy.
Comment: You do see SMTP traffic when you TELNET to the SMTP server manually, though, right?
Comment: Yes.  All the trappings of the protocol appear to be working through SMTP.
Answer: We just talked to Microsoft's support, and we figured it out.  The fully-qualified domain name setting under the advanced dialog of the delivery tab was supposed to be the virtual SMTP server's name, not just the domain name.  Now that it's set to myvirtualsmtpserver.mycompany.local, mail is being relayed as expected.
Comment: Well done Jacob! Just the ticket. Our Fully Qualified Domain Name (FQDN) was set to the local server and worked fine for 8-years. In Feb 2014 we could no longer relay emails. Having followed your advice it solved the problem! Thanks :-)

Virtual SMTP Server not relaying mail


Categorical variable as independent variable

Question: I am using the variable education level as a control variable and this variable consists of 7 education levels (1-7). Now I can't use it as it is converted in the data. My teacher has messaged me that I have to use education fixed effects by computing the variable into a binary variable for each education level, however, I am not sure how to do this in stata.
Does anyone have tips on how to covert this variable?
Answer: you do not need to that.
simply type
<code>regress yvar xvar i.educvar
</code>
where y is your dependent variable,
x are all other independent variables, and
educvar is your education variable in categories.
If you have stata 12 or above, it will automatically create the binary variables in the background.


Find $ k $ if both roots of this equation $ x^2-2kx+k^2+k-5=0 $ are less than 5

Question: If both roots of this equation $ x^2-2kx+k^2+k-5=0 $ are less than $ 5$, then find the limit of $ k$.
Method-1
Let's say,
\begin{align}  f(x)=x^2-2kx+k^2+k-5  \end{align}
\begin{align} f(0)=0 →\alpha,\beta \end{align}
$ a=1 \gt 0 ,$ So graph is upward. Minimal point $ x_{m} \lt 5$.
Since, the roots$ \alpha,\beta \lt 5, f(5) \gt 0$. And also to have the roots, $ D \geq 0 $ must be followed.
(i)
\begin{align}  x_{m} \lt 5 \end{align}
\begin{align}  \Rightarrow -\frac{(-2k)}{2×1} \lt 5 \end{align}
\begin{align}  \Rightarrow k \lt 5 \end{align}
(ii)
\begin{align} D \geq 0 \end{align}
\begin{align} \Rightarrow (-2k)^2-4(k^2+k-5) \geq 0 \end{align}
\begin{align} \Rightarrow k \leq 5 \end{align}
(iii)
\begin{align} f(5) \gt 0 \end{align}
\begin{align} \Rightarrow 25-9k+k^2-5 \gt 0 \end{align}
\begin{align} \Rightarrow (k-4)(k-5) \gt 0 \end{align}
\begin{align} \Rightarrow k\lt 4,
k \gt 5 \end{align}
Now, from (i),(ii),(iii) we can say, $ k \lt 4 $ .
Method-2
Given that , $ \alpha,\beta \lt 5$
So, \begin{align}  \alpha+\beta \lt 10 \qquad{(1)} \end{align}   \begin{align} \alpha\beta\lt 25 \qquad (2) \end{align}
From, (1)
\begin{align}  2k \lt 10 \end{align}
\begin{align} \Rightarrow k \lt 5\end{align}
From (2)
\begin{align} \Rightarrow k^2+k-5 \lt 25\end{align}
\begin{align} \Rightarrow (k+6)(k-5) \lt 0\end{align}
\begin{align} \Rightarrow -6 \lt
k \lt 5 \end{align}
Now, from (1),(2) also including (ii) we can say, $-6 \lt
 k \lt 5$
Two different answers!
Comment: @dxiv umm I just missed it. So method 2 is wrong.
Comment: $\alpha,\beta \lt 5$ does not imply $\,\alpha\beta \lt 25\,$ as in $\,(2)\,$.
Comment: You can only say $k<4$.
Answer:
Find $ k $ if both roots of this equation $ x^2-2kx+k^2+k-5=0 $ are less than 5

Alternative approach:
Use the quadratic equation directly, calculate the value of the two roots, in terms of $k$, and then apply the constraint that both roots are less than $5$.
The roots are
$~\displaystyle \frac{1}{2}\left[2k \pm \sqrt{4k^2 - 4(k^2 + k - 5)}\right]$
$= ~\displaystyle k \pm \sqrt{k^2 - (k^2 + k - 5)} = k \pm \sqrt{5-k}.$
At this point, the first observation is that the equation will have one or more real roots if and only if
$$(5 - k) \geq 0. \tag1 $$
The larger root is taken by adding, rather than subtracting the square root, which is always non-negative.
Therefore, the problem reduces to finding all values of $k$ such that
$$k + \sqrt{5 - k} < 5. \tag2 $$
Warning
The following conclusion to this problem is a one-off.  Apparently, the problem composer wanted the Math student to have a fairly easy time of it, from this point forward.  Normally, you would reason that $\displaystyle ~\sqrt{5-k} < 5-k,~$ square both sides, and see where that leads.
For this particular problem, there happens to be a shortcut.  The constraint in (2) above will be satisfied if and only if
$$\sqrt{5-k} < (5-k). \tag3 $$
Here, it helps to know that for any non-negative real number $r$,

if $r = 0$ then $\sqrt{r} = r.$

if $0 < r < 1$, then $\sqrt{r} > r.$
This is a direct consequence of the fact that
if $0 < r < 1$, then $r = \sqrt{r} \times \sqrt{r} < \sqrt{r} \times 1 = \sqrt{r}.$

if $r = 1$, then $\sqrt{r} = r.$

if $r > 1$, then $\sqrt{r} < r.$
This is a direct consequence of the fact that
if $1 < r$, then $r = \sqrt{r} \times \sqrt{r} > \sqrt{r} \times 1 = \sqrt{r}.$

So, under the constraint imposed by (1) above, that $(5 - k) \geq 0$, the constraint in (3) is equivalent to the constraint that $1 < (5 - k).$
Therefore, since the constraint that $(5 - k) \geq 0$ is subordinate to the constraint that $(5 - k) > 1$, all satisfying values of $k$ are given by
$$1 < (5-k) \iff k < 4. $$


Applying function within a user-defined function to round off

Question: I'm trying to roundup numbers that satisfy a condition and round down numbers that satisfy a different condition. I wrote the below function to do this, but there seems to be a problem with it.
Range   New Range     I/D         Expected output
1         1.1         Increase       2
1         1.4         Increase       2
1         .7          Decrease       0
1         .9          Decrease       0
3         2.2         No Change      2
5         4.8         No Change      5

Basically if there's a flag to increase, apply the function to round up; a flag to decrease would mean apply the function to round down; and no flag would be a basic roundoff.
def inc(row):
    if row['increae']=='increase':
        val= row['Final New Range'].apply(np.ceil)
    elif row['increae']=='increase':
        val= row['Final New Range'].apply(np.ceil)
    else:
        val='None'
    return val

Traceback
<ipython-input-35-8f7b70f1c7f8> in inc(row)
     17 def inc(row):
     18     if row['increae']=='increase':
---> 19         val= row['Final New Range'].apply(np.ceil)
     20     elif row['increae']=='increase':
     21         val= row['Final New Range'].apply(np.ceil)

AttributeError: 'float' object has no attribute 'apply'

Comment: Please read this [post](https://stackoverflow.com/help/how-to-ask) and provide sample df along with your explanation and expected output to improve your chances of getting a response
Answer: The function you want would be something like this:
def inc(row):
    if row['increae']=='Increase':
        return int( np.ceil(row["New Range"]) )
    elif row['increae']=='Decrease':
        return int( np.floor(row["New Range"]) )
    else:
        return int( np.round(row["New Range"]) )

Run this piece of code to test it out:
import pandas as pd
import numpy as np

def inc(row):
    if row['increae']=='Increase':
        return int( np.ceil(row["New Range"]) )
    elif row['increae']=='Decrease':
        return int( np.floor(row["New Range"]) )
    else:
        return int( np.round(row["New Range"]) )

# Example of use

# Sample data frame
df = pd.DataFrame([[1, 1.1, "Increase"],
                   [1, 1.4, "Increase"],
                   [1, 0.7, "Decrease"],
                   [1, 0.9, "Decrease"],
                   [3, 2.2, "No Change"],
                   [5, 4.8, "No Change"],
                   ]
                  , columns=['Range', 'New Range', 'increae']) # column names

# Iterating through the rows
for index, row in df.iterrows():
    print(row[0], row[1], row[2], "--> output", inc(row) )

inc(row) gets the result for each row
Output of running that:
1 1.1 Increase --> output 2
1 1.4 Increase --> output 2
1 0.7 Decrease --> output 0
1 0.9 Decrease --> output 0
3 2.2 No Change --> output 2
5 4.8 No Change --> output 5

This should work for you if you change the column names for whatever you have in your original dataframe.


Notification when a shopping cart is abandoned

Question: How to create a notification when a shopping cart is dropped ?
I wish that the user who has not completed his / her order, receives an email 1 day after, to tell him that he has a basket in progress.
I think this should be possible with the "Rules" module.
Thank you
Comment: Bonjour! Can you think of a way to create a "view" of such carts? FYI: that's a prerequisite of "a" solution I can think of to make it work.
Comment: @Pierre.Vriens Hello, yes I created a shopping cart view. How to create the rule? I tested the module "Commerce Abandoned Cart Notification", but it is full of bug and works very badly.
Answer: I'd start by trying the existing Commerce Abandoned Cart Notification module. This module was specifically designed to send abandoned cart notifications.

This module allows you to notify your customers by email about their abandoned their cart.
Abandoned Shopping Cart mailings generate more than 55% more conversion compared to regular email campaigns. –SeeWhy research (2011)
Features

List your customers abandoned carts
100% integration with Commerce VBO
Edit the notification email directly from the Rule component


What is the matrix representation of Radon transform?

Question: Just as the title, my question is what is the matrix representation of Radon transform (Radon projection matrix)? I want to have an exact matrix for the Radon transformation.
(I want to implement some electron tomography algorithms by myself so I need to use the matrix representation of the Radon transformation.)
(An introduction of the Radon transformation: click here.)
Answer: A couple of years ago I was looking for the same answer. You can see that thread here. However, I don't think my solution is the only way to do it nor necessarily the best way.
We know it's a linear transform, so if you can take the transform of the right identity matrix, you'll get the matrix representation. As an easy example using matlab notation, if we wanted to get the matrix representation of a column-wise DFT matrix using the fft() function, we could do it with A = fft(eye(N)). Now, it's a little more complicated with the radon transform to do it efficiently, but the same idea applies.
If the image is $\mathbf{X} \in \mathbb{C}^{M \times N}$ and we wanted to find the DRT matrix $\mathbf{R} : \mathbb{C}^{M \times N} \rightarrow \mathbb{C}^{L\times P}$, then we know that $\mathbf{R} \in \mathbb{C}^{LP \times MN}$ and that the DRT is given by $\mathbf{Y} = \mathbf{R} \cdot \operatorname{vec}(\mathbf{X}) \in \mathbb{C}^{LP \times 1}$, where $\operatorname{vec} : \mathbb{C}^{A\times B} \rightarrow \mathbb{C}^{AB \times 1}$. The typical 2-D display of the DRT would then be had by simply reshaping the $LP \times 1$ vector into a $L \times P$ array.
We don't know $\mathbf{R}$, but we have access to a function that will efficiently compute the DRT, call it radon(), such that Y = radon(X) is equivalent to $\mathbf{Y} = \mathbf{R} \cdot \operatorname{vec}(\mathbf{X})$. Since $\mathbf{R} \cdot \mathbf{I} \cdot \operatorname{vec}(\mathbf{X}) = \mathbf{R} \cdot \operatorname{vec}(\mathbf{X})$, where $\mathbf{I}$ is the identity matrix, if we can used radon() in such a way that A = radon(I), then we have that A * vec(X) = radon(X).
The problem is that I don't see how to use radon to efficiently compute the above. Most radon() implementations take a 2-D input and output a 2-D array. It's simple enough to reshape the input/output into vectors, but the problem is that you would have to do that $MN$ times. Even for modest image sizes, the above will become computationaly prohibitive rather fast.
I hope the above helps. If you come up with an efficient solution, please post it here or at the stackoverlow thread linked above.
Comment: So what abut the answer you gave yourself on the thread you posted several years ago? Is it a good solution for find the Radon?
Comment: For that thread and the answer, the Matlab code you gave, what is `(ceil(-M/2) : floor(M/2)-1)` and `(ceil(-M/2) : floor(M/2))`? Why in parenthesis? There is no Matlab expressions like that... What is the imggrid function exactly? I still don't understand. Thanks!
Comment: @Ian It worked from what I remember. I'm not sure what the confusion about the matlab syntax is; it's perfectly valid. However, I added the contents of `imggrid` to my answer in that post. Hopefully that will clear things up.
Comment: Does radon matrix just have value 0 and 1? Like the output of your code. Why?
Comment: @Ian Because all it is doing is summing a certain set of pixels together. Each output pixel in the radon transform is the sum of the pixels that lie along a certain line. To calculate this sum, we weight the pixels along this line by $1$ and those that don't by $0$, then we sum the weighted pixels together.
Comment: In theory and following the definition of DRT, should the matrix representation of Radon just have value 0 or 1? Or is it just your estimation for your code? Because according to the definition of DRT I don't see why it's just 0 and 1.
Comment: @Ian All each matrix row does is choose which pixels to sum. These pixels will all lie along the line represented by that row. Unless you want to include an interpolation step prior to the summation, then yes, it will only have entries of zero and one. It would be entirely doable to work a bilinear interpolation into the matrix if you wanted to. Rather than grabbing and summing the nearest pixels to the line like I did, the interpolation could interpolate at intervals of $\mathrm{d}s$ using the nearest four pixels to each point. That, however, was more work than I wanted to put into it.
Comment: Can you favorably leave me your email address or sth.? I am reading your code in the answer for the other thread and get confused at some places. So I can ask you more easily. Thanks!
Comment: Let me put my main questions here regarding the codes you gave in the other thread. 1) why you chose `rho = -W/2 : drho : W/2`? Why `-W/2` and `W/2`? 2)what do you mean by "We chose which one based on angle so that we never get close to dividing by zero."? and why you consider two cases `phi >= pi/4 && phi <= 3*pi/4` and others? I think I don't quite understand here.
Comment: 3) What your purpose for this part for each line? `for jj = 1 : L
      p = round( tn(jj,:) - min( nimg ) ) + 1;
      q = round( mline(jj,:) - min( mimg ) ) + 1;
      inds = p >= 1 & p <= N & q >= 1 & q <= M;
      R( (ii-1)*L + jj, unique( sub2ind( [ M N ], q(inds), p(inds) ) ) ) = 1;
    end`? Can you explain more explicitly or add more comments on the code? Thank you soooo much!
Answer: Radon transform consists in a rotation plus a projection in X axis.
This code will throw True for any squared matrix where there is an inscribed circle containing the target values.
from skimage.transform import radon, rotate
import numpy as np

def get_image_center(img):

    center = (img.shape[0] * 0.5, img.shape[1] * 0.5)

    return center

def rotate_image(img, deg):

    rotated_img = rotate(img,
                         deg,
                         center=get_image_center(img),
                         preserve_range=True)

    return rotated_img

theta_test = np.linspace(0, 360, 100)

sinogram = radon(image, theta=theta_test, circle=True)

def perform_radon(img, angle_vector):

    radon_result_list = []
    x_projection_matrix = np.ones(img.shape[0])

    for angle in angle_vector:
        rotated_img = rotate_image(img,  - angle)
        radon_transform = np.dot(x_projection_matrix, rotated_img)
        radon_result_list.append(radon_transform)

    arr = np.vstack(radon_result_list).T

    return arr

manual_radon = perform_radon(img, theta_test)
manual_radon.shape

np.allclose(manual_radon, sinogram)

The last thing needed to get a linear transformation that represents Radon transformation is to get a linear operator that represents the rotation.
Answer: Currently I am solving the same problem as you guys.
I found a way to find the matrix.
First, we may view image(MxN) as a vector by certain reshape.
Second, set the ONLY one entry to 1, and others to 0.
Third, input this image to the function 'radon' then you way get the transformed image(LxP)
Loop over these three steps for every entry of image, which may causes MxN times.
cascade the result image(LxP) MxN times, then you will get the answer.
I.e. for 2x3-->3x4
[1 0 0 0 0 0]-->X_1 (reshape to a row vector)
[0 1 0 0 0 0]-->X_2 (reshape to a row vector)
[0 0 1 0 0 0]-->X_3 (reshape to a row vector)
[0 0 0 1 0 0]-->X_4 (reshape to a row vector)
[0 0 0 0 1 0]-->X_5 (reshape to a row vector)
[0 0 0 0 0 1]-->X_6 (reshape to a row vector)

Finally, stack result row vectors
[X_1, X_2, X_3, X_4, X_5, X_6].T


Pushed my mongodb url in my github repo how to hide the url in github

Question: I am doing an app in nodejs i have pushed my mongodb url in my github repo which is not safe. So how can i hide or move to somewhere where it won't be pushed in nodejs.
I mistakenly pushed in github and it received a mail about it .
GitGuardian has detected the following MongoDB URI exposed within your GitHub account.
How to fix this by using env variable or include variables from other files which will not be pushed
Comment: Don't push it up, keep your `.env` file in your `.gitignore`. Or if you use github actions and you *have* to have it somewhere for pure github CI/CD or something, at least use [github secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets), but those are "you get to set them, you don't get to look them up after the fact", as action secrets should be)
Answer: You don't have to push the .env file(Which may contain your credentials and your db url) to github. When you will host your repo to a hosting service they will provide you functionality to make .env file on the server.
Answer: You could also store your variables outside the repo entirely, which is how AWS commonly recommends with their ~/.aws/credentials approach. Then, on whatever platform you use for production, leverage their built in credentials management like Azure Vault or AWS Secrets Manager.
Another approach, aside from using an .env or credential file at all, would be to adopt a secrets manager like free and open source Hashicorp's Vault to safely store the credentials and then programmatically call them when needed. Most platforms can integrate with such tools, making it easier to keep your credentials encrypted throughout your development and build process.
Further: You can also look into tools that leverage git hooks to help keep you from adding commits that contain a credential to your git history in the first place.  AWS-Labs, Trufflehog and (since you mentioned them) GitGuardian all have tools like this.


Can we choose smoothly the singular vectors of a matrix?

Question: Let $X$ be the space of all real $n \times n$ matrices, with strictly negative determinant, and pairwise distinct singular values. $X$ is an open subset of the space of all real square matrices. Is there a way to choose smoothly the singular vectors over $X$?
More precisely, I want smooth maps $U:X \to \text{SO}_n,V:X \to \text{O}_n^-$ such that
$$ A=U(A)\Sigma(A)V(A)^T,$$ holds for every $A \in X$, where
$\Sigma(A) = \text{diag}\left( \sigma_1(A),\dots\sigma_n(A) \right)$, and $\sigma_1(A)$ is the smallest singular value of $A$. (i.e. I specifically want the first diagonal element of $\Sigma(A)$ to be minimal).
Do such smooth maps $U,V$ exist?
Edit: I now see that that if such $U,V$ exist, then the map $A \to \Sigma(A)$ is also smooth. I guess that in general, as long as the singular values are distinct, they can be chosen smoothly (this should probably follow from more general theory of smooth selection of eigenvectors), but I am not sure that one can choose them in a way which keeps the "identity" of the smallest one. Anyway, any reference on that part would be appreciated (although I am really interested in the "harder" question of a possible smooth selection of the singular vectors themselves, not just the singular values).
Answer: Let $\mathcal D$ be the space of $n\times n$ diagonal matrices with distinct non-zero positive entries. This has $n!$ connected components corresponding to the ways to order the elements on the diagonal. Fix a connected component $\mathcal D_0\subset \mathcal D.$ I claim that the map
\begin{align*}
\mu: SO_n\times \mathcal D_0\times O^-_n\to X\\
(U,\Sigma,V)\mapsto U\Sigma V^T
\end{align*}
is a $2^{n-1}$-fold smooth covering map from a connected space (for $n\geq 2$). So it can be inverted locally but has no global section.
$A\mapsto \Sigma(A)$ by itself is a smooth function, because $\Sigma\in\mathcal D_0$ is uniquely determined. It may be worth mentioning that while the $k$'th singular value is not smooth for arbitrary matrices - consider $\mathrm{diag}(1,t)$ as $t\in(0,2)$ - it is Lipschitz continuous in the singular (i.e. operator) norm. See Golub-van Loan, Matrix Computations, Corollary 8.6.2.
Although $\Sigma$ is uniquely determined by $U\Sigma V^T,$ the matrices $U$ and $V$ are not. If $\mu(U',\Sigma,V')=\mu(U,\Sigma,V)$ then $U^{-1}U'$ and $V^{-1}V'$ are equal and of the form $\operatorname{diag}(\pm1,\dots,\pm1)$ with an even number of $-1$'s - see for example the answer at How unique (on non-unique) are U and V in Singular Value Decomposition (SVD)?. This explains the $2^{n-1}.$ In short: let $\hat U=U^{-1}U'$ and $\hat V=V^{-1}V'^T.$ Then $\hat U\Sigma \hat V^T=\Sigma,$ so $\hat U\Sigma^2 \hat U^T=(\hat U\Sigma \hat  V^T)(\hat U\Sigma \hat V^T)^T=\Sigma^2,$ which means $\hat U$ commutes with $\Sigma.$ This forces $\hat U$ to be diagonal. Similarly $\hat V$ is diagonal. My intuition for this is that if $A=U\Sigma V^T$ then $U$ has to map standard basis vectors to the corresponding left singular vectors of $A,$ and if we ignore the condition $\det U=1$ for a moment, there are exactly two ways to do that for each vector because only the sign is ambiguous. $V$ also has to map standard basis vectors to right singular vectors of $A,$ but the sign is already determined by the choice of $U.$
To see that it's a local diffeomorphism, use the inverse function theorem. By a symmetry argument it suffices to check the derivative at $U=V=1.$ We need to check that $(u,s,v)\mapsto D\mu(u,s,v)=u\Sigma + s + \Sigma v$ is an injective linear map, where $u,v$ are skew-symmetric and $s$ is diagonal. The diagonal entries are just those of $s.$ The $i,j$ entry is $u_{ij} \sigma(j)+\sigma(i) v_{ij},$ and the $j,i$ entry is $u_{ji} \sigma(i)+\sigma(j) v_{ji}=-u_{ij} \sigma(i)-\sigma(j) v_{ij}.$ Since $\begin{pmatrix}\sigma(j)&\sigma(i)\\-\sigma(i)&-\sigma(j)\end{pmatrix}$ is invertible, we can recover $u_{ij}$ and $v_{ij}$ from these.
Finally, $\mu$ is a covering map because each fiber has the same (finite) cardinality. Indeed for any $x\in X$ by the local homeomorphism and Hausdorff properties, there are disjoint open sets $U_1,\dots,U_{2^{n-1}}$ each mapped diffeomorphically by $\mu$ to a (possibly different) open neighborhood of $x.$ This implies that $\bigcap_i\mu(U_i)$ is an evenly covered neighborhood of $x.$

The way I originally thought of this problem is to consider the map $f:SO_2\to \mathbb R^{2\times 2}$ that sends $U$ to $U\cdot \mathrm{diag}(2,1)\cdot U^T.$ This is a slightly different situation, but perhaps a bit easier to visualize. $f(U)$ is a positive definite matrix, and $x^Tf(U)x=1$ describes a certain ellipse with axes of length 1 and $1/\sqrt 2.$ The question is whether we can smoothly choose the rotation matrix $U,$ given the ellipse. This is impossible because continuously rotating by 180 degrees gives the same ellipse, but forces $U$ to end up with an extra 180 degree rotation. Actually $f:SO_2\to f(SO_2)$ is just the map $S^1\to S^1$ of degree $2.$
This argument relies on the fact that the fibers are discrete. Otherwise you'd get a more general fibration.
Comment: Thank you! This is a really impressive, beautiful and illuminating answer. This is not the first time you are giving me such insightful answers, and I am really grateful. I have a few comments, to make sure that I understand: (1) I only assumed that the first diagonal element $\sigma_1$ is the smallest one, not that all the singular values are ordered in a strictly increasing manner. I guess the question can be reduced to this case, though:  Since the $\sigma_i(A)$ remain distinct, while they change continuously with $A$, they cannot "cross" (since the domain is connected);...
Comment: i.e. the relative order must be *fixed*. Thus W.L.O.G we can assume it is strictly increasing. (e.g. by padding with permutation matrices). Was that your thinking? (2) Was your original argument for showing that the orthogonal matrices fixes the standard basis vectors based on comparison of norms (after we act on vectors)? (here we use the fact the singular values are distinct). (3) I think that the properness is actually not hard: The orthogonal components always converge after passing to a subsequence, and the middle part follows.
Comment: (4) The idea that this is a covering map is really cool! Was there any particular source of inspiration (or: how did you think about it?) (5) Maybe you will be interested to know the source of this question: I tried to find out wether a certain minimizer behaves smoothly. (here:https://mathoverflow.net/questions/326374/is-there-a-formula-for-the-point-in-textson-which-is-closest-to-a-given). In particular, the local invertibility you established implies this.  (6)  Finally, do you have any idea whether or not the singular values (only them) can be chosen globally in a continuous manner?
Comment: I meant to reply to this properly but had to run - I'll try to respond by next week.
Comment: Thank you. After some more thought, I think I can answer two of my points above: Regarding the covering map, I guess that after you see that the fibers are of constant size, it is a rather natural guess (I guess that most "natural" local diffeomorphisms with fibers of constant size are coverings). I also see now that the the singular values can be chosen globally in a continuous manner - you can do this locally via your argument, but all these local pieces must glue together to a consistent choice-which is forced upon us by the order.
Comment: @AsafShachar: I've added some more remarks and a bit about my own intuition, for what it's worth. For (1), actually I just assumed $\sigma_i$ were ordered - I see now this wasn't in the question. And yes actually all local diffeomorphisms with fibers of constant size are coverings - this is a much easier argument than what I was thinking.


Convergence of Sum of Orthogonal

Question: Let $\{x_n\}$ be an orthonormal basis of a Hilbert space $H.$
Can anyone help me how to show that $\sum_{n=0}^{\infty}|(x_n,x)|^2$ is convergent and $\|x\|^2=\sum_{n=0}^{\infty}|(x_n,x)|^2?$
This is to show that $(x_n,x)\rightarrow 0.$
I used Bessel's Inequality to show that $\|x\|^2\geq\sum_{n=0}^{\infty}|(x_n,x)|^2$. Is this even right?
Thanks a lot.
Answer: The usual definition of a basis for a Hilbert space denoted $\{x_n\}$ you mean that the set is orthonormal and that
$$x = \sum_{n=1}^\infty \langle x,x_n\rangle x_n$$
meaning that
$$\lim_{N\rightarrow \infty} \left\|x-\sum_{n=1}^N\langle x,x_n\rangle x_n\right\| = 0\quad \text{Convergence in the Hilbert space norm}$$
Now if two vectors are orthogonal its easy to prove Pythagoras Theorem in this general setting so that $x\perp y\Rightarrow \|x+y\|^2 = \|x\|^2+\|y\|^2$. Now we can write
$$\left\|x\right\|^2 = \left\|x-\sum_{n=1}^{N}\langle x,x_n\rangle x_n+\sum_{n=1}^{N}\langle x,x_n\rangle x_n\right\|^2 = \left\|x-\sum_{n=1}^{N}\langle x,x_n\rangle x_n\right\|^2+\left\|\sum_{n=1}^{N}\langle x,x_n\rangle x_n\right\|^2$$
Why is this equality true? How can you use this to prove Bessel's inequality? Taking the limit as $N$ tends to infinity you should get the equality you want after having applied Pythagoras theorem to the last term.
Note further that if you only want to prove that $\langle x,x_n\rangle \rightarrow 0$ then you only need that Bessel's inequality is true and then you don't need that $\{x_n\}$ is a basis, it suffices that it is an orthonormal set.
Comment: yes because $\|x\|$ is finite. Any positive series bounded above must converge. A necessary condition for a sum $\sum a_n$ to converge is that $a_n\rightarrow 0$.
Comment: Well their absolute value is the same
Comment: After proving the equality i.e $\|x\|^2=\sum_{n=0}^{\infty}|(x_n,x)|^2$, does it already imply that $\sum_{n=0}^{\infty}|(x_n,x)|^2$ is convergent, hence $(x_n,x)\rightarrow 0?$
Comment: Is $(x,x_n)=(x_n,x)?$ Or they're not since $x_n$ is a sequence?

Convergence of Sum of Orthogonal


Apache Commons IO not getting added to jar

Question: I've recently added Apache Commons IO to a small project of mine so that I can tail a log file.  Everything works great in my IDE (IntelliJ), but when I create the executable jar, Commons IO isn't in there, so I get :

Exception in thread "main" java.lang.NoClassDefFoundError:
  org/apache/commons/io/input/TailerListener.

Commons IO has been added to my POM:

<code><dependency>
     <groupId>commons-io</groupId>
     <artifactId>commons-io</artifactId>
     <version>2.1</version>
</dependency>
</code>

I've never had issues with added dependencies like this before.  What am I missing?
Answer: That's not exactly how dependencies work. Dependencies are just there to tell other projects what to pull in. They don't become automatically included in your jar.
The reason for this is because it's wasteful under certain circumstances. Imagine you have two jars: a.jar and b.jar. Both rely on apache commons. It would probably be more efficient (space-wise) to simply have each separated and loaded from a common library directory.
If you want a so-called "fat jar" (or whatever the proper term for having all of your dependencies in one jar is), you need to use a plugin like this one:
<code>  <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2.1</version>
    <configuration>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
      <archive>
        <manifest>
          <mainClass>com.test.App</mainClass>
        </manifest>
      </archive>
    </configuration>
    <executions>
      <execution>
        <id>make-assembly</id> <!-- this is used for inheritance merges -->
        <phase>package</phase> <!-- bind to the packaging phase -->
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</code>
Comment: I found my problem, IntellJ wasn't adding the jar in for some reason.  Redoing the Artifact settings corrected the problem.


What can the range of a measure be?

Question: Given a measure space $(X,\mathcal{A},\mu)$, what can the range of the measure, $\mu[\mathcal{A}]$, look like? Clearly it can't be an arbitrary subset of $[0,\infty]$ as we know $0\in \mu[\mathcal{A}]$. We also know $\mu[\mathcal{A}]$ has a maximal element ($\mu(X)$).
A bit less trivially, it must also satisfy the following for any $x,y\in \mu[\mathcal{A}]$:
$\exists z\ \{z,x-z,y-z,x+y-z,x+y-2z\}\subseteq\mu[\mathcal{A}]$
($z$ corresponds to the measure of the intersection of the sets $x$ and $y$ correspond to). This for instance tells us $\mu[\mathcal{A}]\ne \{0,1,3\}$.
Additionally, a fact that as far as I can tell is independent of the above comes from measuring the complement of a set:
if $x\in\mu[\mathcal{A}]$ then $M-x\in\mu[\mathcal{A}]$, where $M$ is the unique maximal element of $\mu[\mathcal{A}]$ corresponding to $\mu(X)$.
Is any complete characterization known?
edit: for example, at first I thought it might have to be closed, as every natural measure I could think had closed range. But the range of measure on $\mathbb{N}$ generated by $\mu(\{0\})=0.9$, $\mu(\{1\})=0.99$, $\mu(\{2\})=0.999$... has a sequence of elements approaching 1, but does not contain 1 as any singleton set has measure less than 1 and any two-or-more element set has measure greater than 1.
Answer: If it's a finite set, there must be $a_1, \ldots, a_m > 0$ such that $\mu[\mathcal A] = \{ \sum_i a_i x_i : x \in \{0,1\}^m\}$.
Comment: Thank you, nice to have such a clean characterization in the finite case. I actually wonder if this might  somehow follow from my last condition, but that's certainly non-obvious.
Answer: It is a well know result by Saks (also generalized by Lyapunov) that if $\mu$ has no atoms, then $\mu$ can take any value in $[0,\mu[X])$. If $\mu$ has atoms, the range of $\mu$ can get a little weird.
Comment: According to Wikipedia, that theorem is due to Sierpinski.
Answer: The range of a measure is either $[0,\infty]$, or there exists $a\in[0,\infty)$ and $S\subset[0,\infty]$ such that $$
\mu[\mathcal{A}] = [0,a] + \left\{\sum_{x\in X} x \mid X\subset S\right\}
$$
where we interpret the sum of two sets $A+B = \{a+b \mid a\in A, b\in B\}$.
Non-atomic case: As Oliver Diaz has pointed out, it is a well-known result that if $\mu$ has no atoms, then $\mu$ can take any value in $[0,\mu(X)]$. See https://en.wikipedia.org/wiki/Atom_%28measure_theory%29.
Purely atomic case:
Suppose $\mu$ is purely atomic. Let $\mathcal{B}\subset\mathcal{A}$ be the set of atomic sets, i.e. for all $B\in\mathcal{B}$, $\mu(B)\ne 0$ but any measurable subset of $B$ has measure $0$ or has the same measure as $B$, and let $\mu(\mathcal{B})$ be the set of measures of atomic sets. For any $B_1,B_2\in\mathcal{B}$, it's straightforward to see that either their intersection has measure $0$ or their symmetric difference has measure $0$. Furthermore, we can take countable unions of them and still get a measurable set, and one can see that any measurable set with finite measure must be such a countable union plus a null set. Hence we have that if $\mu$ is purely atomic and $\mathcal{B}$ is the set of atoms, then for any measurable $A$ either $\mu(A) = \infty$ or $$
\mu(A) = \sum_{b\in\mu(\mathcal{B})}^\infty b x_b
$$
where $x_b:\mu(\mathcal{B})\to\{0,1\}$ has countable support.
General $\sigma$-finite case: Any $\sigma$-finite measure $\mu$ can be decomposed uniquely as $\mu = \nu+\alpha$ where $\nu$ is non-atomic and $\alpha$ is purely atomic. Letting $C$ be the set of measures of atoms of $\alpha$, we have that for any $A\in\mathcal{A}$, either $\mu(A)=\infty$ or $$
\mu(A) = t + \sum_{c\in C} c x_c
$$
where $x_c : C\rightarrow \{0,1\}$ has countable support and $t\in[0,\nu(X)]$. Given any such $x$ and $t$, one can construct a set with the corresponding measure, so this is the full range of $\mu$.
Thus, given any $a\in[0,\infty]$ and set $S\subset [0,\infty]$, there exists a measure space $(X,\mu,\mathcal{A})$ such that $$
\mu[A] = [0,a] + \left\{\sum_{x\in X} x \mid X\subset S\right\}
$$
and all $\sigma$-finite measures have ranges of this form.
General case: Non-$\sigma$-finite measures are often weird and messy, but one can show that their ranges are the same shape of sets. Suppose $(X,\mathcal{A},\mu)$ is not $\sigma$-finite and the range of $\mu$ is not $[0,\infty]$. Then we can let $a = \sup\{x\in\mathbb{R}\mid \exists A\in\mathcal{A}\text{ non-atomic with }\mu(A)=x\}$. Let $X_a\in\mathcal{A}$ be a set with measure $a$. Then any finite-measure non-null set that is disjoint from $X_a$ must contain an atom, which we can show as follows: Let $Y\in\mathcal{A}$ have finite measure and $Y\cap X_a = \emptyset$. If $Y$ contains no atoms, then $(Y,\mathcal{A}\cap P(Y), \mu)$ is a non-atomic measure space, hence $[0,\mu(Y)]\subset\mu[A]$. But, since $Y$ is disjoint from $X_a$, for any measurable subset $Z\subset Y$, $\mu(X_a\cup Z) = a+\mu(Z) > a$, which cannot happen by the definition of $a$, as it would imply $[0,\mu(Y)+a]\subset\mu[\mathcal{A}]$. This furthermore implies that any set with finite non-zero measure disjoint from $X_a$ can be written as a countable union of atoms. Hence, if $C$ is the set of all possible measures of atoms disjoint from $X_a$, the measure of any finite-measure set can be written as $$
t+\sum_{c\in C}c x_c
$$
where $t\in[0,a]$ and $x_c:C\to\{0,1\}$ has countable support. Hence any measure's range has the form $$
[0,a] + \left\{\sum_{x\in X} x \mid X\subset S\right\}
$$
for some $a\in[0,\infty]$ and $S\subset [0,\infty]$.
Comment: Thank you so much! This has been bothering me a while, this is perfect!

What can the range of a measure be?


How do I find out a blocks ID?

Question: $block = module_invoke('menu_block', 'block', 'view', 26);
print $block['content'];

I am trying to use this code to print out a block, but I do not know how to get the ID for the last parameter.
Answer: You just need to look for the hook_block() implementation done from the module for which you are invoking module_invoke(). The last argument in the function call you reported is the $delta parameter that is used from Drupal to identify the block within the module.
For example, looking at the code of forum_block(), the part of the code that implement the "list" operation, 0 is the delta parameter for the "Active forum topics" block, and 1 is the delta parameter for "New forum topics" block.
The code you wrote in your question is invoking the implementation of hook_block made from a module whose short name is menu_block (which means the function implementing the hook is menu_block_block()). If you meant to invoke the implementation of hook_block() made from menu.module, then the code should be the following one:
$block = module_invoke('menu', 'block', 'view', 26);
print $block['content'];

The function implementing hook_block() is menu_block(). The values used as $delta from that function are the values of the "menu_name" field used in the "menu_custom" table.
Answer: How to insert a block into a tpl or into content programmatically with Drupal
See part "Where do I get that information for the block I am trying to call?" at bottom...
Since it was removed from site, I am putting text from cached history of site:

Where do I get that information for the block I am trying to call?
The easiest way is to go to the blocks page and to hover over the "configure" link. Without clicking on the link look in the bottom left hand corner of your browser (at least with Firefox) there you should see the URL that you would be taken to upon clicking. The important information that you need is in the last two elements of the URL. So if the URL of the link is admin/build/block/configure/jquerymenu/0 then the module that created that block is the jquerymenu block and the $delta (or block number) is 0.
So to review, the example code calls module_invoke with the following arguments: 'jquerymenu', 'block', 'view', 0 . What this does is call the jquermenu module, it calls its hook_block, tells it that it wants the information that is returned under $op = 'view' and that it wants only the information from the block with the $delta of 0.
Now that you have the $block (which is an array) you need to get the 'content' element from it by calling $block['content']. You could also call the title by using $block['title'].
I hope that makes this code snippet make sense for you. You can find more information regarding module_invoke at http://api.drupal.org/api/function/module_invoke.
Comment: Link is 404. Is it possible to update the link

How do I find out a blocks ID?


Finding a contour for $\int_{0}^{\infty}\frac{e^{ix}}{x^2+1}\text{d}x$?

Question: Using complex analysis, how does one solve: $$I=\int_{0}^{\infty}\frac{e^{ix}}{x^2+1}\text{d}x$$
I have been able to do this by introducing a variable and performing integration under the integral sign.
However, I would like to  to achieve this via complex analysis.
Were the interval $(-\infty,\infty)$, I could think of a contour that works; just a semicircle in the upper half of the complex plane.
The problem is the interval $[0,\infty)$. I cannot think of a contour that would work for this type of integral.
Hopefully, one can help me in finding an appropriate contour.
Comment: As a general rule: if you try to do a definite integral by contour methods, it will fail unless the two endpoints of the definite integral are "special" points of the integrand, such as poles or branch points.  So in your case perhaps you may try to find two similar integrals from $-infty$ to $+\infty$ that can combine to  yield your integral.
Comment: I'm afraid it can not be done by residue theorem since $\frac{e^{iz}\ln(-z)}{z^2+1}$ doesn't vanish when $z\to\infty$.
Comment: $$I=\frac{\pi}{2e}+\frac{i}2(e^{-1}\operatorname{Ei}(1)-e\operatorname{Ei}(-1))$$
Comment: @KemonoChen Thank you. But yes, I am aware of the answer. I am just trying to find a complex analysis approach. The answer can also be written as $I=\text{Ci}(i)\sin(i)+\left(\frac{\pi}{2}-\text{Si}(i)\right)\cos(i)$.
Answer: Obtaining the answer is much easier when the answer is already known. Deform the contour to $[0, i (1 - \epsilon)] \cup C_\epsilon \cup [i (1 + \epsilon), i \infty)$, where $C_\epsilon$ is the half-circle of radius $\epsilon$ in the right half-plane around $i$, and let $x = i t$. Then
$$\int_0^\infty \frac {e^{i x}} {x^2 + 1} dx = \\
\lim_{\epsilon \to 0^+}
 i \left( \int_0^{1 - \epsilon} + \int_{1 + \epsilon}^\infty \right)
  \left( \frac {e^{-t}} {2 (t + 1)} - \frac {e^{-t}} {2 (t - 1)} \right) dt +
 \lim_{\epsilon \to 0^+} \int_{C_\epsilon} \frac {e^{i x}} {x^2 + 1} dx = \\
\frac i 2 \left(
  \int_1^\infty \frac {e^{-t + 1}} t dt -
  \operatorname{v.\!p.} \int_{-1}^\infty \frac {e^{-t - 1}} t dt \right) +
 \pi i \operatorname*{Res}_{x = i} \frac {e^{i x}} {x^2 + 1} = \\
\frac {i (e^{-1} \operatorname{Ei}(1) - e \operatorname{Ei}(-1))} 2 +
 \frac \pi {2 e}.$$
Comment: Correct, the contour looks like this: https://i.imgur.com/WjT8Co6.png.
Comment: Not really, a contour integral is just an integral along a path. The path doesn't have to be closed. Implicitly we do use a closed contour, namely $[0, R] \cup C_R \cup [i R, i (1 + \epsilon)] \cup C_\epsilon \cup [i (1 - \epsilon), 0]$, where $C_R$ is the quarter-circle from $R$ to $i R$. The integral over this contour is zero, while the integral over $C_R$ tends to zero for large $R$. Which is why we can deform the contour $[0, \infty)$ in the described way.
Comment: I have a bit of trouble visualizing the contour in my head. are the line segments along the y-axis?
Comment: Thank you. Would you call this an unconventional contour since most contours usually connect back to a point?
Answer: Did you tried an sector in the upper half plane? Something like $\{z=re^{i\theta}: 0<\theta\leq 3 \pi/4 \}$? I think that's a good way, then you can use Cauchy's Theorem.


Using @Repository, @Service and @Controller annotation giving bean creation exception?

Question: I have created a simple spring mvc project to test the @Repository, @Service and @Controller annotation in spring using STS. But I am getting BeanCreationException.
Spring is unable to create @Controller bean as it can not find the bean with annotated with @Service.
As I have used STS, most of the files were automatically created. I am sharing the files, pl tell me what changes should I do in order to fix this issue.
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/root-context.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

servlet-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <annotation-driven />

    <resources mapping="/resources/**" location="/resources/" />

    <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

    <context:component-scan base-package="com.example.annoproject.Controllers" />
    <context:component-scan base-package="com.example.annoproject.Service" />
    <context:component-scan base-package="com.example.annoproject.dao" />

</beans:beans>

root-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">

        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/example_db" />
        <property name="username" value="root" />
        <property name="password" value="password" />
    </bean>

    <bean id = "jdbcTemplate" class = "org.springframework.jdbc.core.JdbcTemplate">
        <constructor-arg ref = "dataSource"/>
    </bean>

    <bean id= "abstractService" class = "com.example.annoproject.service.AbstractService">
    </bean>

</beans>

UserController
package com.example.annoproject.Controllers;

import com.example.annoproject.dao.UserDAOImpl;
import com.example.annoproject.model.User;
import com.example.annoproject.service.UserService;

@Controller
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping(value = "/home", method = RequestMethod.GET)
    public String signupPage(Model model){

        userService.getUser("1");
        return "home";
    }
}

UserService.java
package com.example.annoproject.service;

import com.example.annoproject.dao.UserDAO;
import com.example.annoproject.model.User;

@Service("userService")
public class UserService {

    @Autowired
    UserDAO userDao;

    public User getUser(String uid){
        return userDao.getUser(uid);
    }

}

UserDAOImpl.java
package com.example.annoproject.dao;

import com.example.annoproject.model.User;

@Repository("userDao")
public class UserDAOImpl implements UserDAO{

    @Autowired
    JdbcTemplate jdbcTemplate;

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    @Override
    public User getUser(String id) {

        String query = "SELECT * FROM empl where uid = ? ";

        User user = jdbcTemplate.queryForObject(query, new Object[]{id}, new RowMapper<User>(){

            @Override
            public User mapRow(ResultSet rs, int rowNum) throws SQLException {
                User user = new User();
                user.setFirstName(rs.getString("empF"));
                user.setLastName(rs.getString("emplL"));
                return user;
            }});

        return user;
    }

}

I have tried a lot of things. The problem is while using @Controller UserController, userService bean has not yet been created. Hence we get the exception. The solution is to defined userService bean in root-context.xml. But the point is I dont want to defined any bean, context <context:component-scan.. should have taken care of that. As root-context is the first file that gets read, as defined in web.xml - deployment descriptor, we need to change something there so that package are scan first, and userDao, userService, datasource etc bean are created well in advance. But I am not able to resolve it neatly. Can anyone pl tell me whats the standard practice? What am I missing here. Thanks.
Btw here is the exact exception :
WARN : org.springframework.web.context.support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.example.annoproject.service.UserService com.example.annoproject.Controllers.UserController.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.example.annoproject.service.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:298)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1148)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:636)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:602)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:521)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:462)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1241)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1154)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1041)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4944)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5230)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:581)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1683)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

Comment: Your package names have the wrong case in the XML.
Answer: Your context scans the package com.example.annoproject.Service. But your service is in the package com.example.annoproject.service.
Respect the naming conventions: packages are in lowercase only. You won't make such mistakes anymore.


Is it possible to demonstrate two groups are isomorphic without specifying an isomorphism between them?

Question: Usually, when there are two finite groups of small order, we can check if they are isomorphic by trying to impose an isomorphism.
But suppose we have two very large finite groups, what are some conditions on the two groups I can scrutinise so as to conclude an isomorphism exists between them or not? One condition I can think of is they must have the same order. My another crude guess is

If an isomorphism $\phi$ exists between two finite groups $G_1$ and
  $G_2$ , then $\phi$ must map element of order $a$ in $G_1$ to element
  of order $a$ in $G_2$ too.

So there are two main questions in this post:

1.What are some conditions on the two groups one can scrutinise so as to conclude an isomorphism exists between them or not
2.Whether my guess is true, and whether there is a counterexample.
Comment: Incidentally, it's worth mentioning that (assuming the axiom of choice) the groups $(\mathbb{R},+)$ and $(\mathbb{C},+)$ are isomorphic(!) but **provably** no easily-describably isomorphism between the two exists (e.g. they aren't Borel isomorphic).
Comment: @Moritz I agree that you can use presentations to prove groups isomorphic, but I don't see how you conclude that the answer to the question is yes. By finding a presentation you are effectively finding a specific isomorphism.
Answer: Perhaps what you are seeking are "classification theorems", namely theorems which have the following format: If $G,H$ are two finite groups having property $P$ then $G$ is isomorphic to $H$ if and only if $G$ and $H$ have the same properties $Q_1,...,Q_n$.
For example, the classification of finite cyclic groups says that if $G$ and $H$ are two finite cyclic groups then $G$ is isomorphic to $H$ if and only if $G$ and $H$ have the same order. So if you know the two groups are cyclic, all you have to do is count how many elements they have to determine whether they are isomorphic.
The next step up is the classification of finite abelian groups. First one proves a theorem: for every finite abelian group $G$ there exists a direct sum decomposition of the form $G = G_1 \oplus G_2 \oplus \cdots G_K$ such that each $G_i$ is a finite cyclic group of some order $d_i$, and such that the sequence of group orders is linearly ordered by divisibility: $d_1$ divides $d_2$ which divides $d_3$ which divides... which divides $d_K$. There's a word for this sequence $d_i$ which I don't know, so I'll just temporarily call it the "divisor sequence" of the group $G$. The classification theorem says that if $G$ and $H$ are finite abelian groups then $G$ is isomorphic to $H$ if and only if they have the exact same divisor sequence.
There are a lot of examples of theorems like this, of more and more power applying to more and more general classes of finite groups. They get harder and harder to prove, as the class becomes more and more general.
Keep in mind, though, that there is an important reality hidden in the proofs: when you trace through the proof of existence of an isomorphism between two finite groups, you will almost always find the construction of an isomorphism. (In finite group theory, I doubt there's a single exception to this rule. In infinite group theory, there are probably many exceptions in which the proof of existence of an isomorphism leads instead to some existence axiom such as the axiom of choice).
Answer:
You already mentioned the order of the group and the order of elements in the group. There are several other easy invariants we can use. For example, is there an isomorphism between $S_4$ and $D_6\times D_6$? Both groups have the same order, namely $24$. But $S_4$ has trivial center, whereas $D_6\times C_2$ has not. So there cannot be any isomorphism between them!

Your question in 1. is: "so as to conclude an isomorphism exists between them or not".
It is often very easy to show that two groups are not isomorphic. But then we have decided the question.

Your guess is true.


Get in touch with IT Administrators for Website upgrades

Question: My company has created a charting component designed to work with "technical specs" pages on websites, so we would like to contact Website Administrators, so we can propose our component for integration into their websites. It has to be someone who has enough technical know-how to understand our component, its usefulness and applicability, and who has access to the site via FTP. Any idea how we can contact such people? System Administrators? or IT Admins? Whom and How?
I was thinking of these business communities such as LinkedIn and FaceBook but I don't know whether the people there would be in charge of their company's website or whether they would be willing to listen to my proposal. Our component is very straight forward to integrate so its shouldn't be a problem convincing them, after we get in touch. This is a long-term marketing strategy so any help would be appreciated. Thank you.
Comment: Technical know-how is all fine and dandy, but even if it's the slickest thing ever created - you should promote it based on the business value it adds. What does it do to the web site that makes it a better web site? Then go for the CCO (dunno the english title, the communications officer role thingie).
Comment: English title you're looking for would be CTO or CIO most places.
Comment: This is way out of the scope of questions defined in the [FAQ], and to be blunt, Server Fault is not here to help you do targeted spamming.  I suggest you consider contacting Stack Exchange re: advertising on sites like webmasters.stackexchange.com - I don't know what their rates are, but I have to assume they're pretty reasonable.
Answer: Why don't you advertise on sites like Server Fault oder Stack Overflow? Seems to be the perfect place to get in touch with IT administrators.
Since your potential customers are a global community, a good alternative would be to pay for Google Adwords. You'll have to choose some good keywords to reach the right people.
Comment: Ideally something that's cheap, like communities of such people we can contact for free.


Merge two examples in Angularjs

Question: I am trying to build @TagFriends and comment box feature from FACEBOOK.
I found two examples that might help, I am having library issue when I import one examples library in second one, whole code fails to work, if they are executed individually they work correctly.
1.Simple comment box :
http://devzone.co.in/angularjs-example-simple-user-comment-box/
2.@Tag friend code Below:
  <!DOCTYPE html>

    <link data-require="bootstrap@*" data-semver="3.3.2" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
    <link rel="stylesheet" href="http://urbanoalvarez.es/smart-area/dist/smart-area.css">

MOC 12

      <textarea class="form-control code" rows="5" ng-model="text" ng-trim="false" msd-elastic smart-area="config"></textarea>

        Available users:
 Bret, Antonette, Samantha, Karianne, Kamren, Leopoldo_Corkery, Elwyn.Skiles, Delphine, Maxime_Nienow, Moriah.Stanton

        Type for example "Hey @Antonette"

Comment: What does "fails to work" mean? Do you get an error? What have you already tried that didn't work?
Comment: Hi @JoshDavidMiller Looks likes the source libraries from 1.simple comment box are creating problem, whenever I copy libraries from eg1 into eg2 the tag friend feature stops working
Comment: when I execute @Tagfriend(above code) code and type "Hi @Br" all users starting with "Br" are visible in the dropdown, which is perfect, but whenever I copy Simple comment box code(code from the link) in above @TagFriend code and type "Hi @Br" , the features stops working, the DD list is not visible.
Comment: You'll have to post a minimal fiddle. "Library A makes library B stop working" is not going to be easy to troubleshoot without code.
Comment: @JoshDavidMiller  I have to merge below to examples, but I dont have enough knowlege to about how it can me done, can you please help me in merging them???
Comment: https://jeff-collins.github.io/ment.io/#/
Comment: http://devzone.co.in/angularjs-example-simple-user-comment-box/
Comment: I don,t have any code snippet apart from above two Links, I just have to create a FACEBOOK style comment box using above example or any logic.
Comment: I'm voting to close this question because "write my code" questions are not a good fit for SO. A good question must start with code and a clear problem statement.
Comment: I have implemented this feature. Find the GitHub: https://github.com/noob93/Smart-Comment-Box
Answer: I have implemented this feature. Find the GitHub: github.com/noob93/Smart-Comment-Box
The Devzone example is using a deprecated feature of AngularJs, I modified the code and feature started working fine.

Merge two examples in Angularjs


Prove that f(m, n) = 5mn is onto and not one to one

Question: I have this problem where I understand the meanings of both one to one and onto but proving it with functions I become very confused.
Prove that f(m, n) = 5mn is onto, where the domain of f is R × R and the co-domain of f is R. Show that f is not one-to-one
R being any real numbers.
Comment: For a one line proof: $\;x = f(x/5,1)=f(-x/5,-1)\,$ for $\,\forall x \in \mathbb{R}\,$. First equality proves surjectivity, second one proves non-injectivity.
Comment: See [Surjective function](https://en.wikipedia.org/wiki/Surjective_function) : "a function f from a set X to a set Y is surjective (or onto), if every element y in Y has a corresponding element x in X such that f(x) = y".
Comment: You have to apply the def, showing that "every element y in R has a corresponding element (m,n) in R × R such that f(m,n) = y". Thus means to show that for every real r we can find reals m, n such that r=5mn.
Answer: $f$ is onto if, for any real number $z$, there exists a pair of real numbers $(m,n)$ such that $5mn=z$. Let $z\in\mathbb{R}$ be any real number. Then $z=5\times\frac{1}{5}\times z=f(\frac{1}{5}, z)$, and since $1/5, z$ are real numbers we conclude that $f$ is onto.
$f$ is one-to-one if different elements of $\mathbb{R}\times\mathbb{R}$ have different images in $\mathbb{R}$. This is clearly false; for example, $f(0,1)=0$ and $f(1,0)=0$, and $(0,1)\neq (1,0)$.


Unable to post data using HttpURLConnection, getting 404 file not found exception in Android

Question: I have written a code to register a user or post some data but i am unable to post the data as i am getting 404 file not found exception.
<code>Class A.java

Map<String, Object> param = new LinkedHashMap<>();
param.put("UserName", user.getUser_name());
param.put("Password", user.getPassword());
param.put("EmailId", user.getEmailid());
param.put("MobileNo", "NA");
String str_url =
"http://syncroft.in/SupervisorProductivity/RegisterUser"
AsyncTaskPost asyncTaskPost = new
AsyncTaskPost(context,param,str_url,Register.this);
asyncTaskPost.execute();

AsyncTaskPost.java

@Override
protected String doInBackground(Integer... integers) {
    try {
        JSONObject jsonObject = CustomHttpClient.post(url,
        localparams);
        jsonresult = jsonObject.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

CustomHttpClient.java

public static JSONObject post(String str_url, Map<String,Object>
    params) throws Exception {
    StringBuilder postData = new StringBuilder();

    for (Map.Entry<String,Object> param : params.entrySet()) {
        if (postData.length() != 0) postData.append('&');
        postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
        postData.append('=');
        postData.append(URLEncoder.encode(String.valueOf
        (param.getValue()),
        "UTF-8"));
    }
    byte[] postDataBytes = postData.toString().getBytes("UTF-8");

    URL url = new URL(str_url);
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    conn.setRequestMethod("POST");
    conn.setRequestProperty("Content-Length",
    String.valueOf(postDataBytes.length));
    conn.setDoOutput(true);

    DataOutputStream dStream = new
    DataOutputStream(conn.getOutputStream());
    dStream.writeBytes(postData.toString());
    dStream.flush();
    dStream.close();

    int responseCode = conn.getResponseCode();

    BufferedReader br = new BufferedReader(new
    InputStreamReader(conn.getInputStream()));
    String line = "";
    StringBuilder returnvalue = new StringBuilder();

    while((line = br.readLine())!= null){
        returnvalue.append(line);
    }
    br.close();

    JSONObject responseObj = new JSONObject(returnvalue.toString());

    conn.disconnect();
    return responseObj;
}
</code>
Can anyone tell me where i am going wrong as i am getting 404 as response code , File not found exception. The above Url is working in postman but does not work in java code.
Comment: Where are you posting to? Php?
Comment: web service is in c#
Comment: Then.. Which file is not found? I see no file in your url.
Answer: Maybe you just call a wrong api or this is an api issue that server side must handle this.


Partial Fraction Decomposition with x and y in numerator and denominator

Question: I am trying to find the partial fraction decomposition of
$$\dfrac{x^2+y^2}{x^2-y^2}$$
I got it down to $x^2+y^2 = (A+B)x+(A-B)y$, but I cannot simplify it down anymore. Is this the wrong approach or am I not seeing something?
Comment: Yes, sorry, I cannot get the formatting to work.
Comment: Please identify the variable and the (constant) parameter. Use polynomial division with remainder to reduce the degree of the numerator first.
Comment: y is a fixed point, but they can both be any number.
Comment: So $x$ is the variable, and the pfd would look like $A(x)+\frac{B}{x-y}+\frac{C}{x+y}$.
Answer: As a first step, you need to divide the polynomials so that the degree of the top (with respect to $x$) is less than the degree of the bottom.  In this case, we have
$$
\frac{x^2 + y^2}{x^2 - y^2} = \frac{(x^2-y^2) + 2y^2}{x^2 - y^2} = 1+\frac{2y^2}{x^2 - y^2}
$$
Now, we set
$$
\frac{2y^2}{x^2 - y^2} = \frac{A}{x-y} + \frac{B}{x+y}
$$
To get
$$
2y^2 = (A+B)x + (A-B)y
$$
Which gives us the system of equations
$$
\begin{cases}
A+B = 0\\
Ay-By = 2y^2
\end{cases}
$$


What is the inverse of the linear map $T(\phi) = \phi(1)$?

Question: Let $V$ be a vector space over the reals, and define $T: \mathcal{L}(\mathbb{R}, V) \to V$ by $T(\phi) = \phi(1)$. I want to find the inverse of this map. One idea I came up with was $T^{-1}v = \psi$ where $\psi(\lambda) = \lambda v$. But I have trouble showing that $T^{-1}T = I$.
Comment: Here $\mathbb R$ is the one-dimensional vector space, and $\{1\}$ is taken as its basis. Then $T(\phi) = \phi(1)$ sets up a one-to-one correspondence between $\mathcal{L}(\mathbb{R}, V)$ and $V$.  So what is the inverse of that?
Comment: @Gedgar $T$ maps every linear functional to its evaluation at $1$, which is a vector. but I can't seem to figure out what the opposite of that would be...$T^{-1}$ maps every vector to some functional that i am not sure how to define.
Comment: @a6623 try to reverse engineer this. Suppose you were given $S \colon V \to \mathcal{L}(\mathbb{R}, V)$ which is inverse to $T$. What do you know about $S$? In particular, for any $v \in V$, what is the value of $S(v)$ at $1 \in \mathbb{R}$? Now recall what you know about bases, and try to use GEdgar's hint that $\{1\}$ is a basis for $\mathbb{R}$.
Comment: Oh I got it! So my original idea was correct then
Comment: @a6623 yes, that's right. I encourage you to write the details out in your own answer. If you get stuck, you can update your original question - people will be happy to help.
Answer: Thanks to the help of the comments, here is how to see that the $\psi$ as I have defined above, is indeed the inverse.
First, $TT^{-1}(v) = T\psi = \psi(1)$. But by definition of $\psi$, $\psi(1) = 1 \cdot v = v$ so $TT^{-1} = I$.
On the other hand, $T^{-1}T(\phi) = T^{-1}(\phi(1)) = \psi$ where $\psi(\lambda) = \lambda \cdot \phi(1)$. Now, notice that $\phi(\lambda) = \phi(\lambda \cdot 1) = \lambda \cdot \phi(1)$ by linearity, so we have that $\psi = \phi$ (in this case) and $T^{-1}T = I$.
Comment: Well done, +1. For completeness, you might want to justify that $\psi$ is linear, even though it is straightforward. And if you are in the mood, you might think about how you would prove the following more general fact, of which your question is a special case: let $V, W$ be vector spaces over a field $F$, and suppose $V$ has a basis given by $\{v_{i}\}_{i \in I}$ for some index set $I$. Then there is an $F$-linear isomorphism $\mathcal{L}(V, W)  \to W^{I}$ sending $\varphi$ to $\{\varphi(v_{i})\}_{i \in I}$.


Why is restarted GMRES used?

Question: I know the GMRES (Generalized minimal residual method) is a method to solve a system of equations Ax=b where A is non singular matrix of size m by m. My question what is restarted GMRES method ? Why is it used?
Answer: GMRES builds up a basis where each vector is expected to have few zeros, which means it needs a lot of memory. In many problems we cannot even save $A$ as a matrix in the first place so it is impossible to store the complete basis.
A way to "solve" this problem is just using a fixed number of basis vectors, and as soon as you've used up those slots, you just delete them and begin over again, but with the current approximation. The convergence is obviously not guaranteed anymore, and in practice, this method often even leads to stagnation. But in many practical applications this is sufficient. (Or all you can hope for.)
(There are also other reasons to use restarted GMRES, but these are rather technical and usually very dependent on the actual problem.)

Why is restarted GMRES used?


Null check for a value is not working in Javascript

Question: I am trying to null check in one input field and pop up a required message in another input field. To achieve this function i have used the below Javascript code.
$(document).on('change', '.address',function () {

  if ($(this).val() == null ) {
    $('#cutomer_id').prop('required',true);
  }
});

but this is not working as expected. but when i try the opposite if ($(this).val() != null ) its fire the required messege.
Comment: Because it's not actually null? Print it and see https://stackoverflow.com/questions/4456336/finding-variable-type-in-javascript.
Comment: console.log($(this).val()) is the absolute first thing you should do.
Comment: `null` and empty string are not the same thing.
Answer: It's because null is an object, but value of  element is a string
What you need is check against an empty string:
if (this.value.trim() == "")
{
  $('#cutomer_id').prop('required',true);
}

The trim() added to remove trailing spaces.
P.S.
please avoid unnecessary use of jquery or any other bloatware, $(this).val() is absolutely ridiculously unnecessary


how can i print all properties of the objects of a list in c#? I want to print all objects of the boklista in case 2

Question: using System;
using System.Collections.Generic;

namespace bokhylla
{
//*******************************************************************
class Bok
{
    private string title = "";
    private string skribent = "";
    private string typ = "";

    public string Title
    {
        get { return title; }

        set { title = value; }
    }
    public string Skribent
    {
        get { return skribent; }

        set { skribent = value; }
    }
    public string Typ
    {
        get { return typ; }

        set { typ = value; }
    }

}
class Roman : Bok
{
    private int antalSidor = 0;
    public int AntalSidor
    {
        get { return antalSidor; }

        set { antalSidor = value; }
    }
    public Roman()
    {
        Typ = "Roman";
    }
}
class Tidskrift : Bok
{
    private string manad = "";
    public string Manad
    {
        get { return manad; }

        set { manad = value; }
    }
    public Tidskrift()
    {
        Typ = "Tidskrift";
    }

}
class NovellSamling : Bok
{
    private int antalNovell = 0;
    public int AntalNovell
    {
        get { return antalNovell; }

        set { antalNovell = value; }
    }
    public NovellSamling()
    {
        Typ = "Novellsamling";
    }
}
//*************************************************************************
class Program
{
    static List<Bok> BokLista = new List<Bok>();
    static void Main(string[] args)
    {
        bool running = true;
        while (running)
        {
            Console.WriteLine("\tHej och välkommen!");
            Console.WriteLine("\t[1] Registera ny bok");
            Console.WriteLine("\t[2] Visa böcker");
            Console.WriteLine("\t[3] Avsluta");

            if (Int32.TryParse(Console.ReadLine(), out int val))
            {
                switch (val)
                {
                    case 1:
                        Console.WriteLine("\tÄr boken en [1]roman, [2]novellsamling eller [3]tidskrift");
                        Int32.TryParse(Console.ReadLine(), out int boktyp);
                        if (boktyp == 1)
                        {
                            Console.WriteLine("\tSkriv bokens title: ");
                            Roman bok1 = new Roman();
                            bok1.Title = Console.ReadLine();
                            Console.WriteLine("\tSkriv bokens skribent: ");
                            bok1.Skribent = Console.ReadLine();
                            Console.WriteLine("\tSkriv bokens antal sidor: ");

                            bool siffra1 = false;
                            while (!siffra1)
                            {
                                if (Int32.TryParse(Console.ReadLine(), out int sidor))
                                {
                                    bok1.AntalSidor = sidor;
                                    siffra1 = true;
                                }
                                else
                                {
                                    Console.WriteLine("\tSkriv gärna antal sidor med siffror: ");
                                }
                            }
                            BokLista.Add(bok1);
                        }

                        if (boktyp == 2)
                        {
                            Console.WriteLine("\tSkriv bokens title: ");
                            NovellSamling bok2 = new NovellSamling();
                            bok2.Title = Console.ReadLine();
                            Console.WriteLine("\tSkriv bokens skribent: ");
                            bok2.Skribent = Console.ReadLine();
                            Console.WriteLine("\tSkriv bokens antal novell: ");

                            bool siffra2 = false;
                            while (!siffra2)
                            {
                                if (Int32.TryParse(Console.ReadLine(), out int novell))
                                {
                                    bok2.AntalNovell = novell;
                                    siffra2 = true;
                                }
                                else
                                {
                                    Console.WriteLine("\tSkriv gärna antal novell med siffror: ");

                                }
                            }
                            BokLista.Add(bok2);
                        }
                        break;

                    **case 2:
                        foreach (var item in BokLista)
                        {
                            Console.WriteLine(item);
                        }**

                        break;

                }
            }
            else
            {

            }

        }

    }
}

}
//how can i print all properties of the objects of a list in c#? I want to print all objects of the boklista in case 2.
Answer: You have to write each property with dot (.) operator:
...
case 2:
      foreach (var item in BokLista)
           {
              Console.WriteLine(item.Title);
              Console.WriteLine(item.Skribent);
              Console.WriteLine(item.Typ);
           }

Answer: Use reflection to get all the properties of the class and display it as below
foreach (var item in BokLista)
{
   Type t = item.GetType();
   PropertyInfo[] props = t.GetProperties();
   foreach (PropertyInfo prp in props)
   {
        object value = prp.GetValue(atype, new object[]{});
        Console.WriteLine(prp.Name+":"+ value);
   }
}

Another approach will be to have a PrintAllMethod in base class and override it in all the sub classes
Comment: @HosseinHosseini mark this as answer if it has helped


What acoustic percussion instrument sounds like handclaps?

Question: When there's a group of musicians playing, it's often not practical for several of them to stop what they're doing so they can clap instead, so is there an acoustic percussion instrument that can be played by one person, that sounds like ensemble handclaps, i.e a group of people clapping together?
Comment: If you know you need to google "Acoustic Palmas" than it's a 45 second search. If, like me, you *don't* know what to search for, you post a question here on Music SE.
Comment: The words used on Google were acoustic, handclap, percussion, instrument.
Comment: To quote what people always say on StackOverflow: This website intends to be the top result when simple questions are googled. If something is easy to google, it does not mean that it should not be asked on here.
Comment: Whether or not something is easy to google is immaterial to the goodness of a question.  The SE network aims to be a canonical reference of questions/answers.  SE doesn't aim to replace google, but it does aim to be one of the links that google gives you when you do ask a question.
Comment: Acoustic Palmas or Slap-pads. 45 secs to find via Google...
Comment: I googled first - then I posted the question here. I've also asked a professional percussion repairer. As far as I know no such instrument exists.
Comment: I googled "Acoustic Palmas" and there was a site with loops labelled "acoustic palmas" which I think is the Spanish for "acoustic palms". So the loop is *actual* handclaps.  I'd like the name of the instrument and a picture too.
Comment: And from the question downvote hover text: "This question does not show any research effort."
Answer: Uncannily, youtube suggested this video for me to watch.

The instrument here is a an Istanbul Clap Stack. Thank you youtube!
Answer: There was an acoustic clapping device that was a metal rod and it had plastic or hard rubber discs that you slid down to create the clap sound. Haven't seen it in years......
Comment: Fascinating! Do you have a picture?
Answer: I don't think I've encountered an acoustic instrument as a percussionist that perfectly emulates a hand clap sound. Typically you could use something like a small whip (two boards hinged together), or large castanets to provide a similar effect.
SONOR apparently makes a 'hand clap box' that is supposed to sound like hand clapping and would be playable by a single musician (Although personally I think it sounds too close to a woodblock):
http://www.sonor.com/instruments/percussion/hand-percussion-add-ons/hand-clap-block/
Comment: I haven't ever seen a multi-whip before, although I'm sure that one could be engineered if you feel like having some woodshop fun. I could see maybe a dowel with three or four small whips affixed to the top such that you roll the dowel between your hands vertically and the whips go off in succession giving a flam effect?
Comment: Thanks for the suggestions. I agree that the 'hand clap box' sounds like a woodblock. And castanets don't really sound like handclaps. But I suppose the small whip sounds a bit like *one person* clapping. Is there a sort of multiple ganged version that duplicates the 'flam' effect you get from ensemble clapping?
Answer: Not sure what you mean by "ensemble" hand claps, though there are a few ways drummers have tried to emulate electronic clap sounds. Basically, they boil down to various rim-flam techniques. You can experiment and adapt whatever sorts of drums you have available.
Comment: Ensemble hand claps is the sound of a group of people clapping together. I'm pretty certain that the required sound can't be achieved using conventional drum-kit drums, no matter what techniques you use or how or where you hit them. You do get a flam effect when two or more people clap together, so I can see the sense in your answer. But it doesn't answer the original question - is there a distinct instrument playable by one person which sounds like a group of people clapping?
Answer: I wanted such an instrument to cover some pop songs tomorrow, e.g. Macklemore's "Thrift Shop" at 00:30:

I also couldn't find anything I could easily buy at a music store, so I experimented with household items. I imagined maybe a folding paper or plastic fan might work, but I didn't have one.
But I found you can get pretty close with half a deck of cards. Hold the half-deck in one hand and use the other hand's thumb to do a controlled snap on the short side, like a flip book but really fast.

It's easy to improve technique by playing around with it. I've found that if you hold the deck in a shape like, um... remember those old-school rubber erasers?

If you make your deck look like that, you add on more choral "voices" (separation between claps), and sounds even more like an ensemble clap.
Of course, not loud enough by itself but I plan to hold it near a microphone.
Answer: Though you do specifically ask for acoustic percussion instruments, I'll answer off topic that, in terms of faithfully simulating a sound, an electronic sample would be very effective and there are hardware form factors that would work nicely in a live, acoustic group setting: pad or button to trigger, built-in speaker, etc.


Botão ao clicar pisca azulado

Question: Criei 3 botoes (aplicação web), o problema é que quando clico neles(nos botoes) na tela do celular a area da div do botão fica azulada (acende e apaga). O curioso é que quando clico com o mouse pelo computador não acontece, funciona normalmente. Alguem sabe o por que?
HTML

Comment: Isso é recurso do aparelho para realçar que algo foi clicado (ou tocado).
Comment: Acredito que não, por que se fosse em outros sites teria o mesmo efeito, e já testei, não acontece.
Answer: Você pode usar a seguinte propriedade CSS para o elemento:
-webkit-tap-highlight-color: transparent;

-webkit-tap-highlight-color é uma propriedade CSS não padrão que define a cor do destaque que aparece sobre um link enquanto ele está sendo tocado. O realce indica ao usuário que seu toque está sendo reconhecido com sucesso e indica em qual elemento ele está tocando.

Veja este link: https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-tap-highlight-color
Comment: Isso cara, deu certo. Valeu!

Botão ao clicar pisca azulado


Arithmetic Base Conversion

Question: Consider a number Q in a made up base system:
The base system is as follows:
It encodes a number as a sum of odd numbers:
1 3 5 7 9 ...
If the number can be expressed as a sum of unique odds. For example, the number 16 is expressed as:
1110 = 7 + 5 + 3 + 1
The system is also redundant as 16 can also be expressed as:
11000
My question:
Given a natural number  u, how can u be expressed in this system quickly if u can be expressed in the system, quickly.
Comment: If x is an even number (except 2), write 1 + (x-1). If x is an odd number (except 1, 3, 5, 7), write 1 + 3 + (x-4). Or, if you like, x is already a sum of one odd number (x).
Answer: If $u$ is odd, write $u$ as the following sum of odd numbers:
$$u$$
If $u$ is even (and $\geq 2$), write $u$ as the following sum of odd numbers:
$$(u-1)+1$$
(Converting into a string of ones and zeros is straightforward.)
Answer: If $u$ is even and greater than two: represent $u$ as $110\dots0$, where the number of $0$s is equal to $\frac{u}{2} - 2$.
If $u$ is odd: represent $u$ as $10\dots0$, where the number of $0$s is equal to $\frac{u - 1}{2}$.
$2$ cannot be represented in this system, but is the only nonnegative number for which this is the case.

Arithmetic Base Conversion


How can I allow a Limited User to change TCP/IP settings, while strictly maintaining the principle of least privilege?

Question: In Windows XP or Windows Server 2003:
I have a laptop configured with software for network-based vulnerability scanning of systems. The reason this is put on a laptop instead of a desktop or server, is to check systems that normally operate independently of a network, or are on remote isolated networks.
Since this laptop's primary purpose entails travel between networks, all users of the system will need access to change the TCP/IP configuration. Within our department, that's not an issue. We're all Administrators on this system for maintenance purposes anyway.
However, we plan on loaning this system out to other departments or organizations from time to time. Obviously, we do not want these other groups to have full privileges on the system if they don't need them. As far as I can tell, the only Administrator-like privilege they should need is to change the IP Address, Subnet Mask, Gateway, and DNS Servers.
How can this be done for Limited Users, without giving them any more privileges from the higher groups?
Comment: You might check this question to see if any of the [windows sudo](http://superuser.com/questions/42537/is-there-any-sudo-command-for-windows) equivalents allow you to specify specific apps a user can run with elevated privileges.
Answer: I don't have a machine to test whether or not a limited user can double-click pre-configured scripts at the moment.  You could create some scripts and add them to the all-users desktop (so they're visible to everyone) and use a netsh command for each of the different networks.
I'm assuming you have to allow them to enter manually instead of dhcp?
This idea would of course mean that you have SOME idea of the networking setups of these various networks.
Examples:
<code>netsh int ip set dns name="Local Area Connection" source=static addr=192.168.1.1

netshint ip set address name="Local Area Connection" source=dhcp
</code>
Edited to add:
Do you have a Network Configuration Operators Group?  Make the local users a part of this group.
Comment: Thanks for the response.  However, one of the reasons this issue has come up is because I don't always know the details what networks this system may be connecting to.  Sure, a batch script or something could be written that prompts for the necessary input.  However, scripts still require that the user have appropriate privileges to the programs that they run, and the functions those programs perform.  So, this suggestion - while providing a nice idea for automation - is not useful for this scenario.
Comment: @Iszi - I added information to my original answer.  If that ends up helping you, let me know.


Equivalent of $ I_{n}=\int_0^1 \frac{x^n \ln x}{x-1}\mathrm dx, n\rightarrow \infty$

Question: I would like to show that
$$ I_{n}=\int_0^1 \frac{x^n \ln x}{x-1}\mathrm dx \sim_{n\rightarrow \infty} \frac{1}{n}$$
Using the change of variable $u=x^n$:
$$ I_{n}=\frac{1}{n^2} \int_0^1 \frac{u^{1/n} \ln u}{u^{1/n}-1} \mathrm du=\frac{1}{n^2}\left(\int_0^1 \ln x \mathrm dx+\int_0^1 \frac{\ln x}{x^{1/n}-1} \mathrm dx \right)=\frac{-1}{n^2}+\frac{1}{n^2}\int_0^1 \frac{\ln x}{x^{1/n}-1} \mathrm dx=o(1/n)+\frac{1}{n^2}\int_0^1 \frac{\ln x}{x^{1/n}-1} \mathrm dx$$
So I have to show that
$$ \int_0^1 \frac{\ln x}{x^{1/n}-1} \mathrm dx \sim_{n \rightarrow \infty} n$$
Could you help me?
Comment: I don't understand the last equality sign in the first line of your computation.
Comment: Oddly by my slightly non-rigorous methods, I am getting your original integral ($I_n$) to be roughly $\zeta(2) - H_{n,2}$. So, that would suggest as $n \rightarrow \infty$, the value to go to zero so I am quite baffled by your question at the moment. (Or it could be that I am horribly wrong in my method :-) )
Answer: $$\frac{x^n}{x-1} = \frac{x^n-1}{x-1} + \frac{1}{x-1}= \left(1+ x+ \cdots + x^{n-1}\right) +\frac{1}{x-1}.$$
So $$I_n = \int^1_0 (1+x+\cdots + x^{n-1}) \log x + \int^1_0 \frac{\log x}{x-1} dx.$$
Integration by parts shows $ \int^1_0 x^k \log x = -1/(k+1)^2$ and expanding $\log$ by Taylor series will show $\displaystyle \int^1_0 \frac{\log x}{x-1} dx = \frac{\pi^2}{6}$ so $$I_n = \sum_{k=n+1}^{\infty} \frac{1}{k^2}.$$
Thus $$nI_n = \frac{1}{n} \sum_{k=n+1}^{\infty} \frac{1}{(k/n)^2} \to \int_1^{\infty} \frac{1}{x^2} dx=1$$
so $I_n \sim 1/n.$

You can skip showing $\displaystyle \int^1_0 \frac{\log x}{x-1} dx = \frac{\pi^2}{6}$ if you expand $x^n/(x-1)$ as a geometric series from the start.
Instead of using Riemann sums we could also have noted that $1/x^2$ is monotonically decreasing and use the well known theorem that if $f$ is monotone then $\displaystyle \int^n_1 f(x) dx \sim \sum_{k=1}^n f(n).$
Comment: @TenaliRaman Thanks for pointing that out. All your thoughts are correct, so perhaps you just misunderstood what the question was asking. It is indeed true that $I_n = \zeta(2) - H_{n,2}$ and that $H_{n,2}\to \zeta(2) $ so $I_n \to 0$, but the question was a more precise statement: How quickly does it go to zero? We showed that $\lim_{n\to\infty} nI_n=1$ so for very large values of $n$ we will have $I_n \approx 1/n.$
Comment: +1 Typo $I_n \sim 1/n$. Nice, I reached $I_n = \zeta(2) - H_{n,2}$ but somehow thought since $H_{n,2} \rightarrow \zeta(2)$, $I_n$ must go to zero, but your final step was so simply done.
Comment: Ah, it was indeed the case of me completely misunderstanding the question. Thanks for that clarification :-)
Comment: @RagibZaman The $\sum_{k\ge{}n}k^{-2}$ can also be estimated by Euler-Maclaurin formula, which gets $n^{-1}+\frac12n^{-2}+O(n^{-3})$, so $\sum_{k>n}k^{-2} = n^{-1}-\frac12n^{-2}+O(n^{-3})$.
Comment: @Frank Science In fact we don't even need to full force of Euler-Maclaurin for that estimate, the Trapezoidal rule is enough to tell us that.
Comment: Thanks a lot! Once again the key was to use the geometric series...
Comment: @RagibZaman In fact we don't even need to full force of integration of that estimate. It's easy to show that $\sum_{k>n}1/k(k+1) < \sum_{k>n}k^{-2} < \sum_{k>n}1/k(k-1)$, so $1/(n+1) < I_n < 1/n$. Hence $I_n = \Theta(n^{-1})$. I use Euler-Maclaurin formula to show that the more precise asymptotics can be obtained through a systematic way.
Answer: I propose different approach.
First, consider integral:
$$J_n = \int_0^1 \frac{x^n -1}{x-1} \, dx$$
than we have $I_n = \tfrac{dJ_n}{dn}$. Observe that:
$$J_n = \int_0^1 \frac{x^n - 1 }{x-1} \, dx = H_n \sim \ln n + \ldots$$
So it's now easy to note that:
$$I_n \sim \frac{1}{n}$$
for large $n$.
Comment: Differentiating both sides of an asymptotic formula is troublesome, for example consider $n+\sqrt{n}\sin n \sim n.$
Comment: @qoqosz This was precisely how I approached to solve and find the value of the integral, though I considered $J_n$ to be $\int_0^1 \frac{x^n - 1}{x - 1}$ since the $J_n$ as currently defined will have a diverging term. $J_n$ then by my definition is simply $H_n$ whose derivative comes out to be $\zeta(2) - H_{n,2}$ as given [here](http://en.wikipedia.org/wiki/Harmonic_number#Relation_to_the_Riemann_zeta_function).
Comment: @RagibZaman sure, but here $I_n$ behaves fine enough.
Comment: @TenaliRaman you're right, I haven't noticed this divergence before. Thanks!
Answer: Actually, a closed form solution may be given:
$$I_{n}=\int_0^1 \frac{x^n \ln x}{x-1}dx=-\int_0^1[x^n(1+x^2+x^3+...)\ln x]dx=$$
$$=-\sum_{k=0}^\infty \int_0^1 (x^{k+n}\ln x)dx=\sum_{k=0}^\infty\frac{1}{(k+n+1)^2}=$$
$$=\frac{1}{(n+1)^2}+\frac{1}{(n+2)^2}+...=\zeta(2,n+1) $$ where $$\zeta(s,a)=\sum_{k=0}^\infty\frac{1}{(k+a)^s}$$ is so called Hurwitz Zeta Function


find proportions between two length

Question: let us consider following problem :
A tower casts a shadow of $6$ meters at a certain time of the day. If at exactly the same time, a man stands at the top of the tower, the length of the shadow increases by $2$ meters. What is the height of the man if the tower is $5$ meters high?
we have following diagram

i wanted to  determine if these two triangle are similar,but solution  of this problem says that
The basic concept is that when the man stands on the top of the tower, the length of the shadow increases proportionately to total height of the tower and the man,
if there is not  similar between triangles according angles,how can i assume this?please help me
Answer: The triangles are similar, but the solution you quote from prefers (for some reason) to view the problem algebraically rather than geometrically.
The fundamental observation is that because the sun is very far away -- we can assume it is "at infinity", certainly for the purpose of measuring shadows -- the two diagonal lines in your diagram are parallel. In particular they have the same slope, so for some $m$ we have
$$6m=5 \qquad\text{and}\qquad (2+6)m=5+x$$
Then $m$ is the proportionality constant your model solution speaks of. Solve the left equation for $m$ and insert into the right one to get an equation for $x$.
Comment: By the way, we also assume that the center of Earth is infinitely far away :)
Comment: @Hagen: No just that the ground is flat and perpendicular to the tower in its immediate vicinity. :-)
Comment: does it means that parallel lines when they cut  two intersected lines ,do they cut proportional length or?
Comment: @dato: Yes -- because the lines are parallel, all of the angles in the two triangles are the same, so they are similar.
Comment: could you give me link of such   statements?
Comment: is it this one http://en.wikipedia.org/wiki/Antiparallel_(mathematics)
Answer: The Sun is a very very large object (as compared to the Earth) that emits lights.  Thus, all light rays from the Sun are considered as parallel (rather than radiating). That is why your figure consists of two similar triangles.
Besides, the fastest way to compute x is :-
x / 5 = 2 / 6 giving x = 5 / 3.

find proportions between two length