Prove that the set is subspace of $P_3$

Question: ${P_3}\ (R)  :
$$
 \{ax^3 + bx^2 + cx + d \ \ | \ \ a + b + c + d = 0\}
$
For this type of situation, is there a way to choose values to prove that it is a subspace or is it necessary to use generalizing vectors? Example :
$$
\displaylines{{\vec V1  = a_1x^3 + b_1x^2 + c_1x + d_1} \\ \vec V2 = a_2x^3 + b_2x^2 + c_2x + d_2
\\ a_1x^3 + b_1x^2 + c_1x + d_1 = 0 \ \\ a_2x^3 + b_2x^2 + c_2x + d_2 = 0 }
$$
Comment: Your question needs more context. Any subspace $U$ is a subset of a vector space $V$. What vector space $V$ are you working in?
Comment: Sorry.
I want to prove whether or not it is a subspace of $P_3$
Answer: There's a number of ways you can show that. I'll write here what I thought.
You can try to find some polynomials $p,q,r,...$ such that the subspace generated by them is equal to $S := \{ax^3 + bx^2 + cx + d | a + b + c + d = 0\}$, but I think there's no trivial way to find these guys (I thought a little bit and didn't come up
with anything).
I believe the simplest way to prove this is using the definition of subspace: taking two general polynomials in S and proving that their sum is in S and do the same for scalar multiplication. It's not a difficult argument. If you have any problems doing that, we can chat in the comments.
A "more advanced" way is showing that $S$ is the kernel of a certain linear functional in $P_3$, since kernels are always subspaces.
Comment: I was looking for a shortcut to using values. But I did it this way:
$$
\displaylines{{\vec V1  = a_1x^3 + b_1x^2 + c_1x + d_1} \\ \vec V2 = a_2x^3 + b_2x^2 + c_2x + d_2
\\ a_1x^3 + b_1x^2 + c_1x + d_1 = 0 \ \\ a_2x^3 + b_2x^2 + c_2x + d_2 = 0
\\ \vec V1 + \vec V2 = (a_1x^3 + b_1x^2 + c_1x + d_1) + (a_2x^3 + b_2x^2 + c_2x + d_2)
\\ \vec V1 + \vec V2 = (0) + (0) => \vec V1 + \vec V2 = 0
\\
\\ α \in R. \\ α \vec V1 = α(a_1x^3 + b_1x^2 + c_1x + d_1)
\\  α \vec V1 = α(0)  }
$$
Comment: Your idea is good, but what you wrote is not entirely right. Notice that the set is
$$
\{ ax^3 + bx^2 + cx + d : a + b + c + d = 0\}
$$
and **not**
$$
\{ ax^3 + bx^2 + cx + d : ax^3 + bx^2 + cx + d = 0\}.
$$

Notice that the first set has polynomials different from zero. For example: $x^3 - x^2$ ($a = 1, b = -1, c = d = 0), 3x^3 - 3/2x - 3/2 (a = 3, b = 0, c = -3/2, d= - 3/2$. The second one has only the polynomial with all coefficients zero.
Comment: I really got confused when performing the calculations.

I got stuck in the penultimate equation. I jumped to the last equation that I believe would be the last phase of the calculations.
Comment: $$
\displaylines{{\vec V1  = a_1x^3 + b_1x^2 + c_1x + d_1} \\ \vec V2 = a_2x^3 + b_2x^2 + c_2x + d_2
\\ a_1+ b_1 + c_1 + d_1 = 0 \ \\ a_ 2+ b_2 + c_2 + d_2 = 0
\\ \vec V1 + \vec V2 = \bigl ((a_1x^3 + b_1x^2 + c_1x + d_1) + (a_2x^3 + b_2x^2 + c_2x + d_2) \bigr)
\\ \vec V1 + \vec V2 = \bigl ((a_1+a_2)x^3 + (b_1+b_2)x^2 + (c_1 + c_2)x + (d_1 + d_2) \bigr)
\\ \vec V1 + \vec V2 = \bigl ((a_1+ b_1 + c_1 + d_1) + (a_2+ b_2 + c_2 + d_2) \bigr)}
$$
Comment: Exactly! The penultimate equation is correct, now considering
\begin{align*}
a = a_1 + a_2 \\
b = b_1 + b_2 \\
c = c_1 + c_2 \\
d = d_1 + d_2 \\
\end{align*}
what can you say about $a + b + c + d$ ?
Comment: Would a + b + c + d = 0?

I could rewrite this equation in this format: $$
\displaylines{
\\ \vec V1 + \vec V2 = \bigl ((a_1+a_2)x^3 + (b_1+b_2)x^2 + (c_1 + c_2)x + (d_1 + d_2) \bigr)
\\ \vec V1 + \vec V2 = \bigl ((a)x^3 + (b)x^2 + (c)x + d )\bigr)}
$$
Comment: Yeah, exactly. Notice that
\begin{align*}
(a_1 + a_2) + (b_1 + b_2) + (c_1 + c_2) + (d_1 + d_2) = \\
= (a_1 + b_1 + c_1 + d_1) + (a_2 + b_2 + c_2 + d_2) = 0 + 0 = 0 \\
\end{align*}
Comment: I could extrapolate this way to scale it:$$
\displaylines{
\\ α  \vec V1 = α\bigl ((a_1)x^3 + (b_1)x^2 + (c_1)x + (d_1) \bigr)
\\ N\ o \ t \ e \ : αax^3 + αbx^2 + αcx + αd = 0
\\=> α(ax^3 + bx^2 + cx + d) = 0
\\ α\vec V1 = α\bigl ((a_1)x^3 + (b_1)x^2 + (c_1)x + (d_1) \bigr) = 0)
}
$$
Comment: Be careful with notation. The equation
$$
\overrightarrow{V} = ax^3 + bx^2 + cx + d = 0
$$
means that the polinomial $ax^3 + bx^2 + cx + d$ is the zero vector (the polynomial with all coefficients zero). Now, the equation
$$
a + b + c + d = 0
$$
means that the sum of these four real numbers is zero.
Comment: So, given a scalar $\alpha \in \mathbb{R}$ and $\overrightarrow{V} = ax^3 + bx^2 + cx + d$ such that $a + b + c + d = 0$, we have
$$
\alpha \overrightarrow{V} = \alpha a x^3 + \alpha b x^2 + \alpha c x + \alpha d
$$
and notice that
$$
\alpha a + \alpha b + \alpha c + \alpha d = \alpha (a + b + c + d) = \alpha \cdot 0 = 0
$$
so the vector $\alpha \overrightarrow{V}$ is in the same space as $\overrightarrow{V}$, because the sum of its coefficients is zero.

Prove that the set is subspace of $P_3$


Prove the positivity of a sequence

Question: Let $a>0$ a real number and $(u_n)$ the sequence defined by
$$
u_{n+1} = a - \frac{1}{u_n}\text{ and } u_0 = a.
$$
Question: Determine condition on the value of $a>0$ such that the sequence $(u_n)$ is always positive.
Attempt: I tried to establish a general formula of $u_n$ in order to set up a condition on $a$, by calculating $u_n$ with some $n$:
$$
u_1 = a - \frac{1}{u_0} = a - \frac 1a = \frac{a^2-1}{a},\\
u_2 = a - \frac{1}{u_1}= a - \frac{a}{a^2-1}=\frac{a^3-2a}{a^2-1},\\
u_3 = a - \frac{1}{u_2} = a - \frac{a^2-1}{a^3-2a}=\frac{a^4-3a^2+1}{a^3-2a},\\
u_4 = a - \frac{1}{u_3} = a - \frac{a^3-2a}{a^4-3a^2+1}=\frac{a^5-4a^3+2a-1}{a^4-3a^2+1}.
$$
But I wasn't successful, it seems that there is no general formula of $u_n$. So I would be appreciate for any suggestion of solution. Thank you!
Comment: it is a General formula for this sequence
Answer: Notice that if the sequence $u_n$ is positive, then it must be decreasing. This can be proven by induction.
In this case, the sequence $u_n$ is monotonic and bounded, so it has a limit $L$ that has to be positive.
From the formula,
$$L=a-\frac{1}{L}$$
Thus
$$a=L+\frac{1}{L} \ge 2$$
So a necessary condition is $a \ge 2$.
To prove that the condition is suffecient, Take $L>0$ such that $a=L+\frac{1}{L}$ and prove by induction that $u_n$ is decreasing, positive and $u_n > L$.
Answer: hint
Let $f (x)=a-1/x $.
$f $ is increasing at $(0,+\infty) $.
$(u_n) $ is monotonic.
$u_1 <u_0$ thus it is strictly decreasing.
the sequences terms are $>0$ if the limit (if it exists) is  $\ge 0$.
the limit $l $ satisfies $l=a-1/l .$
if $a\ge 2$ then
$l=(a\pm\sqrt {a^2-4})/2>0$.
If $a<2$  , $u_2<0$.
So, the condition is $a\ge 2$.
Comment: I think you have a mistake. Why is $l=1-\frac{1}{l}$? it should be $l=a-\frac{1}{l}$, which has a solution for $a \ge 2$. See my answer.
Comment: @idok Yes right. i edited. thanks.
Comment: Also, the series does not tend to $-\infty$ when $a < 2$. this mistake is not crucial to the argument, but it is important not to confuse the asker.
Comment: @idok If $a <2$, it will have no limit.
Comment: Thank you all for your anwsers.
Answer: Hint: $\;\require{cancel}
u_{n+1} - u_n = \left(\cancel{a} - \dfrac{1}{u_n}\right) -  \left(\cancel{a} - \dfrac{1}{u_{n-1}}\right)=\dfrac{u_n-u_{n-1}}{u_nu_{n-1}}
\,$, so as long as the terms are positive the differences between consecutive terms have the same sign i.e. the sequence is monotonic, and is in fact decreasing since $\,u_1-u_0=\left(\cancel{a} - \dfrac{1}{a}\right) - \cancel{a} \lt 0\,$. For it to be positive it is necessary and sufficient that $\,0\,$ is a lower bound, so the sequence is positive iff it is convergent. In this case, passing the recurrence relation to the limit, its limit $\,A\,$ must satisfy $\,A = a - \dfrac{1}{A}$ $\iff A^2 - aA + 1 = 0\,$. The latter equation has real roots iff $\,\Delta = a^2 - 4 \ge 0 \iff a \ge 2\,$.

Prove the positivity of a sequence


How do I mirror a folder (copy only missing and changed files recursively) in windows?

Question: I'm trying to find a fast way to recursively update a folder and all subfolders from another folder.  Obviously, a full delete and Xcopy would work but that is very slow.
After the update, the destination folder should exactly match the source folder.  Changed files and new files should be copied.
If it makes it easier, don't worry about deleting files that are in the destination folder but missing in the source folder.
This deploy/mirror/update operation seems pretty basic.  Do I really need to write a C# script to accomplish it?
Comment: This belongs on superuser.com
Comment: I've used Karen's Replicator in the past and it's been very good: http://www.karenware.com/powertools/ptreplicator.asp
Comment: Unless you are using C# libraries which manipulate the NTFS file system directly, you are not going to see any performance gain over calling a process for a program which manipulates files, such as those mentioned thusfar.
Comment: This is quite simple to do from .net. You compare src and destination by checking date stamps and file length. Copy what has changed only, remove what no longer exists.
Answer: RoboCopy is a command line tool provided by Microsoft that can do mirroring.  The Wiki page also mentions a GUI.
Comment: I use `robocopy /mir source dest` quite a lot
Comment: Robocopy does work quite well, except for changes to permissions.  If the only change is to permissions, that would not be picked up as a change and re-copied.  To ensure that permissions are mirrored, there would need to be a second permissions-only copy with the COPY:SOU switch.
Comment: Oooh.. how did I not know about this?
Comment: Robocopy tip: add `/DCOPY:T` if you want to folder timestamp to stay the same. Otherwise it will be the current timestamp.
Answer: Total Commander has a synchronization function.
Answer: If you're happy with doing it from the CLI, xcopy (built into WinXP) and robocopy (built into Vista/Win7) both do "only if newer" copies.
Answer: Given a folder "source" and "dest", where you want "dest" to match "source".

xcopy /e /d source dest

Saw your comment "dont worry about deleting outdated files".
Comment: wait.. this is silly, editing..
Comment: i'm pretty much doing that now but it's really slow.
Answer: <code>    cls
    @echo off
    pushd %~dp0 >nul 2>&1
    if not "%1" == "max" start /max cmd /c %0 max & exit/b >nul 2>&1
    color 1f
    TITLE robocopy "Source" "Dest" /FFT /NC /NDL /MIR /IT /MT:1 /R:0 /W:0
    robocopy "Source" "Dest" /FFT /NC /NDL /MIR /IT /MT:1 /R:0 /W:0
    exit /b n
</code>
Comment: please add some context to your answer, posting code alone is not enough. Some small comments will suffice.
Also your comment about Win7 belongs to the answer itself, not the comment area.
Comment: /MT:1 option only available in Win7 and up.
Answer: I would probably do this with some version control system, probably git.  Just create a repo in the source and destination directories.  To sync, just commit from the source directory and checkout from the destination directory.
Git is very, very fast.  I've heard that Mercurial is also (though I don't know from experience).
This approach will also give you lots of flexibility if you need to do more later.


NHibernate projection: How to get a typed type using the Criteria API with projection

Question:  List<object[]> products = GetSession().CreateCriteria<Product>()
            .SetProjection(Projections.ProjectionList()
                               .Add(Projections.Property("Id"))
                               .Add(Projections.Property("Name"))
                               .Add(Projections.Property("Price"))
             )
             .List();

public class ProductRow
{
     public int Id { get; set; }
     public string Name { get; set; }
     public double Price { get; set; }
}

How can I get the result as a List<ProductRow> type?
I see there is a function Projection.Cast, but I don't see any documentation on how to use it.
Comment: porjection --> projection
Ceritria --> Criteria
Answer: You may try setting a result transformer:
var result = GetSession()
    .CreateCriteria<Product>()
    .SetProjection(Projections.ProjectionList()
        .Add(Projections.Property("Id"), "Id")
        .Add(Projections.Property("Name"), "Name")
        .Add(Projections.Property("Price"), "Price")
    )
    .SetResultTransformer(Transformers.AliasToBean<ProductRow>())
    .List<ProductRow>();

Note the usage of alias pointing to a property name of a ProductRow when adding each projection.
Comment: `.Add(Projections.Property("Category.Name"), "Category")` in this case I getting error: 'could not resolve property: Category.Name of Project.Domain.Model.Product'.
Comment: I believe you need to add an alias for your Category property and use the alias name instead. So if you'd use AddAlias to give "Category" an alias of "c", you'd use "c.Name" instead of "Category.Name".


BigDecimal Rounding discrepancy using string and (int, long, double) constructors

Question: What is the difference between using different constructors in bigdecimal when using round off. When running the below code:
public class RoundTest {

    /**
     * @param args
     */
    public static void main(String[] args) {//2.425
        BigDecimal intv = new BigDecimal(4.645);
        BigDecimal doublev = new BigDecimal(4.645);
        BigDecimal strV = new BigDecimal("4.645");
        BigDecimal longV = new BigDecimal(4.645);

        System.out.println("Int - "+intv.setScale(2, RoundingMode.HALF_UP));
        System.out.println("Int - "+intv.setScale(2, RoundingMode.HALF_DOWN));
        System.out.println("Int - "+intv.setScale(2, RoundingMode.HALF_EVEN));

        System.out.println("Double -"+doublev.setScale(2, RoundingMode.HALF_UP));
        System.out.println("Double -"+doublev.setScale(2, RoundingMode.HALF_DOWN));
        System.out.println("Double -"+doublev.setScale(2, RoundingMode.HALF_EVEN));

        System.out.println("String - "+strV.setScale(2, RoundingMode.HALF_UP));
        System.out.println("String - "+strV.setScale(2, RoundingMode.HALF_DOWN));
        System.out.println("String - "+strV.setScale(2, RoundingMode.HALF_EVEN));

        System.out.println("Long - "+longV.setScale(2, RoundingMode.HALF_UP));
        System.out.println("Long - "+longV.setScale(2, RoundingMode.HALF_DOWN));
        System.out.println("Long - "+longV.setScale(2, RoundingMode.HALF_EVEN));
    }
}

Output is :
Int - 4.64
Int - 4.64
Int - 4.64
Double -4.64
Double -4.64
Double -4.64
**String - 4.65**
String - 4.64
String - 4.64
Long - 4.64
Long - 4.64
Long - 4.64

Why does round off using string constructor give a different result than the others? Are there any more differences when using rounding off with BigDecimal?
Comment: It's not clear why you've got `intv` and `longv` - they're exactly the same as `doublev` because you're calling the `BigDecimal(double)` constructor in all cases.
Answer:
Why does round off using string constructor give a different result than the others?

Because it's the only time you're actually passing in a value of exactly 4.645. The rest of the time, you're passing in the double value closes to 4.645, which isn't actually 4.645 - it's 4.644999999999999573674358543939888477325439453125.
You can use BigDecimal.valueOf(double) to create the BigDecimal value which effectively parses the double value's canonical string representation instead - then you'd get the same results as for String.


Name and meaning of "mirrored" accent sign

Question: I'm currently engraving a hand-written SATB piece in LilyPond and encountered some music notation I'm not really sure what to do with. It consists of four consecutive quarter notes with each note having "<" and ">" signs below them (it's in the alto part). The lyrics are in Swedish.

An ASCII art attempt at this looks something like this:
--|--|--|--|--
--o--o--o--o--
  <  >  <  >

My interpretation is that they are intended as single-note crescendos followed by decrescendos. Are there other valid interpretations of this that are specific to choral music?
Also, I still haven't found a way to produce this "decrescendo" sign in LilyPond, at least not in a visually appealing way. Maybe taking an accent sign and mirroring it horizontally could work, but I haven't delved into tweaking LilyPond out that far yet.
I'm now going with the Unicode MUSICAL SYMBOL CRESCENDO (U+1D192) and DECRESCENDO (U+1D193) simply attached as markup strings to the notes in question. For now, that is as close as I can get, semantically and visually. This is the LilyPond output:

The arranger of this piece is Hans Zimmergren (1937-2018), and the music (according to the manuscript) is based on an english traditional melody. The lyrics are an excerpt from Sakarias 9:9 (which is probably Zachary 9:9 in the English-speaking world). It's a single-page manuscript of 16 bars, probably intended as part of service. No tempo indicated, but as it is kind of hymnal it's probably andante at the most.
Comment: Are you sure that they're not very short crescendo/decrescendo pairs?  Do you not have access to the composer or copyist?  I certainly can't think of anything else they'd mean, but maybe seeing an image would help bring something to mind.  What language is the piece in?
Comment: My first guess was exactly that of cresc/decresc pairs. The arranger is long dead, I'm afraid, and we haven't performed it yet, so I'm not sure how it's meant to sound.
Comment: Is the arranger also the composer? That is, although the arranger is dead, might there be other arrangements of the piece? They could give clues. So, title and composer ...? (Thanks for the image. Very helpful.)
Comment: Do you know anyone who performed this arrangement with the arranger's participation?  A member of the choir for which it was arranged, perhaps?  That's probably your best bet to avoid having to guess at what it means.
Comment: I've seen very short hairpins before. Is there a tempo marking? The slower the tempo the more likely they are hairpins, IMHO
Comment: I will be talking to our choral director soon about this :-) Thanks to all who pitched in, it's been very interesting!
Comment: Possibly related: [Strange "less than" accent or ornament in Sullivan's "The Mikado" score](https://music.stackexchange.com/questions/122490/strange-less-than-accent-or-ornament-in-sullivans-the-mikado-score)
Answer: A simple way to obtain this symbol in LilyPond is to use the rotation property to rotate a normal accent.
\version "2.22.2"

reverseAccent = \tweak rotation #'(180 0 0) \accent

{
  c'-> c'\reverseAccent
}

See https://lilypond.org/doc/v2.23/Documentation/notation/rotating-objects.html#rotating-layout-objects
Answer: The "reverse accent" is a legitimate articulation symbol in Musescore called "Fade in":
Comment: Worth noting that the corresponding "accent symbol" to the right of it is called "fade out".
Comment: They also look quite different than the accent symbol, but in handwriting they could look the same.
Comment: Also, worth noting that outside of Musescore/Lilypond, I think any performer would simply refer to these as crescendo/decrescendo or "hairpins." The notes pictured would be odd with accents, but hairpins would make sense.
Answer: The arranger is indicating that the word should be accented against its normal pattern of emphasis.
Ordinarily, the second syllable of "rättfärdig" ("-fär-") receives the emphasis; however, Zimmergren is asking for the first and third to be emphasized on the second and fourth beats of the measure.
There is no standard "anti-accent" symbol, but sometimes a u-shaped arc attached to the note. Lilypond does not have a native symbol for anti-accents.
See also

Strange "less than" accent or ornament in Sullivan's "The Mikado" score
What should I do about composing 'soft' accents for piano?
Soft note marking
Answer: They certainly look like accents to me.  A crescendo or diminuendo should extend into the space that represents the note's duration, almost to the point underneath the following note.  But indeed I suspect that you are correct to suspect that these are not accents.
In applying dynamic markings to a staff containing more than two parts, one generally puts them below the staff only, and the markings apply to both parts.  If the parts require different dynamic markings, then the markings for the upper part go below the staff.
In vocal music, however, dynamics usually go above the staff because the lyrics are below the staff.  That might suggest that these markings apply only to the alto part.  On the other hand, this arranger has written the words farther away from the staff than normal -- on the staff below -- so it's possible that all the dynamics are written below the vocal staff.  In that case, these marks would apply to both parts.  Some comparison of the arranger's other work might be in order, if possible, to get a better sense of his style.
My best guess, without seeing other manuscripts or indeed the rest of this piece, is that the marks are intended to highlight the melodic contour of the soprano part.  Whether this means that the entire choir should do this or only the altos (because the sopranos should do it naturally on account of the melodic contour itself) is probably a matter for debate, but in any event it's clear that the altos should be aware of the sopranos' melodic contour and that they should be supporting it by singing a bit more loudly under the higher notes and more softly under the lower ones.  This is especially so because the lower notes are low in the soprano range, so the sopranos won't have as much volume as the altos.
There is a good deal of speculation here, of course.  This is the most plausible explanation given the little information in the question, but it could be way off.  To reiterate, looking at other work by the arranger could well point in a different direction.
If I were engraving this, I would probably not make these crescendo/decrescendo pairs, because that actually implies that the low note is the loudest point of each swell.  Since I think that's the opposite of the intention, I would either change the dynamic markings entirely or reproduce them as written; in both cases I would add a note of explanation.
Comment: The arranger (or copyist) apparently used three staves for each system; the middle staff is used for lyrics (which are the same for all voices). My guess is that the dynamics discussed apply to all voices. There are no other explicit dynamics in the piece to compare with.
Comment: @gmw normally dynamics apply to all the voices on the same staff only.  This would be even more true if there are words written between the staves, preventing the dynamics from being there (in the middle).  To indicate dynamics that apply to the whole ensemble, they should be applied separately to all staves, so singers don't have to pay attention to the staff they're not singing from.


IP Address Mismatch on signing into Heroku CLI

Question: Previously I could sign into the heroku command line interface with heroku login. But now I get an IP address mismatch error. How should I resolve this?
Answer: Copy and paste heroku login -i in your terminal. This is what solved it for me.
Comment: This is no longer the case when you have "authorization token" attached to your account!
Comment: Error: Your account has MFA enabled; API requests using basic authentication with email and password are not
 »   supported. Please generate an authorization token for API access.
Comment: This works for me but instead of setting your usual password, you should use the generated token available on your account.
Comment: This won't work with macOS 12 and later. You'll need to temporarily turn off Private Relay
Comment: Interestingly ... I ran this (and it failed because I have MFA enabled), but afterwards `heroku login` worked (I kept getting `IP address mismatch` after logging in via browser before).
Answer: Just adding some detailed steps to resolve the issue

Navigate to https://dashboard.heroku.com/account/applications
In Authorizations click on create authorization button
Add description in pop up eg.heroku cli and leave expire after blank if you dont want it to expire
You will get authorization token
in cli run heroku login -i
when it prompts for password enter the authoriation token
Comment: This is what worked for me
Comment: This is the way to do it if you use authorization tokens.
Answer: The accepted answer (run heroku login -i) doesn't work for accounts with MFA enabled. What I did instead was to reveal my account's API key and put it into ~/.netrc like so:
machine api.heroku.com
  login <MY_EMAIL>
  password <API_KEY>
machine git.heroku.com
  login <MY_EMAIL>
  password <API_KEY>

And voila! I can now use the CLI. This worked for me with Google CloudShell.
P.S. -- I added my machine's SSH key but could not understand how to use that to configure the CLI's access. It seems hard-coded to look for API keys in ~/.netrc.
Answer: If you are using Multi-Factor Authentication you could generate an Authorization token in settings page: https://dashboard.heroku.com/account/applications
Run heroku login -i and use the generated token as password.
Comment: works for me - annoying though
Comment: I tried many of the suggested solutions on here.This is the first one that worked for me. Tanks!
Answer: For accounts that have MFA.
Run heroku login, press any key to open up browser window. Copy the url and open it in incognito mode.
Answer: If you're using a Mac running macOS 12 Monterey with the Private Relay feature enabled, you'll need to turn that off while you complete the Heroku CLI authentication workflow, since that feature is obfuscating your actual IP address by proxying your traffic through a pool of IP addresses.
Comment: Thank you. This explains why it is just started happening, seemingly out of nowhere; but it had been a week or more since I enabled Private Relay. But `heroku login -i` worked.
Answer: This error will occur when your machine is behind a proxy if you disable the proxy temporarily then authentication will be done.
Comment: this was the only  answer that helped me. thx!
Comment: This worked. I had a  local DNS server running, I stopped for a few seconds and it was able to log in.
Answer: for me heroku login -i worked..
didnt need the token.after heroku login -i it wanted my credentials...i.e email and password and i was logged in
Comment: As it's currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Answer: If you're using Multi Factor Authentication you have to create an API key. To do that:

Go here: https://dashboard.heroku.com/account (login if asked)

Click here:

Open the hidden file located at ~/.netrc and paste your API key in the two 'password' fields.
For example, if your API key is 'a8g73nga-9vb2-0184-afbc-54fac2b66c75', then it should look like this:

machine api.heroku.com
  login firstname.lastname@example.com
  password a8g73nga-9vb2-0184-afbc-54fac2b66c75
machine git.heroku.com
  login firstname.lastname@example.com
  password a8g73nga-9vb2-0184-afbc-54fac2b66c75

The heroku CLI will now work!

Reference

Heroku CLI Authentication docs
Answer: New changes where added by Heroku on login. You can find the change logs here.
In case if you are behind the firewall you may need to set the proxy.

set HTTP_PROXY=http://proxy.server.com:portnumber
Comment: what does portnumber refer to, and what should it be set to?

are `proxy` or `server` also meant to be place holders for some other value, or should they be interpreted literally?
Comment: Probably due to this issue, I found that as a workaround I could just turn on a VPN, redo the login and everything worked.
Answer: If you are a Mac user on 12.3 or later, you need to open System Preferences, > Network > Wi-Fi, and then uncheck "Limit IP Address Tracking" for the duration of your authentication.
New OSX masks your IP address, and Heroku login doesn't know how to deal with it. All you need is to let Heroku verify IP before/after auth, and you'll be good to go.
Answer: This worked for me:
1/ Logout in the browser
2/ Clear cache and cookies for heroku.com (optional)
3/ Run "heroku login"
4/ Logging in the browser tab opened by the CLI
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Answer: Close or switch terminal, and then rerun the command "heroku login" This works for me!
Answer: I initially installed Heroku with Snap software package manager.
Installing it with npm solved my problem.
copy and paste the code below.
npm i -g heroku

Answer: My default browser is Safari with private relay on. This was my issue. I just copied the url from the Safari browser to one of my other browsers (Brave) and it worked.
Answer: I was able to connect with the following:
heroku login -I //
email: firstname.lastname@example.com //
password: api key # from account settings
So satisfying!
Answer: For some reason heroku login -i led to some I/O issues on Google Colab for me.
I needed to press the return key multiple times after entering the password, and that somehow made the credentials incorrect.
I had to open up a Colab Terminal to login as I would via any Linux-based shell (The Colab terminal is available on Colab Pro and Pro+).
Answer: Turning on a VPN solved it for me. It's possible the incognito browser or clearing cookies would work, too.
The issue is that my browser and CLI had different IP addresses: https://help.heroku.com/CBF0T4AJ/can-t-login-to-heroku-using-cli-getting-ip-address-mismatch#:~:text=This%20means%20that%20you%20will,the%20changes%20to%20take%20effect.
Heroku's suggestion is to set up a server proxy, but the VPN is effectively proxying all the traffic anyway, so that works.
Answer: Leaving this here for next time.

login in heroku in browser
generate and open link again
Answer: I tried all the Solutions mentioned above but the VPN solved my issue.
I think i have a problem with my ISP or HTTP PROXY

HTTP_PROXY=http://proxy.server.com:portnumber
Comment: As it's currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Comment: This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30444778)


Complex integral containing Gaussian

Question: I want to calculate the integral using complex integration:
$$ f(t) = \int_{-\infty}^\infty \dfrac{e^{-(z+iat)^2}}{4z^2+1} dz = \int_{-\infty}^\infty \dfrac{e^{-(z+iat)^2}}{(2z-i)(2z+i)} dz$$
where $a$ is real.
There are poles at $z=\pm i/2$. If I draw a semicircle anticlockwise contour on the upper half of the complex plane, the contour encloses the $i/2$ pole. Then by the method of residues,
$$f(t) = 2\pi i\mathrm{Res}_{z=i/2} = 2\pi i \left( \dfrac{1}{2i} e^{(1/2+at)^{2}}\right)$$
I double checked on Mathematica and this is not the correct answer.
I suspect I need to do something with the $e^{-(z+iat)^2}$ part, but I'm not sure what (I'm a novice at solving complex integrals). Can you please help?
Comment: Hi Medulla Oblongata, what are the signs of $a,t$?
Comment: Hello again, Szeto. Both $a$ and $t$ are real, $t$ is positive and negative but $a$ can be restricted to being positive if necessary.
Comment: You can not use the Jordan's lemma, because on the imaginary axis in both directions $e^{-z^2}$ diverges. Usually, integrals of a Gaussian with a simple poles is some special function (some type of a complex-valued error function)
Answer: How did you get $-1+i$? The residue at $z=i/2$ is $\lim_{z\to i/2} (z-i/2) \frac {e^{-(z+iat)^{2}}} {(2z-i)(2z+i)}=\frac 1 {4i} e^{(1/2+at)^{2}}$ and you have to multiply this by $2 \pi i$
Comment: thanks, I fixed the error

Complex integral containing Gaussian


Porque quando clico no botão para executar a função de mostrar um formulário invisível mostra o formulário mas depois some?

Question: Sou novo em desenvolvimento web e uso xampp v5.6.28 fiz uma função javascript que quando carrega a pagina, form1 é visível e o form2 é display:none mas quando clico no botão pra deixar o form1 invisivel e mostrar o form2, mostra o form2 rapido e depois volta o form1. Eu gostaria de saber o que causa isso.
HTML:
<!DOCTYPE html>

    <title>Login</title>
    <link rel="stylesheet" type="text/css" href="estilo.css"/>

      <form id="form1">

Login

        <input type="text" placeholder="Username"/>
        <input type="password" placeholder="Password"/>

          <button id="btns" onclick="muda1">Signup</button>
          <input type="submit" value="Login"/>

      </form>

      <form id="form2" onload="carrega()">

Signup

        <input type="text" placeholder="Name"/>
        <input type="email" placeholder="Email"/>
        <input type="text" placeholder="Username"/>
        <input type="password" placeholder="Password"/>
        <input type="password" placeholder="Confirm Password"/>

          <button id="btnl">Back</button>
          <input type="submit" value="Signup"/>

      </form>

css:
@import url('https://fonts.googleapis.com/css?family=Roboto');

html, body{
  font-family: 'Roboto', sans-serif;
  width:100%;
  height:100%;
  background-image:-webkit-linear-gradient(#5b82c1,#74a6f7);
  margin:0;
  padding:0;
}

body{
  display: flex;
  justify-content: center;
  align-items: center;
}

#box{
  display:flex;
  align-items: center;
  flex-flow: column wrap;
  width: 30%;
  background-color:#fff;
  padding:18px;
}

h1{
  color:#5b82c1;
  font-size:2em;
}

form{
  width:90%;
}

form input{
  border:none;
}

form input[type="text"],
form input[type="email"],
form input[type="password"]{
  width:100%;
  height:35px;
  font-size:20px;
  margin-bottom:8%;
  border-bottom: 1px solid #5b82c1;
}

form input[type="submit"]{
  background-color:#5b82c1;
  width:95px;
  height:45px;
  font-size:1.5em;
  color:#fff;
  margin-left:46%;
}

button{
  border:none;
  background-color:#5b82c1;
  width:95px;
  height:45px;
  font-size:1.5em;
  color:#fff;
}

.hiddenclass{
  display:none;
}

.showclass{
  display:block;
}

JAVASCRIPT que tentei:
function carrega(){
  document.getElementById("form2").style.display = 'none';
};

function muda1() {
  document.getElementById("form1").style.display = 'none';
  document.getElementById("form2").style.display = 'block';
};

Comment: Dá uma olhada aqui: https://jsfiddle.net/txy4yjhx/15/
Answer: Seria isso?
Acrescentei na funcão muda1() para que a mesma função faça a alternância dos formularios.

function carrega(){
  document.getElementById("form2").style.display = 'none';
}

function muda1() {
  if(document.getElementById("form2").style.display =="none"){
  document.getElementById("form1").style.display = 'none';
  document.getElementById("form2").style.display = 'block';
    }
  else{
      document.getElementById("form1").style.display = 'block';
  document.getElementById("form2").style.display = 'none';
    }
}
@import url('https://fonts.googleapis.com/css?family=Roboto');

html, body{
  font-family: 'Roboto', sans-serif;
  width:100%;
  height:100%;
  background-image:-webkit-linear-gradient(#5b82c1,#74a6f7);
  margin:0;
  padding:0;
}

body{
  display: flex;
  justify-content: center;
  align-items: center;
}

#box{
  display:flex;
  align-items: center;
  flex-flow: column wrap;
  width: 30%;
  background-color:#fff;
  padding:18px;
}

h1{
  color:#5b82c1;
  font-size:2em;
}

form{
  width:90%;
}

form input{
  border:none;
}

form input[type="text"],
form input[type="email"],
form input[type="password"]{
  width:100%;
  height:35px;
  font-size:20px;
  margin-bottom:8%;
  border-bottom: 1px solid #5b82c1;
}

form input[type="submit"]{
  background-color:#5b82c1;
  width:95px;
  height:45px;
  font-size:1.5em;
  color:#fff;
  margin-left:46%;
}

input[type=button]{
  border:none;
  background-color:#5b82c1;
  width:95px;
  height:45px;
  font-size:1.5em;
  color:#fff;
}

.hiddenclass{
  display:none;
}

.showclass{
  display:block;
}
<!DOCTYPE html>

<title>Login</title>
<link rel="stylesheet" type="text/css" href="estilo.css"/>

  <form id="form1">

Login

    <input type="text" placeholder="Username"/>
    <input type="password" placeholder="Password"/>

      <input type="button" value="SingUp" id="btns" onclick="muda1();">
      <input type="submit" value="Login"/>

  </form>

  <form id="form2" onload="carrega()">

Signup

    <input type="text" placeholder="Name"/>
    <input type="email" placeholder="Email"/>
    <input type="text" placeholder="Username"/>
    <input type="password" placeholder="Password"/>
    <input type="password" placeholder="Confirm Password"/>

      <input type="button" id="btnl" onclick="muda1();" value="Back">
      <input type="submit" value="Signup"/>

  </form>

Comment: obrigado pela ajuda vlw
Comment: vc mudo alguma coisa?
Comment: Estou editando novamente calma ai
Comment: eu vi que eu esqueci de por o onload no body
Comment: Seria isso? Mudei a sua função para utilizar a mesma para desaparecer e aparecer e o seu ` onclick="muda1" `
Comment: aqui o codigo roda direitinho mas no xampp não, acontece a mesma coisa da minha pergunta
Comment: O seu código aqui esta exatamente o de la?
Comment: sim esta igual a aqui
Comment: Ve no console se dá algum erro...
Comment: do navegador não, mas mesmo só rodando no chrome sem usar o xampp o problema persiste
Comment: Consegui replicar seu erro aqui, jaja edito a resposta
Comment: o problema de atualização da pagina?
Comment: O problema está que não sei porque, mas de alguma forma ele estava entendendo o `` como o submit e ele estava meio que submetendo o form. Então eu os alterei colocano como ` <input type="button" ` e tive que alterar o css tambem. E tambem o seu form esta sem o method, isso faz com que a url fique daquela forma
Comment: ai ele tava atualizando a pagina
Comment: É isso, mas agora consertei ai, roda ai. Espero ter ajudado :)
Comment: Mas agradeço desde ja
Comment: como q vc replicou meu erro?
Comment: Rodei no localhost. Funcionou?
Answer: Segue trecho de código funcionando. Só executar para conferir.

function carrega(){
  document.getElementById("form2").style.display = 'none';
};

function muda1() {
  document.getElementById("form1").style.display = 'none';
  document.getElementById("form2").style.display = 'block';
};

function muda2() {
  document.getElementById("form1").style.display = 'block';
  document.getElementById("form2").style.display = 'none';
};

(function() {

   var btn = document.getElementById("btns");
   var btnBack = document.getElementById("btnl");

   btn.addEventListener("click", muda1, false);
   btnBack.addEventListener("click", muda2, false);

   carrega();

})();
@import url('https://fonts.googleapis.com/css?family=Roboto');

html, body{
  font-family: 'Roboto', sans-serif;
  width:100%;
  height:100%;
  background-image:-webkit-linear-gradient(#5b82c1,#74a6f7);
  margin:0;
  padding:0;
}

body{
  display: flex;
  justify-content: center;
  align-items: center;
}

#box{
  display:flex;
  align-items: center;
  flex-flow: column wrap;
  width: 30%;
  background-color:#fff;
  padding:18px;
}

h1{
  color:#5b82c1;
  font-size:2em;
}

form{
  width:90%;
}

form input{
  border:none;
}

form input[type="text"],
form input[type="email"],
form input[type="password"]{
  width:100%;
  height:35px;
  font-size:20px;
  margin-bottom:8%;
  border-bottom: 1px solid #5b82c1;
}

form input[type="submit"]{
  background-color:#5b82c1;
  width:95px;
  height:45px;
  font-size:1.5em;
  color:#fff;
  margin-left:46%;
}

button{
  border:none;
  background-color:#5b82c1;
  width:95px;
  height:45px;
  font-size:1.5em;
  color:#fff;
}

.hiddenclass{
  display:none;
}

.showclass{
  display:block;
}
<!DOCTYPE html>

    <title>Login</title>
    <link rel="stylesheet" type="text/css" href="estilo.css"/>

      <form id="form1">

Login

        <input type="text" placeholder="Username"/>
        <input type="password" placeholder="Password"/>

          <button id="btns" onclick="muda1">Signup</button>
          <input type="submit" value="Login"/>

      </form>

      <form id="form2">

Signup

        <input type="text" placeholder="Name"/>
        <input type="email" placeholder="Email"/>
        <input type="text" placeholder="Username"/>
        <input type="password" placeholder="Password"/>
        <input type="password" placeholder="Confirm Password"/>

          <button id="btnl">Back</button>
          <input type="submit" value="Signup"/>

      </form>

Qualquer dúvida é só postar um comentário.
Espero ter ajudado.
Comment: obrigado pela ajuda
Comment: @jaojpaulo, se minha resposta foi útil, seria bom marcar com +1
Comment: executando o código aqui funciona direitinho mas quando rodo no xampp não funciona pq?
Comment: acontece o que eu disse na pergunta
Comment: Um pouco difícil afirmar o que pode estar acontecendo. Posso acessar remotamente para olhar se quiser... tem teamviewer?
Comment: não tenho, mas oque é estranho é que não mudei nada
Comment: Tem algo no firebug (F12 no chrome)? algum erro?
Comment: criei arquivos novos e com seu código no console ta dando "Uncaught TypeError: Cannot read property 'addEventListener' of null
    at script.js:19"
Comment: e esse problema persiste mesmo rodando só no chrome sem usar o xampp
Comment: Alterei a resposta. Só a parte do JavaScript. Me fala se deu certo.
Comment: Testou o JavaScript alterado?
Comment: ainda não pq vou precisar sair mas quando testar respondo, mas desde ja obrigado ajudou mto


Setting a Html table 'tr' width to have a different width for each cell on one row

Question: I have the following table declaration:

This is a very long first line here, taking the entire width of the table

Comment
My text on the comment cell

I don't understand why my second column is as wide as the first one. I thought that by specifying the table-layout: fixed; property for the table, and setting the columns widths, I would obtain what I wanted, which was:

A first row with only one cell of a width which would be 100% of the table width
A second row with a small first cell, and a second wide second cell
Answer: In the fixed table layout, when the first row of the table can't describe the individual column widths, you need to use the col element to define those widths. So:

table {
  width: 80%;
  border-collapse: collapse;
  table-layout: fixed;
}
col:nth-child(1) {
  width: 20%;
}
col:nth-child(2) {
  width: 80%;
}
td {
  border: 1px solid black;
}

    <col><col>

        This is a very long first line here, taking the entire width of the table

        Comment
        My text on the comment cell

Comment: @zer00ne - when the first row's cells span multiple columns.
Comment: Ahh, I see what you mean. I would never have a table without a `` so it never occurred to me. You should add your comment to your question.+1
Comment: When does the first row not able to set it's own widths and the table not "describe" them?
Answer: table-layout: fixed allows you to set the widths of each  or the first row of  within the
 if there's no
. Once the widths are established, each column will conform to those widths. It's the nature of a column. If you want different widths for each row try colspan.

table {
  table-layout: fixed;
  border-collapse: collapse;
  width: 100%;
}

table,
th,
td {
  border: 3px solid black;
}

th {
  width: 25%
}

      I
      II
      III
      IV

      colspan="4"

      colspan="3"

      colspan="2"
      colspan="2"

Comment: Thanks, it works, I was not aware that it worked like that


Metallic sparkle effect in OpenGL ES?

Question: I'm working on an Android and iPhone app. I'm rendering lots of smallish (about 32 pixels) billboards to the screen for a particle system and want to give a glitter-like sparkle to each billboard e.g. as the particles are falling, random ones will briefly light up and sparkle as they catch the light. Is there a simple way to achieve this effect? As a limitation, I cannot use pixel/vertex shaders.
I was thinking something along the lines of a giving each billboard metal-like lighting effect (although I'm not sure how to do this part) coupled with giving each billboard a random and constantly rotating normal with flat shading so that each billboard would randomly light up. I'm having trouble making it look nice.
Comment: I think that's unfair; I'm not asking anyone to teach me OpenGL and I haven't asked for code. I'm asking for some high-level hints at what techniques I can use to simulate this effect given the limitation of no pixel/vertex shaders (which are involved in every tutorial I'm finding). Something high-level like "use a texture like this...set the lightning like this" would be fine. I'm not expecting an exact solution, just some pointers for what I can try.
Comment: This kinda comes across as a "Teach me OpenGL" question.  There isn't some simple solution someone can give you, without actually coding it for you.
Answer: Disclaimer: I don't know OpenGL, and I did't actually try anything I write below.
You can have another, 'brightly lit', texture and substitute it when normal is nearly at the 'shine' position.
Take a piece of metal and rotate it. Once the normal is close to 'full shine' position, the metal shines a bit brighter, and a muted reflex travels through it, with a bright flash in the middle, then it is dull again.
If you can, apply a second bright texture of a narrow 'reflex' band and move it through surface of the billboards that are in a near-shine position, shifting them accordingly to normal angle. When the normal is at the shine position (± epsilon), apply the 'full shine' texture.
Also, unless your plates fly in vacuum, there will be a halo due to atmosphere. Add a rectangle say 50% bigger than the plate right behind it, and apply to it a semi-transparent halo texture that becomes fully transparent closer to edges. You only need it at the fill shine moment.

Metallic sparkle effect in OpenGL ES?


Rewriting this complex square root

Question: for some reason I can to figure out how to rewrite this square root.
I have:
$\sqrt{2+i}$
And I need to rewrite it into:
$\frac{\sqrt{2(\sqrt{5} + 2)} + \sqrt{-2(\sqrt{5} - 2)}}{2}$
Can anybody show me I to do this? I've been trying for an hour now..
Comment: **Hint:** $\sqrt{\cos \theta + i \sin \theta} = \cos(\theta/2) + i \sin(\theta / 2)$.  Note $2 + i = \sqrt{5} \cdot \left(\frac{2}{\sqrt 5} + i \frac{1}{\sqrt 5}\right)$
Comment: @DaneBouchie Read that again.  I say
$$
2 + i = \sqrt{5} \cdot \left(\frac{2}{\sqrt 5} + i \frac{1}{\sqrt 5}\right)
$$
Comment: Solve $(x+iy)^2=x^2-y^2+2ixy=2+i$.
Comment: Ah, my bad. I read $.$ as a period for some reason. Even then, lazy reading on my behalf.
Answer: One can use trigonometry for sure but I thing the fastest way to solve this is just to solve the quadratic.
$$(x+yi)^2=2+i$$ so
$$x^2-y^2=2$$
$$2xy=1$$
and $$(x^2+y^2)^2=(x^2-y^2)^2+4x^2y^2=4+1=5$$
So $$x^2+y^2=\sqrt{5}$$
(positive since $x$ and $y$ real)
and
$$x^2=\frac{\sqrt{5}+2}{2}$$
$$y^2=\frac{\sqrt{5}-2}{2}$$
so
$$x=\pm\sqrt{\frac{\sqrt{5}+2}{2}}$$
$$y=\pm\sqrt{\frac{\sqrt{5}-2}{2}}$$
Both $x$ and $y$ have same sign since $2xy=1$.

Rewriting this complex square root


Given the approximation of $\bar{X}$, find the approximation of $\bar{X}^3$

Question: We know that $\bar{X}$ is approximately $N(μ,\frac{σ^2}n)$ for large n. Find the approximate distribution of $u(\bar{X}) = \bar{X}^3$, provided that $μ\neq0$.
How do you go from $\sqrt{n}\frac{\bar{X}-\mu}\sigma \sim N(0,1)$ to $\sqrt{n}(\bar{X}-\mu) \sim N(0,\sigma^2)$
Comment: please look up Delta Method, try using it and come back if you still have a question: https://en.wikipedia.org/wiki/Delta_method
Comment: Okay, just one question, how do you go from $\sqrt{n}\frac{\bar{X}-\mu}\sigma \sim N(0,1)$ to $\sqrt{n}(\bar{X}-\mu) \sim N(0,\sigma^2)$
Comment: @angelo086 use [mgf](https://en.wikipedia.org/wiki/Moment-generating_function#Linear_combination_of_independent_random_variables)? I mean, in the first place what does it mean for a random variable to be distributed $N(0,1)$? We are given that $M_Z(z) = e^{t^2/2}$ What is $M_{\sigma Z}(z)$ then?
Answer: First, your question $\sqrt{n}\frac{\overline{X}-\mu}\sigma \sim N(0,1) \iff \sqrt{n}( \overline{X} - \mu) \sim \sigma N(0,1) \iff \sqrt{n}(\overline{X} - \mu) \sim N(0,\sigma^2)$.
Now, on to the main problem. Let $X_1,\dots,X_n$ be a random sample from a distribution with mean $\mu$ and variance $\sigma^2$. From CLT, we know $\sqrt{n}\left( \dfrac{\overline{X}-\mu}\sigma\right) \xrightarrow{d} N(0,1)$; i.e. $\overline{X} \stackrel{asymp.}{\sim} N(\mu,\sigma^2/n)$.
The Delta method tells us that
$$
\sqrt{n}([\overline{X}]^3 - \mu^3) \xrightarrow{d} N(0, \sigma^2 [3 \mu^2]^2 ) = N(0,(3 \sigma \mu^2)^2)
$$
so that
$$
\sqrt{n} \dfrac{([\overline{X}]^3 - \mu^3)}{3 \sigma \mu^2} \xrightarrow{d} N(0,1)
$$
which means
$(\overline{X})^3 \stackrel{asymp.}{\sim} N(\mu^3, (3 \sigma \mu^2)^2 / n)$.
Comment: nice and clear, +1


AutoMapper profile class in library - AutoMapperMappingException: Missing type map configuration or unsupported mapping error

Question: I am trying to use AutoMapper in multi-layered .Net Core Web API. Here are the layers

API - all controllers (Web API)
Business - business logic (library)
Models - DTO and Automapper profiles (library)
Data - EF layer (library)

In Web API, I've injected the required interface and concrete class in the startup along with initializing AutoMapper and also referenced the Models project
  services.AddAutoMapper(typeof(Startup));
  services.AddDbContextPool<ApplicationContext>(options => options.UseSqlServer(Configuration.GetConnectionString("Default")));
  services.AddScoped<IStudent, Student.Business.Student>();

In the model layer, I created a Automapper profile class.
namespace Student.Models.Mapper
{
    public class StudentProfile : Profile
    {
        public StudentProfile()
        {
            CreateMap<Student, Entities.Student>().ReverseMap();
            CreateMap<StudentAddress, Entities.StudentAddress>().ReverseMap();
        }
    }
}

In the business layer
namespace Student.Business
{
    public class Student : BaseClass, IStudent
    {
        private readonly ApplicationContext _context;
        private readonly IMapper _mapper;

        public Student(ApplicationContext context, IMapper mapper)
        {
            _context = context;
            _mapper = mapper;
        }

        public async Task<Response<Models.Student>> CreateStudentAsync(Models.Student student)
        {
            var studentEntity = _mapper.Map<Entities.Student>(student);
            _context.Students.Add(studentEntity);
            await _context.SaveChangesAsync();
            var response = new Response<Models.Student>
            {
                Content = student
            };
            return response;
        }
    }
}

I am getting the following error
AutoMapperMappingException: Missing type map configuration or unsupported mapping. Mapping types: Student -> Student Student.Models.Student -> Student.Entities.Student

lambda_method(Closure , Student , Student , ResolutionContext )
lambda_method(Closure , object , object , ResolutionContext )
AutoMapper.Mapper.Map<TDestination>(object source) in Mapper.cs
Student.Business.Student.CreateStudentAsync(Student student) in Student.cs

var studentEntity = _mapper.Map<Entities.Student>(student);

Student.Api.Controllers.StudentsController.CreateStudentAsync(Student student) in StudentsController.cs

return await _student.CreateStudentAsync(student);

lambda_method(Closure , object )
Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable+Awaiter.GetResult()
Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor+AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Comment: http://docs.automapper.org/en/latest/Dependency-injection.html#asp-net-core
Answer: You're getting this error because AutoMapper cannot find your mapping profiles.
Your mapping profiles are defined in "Models" assembly, and Startup class is in the "API" assembly.
You have:
services.AddAutoMapper(typeof(Startup));

Automapper will search for profiles in the assembly in which the type Startup is defined. That's not what you're looking for. Modify the call to AddAutoMapper() and pass a type from the "Models" assembly.


Flight board effect using jquery

Question: I am trying to build a flight board effect using jquery.
So far i have been able to create an effect that rotates characters. Here's what I have achieved so far: http://www.jaspreetkaur.com/chatter/
See the text "get to the chatter that matters"
However O do not feel this effect is realistic. I want the text flip to be like http://nolanow.cacno.org/ (see the word NOW in logo) This effect is created with help of images.
I do not want to use images to keep the effect reusable, so how can i create the effect without use of images?
Comment: You might find this post useful; [Best Implementation of: Airport/Train Station departure board (html/css/jquery)](http://stackoverflow.com/questions/4869405/best-implementation-of-airport-train-station-departure-board-html-css-jquery)
Comment: Thanks Matt, i have already created that effect, what i want to add is flip effect as shown here http://nolanow.cacno.org/
Comment: I have used Flash to create this effect.
Answer: I was able to create the effect upto some extent, here's the code: http://jsfiddle.net/alokjain_lucky/QZuku/
I am still trying to improve the code however to make it more useful.
Answer: try using a font like YonderRecoil - just an example, there are bound to be better fonts than this one out there
Answer: I was looking for the same effect and couldn't really find a library that did it the way I wanted, so I created a jsFiddle with the effect as well in case anyone is still interested in this.
http://jsfiddle.net/jacoswarts/neUtP/

5

4

The HTML is a bit bulky, so converting it into a jquery plugin that injects the boards would be nice.

Flight board effect using jquery


JS or jquery to auto style/highlight matched words as typed

Question: I need to be able to style/format text when specific words are typed into a content-editable iframe on the fly. For instance say the word "danger" was one of the key words, when the user types the word danger into  the content-editable it wraps that word in a div that makes the word bold and red. JS Bin type functionality for their syntax highlighting as you type is what I'm trying to achieve, any suggestions?
Answer: You should definitely check out CodeMirror... it is used by jsFiddle actually. Once you've installed it, I'm pretty sure you could create your own stylesheets and your own syntax highlighting. It might involve some extra coding but it will be totally worth it!
I hope this helps.
Comment: thanks I will check it out, one thing I forgot to mention is that the words that need to be parsed/formated on the fly will be dynamic, an array of words to match would be generated dynamically each page load, not pre-defined words since the words are based on user specific settings
Comment: hmm... that makes it more difficult. I'm sure you could still do it though, but it will take some reading through the code to understand how it works. You could also probably just email the dude that wrote CodeMirror and ask him if what you are trying to do can be done with CodeMirror... his email is on the site.


Confusion with matrix algebra when deriving GLS

Question: Consider the following linear model
$$y = X\beta + u$$
where $Var(u) = \mathbb{E}(uu') = \sigma^2\Omega$. I watched video on GLS derivation which proceeds as follows: since OLS is BLUE in case of homoskedasticity, we require such linear transformation (with transformation matrix $A$) of the regression equation that will bring us to this case, i.e. $Ay = AX\beta + Au$, where $Au = \sigma^2I$ and then estimate it with OLS. Since $u = y - X\beta$ we have the following:
\begin{equation}
\begin{aligned}
Var(Au) &= \sigma^2I \\
\Leftrightarrow \mathbb{E}(Auu'A') &= \sigma^2I \\
\Leftrightarrow A\mathbb{E}(uu')A' &= \sigma^2I \\
\Leftrightarrow \sigma^2AVA' &= \sigma^2I \\
\Leftrightarrow AVA' &= I  \\
\Leftrightarrow AV &= (A')^{-1} \\
\Leftrightarrow V &= A^{-1}(A')^{-1} \\
\text{(assuming $A$ is symmetric)} \; V &= A^{-2} \\
\text{(part of confusion)} \Leftrightarrow A &= V^{-1/2}
\end{aligned}
\end{equation}
I mean why the last step follows? First, $V$ is diagonal which simplifies the case. But we did not impose any structure on $A$ (except it is symmetric). $V^{-1/2}$ means take square root of each diagonal element. However, I am not convinced about the last step. In addition, would it work if I assume that $V$ is not diagonal?
Answer: It is not generally the case that the "matrix square root" just consists of the square roots of the elements on the main diagonal.
Consider a symmetric $V^{-1/2}$ via the Singular Value Decomposition (SVD), or eigenvalue decomposition, of $V$:
\begin{align*}
V&=PDP'\\
P'P&=PP'=I
\end{align*}
with $D$ diagonal. Then
\begin{eqnarray*}
V^{1/2}=PD^{1/2}P',
\end{eqnarray*}
and $V^{-1/2}$ is its inverse given by $PD^{-1/2}P'$.
Also, the "matrix square root" does not have to be symmetric (just as for conventional square roots, the "matrix square root" is not unique).
For example, for AR(1) errors $\epsilon_i=\phi\epsilon_{i-1}+\xi_i$, the variance-covariance matrix can be shown to be
$$
V=\sigma^2_{\xi}\frac{1}{1-\phi^2}\left(%
\begin{array}{cccc}
1 & \phi & \cdots & \phi^{n-1} \\
\phi & \ddots & & \phi^{n-2} \\
\vdots & \ddots & \ddots & \vdots \\
\phi^{n-1} & \cdots & \phi & 1 \\
\end{array}%
\right)
$$
One may verify that
$$
V(\phi)^{-1}=\frac{1}{\sigma^2_{\xi}}\left(%
\begin{array}{cccccc}
1 & -\phi & 0 & \cdots & \cdots & 0 \\
-\phi & 1+\phi^2 & -\phi & \ddots & & \vdots \\
0 & -\phi & \ddots & \ddots & \ddots & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & 0 \\
\vdots & & \ddots & \ddots & 1+\phi^2 & -\phi \\
0 & \cdots & \cdots & 0 & -\phi & 1 \\
\end{array}%
\right)
$$
One can also verify that the condition $V^{-1}=A'A$ is satisfied by the "Prais-Winsten transformation"
$$
A(\phi)=\frac{1}{\sigma_{\xi}}\left(%
\begin{array}{ccccc}
\sqrt{1-\phi^2} & 0 & \cdots & \cdots &0 \\
\hdashline -\phi & 1 & \ddots & & \vdots \\
0 & -\phi & 1 & \ddots & \vdots \\
\vdots & \ddots & \ddots & \ddots & 0 \\
0 & \cdots & 0 & -\phi & 1 \\
\end{array}%
\right)
$$
Comment: Thanks for your reply. I still have some confusion. I guess that the part of your answer that describes SVD justifies step $A^{-1}A^{-1} = A^{-2}$. But why it follows that $V = A^{-2}$ implies $A = V^{-1/2}$? And also what does expression $V^{-1/2}$ mean? Is it one over square root of each element? Does it work only for symmetric matrix?
Comment: @tosik, no, $V^{-1/2}$ would then be $A$ in my second example. As the example shows, it is not one over square root of each element.


Do most professional guitarists use string lubricant?

Question: New electric guitar strings seem to almost stick to the fingers, and within hours start to turn gray/black-ish in the spots I've played them most.
By contrast, lubricating and cleaning the strings with GHS Fast Fret (actually wrapping its cloth around each string and rubbing it thoroughly) before and after each time I play prevents them from getting sticky and keeps them cleaner.
It might also lubricate the contact point between the strings and frets, reducing friction when bending.
I almost never see this subject discussed in interviews with accomplished guitarists. I realize each musician is different, but can you point to particular guitarists and what they do, if anything, about this?
Does the skin on the fingertips of guitarists who play regularly get hardened enough that this stops being an issue?
Note: my hands are clean before playing.
Answer: This issue differs greatly between different guitarists. Some people get the issue you are reporting, that the strings get discoloured almost immediately, while others are not experiencing this at all. This is likely the reason that it is not discussed as a general problem, since it is not something everyone is experiencing.
I don't think calluses help this problem. At any rate, you won't get heavy calluses all over your fingers, so barre chords would still bring the problems.
Answer: Some players have sweat that is acidic, and this can affect strings. It's not that common, but I had a pupil whose strings were always rusty only a week after they were fitted new. Fast fret, etc., work well, but so does just rubbing a dry cloth along the strings, particularly underneath, and also on the fretboard itself. I knew one guy who would put talcum powder (French chalk) all over his strings before playing.As M.U. says, the callouses wont make any difference.Try drying your hands every 10/15 mins or so - it may make the strings last better.
Answer: You've really got a couple of questions here: one about string lubricants, and one about whether calluses eventually get hard enough that it's not an issue.
I've been a pro guitarist since 1976 (and yes, it's my full-time job).  I never use string lubricants, and I'm not aware of any other pros who do.
Fast Fret is marketed as a string cleaner, but I think it's just mineral oil - I couldn't find an MSDS online.  Any oil will prevent dead skin cells from sticking to the strings, which will prolong their life - if you're interested in why, I can go into more detail.  But if you're a working guitarist, you're going into gigs with new (or at least new-ish) strings, so intonation isn't going to be an issue.
The oil will repel water, so if you sweat a lot I guess that might help prevent strings from rusting.  But I just keep some talcum powder in my case in the event I have a gig in high temperatures, so that's never been an issue for me.
FWIW, a competing product (Finger-Ease) is mostly naptha, a solvent.  I do use naptha to clean my fretboards when I do string changes, but I use the much cheaper version - old school lighter fluid.  It's the same stuff without the aerosol propellants.  But I don't use it on the strings.
For the second part (the calluses), the answer is yes/maybe.  When I was younger my fingertips looked like glass - perfectly smooth, you couldn't see any fingerprints, and if I tapped them against a piece of glass they sounded like metal.
They're not like that anymore, even though I play just as much.  The difference?  I have better gear, and it's better maintained.  When the best instruments I could afford weren't really that good, thicker calluses were the result.  As I was able to afford better gear, my calluses downsized.  Now they feel kind of like smooth leather - there's a bit of 'give' to them.  I can still get a clear sound by tapping on a piece of glass (I just tried it!), but it's not the clear metallic sound they once had.
Answer: I never use it. Before playing I wash my hands, and make sure the neck, fingerboard and strings are very clean.
I found that using teflon-coated strings makes a big difference in how my fingers (don't) stick too. Better quality strings seem to avoid corrosion better than cheap ones also.
Professional players often have their strings changed nightly by their tech, so it's not much of an issue for them.
Answer: I used to live in California (dryer type climate). I now live in Hawaii (more humid). I have many guitars so this is an issue with me. I am convinced that the humidity has an impact. I have found also that cleaning the strings after playing is even more important than before playing. The acids that are mentioned in other posts do the most damage when the guitar is in between uses. It has time to corrode the strings. This is all just my opinion but it is based on 40 years of learning how to play. Still learning!


Resolving CoreDNS Loop Error

Question: I am trying to resolve a loop error with CoreDNS as part of a 2-node Kubernetes cluster. The issue is thoroughly documented (below), but I am not strong on dns and networking so am having trouble working through it.
Core DNS doco: https://coredns.io/plugins/loop/
Kubernetes manifestation: https://github.com/kubernetes/kubeadm/issues/1162
Environment:

Home network with no DNS DHCP served through router.
CIDR: 10.10.0.0/32
Two Ubuntu 16.x nodes in the cluster (Master is also a Minion)
/etc/resolv.conf contains:

nameserver 127.0.1.1

Question
In order to get this working, do I need to set up a nameserver? If so, what should I use? (I have been reading about BIND.) If so, can you please provide some good entry-level info for getting my head around what I need to do?
Thanks!
Comment: Have you seen [this](https://stackoverflow.com/questions/53075796/coredns-pods-have-crashloopbackoff-or-error-state/53414041#53414041)? It looks like someone has an issue like yours with the DNS.
Answer: I have worked out that yes you do need a DNS server for a multi-node cluster.
The link @Manuel posted is essentially what I was doing and it needs to be done, but they infer you need an external DNS. The instructions for configuring the target DNS server are also incorrect; you cannot make the changes to /etc/resolv.conf the way it describes (or at least I couldn't).
Comment: An update on changing the DNS in resolv.conf...  See this topic where I posted my solution. https://serverfault.com/questions/230456/permanently-change-dns-settings-in-ubuntu-server/949063#949063

Resolving CoreDNS Loop Error


É possível usar 2 @media screen?

Question: Estou com um problema, uso o Media Queries: @media screen e ele esta configurado com max-widht:375px.
 quero colocar um @media screen para max-widht:1024
Tem como?
Comment: Sim, é possível. Quando fechar as chaves de um, você ja pode criar o outro. Leia mais: https://www.w3schools.com/css/css_rwd_mediaqueries.asp
Comment: Talvez isso te ajuda: https://pt.stackoverflow.com/questions/224216/porque-media-queries-funcionam-assim
Comment: https://pt.stackoverflow.com/questions/58524/como-eu-trabalho-com-design-responsivo/58525#58525
Answer: Sim. Tem como
Você pode declarar um e outro desta forma:
@media screen and (max-width:1024px){
    .tela{
         width: 400px;
     }
}
@media screen and (max-width:375px){
    .tela{
         width: 250px;
     }
}

se for apenas por um elemento, você pode também utilizar de JQuery para fazer essa verificação. Se quiser se informar, segue o link

É possível usar 2 @media screen?


Map values to javascript variables

Question: http://www.speedtest.net/mini.php In the following link .Is it possible to get the upload /download limit which is displayed on the screen to a javascript alert(uploadlimit) or alert(downloadlimit)
Comment: Do you means extract the content in http://www.speedtest.net/mini.php? Or, you want to know how to connect flash and js?
Comment: How can i upload a file on SO?I have this working but how will i alert the values
Comment: You can't.  You can link to a free file sharing site, though.
Answer: From AS3 to JS:
AS3
if (ExternalInterface.available)
{
    ExternallInterface.call("alert", uploadlimit);
}

You may also replace "alert" by any custom available function.

And from JS to AS3:
JS
 function thisMovie(movieName) {
     if (navigator.appName.indexOf("Microsoft") != -1) {
         return window[movieName];
     } else {
         return document[movieName];
     }
 }
 function sendToActionScript(value) {
     thisMovie("ExternalInterfaceExample").sendToActionScript(value);
 }

AS3
if (ExternalInterface.available)
{
    ExternalInterface.addCallback("sendToActionScript", receivedFromJavaScript);
}

Then you only have to create an AS3 method called receivedFromJavaScript, the parameters given in JS will fly magically to your AS3 method.
Comment: Is it possible to call a Button in flex/AS3 from javascript.i.e,On click of a javascript variable invoke some button in fles/AS#,if so please point me to some example.Thanks..

Map values to javascript variables


Debian - Postfix rejecting user (User unknown in local recipient table (in reply to RCPT TO command))

Question: I recently have been moving from Centos to Debian. A few weeks ago I setup up a server with Postfix / Dovecot and it went fine. I'm doing the same again today but keep getting bounces with the error:
Recipient address rejected: User unknown in local recipient table (in reply to RCPT TO command)

This happens if I send remotely or via sendmail locally.
The users are setup in /etc/postfix/virtual-mailbox as normal; e-mail address then a space then the domain. I have run postmap /etc/postfix/virtual-mailbox to create the db file successfully.
This is the result of postconf -n showing my config changes:
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
compatibility_level = 2
content_filter = smtp-amavis:[127.0.0.1]:10024
daemon_directory = /usr/lib/postfix/sbin
data_directory = /var/lib/postfix
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = ipv4
local_recipient_maps = unix:passwd.byname $alias_maps
mail_owner = postfix
mailbox_size_limit = 1073741824
mailq_path = /usr/bin/mailq
message_size_limit = 10485760
mydomain = domain.net
myhostname = domain.net
mynetworks = 127.0.0.0/8, 10.0.0.0/24
mynetworks_style = subnet
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases
sendmail_path = /usr/sbin/postfix
setgid_group = postdrop
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3
smtp_tls_security_level = may
smtpd_banner = $myhostname ESMTP
smtpd_recipient_restrictions = permit_mynetworks,reject_invalid_hostname, reject_unknown_recipient_domain,reject_unauth_destination,reject_rbl_client sbl.spamhaus.org,permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.domain.net/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.domain.net/privkey.pem
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
unknown_local_recipient_reject_code = 550
virtual_alias_domains = virtual.host
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_gid_maps = static:20000
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = domain.net
virtual_mailbox_maps = hash:/etc/postfix/virtual-mailbox
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_uid_maps = static:20000

I can see no other errors in the logs just the same Recipient address rejected: User unknown in local recipient table.
Although it's possible I still haven't got Clam AV / Amavis and Dovecot setup 100% correctly yet, this reject seems like a purely Postfix problem. I can connect to the account's mailbox by the way, so Dovecot appears to be working.
Comment: I've now uninstalled Postfix, reinstalled and get exactly the same problem.
Answer: Postfix - in the default configuration - assumes that mail destined for the mail server gets handled locally. So if you are receiving mail for email@example.com, and your mail server is called mydomain.example, that gets handled locally. This is how you got the "in local recipient table" error message.
You can see that you are using this default by letting postconf display & expand that setting:
# postconf mydestination
mydestination = $myhostname, localhost.$mydomain, localhost
# postconf -x mydestination
mydestination = mydomain.example, localhost.mydomain.example, localhost

Configure a proper mail server host name & domain. Ideally, not just the second-level mydomain.example but with a name like mx2.mydomain.example. The settings myhostname and mydomain should typically not equal.
Of course, you can also change which domains are handled locally by configuring mydestination - removing from that setting those destinations handled via virtual i.e. via Dovecot. In fact, it is perfectly valid to hand all mail to a virtual transport and keep mydestination empty.
In any case, do setup a hostname though, many recipients strongly prefer to receive mail from servers that know who they are. That this indicate that the person who set them up was willing and able to configure a hostname and register its address/name pair in DNS, in both directions.
Answer: The answer to this was to make mydestination = localhost and therefore avoid $myhostname / $domain being handled locally. It was not an issue as anx suggested to have $myhostname & $domain be equal or for that value to be the main domain name e.g example.domain.
Of course this setup requires virtual_mailbox_domains to include the domain so it can be handled as a virtual mailbox (as I had), but crucially the domain must not be included in virtual_alias_domains or this produces a further error.
Comment: `mydestination` is not the only setting that by default references `myhostname` &/ `mydomain` with the expectation that those are setup following standard practices. Run `postconf | grep myhostname` and `postconf | grep mydomain` to see other uses.


Fractional index fallacy

Question: According to index laws, $(a^b)^c=a^{b\cdot c}=(a^c)^b$
However, if for example we have $a=-1, b=4, c=1/2$, then we get the equation:
$$((-1)^4)^{1/2}=(-1)^2=((-1)^{1/2})^4$$
The first equation is equal to $1$, however, the last one is undefined. How is this possible?
P.S. I'm sorry the formatting of the indexes is not ideal, I'm not sure how to do it properly
Comment: The reason is that $(-1)^{1/2}$ does not exist.
Comment: Did you think about $i^2=-1$ ?
Comment: When fractional exponents are involved the "law" $(a^b)^c=a^{bc}=(a^c)^b$ holds only if $a>0$, and the powers use the principal value. If $a<0$, and the exponents are not integers, then the power has multiple values, and the perils of multi-valued "functions" rear their ugly head. There are plenty of examples like this tagged under *fake-proofs*.
Comment: Thanks @claude That is helpful in this situation, but what if we consider $b=2$ as oppose to $b=4$. In that case, the first equation is $$((-1)^2)^1/^2)=(1)^1/^2=1$$ and the last is $$((-1)^1/^2)^2=(i)^2=-1$$ have I done something wrong?
Comment: @Jas: Please check that I fixed your TeX. I guessed that you wanted the exponents to be the ones I wrote. Click "edit" button to see how it is done. You need curly braces {} around the exponent.
Comment: Thanks @JyrkiLahtonen that makes sense
Comment: For the case $b=2$, working in the complex domain, you have to consider that the square root function has two "branches", so that $1^{1/2}$ is one of $+1$ or $-1$ (similarly, ${(-1)}^{1/2}=\pm i$, but this makes no difference after squaring).
Answer: Attention the exponent law you give is only true under certain assumptions.
A few example:

If $a \in \mathbb R$ and $b,c \in \mathbb Z$ then $a^{bc} = (a^b)^c$
If $a \in \mathbb R$, $a > 0$ and $b,c \in \mathbb{R}$ then $a^{bc} = (a^b)^c$

But $a^{bc} = (a^b)^c$ is not always true for $a,b,c \in \mathbb{R}$... In particular if $a<0$ and $b$ or $c$ is not an integer.

Fractional index fallacy


Deploy bitbucket public repo as application dependancy through composer on Heroku

Question: My application's dependencies are managed using composer, and one of dependency is from bitbucket public repo. Which is working fine locally, but when I deploy it to Heroku its not resolved and even not getting any error.
My composer.json is:
"repositories": [
    {
        "type": "vcs",
        "url":  "firstname.lastname@example.com:vendor/repo.git"
    }
],

"require": {
    "vendor/repo": "dev-master"
},

Thank for any help.
Comment: I think there might be a problem with ssh keys composer needs to access the bitbucket repository.
Comment: @HonzaHaering for public repo as well? I will give a try and see. Thanks
Comment: @HonzaHaering I tried the solution and working fine now even though I am getting some class auto-loading issue but composer is resolving dependencies as expect. Thanks
Answer: At last, I am able to fix problem. Actually it was SSH Keys issue as mentioned by @HonzaHaering in comment. I thought it will be useful for someone to add solution here.
First check do you have any SSH-Key on Heroku by:
ls ~/.ssh/id_rsa

If you don't have key then generate key using:
ssh-keygen -C email@example.com -t rsa

You will be prompted for passphrase enter passphrase if you want and at the end you will be presented with fingerprint etc. on successful key generation.
Than go to bitbucket account and follow instructions to add generated SSH Key to account:
https://confluence.atlassian.com/display/BITBUCKET/Add+an+SSH+key+to+an+account
Comment: Good, it works. Also, I think if you reference public repo like `https://bitbucket.org/vendor/repo`, then no need for ssh keys. Sorry, it didn't come to my mind before :-)
Comment: Yes, that was in my mind, and even i tried but might be I was doing something wrong :) . Otherwise for public repo it should work this way as well.


Validar conteúdo de TextBox

Question: Tenho os campos TextBox, por exemplo:

txtValorCompra teria que ser digitado pelo usuário 98,90 e não pode ser letras
txtNumero entrada com números inteiros
nome somente letras.

Teria como fazer isso no formulário?
Comment: Você pode usar um outro controle que permite usar uma máscara ([MaskedTextBox](http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox(v=vs.110).aspx)). Ou usar o sistema de [eventos do controle](http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox_events(v=vs.110).aspx) para validar manualmente o que foi entrado durante a digitação ou ao final dela.
Comment: Alguma coisa para você ler: http://www.codeproject.com/Articles/220519/Numbers-or-Characters-only-Textbox-Validation-in-C, http://stackoverflow.com/questions/15399323/validating-whether-a-textbox-contains-only-numbers,
Answer: pessoal fiz uma coisa que deu certo vou postar aqui para ajudar outros usuarios
        //não permitir augumas coisas
        if (char.IsLetter(e.KeyChar) || //Letras

            char.IsSymbol(e.KeyChar) || //Símbolos

            char.IsWhiteSpace(e.KeyChar)) //Espaço

            e.Handled = true; //Não permitir

        //só permitir digitar uma vez a virgula
        if (e.KeyChar == ','
            && (sender as TextBox).Text.IndexOf(',') > -1)
        {
            e.Handled = true;
        }

Answer: Em meu projeto, tive a necessidade de desenvolver vários controles para atender necessidades específicas e uma delas era justamente a questão acima. Desenvolvi um UserControl que aceitava apenas números. O componente seguiu a referência presente no link abaixo:
http://www.vcskicks.com/numbers_only_textbox.php
Answer: Precisei fazer isso em um projeto recente.
O que eu fiz foi utilizar o evento Leave do TextBox para validar os dados usando REGEX.
public const string EXPRESSAO = @"^\d+(\,\d{1,2})?$"; //Expressão para validar decimais

private void TextBox_Leave(object sender, EventArgs e)
{
    var tb = sender as TextBox;

    var valido = System.Text.RegularExpressions.Regex.IsMatch(tb.Text.Trim(), EXPRESSAO);

    if (!valido)
    {
        MessageBox.Show("Valor inválido!");
        tb.Focus();
    }
}

Answer: Pode usar uma MaskedTextBox para o que pretende. A propriedade Mask permite-lhe definir quais são os inputs aceites.
No seu caso a Mask ficaria:

txtValorCompra (98,90) => 00,00 (Obrigatório introduzir 4 números, a MaskedTextBox coloca automaticamente o separador decimal);
txtNumero => 0000 (Obrigatório colocar 4 números);
nome somente letras => LLLL (Obrigatório colocar 4 caracteres);

Existem mais combinações que pode utilizar.
Finalmente no seu codigo, para validar e usar o texto introduzido:
aminhamaskedTextBox.ValidateText();

Se necessitar de apresentar uma mensagem ao utilizador quando o input introduzido e invalido, pode utilizar o evento aminhamaskedTextBox_MaskInputRejected(object sender, MaskInputRejectedEventArgs e).
Answer: void validar_TextBox() {
  foreach (Control verifica in this.TabControl.Controls) {
    if (verifica.GetType().Equals(typeof(TextBox)) ||
    verifica.GetType().Equals(typeof(MaskedTextBox)) ||
    verifica.GetType().Equals(typeof(ComboBox))) {
      if (verifica.Text == string.Empty) {
        verifica.BackColor = Color.cyan;
      }
    }
  }

Validar conteúdo de TextBox