Azure Devops - trigger pipeline on Pull Request but not Push?

Question: I have a ADO git repo with a YAML-based build pipeline that builds a docker image, runs some tests using Docker Compose, and then pushes the image and a helm chart to an ACR.
I'd like the have the build/test part run on PRs too. I have created a second pipeline that's just the first half of the normal build, and assigned it as a Build Validation pipeline for a branch.
However, I don't seem to be able to get the triggers right. If I have trigger: none in the test pipeline, it never triggers. If I have branch names, it is also run on merge alongside the normal build pipeline. How is this supposed to work? The docs define all the individual parts, but not really how they are expected to interact!
Am I supposed to have a multistage pipeline and use that somehow for the validation? (it's just 4 Steps in one Job in one Stage currently).
I am hoping to avoid building the same image too many times, or storing untested images anywhere outside the build agent.
Comment: the `trigger: none` shouldn't affect the Build Validation
Answer: I make it work with the following configuration:
In my YAML pipeline, I set the trigger: none.
In branch policies of a branch, I create a build validation with automatic trigger:

Then I create a pull request to that branch, and the pipeline runs automatically:

There are two possible mistakes:

The "Manual" trigger is selected in build validation, so that the pipeline needs to be run manually rather than triggered automatically.
The branch with branch policy set should be the same branch as the target branch of pull request.
Comment: I don't know what I missed the first time, but this is now working as expected for me. Thanks for the detailed description!
(I think it might have been setting the default branch to the one that I usually merge PRs into, so that the pipeline definition is definitely the current one)


Trajectory of a projectile meets a moving object (2D)

Question: First of all, I asked this question on Stackoverflow, but I realize this is a better place to ask the question. So i moved it here.
I've looked for quite some time now to find a nice math solution for my cannon firing a projectile at a moving target, taking into account the gravity. I've found a solution for determining the angle at which the cannon should be fired, based on the cannon's position, the target's position and the start velocity. The formula is described here: http://en.wikipedia.org/wiki/Trajectory_of_a_projectile#Angle_.CE.B8_required_to_hit_coordinate_.28x.2Cy.29.
Unfortunately I can't post images yet here, so you'll have to do with the link.
This works perfectly. However, my target is moving, so if I shoot at the target and the projectile takes a few seconds to get to its destination, the target is long gone. The target's x position can be determined from the time. Lets say that: x = 1000 - (10 * t) where t is the time in seconds. The y can be described as: y = t.
The problem is, that t depends on the angle at which the cannon is fired.
Therefor my question is: How can I modify the formula as described in the wiki, so that it takes the moving target into account?
I want to fire it now and the target is in range given the speed. The cannon is at {0, 0} and isn't moving. The start speed is 100 m/s. The target is at {1000, 0} and is moving with 10 m/s towards the cannon (v = -10 m/s).
What angle should I use to hit the moving target, when I want to fire at t=0 (immediately)?
If I shoot without taking the target's speed into account, I would aim at {1000, 0} and the angle could be calculated using the mentioned formula. But it will miserably miss the target because its moving.
I could aim at i.e. {500, 0}, calculate what time it takes for the projectile to arrive at those coords (lets say 5 seconds) and wait until the target is 5 seconds away from {500, 0}, being {550, 0}. But this means that I have to wait 450m or 45 seconds before I can fire my cannon. And I don't want to wait, because the target is killing me in the mean time.
I really hope this gives you enough info to go with. I'd prefer some a neat math solution, but anything that would get me really close to firing "right away" and "right on target" is also much appreciated.
I would also be happy if you can tell me if what I want can't be captured in a formula, then I can figure out an algorithm to find it as fast as possible.
Thank you in advance for your braintime!
Comment: If the target is moving with speeds $u_x$ and $u_y$ along the x and y axes respectively, then you can modify the equations of motion to take that into account as follows: $x=vt\cos(\theta)+u_xt$ and $y=vt\sin(\theta)-\frac12gt^2 - u_yt$. Observe how this change doesn't affect the equations much since $u_xt$ and $u_yt$ factor in with the existing $vt$, so that the rest of the derivaton should follow routinely as before.
Comment: Dear QuantumElixer, asking you this feels a bit like not doing my homework, but I didn't manage to solve the equation with the "+ ux/uy t" part. To be quite honest, I just copied the first formula into code straight from the wiki. Could you help me out a bit? Thank you in advance!
Comment: A closed form solution for $\theta$ in this case could be hard. Instead, you could simply plug in the values that you know into those equations and try to eliminate $\theta$ using $\sin^2 \theta + \cos^2 \theta = 1$ to find $t$ and then find $\theta$ using $t$.
Answer: Note: I'm using the same convention used in the wikipedia article that you mention.
Suppose the target is moving with a speed $u$, in a direction that makes an angle $\phi$ with the positive direction of the x-axis, then you can write down the following equations of motion:
$$x = vt\cos\theta + ut\cos\phi$$
$$y = vt\sin\theta - \frac12gt^2 - ut\sin\phi$$
If you eliminate $t$ from those two equations you will get an equation in a very nice form:
$$gx^2+2(v\cos\theta+u\cos\phi)(vy\cos\theta+
uy\cos\phi-vx\sin\theta+ux\sin\phi)=0$$
in which you are required to substitute the values of $g,x,y,v,u,\phi$ and solve the resulting equation for $\theta$. You can use a numerical method which can handle implicit equations like $f(\theta)=0$ as we have here. For instance, you could try Newton's Method.
Comment: Thx alot, this works like a charm and is also something I understand completely! Thx alot for your insight!
Comment: Glad to help! :)


How to remove the leftmost bit and add bit in its rightmost bit

Question: How to remove the leftmost bit?
I have a hexadecimal value BF
Its binary representation is 1011 1111
How can I remove the first bit, which is 1, and then it will become 0111 1110?
How to add "0" also to its last part?
Comment: What code have you tried writing to do this? Where did it go wrong?
Comment: I want to try it in C#, i don't know how to code it.. I think i should need to use ">>" but I don't know how that operator functioning..
Answer: To set bit N of variable x to 0
x &= ~(1 << N);

How it works: The expression 1 << N is one bit shifted N times to the left. For N = 7, this would be
1000 0000

The bitwise NOT operator ~ inverts this to
0111 1111

Then the result is bitwise ANDed with x, giving:
xxxx xxxx
0111 1111
--------- [AND]
0xxx xxxx

Result: bit 7 (zero-based count starting from the LSB) is turned off, all others retain their previous values.
To set bit N of variable x to 1
x |= 1 << N;

How it works: this time we take the shifted bit and bitwise OR it with x, giving:
xxxx xxxx
1000 0000
--------- [OR]
1xxx xxxx

Result: Bit 7 is turned on, all others retain their previous values.
Finding highest order bit set to 1:
If you don't know which is the highest bit set to 1 you can find out on the fly. There are many ways of doing this; a reasonable approach is
int x = 0xbf;
int highestSetBit = -1; // assume that to begin with, x is all zeroes
while (x != 0) {
    ++highestSetBit;
    x >>= 1;
}

At the end of the loop, highestSetBit will be 7 as expected.
See it in action.
Answer: int i=0xbf;
int j=(i<<1) & 0xff;

Comment: "<<" this operator, is this removing the "1" in it's leftmost bit?
and what is the purpose of 0xff?
Comment: The << operator will shift the argument right, filling up with zeroes, so binary `0000 0000 1011 1111` will become `0000 0001 0111 1110`. Since you want to cut off after 8 bits, I do a bitwise logical AND (Operator &) with `0000 0000 1111 1111`, which results in `0000 0000 0111 1110`- your desired result
Comment: Is it required to used Operator &? since I already get my desired result in "<<" operator?
Comment: After the << operator, you get `0000 0001 0111 1110`, which is 0x017E, but you want 0x7E, so you need to cut off. You might get around this with the `byte` datatype: byte j=(byte)(i<<1) - this does exatcly the same thing internally
Comment: thanks Eugen Rieck.. nice explanation about this "<<" operator.
Answer: or you could do:
 (i*2) && 0xff
 if you'd rather not do bit twiddling. >>1 is the equivalent of /2, and <<1 is the equivalent of *2.
Comment: what is the purpose of  0xff?


Tail, grep and count the instances found in one command?

Question: I am tailing a files output and grepping for lines with certain data. I don't want to output the data to the screen but instead count the number of instances it found and send that to the screen. The number of instances can be scrolling and incrementing or it can overwrite existing and only show it as it increments higher. That part is not really important I just need a running count of instances found.
My command right now is
tail -f logfile | grep 'data I want'
I have tried using grep -c and wc -l but nothing have given me the results I am after. This particular Linux distro does not have pv and will not be able to get it. Is there a way I can do this?
Comment: You could compile pv from source - that's what I've done on systems that haven't had it.  You don't even have to install it - you can just grab the binary after running `make`.
Comment: Its a locked down system. We don't have rights to install or compile. But thanks anyway.
Answer: GNU awk can do this fairly easily.
Rolling output:
tail -f logfile | grep 'stuff to grep for' | awk '{++i;print i}'

You can also leave out the grep and use awk's regular expressions instead:
tail -f logfile | awk '/stuff to grep for/ {++i;print i}'

For a single line output you can prepend a CR make it start at the front of the line again (works on a console):
tail -f logfile | awk '/stuff to grep for/ {++i;printf "\r%d",i}'

Comment: \r worked in PuTTY for me as well - that's a great trick to know about!
Comment: Should have mentioned this is not a console session, its a terminal (ssh). Would this make a difference?
Comment: Ok can confirm the second option above works. Testing the 3rd command now.
Comment: 3rd option also works like a charm. Thanks so much!
Comment: Note for future readers: you may have to use `gawk` and/or add `system("")` command to flush the output when tailing (plain awk seems to buffer it for me in Debian 8).
Comment: Right; or `-W interactive` for some versions of `mawk`. Similarly, you may want to run your `grep` with `--line-buffered` when tailing a file / streaming short lines.
Answer: There is always the trusty watch option:
 watch -d grep -c "string" /path/to/file

which is from ideal when your file size is in excess of a a couple of 100 MB's.
Thanks for @sa289's suggestion to use an intermediate file:
 tail -f /path/to/file |grep "string" > /tmp/intermediate-file &
 watch -d grep -c "string" /tmp/intermediate-file

Comment: As a variant of what you posted which would work better with large files, the `tail -f logfile | grep 'data I want'` could be redirected to a file such as `tail -f logfile | grep 'data I want' > grepped_output` and then the `watch` command do a `wc -l` on that file.
Comment: This method just gave me output of file not found etc.. going down the screen. Same thing happened when I redirected to stdout and watched. The suggestions above are working, so I think I can work it from there. Thanks for the help!


Polynomial behavior on hyperbolic plane

Question: More a reference request / more information.
I was reading some websites about hyperbolic geometry and got to thinking about how would polynomials $(x^2-2)$ behave in such a geometry.
So, I need to know of a good book or reference to further study this.  I have only found basic websites, but none with problems and theorems.
So help me, please.
Comment: I don't understand what you mean by "polynomial" in this context.
Comment: @WillJagy Know of a good introduction book?
Answer: First, a definition.  A polynomial on $\mathbb{R}^n$ is a function $p:\mathbb{R}^n\to\mathbb{R}$ which takes the form $$p(x_1,\ldots,x_n) = \sum_{\alpha} a_\alpha x^\alpha,$$ where $\alpha = (\alpha_1,\alpha_2,\ldots,\alpha_n)$ is a multi-index (ordered $n$-tuple of integers), $a_\alpha$ is a constant, and $x^\alpha = x_1^{\alpha_1}x_2^{\alpha_2}\cdots x_n^{\alpha_n}$, a product of powers of coordinates.
Note that polynomials depend very essentially on the coordinate functions you have chosen.  If you transform coordinates by a diffeomorphism $f:\mathbb{R}^n\to\mathbb{R}^n$, there is absolutely no guarantee that polynomials transform to polynomials (i.e., for any polynomial $p$, we would have $p\circ f$ also a polynomial).  For instance, on $\mathbb{R}^2$, the polynomial $p(x) = x_1^2$ transforms to $p(r,\theta) = r^2\cos^2{\theta}$.  This is not a polynomial in $r$ and $\theta$!
Now to the meat of the question: "polynomials" on $\mathbb{H}^n$.  Hyperbolic space is the unique (up to isometry) complete simply connected $n$-dimensional Riemannian manifold of constant curvature $-1$.  As a Riemannian manifold, there is no canonical choice of coordinates.  In fact, there are several common and very useful coordinate systems on hyperbolic space which I'm sure you've seen in your reading: the ball model, the hyperboloid model, the upper half space model.
In each of these models, there are useful coordinate functions.  Once you've chosen coordinates, you can define polynomials, and then you get polynomials.  For example, on the upper half space model of $\mathbb{H}^n$, polynomials are simply the restrictions of polynomials on $\mathbb{R}^n$.  But until you've chosen coordinates, you cannot define polynomials, since they depend on your chosen coordinates - and there is no one "right" choice of coordinates for hyperbolic space!
I think this should settle your question.  To read more about hyperbolic space, I highly recommend the first couple of chapters of Volume 1 of Geometry and Topology of $3$-Manifolds by William Thurston (edited by Silvio Levy).

Polynomial behavior on hyperbolic plane


Removing duplicate entries whilst joining

Question:

user
learning_group
program
learning_group_user
learning_group_program

id
id
id
id
id

name
name
name
learning_group_id
learning_group_id

user_id
program_id

I am working with Postgres. My app will track users and what programs they are assigned to. User are associated with programs by adding them to learning groups. If a user is assigned to a learning group and a program is assigned to that learning group, then he is eligible to complete that program.
Users can be assigned to many learning groups.
Programs can also be assigned to many learning groups
I want to get the total number of users that are associated to a particular program, but, I don't want to count users more than once if they are assigned to multiple learning groups and the program is also associated with those same learning groups.
For example: if user "John Smith" is assigned to 3 learning groups, and, "Science Program" is assigned to all 3 of those learning groups, when I get the total number of users that are eligible to complete the "Science Program", John should only be counted once, even though naturally he would be counted 3 times because he is associated with the program 3 times via the 3 different learning groups.
My plan is to achieve this as a sub query,  so when I query a program by id, I can include the number of users that are enrolled in that program:
SELECT
  p.id,
  p.data,
  (
    SELECT count(u.id)
    FROM learning_group_user lgu
    INNER JOIN learning_group_program lgp ON lgp.learning_group_id = lgu.learning_group_id
    INNER JOIN program p ON p.id = lgp.program_id
    INNER JOIN user u ON u.id = lgu.user_id
    WHERE lgp.program_id = 'e4b284da-c94b-4546-84b9-2616e6a32b53'
  ) program_learners_count
FROM program p
WHERE p.id = 'e4b284da-c94b-4546-84b9-2616e6a32b53';

The above query will count a user multiple times if he is assigned to multiple groups and the program is also assigned to those groups. He should only be counted once.
Update
Based on Simonas Petkevičius answer I was able to complete my full query which now looks like this:
SELECT
    p.*,
    (
        SELECT count(distinct lgl.user_id)
        FROM learning_group_learner lgl
            INNER JOIN learning_group_program lgp
            ON lgp.learning_group_id = lgl.learning_group_id
        WHERE lgp.program_id = '3772c437-f881-4a69-b846-544d1783b1a4'
    )
FROM program p
WHERE p.id = '3772c437-f881-4a69-b846-544d1783b1a4';

Comment: welcome to stackoverflow. it would be best if you could 1) provide relevant table and sample data; 2) describe what you want to achieve. a quick tour on [mcve] would help, really.
Comment: Without going much into details of your models, `SELECT count(distinct u.id)` should calculate count without duplicated user ids, however, note possible performance issues: https://stackoverflow.com/questions/11250253/postgresql-countdistinct-very-slow
Comment: If you could a https://dbfiddle.uk/ with a minimum reproducible example we could help much more efficiently.
Answer: This should do the job:
 SELECT count(distinct lgu.user_id)
   FROM learning_group_user lgu
     INNER JOIN learning_group_program lgp
       ON lgp.group_id = lgu.group_id

 WHERE lgp.program_id = :programId;

it will only count the distinct userIds, however, note possible performance issues, you might need to optimize it along the way postgresql COUNT(DISTINCT ...) very slow.
Also, note that you don't need two extra joins:
INNER JOIN program p ON p.id = lgp.program_id
INNER JOIN user u ON u.id = lgu.user_id

in your subquery, as you already have user_id and program_id in your many-to-many join tables learning_group_user and learning_group_program.
Sample data and query for your subquery to fiddle around:
https://dbfiddle.uk/?rdbms=postgres_14&fiddle=b9a62e9f6d75eb459376a74a589ca46e
Update
Here is a query you could do without a subquery utilizing group by property.
SELECT
   p.id,
   p.name,
   count(distinct lgu.user_id)
 FROM program as p
   JOIN learning_group_program as lgp ON lgp.program_id = p.id
   JOIN learning_group_user as lgu
        ON lgp.group_id = lgu.group_id

    WHERE lgp.program_id = 99
    group by p.id, p.name;

test:
https://dbfiddle.uk/?rdbms=postgres_14&fiddle=2fc33ef133a24165573bb15f6404b17a
Comment: This works, I really appreciate your help. I am going to update my question with the full query I am now using which factors in your answer.
Comment: Glad to be of help:) However, keep in mind to use Distinct sparingly as it can increase the overhead of the query quite a bit. Read through these answers https://stackoverflow.com/questions/11250253/postgresql-countdistinct-very-slow
Comment: @brux you could also get rid of the subquery and make your sql more readable at least for me :D Take a look at this dbfiddle: https://dbfiddle.uk/?rdbms=postgres_14&fiddle=2fc33ef133a24165573bb15f6404b17a
Answer: You can change your perspective a bit, like.. using where exists, something like:
select *
from "user" as u
where exists
      (
        select *
        from "learning_group_program" as lp
          inner join "learning_group_user" as lu
          on lp.learning_group_id = lu.learning_group_id
        where lp.program_id = 1
        and lu.user_id = u.id
      );

Fiddle: https://www.db-fiddle.com/f/t7yFyQEc9KYtLKepuQMb6G/0
I used integer as ID, writing full GUID is just too cumbersome.


How to implement swipe to delete action for listview/recyclerview in Xamarin Android native project

Question: This could be duplicate of similar question. But I have reseached a lot but could not find a satisfactory answer. In my current project requirement, I want to implement swipe gesture for a listview(or recyclerview). For example in each row item if user swipe left the item it will reveal delete option. Otherwise if user swipe right it will reveal make favourite option.
Please suggest what will be approach and if any good article is available on the same it will be very helpful. I am looking for the implementation in Xamarin.Android native
Answer:
For example in each row item if user swipe left the item it will reveal delete option.

If you want to implement this action, I suggest you can use Xamarin.Android Swipe menu Listview.
The detailed info, you can take a look the demo:
https://github.com/WahidNasri/SwipeMenuListView-Sharp
Comment: Thanks @Cherry Bu, This is one solution initially I faced issue to integrate the same into solution so I used https://github.com/xamarin/XamarinComponents/tree/master/Android/AndroidSwipeLayout
There is a nuget for this component available: https://www.nuget.org/packages/Xamarin.AndroidSwipeLayout


Post Removal and Rules Reminder

Question: Recently, we had an answer on a particularly popular question that had a lot of answers from laypeople. The top answer argued that the wage gap outright did not exist. I saw a lot of flags over it when I woke up today (Monday) to look at the site. After some time after writing my own answer and providing my own comments on the top answer, I looked back at the edit history of the answer and talked to the other moderators about the post as a whole. I ultimately decided to delete the answer.
Normally I wouldn't bother explaining the whole decision out unless the user asked me, but since this was a popular thread and people will notice, I figured I'd head things off at the pass and mention briefly why I removed the post.

An answer being wrong is not enough for deletion.

The guidelines in the Meta StackExchange tell us that posts should not be removed just for being wrong. Some sites do end up expanding the criterion for deletion beyond the existing ones, but that is a whole other conversation.

Exceedingly rude or offensive material can be flagged and deleted.

The flag for rude or abusive answers is usually for hate speech, obscenity, etc. I don't necessarily think the post was trying to be hate speech. I disapproved of such language as "inferiority of negotiation skills in women" (and other parts) as discriminating language. I disapproved much more strongly than some of the other mods. Other parts of the economics profession may very well tolerate such language (and even the publishing of more outrageous language), but it will not be tolerated by me. This leads into the next point:

The universal rule across StackExchange is to be civil.

Sexism, however politely it is edited, is not considered civility here, no matter how many people agree or upvote the conclusions of it. I understand this creates some friction when discussing sensitive subjects like gender discrimination. Who determines what is sexism? Ignoring decades of economic research, in an economic forum, in order to claim that there is absolutely no pay gap is something that counts, at least for me. Users of this economic site must make a serious attempt to engage with the economic literature, especially when discussing sensitive topics like wage discrimination.

Low quality answers can be deleted.

There were two articles posted as citations in the top answer. One was an editorial piece with no economic citations, all ancillary citations from other fields, primarily with the purpose to comment on what was an ongoing gender discrimination lawsuit that was dismissed. The last paragraph then discussed the need for "serious research" and asking "the right questions" which is a ridiculous statement for anyone who has bothered to look into the labor economics literature in the last 30, 40 years. The second citation was an actual study, but with the main conclusion misconstrued to fit the answer's conclusion.
Questions like these will attract laypeople, which is good and fine. You are encouraged to read the rules and guidelines for answers on this site and understand how it works. This is not Reddit or another casual forum, but you are participating in serious academic discussion.

I am not happy deleting a highly rated answer. I'd much rather leave the voting system to its own devices and not interfere with it--even if people are upvoting what I think is a wrong answer. Frankly, I would close the question (I am surprised that it did not get enough close votes, as it seems very blatantly too broad) but now it has gotten exceedingly large, and I'm not interested in censoring the topic. This case was a very borderline case for me, which is why I will put a few questions out there.

Should there be more detailed guidelines for post deletion?
Should the site be more or less stringent about posting guidelines (e.g. question quality, citations, etc.)? Particularly, was I too strict here?
Comment: I was very sad (but not suprised) to see that that was the most upvoted answer, and I strongly support your difficult decision. <3
Comment: "I disapproved of such language as "inferiority of negotiation skills in women"" Was it language or the idea? Do you believe that it's impossible for women, on average, to indeed be worse at negotating their wages? If yes, why? If the language is the real problem, then how can the same idea be expressed more appropriately?
Comment: I should add, I personally don't see anything sexist in possibility that women can be worse at negotiating wages. It can be explained by difference in learning of gender roles, by different cultural expectations (like maybe men are more pressured by society to have high wages. Or maybe women, as girls, were taught not to be too stubborn and confrontational)
Comment: Also, maybe it would be a good idea to include text of the answer (and maybe comments under it) to your post, to provide more context for users that haven't seen the answer (or want to double check it).
Comment: If someone wants to talk about stereotypes of an entire group of people, they better 1.) pose it as the possible existence of it and 2.) provide appropriate economic literature, so at least there can be a basis for debating the stereotype. Simply stating the stereotype as fact is not appropriate for this site. It may be acceptable grounds for starting conversation elsewhere, but not here. Even now below the user is talking about how the literature is on his side while providing no appropriate evidence.
Comment: At the end of the day, the criterion for what is acceptable evidence in the economics profession probably is much more different than what a regular person would expect in normal conversation. So I think the rules will have to lay it out much more explicitly.
Comment: Finally, I am a Christian, and I do believe that there do seem to be gender roles for people. That itself is not a problem. In my own answer I provide a paper on the household production model and how it seems men and women, for one reason or another, do seem to have preferences for different kinds of work. But that is not evidence of one group being wholly "inferior" ("on average") at something subjective like negotiating. There are a lot of endogeneity problems with trying to measure skill at negotiation, and the topic must be treated as the complicated topic that it is.
Comment: I have a lot more things I could say, but basically it's not so much about whether I agree or disagree with someone. It's that I think it's wrong (and breaks the rules) to needlessly antagonize any group of people on this site, especially while presenting one's unjustified opinion as fact. Don't care if people think I'm biased for that or if the opinion was popular.
Answer:
Should there be more detailed guidelines for post deletion?

Yes! In my personal opinion the moderation on this site should be more strict. We are far less strict than other science stacks such as Bilogy.SE or History.SE or Physics.SE (see discussion in second half of this E:SE meta answer).
While I firmly believe that even controversial topics should not be shunned (see this meta answer), conversation about any controversial topic should be strictly technical and we should make sure people avoid inflammatory and provocative language and prefer a softer tone.

Should the site be more or less stringent about posting guidelines (e.g. question quality, citations, etc.)?

Yes! Thousand times yes! On History.SE questions answers that get post notice on requiring citations from reputable sources are deleted if they do not provide it after some time. We are currently not doing that as of now but I think we should.
I think we should also have more explicit standards/requirements for citation. Currently, I try to always err on the side of caution when applying the lack of credible sources post notice and I won't apply it when I see that a person made at least some effort to make reference to some reputable medium (e.g. at least to something like NY times, Newsweek, the Economist, Forbs etc), but I think going forward we should require higher standards.
I do not think we should completely exclude any non-academic source but we should not count op-ed pieces or blogs not written by professional economists.
In addition, I think that if a user discovers that answer blatantly misrepresents cited source (e.g. claiming there is no wage gap when the source itself mentions there is some) that should be enough grounds for flagging the answer as low quality deletion of the answer by mods in the future.

Particularly, was I too strict here?

I do not think so although there are few caveats I have to offer:
I was  personally against deletion of the post for the following reasons:

in the past we always tolerated incorrect answers, and even though I personally disliked that I felt it is not my place to go beyond my current moderation mandate without meta discussion (I planned even before your deletion to address that post on meta).
Even though post got flagged by rude or abusive by many users for me it did not clear the criteria of hate speech as suggested by this SE meta.
I felt this should also be first consulted with the community.

However, let me make it crystal clear that despite my doubts and caveats, I support your decision and stand behind your judgement. Also, some things that people who would like to criticize Kitsune should keep in mind:

the post already had 5 rude & abusive flags. 6 flags even from regular users means automatic deletion by the system. While mod flags are typically more powerful (i.e. one mod flag means automatic deletion right away), in this marginal case the mod flag had the same weight as a user flag. I believe in such marginal cases even us mods should feel free to exercise more discretion than usual.

The user was warned about improving the post by moderators before. While the post was edited and was considerably improved relative to the original post, the edits still did not take into account all suggestions that were made when the user was contacted privately by the mod team.

This being said, going forward we should set clear, and preferably as objective as possible (even if some degree of subjectivity is inevitable), criteria on when we delete these posts.  I think having such criteria would prevent from this situation occurring in the first place as very low quality answers could be removed before they start attracting attention from outside the site where nonexperts vote more likely based on their feelings rather than critical examination of arguments of the answer.
In the previous section of this answer I already proposed some criteria, however I am looking forward for more proposals from the members of our community.
Comment: IMO, you and @KitsuneCavalry are both doing great here. Re: strictness guidelines, my suggestions is to not count citations to newspapers, etc, as proof of quality. Even among reputable sources like NYTimes, the quality of economic discourse can be quite low. Also, too much room for debate about bias. My preference is to restrict it to peer-reviewed journals. Sure, you can always include references to newspapers, but if you want to clear the bar you need at least cite one peer-reviewed article. I really like the criteria we formulated here: https://economics.meta.stackexchange.com/a/2098/59
Comment: Also you are right bad decisions can be overruled but both action and inaction leads to harm... if you act too much in inconsistent way it can undermine trust in the institution of moderators and cause harm as well. E.g. see the whole Monica Cello debacle (although I am not implying that this is the same case since Monica did not do anything wrong while here there were issues). Some people might prefer to err on the side of inaction some on the side of action, I don't think it is easy to decide in borderline cases like this. I prefer having clear community approved criteria and exercising
Comment: light discretion since that is what the theory of moderation suggests mods should do. I am in favor of tightening those rules (my past E:SE meta posts gradually make proposals for strengthening the rules) but I think it is important that it is also done in consistent way not just when one bad post becomes too prominent. (PS: note I am also always willing to concede that perhaps I am wrong, I for sure don't have all the answers, I was actually the one who alerted Kitsune and EconJohn to this post precisely because I was questioning if I am doing enough)
Comment: Locked as well). I don't have time to investigate it further as in the morning I teach some classes at uni but I will try to look into it once I clear all the zoom classes and other academic duties. Hopefully, I will have some answer for you by tomorrow evening.
Comment: Existing guidelines seem to cover this. Watchmen sometimes have to make judgement calls without first running to the public. (Batman analogy is unfair.) Moderators have the mandate to do this as they were elected to this exact role. Bad decisions can be overturned, inaction leads to harm.
Comment: @Giskard those are valid points, but we are also required to be consistent and impartial when applying the rules. In addition, note there was action being taken - issuing waring (which is strike 1 and can lead to harsher penalties for same offenses in the future). Regarding the existing guidelines I dont think it clears the criteria set up by SE for hate speech even though it is  half-way there in that direction. However, as mentioned before, I still support the decision after it was made.
Comment: @HerrK. ok, the lock was removed because that was time lock, I only applied the lock for 24h since that is meant to stop people ignoring chat option and not be permanent, so once 24 h passed community automatically unlocked it. Regarding the post notice  I am not sure why community removed post notice even after  search on SE meta but I think it was because there was edit and it was approved by other user. the 2 last lock happened because mod rude/abusive flag automatically deletes **and** locks the post
Comment: I think we should not have too mechanical a notion of credible source. Sometimes, the NYT or WaPo do actual empirical data gathering, and there is no substitute. More importantly, stories can illustrate mechanisms that raise doubts about, say, some identification strategy even without telling us how strong the effect is.
Comment: @MichaelGreinecker that's a good point, but we also need some litmus test maybe we can add or sources that contain data. Also note you can always add anecdotes to answer or link to them in sources, but  answer should not rely just on the anecdote itself I think
Comment: From the [revision history of the deleted answer](https://economics.stackexchange.com/posts/43007/revisions), it appears that the "Community" removed the notice you had posted and reversed the lock status you had placed. Do you know how these "community actions" happened? Was it that your decisions to post notice and lock the answer got appealed and other users voted to reverse them? I thought there are rep thresholds for users to be able to vote on such review tasks (or maybe the thresholds are just not high enough).
Comment: @HerrK. I first put post notice on the post that was later removed by edits. Later I locked comments when people willfully disrespected the fact that comments were moved to chat and were recreating there long discussions - but I only locked the ability to comment all other actions were left unlocked. I know that if moderator flags a post it will get deleted by community (to protect moderators identity) and it also locks the post (in case of rude or abusive flag) but I can't explain why the post is mentioned to be locked 4 times (maybe that somehow captures the fact other posts there were
Comment: Thanks and no worries. This can wait.
Comment: So you think the site should be stricter, KitsuneCavalry was not too strict in this case, but personally you were against deletion?
Comment: @Giskard I was against doing this without first asking for a mandate from community. Let me give you an analogy, a night watchman might think society should be more strict on people disturbing peace by shouting but unless laws change to make that an offence it is not night watchman prerogative to fine people for it. In this case I felt that (going by the past mod decisions (even before I became mod)) we did not have mandate for doing so and I advocated making first meta post, making stricter rules and then getting rid of it (unless community would reject that).
Comment: however, even given my reservation above, I support what Kitsune did, I might disagree on the method (e.g. like night watchman might disagree with Batman vigilante justice) but I think he explained his decision superbly to the community, and that he had good reasons. This was case that was right there on the line, which means that it is hard to say ultimately whether my arguments for going first to the community were right or wrong. I appreciate that this was difficult decision and stand behind my comod regardless of what my thoughts were on it before decision was passed.
Comment: @jmbejara thanks, I guess that is a good idea. I would just also allowing additional  provisions for technical books/textbooks/handbooks, even if papers are the currency of science I think excluding books would go bit too far, even if these textbooks make good references to papers sometimes it is hard to track where the idea coms from (in case of multiple references) and  I seen these to be cited even in articles so I think those should still count.
Comment: " I won't apply it when I see that a person made at least some effort to make reference to some reputable medium (e.g. at least to something like NY times, Newsweek, the Economist, Forbs etc)" Is Forbes really a reputable source? Forbes has "some misleading or false stories related to climate science" accodring to mediabiasfactcheck.com
Comment: @user161005 credible/reputable medium does not mean "always right", even the best journals sometimes print bad science. Here is some good litmus test of whether source is credible/reputable https://sites.umgc.edu/library/libhow/credibility.cfm
Answer:
Particularly, was I too strict here?

Yes. I believe moderators---thanks precisely to their special privileges in the SE system---should refrain from intervening in borderline cases to avoid any apparent or actual conflict of interest. The resolution of such cases should be left to the community as whole. This situation would have been much less controversial if the answer were voted for deletion by community members. If, as @1muflon1 suggested, that answer were but one vote/flag away from deletion, surely that last vote would come before too long. But now that that last vote was from a moderator who admitted the borderline nature of the case, it changes the taste of this whole thing.
It doesn't help that some of the language in your meta post explaining the decision appeared to suggest that your decision was at least (a tiny bit) partially based on personal views on the topic being discussed in that question. Specifically, I am referring to the phrases like: "I disapproved of ...", "more strongly than [...] the other mods", "not be tolerated by me", "at least for me". Maybe I'm just reading too much between the lines, or maybe my own personal bias---I personally don't find the deleted answer particularly offensive---clouded my judgment. Anyway, I just don't think that mod intervention in this case (of deleting the then highest voted answer) was necessary, nor was it necessarily wise to do so.
Don't get me wrong though. I too disapproved of that deleted answer (I was actually among the first few people to downvote it). However, the reason for my disapproval was that the answer lacked sufficient support for its bold claims, and this ran against the community's recently adopted higher standards on citations. Also for this very same reason, I plan to award your answer to that question with a 100-rep bounty so that it gets bumped above the other answers for higher visibility (somehow a bounty must be posted for 24 hours before it can be awarded, hence the delay). You could have had a little more faith in the impact of your own answer, which is an exemplary way to show how a scientific and civil discourse on Econ.SE should look like.
Comment: Thanks for your feedback. I agree the decision would have been much less controversial if I just chose not to say anything and let it show as it being closed by the community. But as well as being a mod, I am also a member of the community, and in this particular case, my vote had no more power than a regular user (normally a moderator's flag for rude/abusive immediately counts as 6). As for when I say "disapproved by me" that is me being honest about what my specific opinion is, but the emphasis in my explanation is on why I felt the post broke the rules. At least I hope that comes across.
Comment: Again, thanks for your criticism. I will keep it in mind in the future. Lately I have been very hands off about moderating (muflon has done a lot of work), so I hope I may be forgiven for moving strongly in the other direction this time. I am trying to be as transparent about my decision as possible. I'm hoping we'll soon make a mod post about more explicit rules for closure/deletion, so that these sort of cases are much clearer.
Comment: (-1) Downvote by me. I think maintaining civil discourse sometimes requires moderator action. I think to most scientists this has a taste of *lèse-majesté*, and hence they tend to err towards inaction. Leaving it up to the community is a nice idea, but this answer has been up for **68 hours**. ([Timeline](https://economics.stackexchange.com/posts/43007/timeline)) Most of the people who visited the question probably saw it as the most upvoted answer.
Comment: @Giskard: I actually agree with you that "maintaining civil discourse sometimes requires moderator action". I just don't think that, in this specific case, the deleted answer was particularly uncivil or egregious. Sure, if enough users were bothered by it and voted for its deletion, so be it. But a mod's direct involvement in catalyzing that outcome just muddled the water, unnecessarily.
Answer: My first answer was response to Kitsune's question, this answer is response to the answer by @nick012000 as it would not fit in comment section.
I wont address all the points you raised but some here are responses to some:

I believe that this was a clear abuse of SE moderator powers to silence your political opponents. Another mod said that it received five "rude and abusive" flags, but all that means is that five people wanted to censor wrongthink and that they realized that that was the best way to do so.

You seem to have misunderstanding of what Economics is. Economics is science, and there is no place for political opinions when discussing scientific matters. This is especially true for positive economics,  which was both subject matter of the question, and which is also economics that deals with empirical matters.
Next, as our help center makes crystal clear, questions by extension answers should asked/answered based on/using facts, studies, economic theory and reasoning - not moral/political/religious/philosophical values.
Previously, I just thought that your answer is a nonexpert attempt at trying to explain the empirical literature behind gender wage gap. If you now say that it was intended to make political point then it without any doubt does not belong on Economics.SE.
For political questions/answers there is Politics.SE and for moral questions answers there is Philosphy.SE.

If I got a group of five friends to go around raising "rude and abusive" flags on all answers that promote Marxist economics, Austrian trickle-down economics, or [insert politically-charged economic theory here] to censor people I disapprove of for political reasons, would that be acceptable as well?

This actually excellently shows the misunderstanding about economics you seem to have here.
There is no economic theory called "trickle-down" economics, the same way as there is no economic theory called "soak the rich" (see more detailed explanation by Mankiw).
"Trickle down" is a pejorative used by left, and "soak the rich" is pejorative used by right but they are not economic theories. They are strawmen of different economic theories on macroeconomics, optimal taxations etc (or even worse, they are strawmen of layman understanding of these theories - they are strawmen of strawmen). If you see these pejoratives used on this site you should flag them, moderator team will definitely have a look!
This does not mean that heterodox economic theories are not welcome. You should feel free to post answers based on actual Marxian or Austrian economics or any other heterodox field.
For example (acceptable topics):

Austrian theory of business cycle or economic development that based on some theory/models shows light taxation  and non-intervention is optimal is completely on topic

Marxian theory of business cycle or Marxian theories of economic development also completely on topic

(unacceptable topics):

Saying "taxes are evil" or "private property is evil" etc is not on topic on this site.

As a matter of fact when it comes to economics it completely possible for a person to be strict adherent to the heterodox Austrian school of economics but be politically left wing and advocate for high taxes, high level of redistribution etc. regardless of what Austrian economic theory says would be efficient, as it is completely possible for strict adherent to Marxian school of economics to politically support minimum taxes on rich, lowering deficit and so on regardless of what Marxist theory implies is efficient.
Yes many economics topics are sadly politicized in real world, but that does not mean politics belongs into the economics, and at Economics.SE we kindly ask users (through our help center) to check their political/moral/religious/philosophical values at the entry. We do not disparage your personal political/moral/religious/philosophical values but there is place and time for everything and Economics.SE is not place for these.

Furthermore, I do believe that I did take into account all suggestions that were made to me by the moderator team;

No, you got 2 suggestions:

To use on average to avoid generalizations since even if research shows that lets say women have on average smaller lung capacity than men there are women who have higher lung capacity than some men.

You were cautioned against use of strong value-laden language like "inferior". You were literary warned that; "Using strong value laden language like "inferior" and implicitly assuming all women have inferior negotiation skills sounds quite strong and might offend some".

When discussing any topic but especially when discussing controversial topics it is always better to use less strong words.
For example, suppose you want to refer to literature showing women tend to have less muscle mass than men. Here are some examples how you can approach this topic:

Non-problematic: "Miller et al (1993) show that in experiments that women are only approximately 52% and 66% as strong as the men, on average, in the upper and lower body respectively."

Fine: "Studies show that women tend to have on average lower strength than men (see here)."

Problematic/Borderline Offensive/Offensive "Women are inferior in body strength to males".

Unacceptable/Clearly Very Offensive:   "Women are inferior".

How you say things matter. The stack exchange explicitly asks you in the code of conduct be inclusive and respectful. and:

No bigotry.
We don't tolerate any language likely to offend or alienate people based on race, gender, sexual orientation, or religion — and those are just a few examples. Use stated pronouns (when known). When in doubt, don't use language that might offend or alienate.

The line between bigotry and making factual claims can often be thin. Humans are sexually dimorphic species so there are bound to be differences between the sexes in various aspects. You can of course reference those differences where relevant, but you should do that using appropriate language.
The difference between using appropriate and inappropriate language can be very thin and hard to see especially for non-native speaker. There is always subjective element involved. It is always best to try to err on the side of caution. If mod teams contacts you in these matters try to take into account all suggestions. Also, different moderators might be more/les sensitive to these issues. If you want to avoid these issues always err on the side of politeness. If you, purposefully or unwittingly, walk on the precipice you risk falling over.

Finally, you claimed that I was being sexist by ignoring "decades of economic research". I was not. The research is on my side: there is no pay gap, or if there is, it is too small to properly measure.

So which is it? Science is not a la carte. Is there no pay gap or is it too small? The Forbs article you linked to explicitly states:

When comparing two people in the same profession, with the same seniority, working the same number of hours, and so forth, women earn \$0.98 for every dollar that a man earns.

This is reasonable and in line with what most research shows, the gender pay gap for same professions and backgrounds differs by countries and places and it is just about 0.8-5%, but it does not show that there is no pay gap, or that it is 'hard to measure'.
When discussing this with layman maybe sweeping statements like "gender pay is myth" would be fine, but don't be surprised if on Economics.SE Q&A for those who study, teach, research and apply economics and econometrics such statements will ruffle some fetters.
If you would post on Astronomy.SE, Earth and Venus are almost same size so there is no difference in gravity between the two, you would likely not make many friends even if Venus's gravity is more than 90% of the Earths one and for laymen discussion saying they are the same would be fine.
Note even ignoring 5 rude or abusive flags, your post got several low quality or fill in comment complaining about low quality as well. Some of those flags were from new users and might be just due to anger/emotional response to your question, but there were few also from high reputation users. Even though in past we did not outright deleted low quality answers (which is actually common on many science stacks) we were considering to start doing that for some time now and your post happened to be the proverbial last straw.
As mentioned in my other answer, I was advocating for not deleting the answer like this, but this has far less to do with people disliking your politics rather than us catching with other science stacks in terms of moderation of content quality.

Lastly, even though the post was deleted you were not issued suspension. You can post new answer/edit your old one. I can't speak for Kitsune but it is possible that if he sees improvement he will reverse his decision. But you should remember to follow code of conduct and guidelines set in help center. You can also take inspiration from answers of high rep users such as Alecos Papadopoulos or other high rep users to see what sort of answers we encourage on this site.
Even if you are non-economist you are welcome to participate here, but if you are not up to date on literature try to avoid very strong statements. It is very easy to experience the Dunning–Kruger effect if you just casually read blogs on some topic, so it is always best to go for softer tone if you are not expert on certain topic. As mentioned above it is likely that going forward we will do more moderation regarding the quality of answers, if you want to be safe use sources from peer reviewed literature directly or technical books/handbooks/textbooks. Make sure source you cite actually support the claims you make in your answer.
Comment: *"Economics is science, and there is no place for political opinions when discussing scientific matters"* - opponents of your view would contend that this claim, that economics is non-political, is itself a political claim. And that the matter inherently becomes political precisely because there is not universal agreement that it is non-political and there are appreciable bodies of polarised opinion on the matter.
Answer: Stack Exchange moderation powers should not be abused to silence political opponents.
As the author of the post in question, I am very unhappy with how this was treated. I had earned hundreds of points of Reputation,  and now not only has that been removed,  but because it was deleted as "abusive", I've lost a hundred Reputation on top of that, almost completely removing all privileges i had on this SE site that experienced SE users take for granted, like commenting or reporting posts. In fact, I even used one of powers that has now been taken away from me to assist the moderators by flagging a comment to my answer that began a discussion in its comment section (after a previous discussion in the comments had been sent to chat), since the purpose of the comment section is to suggest improvements to the answer, and discussions and debates contravene this purpose. This resulted in the comments of my answer being closed, which was regrettable but obviously necessary, and a moderation decision i wholeheartedly supported.
I believe that this was a clear abuse of SE moderator powers to silence your political opponents. Another mod said that it received five "rude and abusive" flags, but all that means is that five people wanted to censor wrongthink and that they realized that that was the best way to do so. If I got a group of five friends to go around raising "rude and abusive" flags on all answers that promote Marxist economics, Austrian trickle-down economics, or [insert politically-charged economic theory here] to censor people I disapprove of for political reasons, would that be acceptable as well?
Let's face it: economics is a politically charged topic, and answers shouldn't be deleted based on the political ideology of the answerer, nor should we allow the "rude and abusive" flag be abused to censor people who disagree with us. I'd be very surprised if the Politics SE site doesn't have a policy for dealing with this, for instance.
Furthermore, I do believe that I did take into account all suggestions that were made to me by the moderator team; the only suggestion  you made was that stating that women had inferior negotiation skills was overly strong, so I edited my post to say "on average" even though that was redundant since I was already talking about women as an aggregate group rather than as individuals. If you made any other specific recommendations, I do not recall them, and I would be willing to implement them if it were to get my Answer undeleted. Additionally, when I responded to your communications with me over the private message you sent me to indicate my compliance with your only explicit request, you did not respond, so I took that as indicating that you were satisfied with my response to your moderator requests. If you had responded with "no, that isn't sufficient, we also want you to change A, B, and C", I would have complied with those requests as well, unless you were to ask me to change the fundamental thesis of my answer - which I now understand to be the core of your disagreement with me, hence my accusations of political censorship.
As for sources, I will state that I repeatedly stated that I was open to having my post edited to include additional sources. After all, the fundamental reason why the edit button exists, and is available to all users with a certain minimum level of Reputation, is so that if you believe an answer can be improved, you can be empowered to improve it by suggesting edits. If any user believes that any of my posts on any SE site could use more sources, I wholeheartedly encourage them to edit those posts to include them! That is, after all, what the edit button is for. In fact, one of the members of the moderation team did so, adding the third source to my post - and leaving aside the possibility of antagonising the mod team by rejecting the edit and removing it, I do believe that unlike what the OP says, it did support my main point.
As for the other two sources, I cited first a Huffington Post article disproving the issue in question, as I believed that such a strongly Left-biased source speaking out against a feminist talking point would be sufficient to prove my case - if even the HuffPo is saying feminists were wrong, then it must be true since their bias would be to say that they are correct, instead. When I was informed in the comments to my answer that biased sources weren't considered suitable for this SE site, I edited my answer to include a link to Forbes instead, as they are generally considered well-respected and politically neutral. In both cases, the authors of the articles cited a number of scientific papers, and distilled their results down into an easily readable article.
Finally, you claimed that I was being sexist by ignoring "decades of economic research". I was not. The research is on my side: there is no pay gap, or if there is, it is too small to properly measure. The raw wage gap is the result of individual choices, which are in turn the results of biological differences between the genders, both as a result of reproductive differences directly (women taking time off for work to have children,  women choosing more flexible hours over higher pay to raise their children, etc), as well as how our reproduction caused evolution to alter our psychology (e.g. men have a higher tolerance for risk and a broader IQ curve because we're more expendable, men are more system-focused while women are more person-focused because the roles our ancestors played in hunter-gather societies, etc); I didn't go into these facts in the post because root causes are a bit irrelevant when asked "does thing exist" and the answer is "no". Also, again, talking about men and women as aggregate groups, and there are always outliers and exceptions whenever you're talking about statistics. Once you control for occupational differences, the wage gap vanishes to an insignificant amount that can be attributed to women's inferior negotiation skills (again, on average, because were talking about women as an aggregate group) due to their higher agreeableness, or to imperfect bucketing systems for the process of controlling for differences in occupation that might compare doctors to nurses, or doctors in higher-paid specialities to doctors in lower-paid specialities.
Comment: Bro, what political opponents are you talking about? This isn't a political forum for political questions. You can post whatever you want, just back that up with citations from the endless supply of peer reviewed journals on this topic, instead of a news article and you'll be fine.
Comment: @BBKing "Bro, what political opponents are you talking about?" Left-wing people who censor anti-feminist ideas, in this case. "This isn't a political forum for political questions." Yes, it is. Economics is a heavily politicized discipline, ranging from Marxist economics on one side to Austrian trickle-down economics and ancap libertarianism on the other. It is heavily tied to the official positions of political parties and is the defining issue of the most common political spectrum.
Comment: @1muflon1 Grants from businesses and private benefactors are just as likely to come with expectations as grants from government are, and can be just as big a force for corruption. Publish something they don't like, watch the money dry up.
Comment: @nick012000, it's a shame to hear of the censorship you have sustained. I too think moderation powers are being abused here to silence political opponents, and it is not proper for the moderators to usurp the voting system in order to express their own view on the correctness of an answer from the perspective of the economics profession.
Comment: you seem to have misconception about what economics is. Even austrian or marxian economics is not political no matter what some pundits without economic degree say. There is actually even whole field of feminist economics, which is also heterodox economics (but again nothing to do with political feminism) but the Kitsune answer was firmly within the mainstream economics (e.g. economics as thought at top universities - which consist of theories from various schools that survive extensive empirical testing), showing that he is not adherent to that heterodox field but regular economist.
Comment: @nick012000 that's a fairly contentious statement on scientists, can you back that one up?
Comment: Please see [a response](https://economics.meta.stackexchange.com/a/2102/42) to your post that's too long to fit into the comment box: https://economics.meta.stackexchange.com/a/2102/42
Comment: in addition, as explained in my answer there is no 'trickle down economics' the same way as there is no 'soak the rich' economics. 'Trickle down' or 'soak the rich' are pejoratives used by left/right they do not belong on economics any respectable economics site, by using pejoratives you are not endearing yourself to the community, please stop.
Comment: @1muflon1 "Even austrian or marxian economics is not political no matter what some pundits without economic degree say." They are, though. "Take from the wealthy and give to the poor", says the Left-wing politician, who stands to benefit from the votes of the poor. "Take from noone, and allow the Invisible Hand to decide who wins", says the Right-wing politician who stands to benefit from the donations of the wealthy. In both cases, they're using economics to make their arguments. Economics is, fundamentally, a machine for generating excuses for politicians to do what gives them power.
Comment: @1muflon1 I'm simplifying a bit, but you understand what I'm saying, right? Politics and economics are fundamentally intertwined on a root level. If you have a political position, you have an economic position. If you have an economic position, you have a political position. That's what the "left/right" political spectrum *is*.
Comment: @nick012000 this is fallacy, politics and economics are not intertwined at root level, economics is a science. That would be like saying politics and physics are intertwined because some politicians want more fossil fuels and some politicians want renewables and well these work of physical processes and our understanding of fossil fuels and renewables comes from physics. Just because politicians 'weaponize' physics, economics, biology etc that does not mean those fields are intertwined - politics corrupts and weaponizes everything it touches and that is precisely why scientists avoid it
Comment: @1muflon1 Climate "science" is also inherently political, yes. It's just a vehicle for politicians to funnel money to their friends. Additionally, economics is worse, because it's about money directly, to the extent it even exists independently from politics at all (if it even does).
Comment: @nick012000 no it is not, politicians might want to politicize for their fights  but climate science (CS) as published in peer review journals, handbooks, textbooks is not political. For example, in the Europe there are many countries where left is the one who is denying climate change and right which is for renewables, this just shows you that politicians from either party will try to politicize anything as it suits them but the CS is not right or left, in eastern europe where left traditionally supported coal they also came to adopt denial about CS the same way as right in other places
Comment: @1muflon1 "climate science (CS) as published in peer review journals ... is not political" It is, though. The scientists are bought and paid for by the grants they're given, and once you've gotten a critical mass of corrupt scientists, you can have them drive out the uncorrupt scientists out by taking control of the peer-review process of the journals and preventing their papers from being published, and then you use claims of "scientific consensus" to destroy the careers of those who disagree.
Comment: @nick012000 with all the respect that sound like a conspiracy theory. 1. Many grants especially in the US are founded not via taxpayers but from donations, some of them through businesses, especially at private universities, or they are paid from endowments of those universities. The top universities tend to be private (Harvard, U of Chicago etc). 2. Scientists can also always publish and get citations from pre-prints like arXiv.org. Even if peer review process would get corrupted (which is not) there is nothing stopping disseminating good research

Post Removal and Rules Reminder


Transforming text into it's appropriate RTL representation

Question: I'm looking for any java library which would help in transforming a piece of text into it's appropriate RTL representation.
For e.g. the hebrew/arabic text when read from a file would be in the LTR representation, however after the transformation it ought to be shown in it's RTL format.
The requirement comes up since in the case of html's we can specify the dir as rtl or ltr. However when we want to have a text variant or a sms variant of the text, the stylesheets don't come into play at all.
Answer: There are two issues that come into play with RTL content. The first is the right alignment of the display. There's nothing you can do about that unless you have control of the output routines that are being called.
The second issue, which is arguably more important, is the base directionality of the text. This you can control to a certain extent by adding bidirectional formatting characters to your content.
For example, given a string in s, you could set the base direction to RTL, with something like this:
<code>String[] lines = s.split("\n");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < lines.length; i++) {
  sb.append("\u202B");   // right-to-left embedding
  sb.append(lines[i]);
  sb.append("\u202C\n"); // pop directional formatting
}
s = sb.toString();
</code>
What this is doing is splitting the text into multiple lines, then adding a right-to-left embedding character at the start of each line, and a pop directional formatting character at the end of each line.
The reason it is done line by line is because the embedding override only lasts for the length of the paragraph.
Example code on Ideone.com
Markup example for comparison


MigratorDotNet and Text Datatype on SQL Server 2008

Question: I am using migratordotnet to sync my SQLServer 2008 database and need to create a column of type Text...
Am at a bit of a loss as to how to do this, as there is no System.Data.DbType.Text??
Answer: Worked it out with some trial and error...
DbType of AnsiString and a length of int.MaxValue does the trick
Database.AddColumn("Notification", "Body", DbType.AnsiString, int.MaxValue);


Is there another name for involature?

Question: This answer...
https://music.stackexchange.com/a/45206/23919
...caught my attention, because while I know about partimenti and solfeggi, I hadn't heard of involature.
I looked for some at IMSLP, but found nothing search on the word involature.
Is there another name for this kind of music?
Answer: I suspect this is just a typo for "intavolatura."
The Italian verb intavolare means to begin or commence. Musical intavolature were either "preludes" in the sense of the first piece in a collection, or sometimes "music tutors" - e.g. this on IMSLP for lute (warning, not much use except to show the title page, unless you can read Italian and lute tablature!)
For example a YouTube video claiming to be a performance of an "Involatura per organo e cimbalo" by Zipoli was titled "Intavolatura" in the published first edition. See Page 18 of the PDF (page number 6 of the edition) at https://imslp.org/wiki/Sonate_d%27Intavolatura_per_Organo_e_Cimbalo%2C_Op.1_(Zipoli%2C_Domenico) and the performance at
Comment: Perfect, thank you! It looks like there are many items at IMSLP too.
Comment: It seems 'intavolatura' is another name for 'figuration prelude'
Answer: I found a different definition of intavolatura. Meaning scoring. In Elizabethan times, of the arrangement of madrigals for keyboard performance - the choral originals being in parts, not in score. Sort of related to partimenti?
Can't find anything relating to 'involature'.
Comment: Where did you find that? Actually, keyboard arrangements of madrigals is something I want. I wish there were the madrigal equivalent of Bach's 371 Harmonized Chorales for keyboard.
Comment: I see that meaning now in Google results. Maybe I can trace that to some madrigal arrangments. According to Richard's answer which I linked intavolatura are connected to partimenti and solfeggi, but just becoming aware of intavolatura.

Is there another name for involature?


Função em Background - Android

Question: Olá,
Preciso colocar uma animação na tela, ela só pode ficar visível durante 10 segundos, depois desse tempo ela some, e caso o usuário clique em um botão específico a animação volta.
Alguém pode me ajudar? Não estou conseguindo resolver.
Muito obrigado!
Comment: Você quer que o `progress bar indeterminate` rode em background? E depois de 10s que der o `show` ele suma (ficar rodando em background)? E quando clicar em um botão específico ela reapareça?
Comment: Quero que depois que eu aperte um determinado botão a progress bar apareça e suma depois de 10 segundos.
Answer: Possível solução seria usar a Classe do pacote java.util: Timer. Com está classe é possível agendar tarefas ou que uma determinada tarefa seja executada em determinados intervalos de tempo ou até então
agendar a tarefa especificada para execução após o atraso especificado. Nela uso a função schedule em uma de suas implementações que recebe 2 parâmetros: TimerTask e delay.
No seu XML:
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Mostrar ProgressBar"
    android:id="@+id/button"
/>

<ProgressBar
    android:id="@+id/progressBar"
    android:indeterminate="true"
    android:visibility="gone"
    ...
/>

...

Aqui no XML adicionei o atributo android:visibility="gone" na View ProgressBar para manter "escondido" o elemento!
Na sua Activity:
//recupera o Button e o ProgressBar do XML
Button bt = (Button) findViewById(R.id.button);
ProgressBar mProgressBar = (ProgressBar) findViewById(R.id.progressBar);

//Evento de click do botão
bt.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {
         //Quando clica no botão torna visível o ProgressBar
         mProgressBar.setVisibility(View.VISIBLE);

         Timer timer  = new Timer();
         timer.schedule(new TimerTask() {
             @Override
             public void run() {

                 runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                       //Depois que passa os 10s "esconde" o ProgressBar
                       mProgressBar.setVisibility(View.GONE);
                    }
                 });
             }
          },10000);//Aqui o delay é um long em milisegundos
      }
});

Internamente no método schedule uso ainda o método runOnUiThread da Activity para manipular (esconder) a View (ProgressBar),  caso contrário geraria uma Exception pelo fato de estar manipulando a UI em segundo plano então com este método move a ação para Thread principal.
Comment: Muito obrigado pela resposta! Me ajudou :D
Comment: De nada! Estamos aqui para ajudar e ser ajudados mesmo.

Função em Background - Android


Java ArrayList addAll only adding 1 element?

Question: So I basically put some Integer objects in an ArrayList x, then put some in an ArrayList y, then did y.addAll(x), but it seems to be only adding the first one and leaving out all the rest! Isn't it supposed to add ALL? I looked it up on Oracle and they showed what seemed to be the EXACT SAME EXAMPLE yet mine is not working properly. Here is my code:
ArrayList<Integer> x = new ArrayList<Integer>();
Integer a = 1;
Integer b = 2;
Integer c = 3;
x.add(a);
x.add(b);
ArrayList< Integer> y = new ArrayList< Integer>();
y.addAll(x);

yet y seems to only have 1 in it and missing the 2 and the 3.
What am I doing wrong?
EDIT:
Yes, sorry, I know I didn't actually add c to x yet, but even when I do, and then print y, I still get [1] instead of [1,2,3]. This is what I don't understand.
import java.util.ArrayList;
public class SumArrayList {

    public static void main(String[] args) {

        ArrayList<Integer> x = new ArrayList<Integer>();
        Integer a = 1;
        Integer b = 2;
        Integer c = 3;
        x.add(a);
        x.add(b);
        System.out.println(x);
        //System.out.println(calculateSumArrayListHelper(x));

        ArrayList<Integer> y = new ArrayList<Integer>();
        y.addAll(x);
        System.out.println(y);
        //System.out.println(calculateSumArrayListHelper(y));
    }
}

Here is a pic of what I see:
http://postimg.org/image/ms0y68nnh/
Comment: [No repro here using your code](https://ideone.com/hfz2zt)
Comment: I'm sure you get [1,2] not just 3 because you haven't added it
Comment: Can you show us the code you used to print all elements ?
Comment: How do you know it only contains one element ?
Comment: Okay, here I'll just give you my entire code, and yeah I realize I didn't add 3, but it's still printing just [1] when I print y and [1,2] when i print x
Answer: In your code after executing y.addAll(x); y will contain only 2 elements [1,2]. you never add c to x:
ArrayList<Integer> x = new ArrayList<>();
Integer a = 1;
Integer b = 2;
Integer c = 3;
x.add(a);
x.add(b);
x.add(c); // add c to x
ArrayList< Integer> y = new ArrayList<>();
y.addAll(x);
System.out.println("size = " + y.size());

Will produce :

size = 3

And y will contain :

[1,2,3]

You are removing item from x in your method calculateSumArrayListHelper(). That's why you don't have the expected result.
Comment all calls to this method and check the content of y... It should be right.
Comment: Yeah this is what I don't understand. I literally have done this exactly, but when I print y, it just gives me "[1]" and not "[1,2,3]"
Comment: And printing `y.size()` what is the result?
Comment: when I print y.size() it says 1
Answer: With the picture you have posted it is clear. You are calling calculateSumArrayListHelper(x) before the addAll(). Inside that method you remove elements from the given list. So at the time you call y.addAll(x), elements have been removed from x.
Comment: Oh my goodddddddd............................ I'm such a idiot. Thank you so much
Answer: Just put sop on last line.
System.out.println(y);

So that you can see the result.which is coming [1, 2] in my system.
You are not getting 3 as because you never add it in X.
x.add(a);
x.add(b);
x.add(c);


What does cron error "exit status 4" mean in syslog? (Ubuntu)

Question: I've never seen this before, my Status Report page says the last cron run was 35 minutes ago at 10:35 today. So I went to watchdog logs and could see that Cron run completed at 10:30.
I've set the cron to run on 0 and 30th minutes of every hour, so twice per hour using sudo crontab -e so it's using the root user's crontab with the following command (cron key intentionally removed):
0,30    * *   *   *     wget -O - -q -t 1 http://localhost/cron.php?cron_key=

I'm not using the cron.module aka poormanscron in D6
I've manually run the cron and it updated the Status Report page after that.
What could cause this weird behavior? I'll admit that I haven't tried flushing the caches, but could caching be the cause of this? Or is there something more sinister?

I've dug around in syslog and found an error relating to the cron, but I have no idea what this means (cron key intentionally removed):
Aug 16 10:30:01 drupal-1 CRON[31372]: (root) CMD (wget -O - -q -t 1 http://localhost/cron.php?cron_key=)
Aug 16 10:30:01 drupal-1 CRON[31370]: (CRON) error (grandchild #31372 failed with exit status 4)

I can see the grandchild #31372 is referring to the first line CRON[31372] but what does exit status 4 mean?
I just wanted to also let people know that the cron has run without any problems so far afaik. But it could be that this is the first time I've noticed this as well.
Comment: I'm almost positive status 4 for wget is a network error, so it may just have been a temporary network problem. Or server config might have changed and http://localhost might not resolve locally any more. Either way the easiest test is to run the command manually and see if it exits with an error again. If not, I _think_ you're safe to assume it was an intermittent internal network problem
Comment: Do you have a 'proper' cron set up or are you using the built-in auto-cron? If it's the latter, it just means that from 10:30 no-one visited the site until 10:35, so the auto-cron didn't get invoked
Comment: @Clive I've updated the question
Comment: Hmm might be worth checking the syslog to check that cron job was fired off properly (I'm sure it will have been, just a good idea to make sure). I can't remember if the 'last ran' is the time at the start of the cron job or the end - if it's at the end, and the job had a max execution time of 300 seconds, and perhaps timed out, that figure might make sense
Comment: @Clive updated the question with syslog message. It shows that the cron started at 10:30:01 and errored out at the same time, so it couldn't have been a timeout.
Comment: You're probably right, I can't see the manual cron run in syslog but I can see the previous ones which had run successfully. Fingers crossed it was a temporary network issue. Thanks @Clive. What can I do to this question? Vote to close? Or if you can put up an answer I can award you the points.
Answer: Ok, I'm such an idiot sometimes.
I've edited the .htaccess file this morning to redirect without www. to www.domain.com and that has caused my cron going to localhost to be redirected to www.localhost which caused the cron to fail. /facepalm
But to answer exit status 4's meaning for wget according to this page it means Network failure (Kudos to @Clive)


Ubuntu 16 64bit - apt-get not working

Question: I have fresh and clean install of Ubuntu 16.04.1 server edition. I have set static IP address. I can ping any domain. I can connect to it via SSH. Basically IP configuration is as it was on old Ubuntu 14. But apt-get doesn't work.
It's 0% [Connecting to gb.archive.ubuntu.com (2001:67c:1560:8001::14)] [Connecting to security.ubuntu.com (2001:67c:1560:8001::11)]
I can ping domains it's trying to connect to gb.archive.ubuntu.com and security.ubuntu.com.
This is the most similar question I've found but this and answers to other questions doesn't resolve the issue.
I don't vahe any iptables rules as this is fresh and clean install.
After 5 hours spent on trying different solutions, different internet connections I'm running out of ideas.
Any help appreciated.
Thanks.
Comment: Sounds like a question for serverfault
Comment: Looks like it's trying to use IPv6. Check you can ping those domains with ping6
Comment: Thanks Rodney. I got ping: unknown host 2001:67c:1560:8001::14
Comment: try ping6, not ping.
Answer: Thanks Rodney. Your comment directed me to find the solution. It's about IPv6. Just needed to disable it. Answer found here.
Comment: Disabling IPv6 is not a useful approach. Nor is disabling IPv4 when an IPv4 endpoint doesn't respond.

Why? Because the problem is on the remote side, not yours. Contact whoever owns that endpoint and ask them to fix it. In the meantime, TCP will eventually fail out addresses that don't respond, trying the others until it finds one that works.
Comment: Thanks Stephen. This is my dev server run on VirtualBox so I don't need IPv6.
Comment: Just be sure to remember your debts! The day apt-get sees a DNS name with a AAAA but no A record, you'll have the same problem.
Comment: Thanks Stephen. I will.

Ubuntu 16 64bit - apt-get not working


Difference between AWS Software Subscription and Launching a Custom AMI?

Question: Amazon AWS seems to provide two methods of launching an instance of Ubuntu 12.04 that confuse me,

one of them is the Software Marketplace
the other method is by launching an AMI on the Ubuntu website

All of these comparisons are 12.04 LTS, Micro, w/ amd64 architecture
With the Software Marketplace, I see these AMI ids for a Micro Instance:
AMI IDs
Region                            ID
US East (Virginia)                ami-967edcff
US West (Oregon)                  ami-c6cc43f6
US West (Northern California)     ami-997356dc
EU West (Ireland)                 ami-e7b6b393
Asia Pacific (Singapore)          ami-5e01400c
Asia Pacific (Tokyo)              ami-c83c8fc9
South America (Sao Paulo)         ami-ea3ce2f7

However, with the Ubuntu Website I see,
Zone            AMI-ID          AKI-ID
us-east-1       ami-83dee0ea    aki-88aa75e1
eu-west-1       ami-aa56a1dd    aki-71665e05
ap-southeast-1  ami-bc7325ee    aki-fe1354ac
us-west-1       ami-c45f6281    aki-f77e26b2
us-west-2       ami-d0d8b8e0    aki-fc37bacc
sa-east-1       ami-d55bfbc8    aki-c48f51d9
ap-southeast-2  ami-e577e9df    aki-31990e0b
ap-northeast-1  ami-f72e45f6    aki-44992845

What is the difference say between ami-83dee0ea (from Ubuntu Website), and ami-967edcff (from the AWS Software Marketplace).
Answer: I can't point on the exact difference but the AMIs have different owners (or maintainer).
So it is possible that there are not all packages up-to-date on any image...
I assume the AMIs on the ubuntu page are maintained directly by Canonical and the others possibly by Amazon.
Most of the time you can choose whatever way you want. I prefer using the EC2 web console and so using the AMIs which are in the marketplace.
Hope that helps.


Clonar + Transferir dados para outro Form

Question: Tenho um formulário onde preencho alguns dados e quero transferir esses dados para outro formulário após preenchimento por JS. Mas ele clona tudo direito mas nao transfere os dados que eu insiro.

const copialoc = document.getElementById('copyLoc');
const copiaRefForn = document.getElementById('copyRefForn');
const copiaRefInt = document.getElementsByClassName('copyRef');

/**
 * clique no botão  +
 */
function create1() {
  duplicar('copyRefForn1', 'nossaRef1', 'copyLoc1');
}

let i = 0;

function duplicar(copyRefForn1, nossaRef1, copyLoc1) {
  const original = document.getElementById('clone');
  const clone = original.cloneNode(true);
  clone.id = "clone" + ++i;

  clone.getElementsByClassName('copyRefForn1')[0].innertext;
  clone.getElementsByClassName('nossaRef1')[0].innertext;
  clone.getElementsByClassName('copyLoc1')[0].innertext;

  lista.appendChild(clone);
}

Ref forn:

Ref:

Localização:

                  <input class='verMais' type="button" id="verMais" value="Ver mais">

Answer: Tenta fazer com incremento em vez de decremento na variável clone.id. Ou seja, coloca
clone.id = "clone" + i++;


Evaluate:$\sum_{n=2}^{\infty}\frac{\tan \theta_{n}}{3^n\left(3-\tan^2\theta_{n}\right)}$

Question: Evaluate:$$\sum_{n=2}^{\infty}\frac{\tan \theta_{n}}{3^n\left(3-\tan^2\theta_{n}\right)}$$
where $$\theta_{n}=\frac{\theta}{3^n}$$ and $0<\theta<\pi$
I did try to find relation between $\tan 3x$ and $\tan x$
$$\tan 3x-3\tan x=\frac{8\tan^3x}{1-3\tan^2x}$$
Also $$3\tan 3x-\tan x=\frac{8\tan x}{1-3\tan^2x}$$
so as to create some kind of telescopic action but couldn't split the expression given in the question
Comment: Related : https://math.stackexchange.com/questions/1280655/find-x-and-y/1281474#1281474
Comment: What is $\theta_n$?
Answer: Note that
$$ \frac{\tan x}{3-\tan^2 x} = \frac{\cot x - 3\cot(3x)}{8}. $$
So we have
$$ \frac{\tan \theta_n}{3^n(3-\tan^2 \theta_n)}
= \frac{1}{8}\left( \frac{\cot \theta_n}{3^n} - \frac{\cot \theta_{n-1}}{3^{n-1}} \right). $$
Summing this from $n = 2$ to $\infty$ yields a telescoping series with the value
$$ \sum_{n=2}^{\infty} \frac{\tan \theta_n}{3^n(3-\tan^2 \theta_n)}
= \frac{1}{8}\left( \lim_{N\to\infty} \frac{\cot \theta_N}{3^N} - \frac{\cot \theta_1}{3} \right)
= \frac{1}{8}\left( \frac{1}{\theta} - \frac{\cot (\theta/3)}{3} \right). $$


using data shared between multiple threads in a QAbstractTableModel

Question: I have a singleton class implemented using Q_GLOBAL_STATIC that contains a data structure that has to be accessed from multiple threads, I implemented accessor functions in the class, that would lock a mutex before accessing the data, so that all accesses to the shared data are serialized.
The problem is that I want to use this data in a QAbstractTableModel, I can simply use the accessor functions I implemented and access one item at a time from my overridden data(), columnCount() and rowCount(). But I think this is insufficient, since between two subsequent calls to data() another thread may jump in and change the number of items for example (rowCount()), and the model's thread may end up accessing out of bounds data.
I think I need to lock the mutex before the very first call of columnCount() and rowCount() of the model reset, and unlock it only when all data is read into the model (after the last call to data()), is there a way to do so? or am I thinking the wrong way?
I thought of copying the shared data structure to a local one on model reset(and have the mutex locked only on the copy operation), and after that access the copied data safely, but isn't that an overkill? isn't there a more efficient solution?
Answer: In Qt's Model-View framework, the interface between QAbstractItemModel and QAbstractItemView is not threadsafe at all, it is designed to be used with only one thread, which must be the GUI thread, i.e. the main thread since view does painting on the GUI, which cannot be done securely in another thread than the main (GUI) thread.
Therefore a model must hold it's own data and synchronize it with real data. If your dataset is large, you can rely on fetchMore() to avoid copying the whole data in every model instance. See what is done in QtSql's sql models code. Then the lock-between-calls issue you raise is easier to solve.
You can even update the model in an event-driven way if the real data holder objects are able to emit signals connected to the model instance. Thanks to auto/queued signal connections, the model slots will execute in the main (GUI) thread and therefore won't need to be threadsafe with the QAbstractItemModel-QAbstractItemView interface.
Comment: PS: You can still share data between several model instances since all views are executed by the main (GUI) thread and won't call two models at the same time.
Comment: Thanks for your answer, I guess I'll have to switch to a single threaded design, to avoid such problems


How does one find the density of the $k$th ordered statistic?

Question: Let $X_1,\ldots,X_n$ be $n$ iid random variables. Suppose they are arranged in increasing order
$$X_{(1)}\leq\cdots\leq X_{(n)}$$
The first ordered statistic is always the minimum of the sample
$$Y_1 \equiv X_{(1)}=\min\{\,X_1,\ldots,X_n\,\}$$
For a sample of size $n$, the $n$th order statistic is the maximum, that is,
$$Y_n \equiv X_{(n)}=\max\{\,X_1,\ldots,X_n\,\}$$
According to Wolfram Mathworld (here), if $X$ has a probability density function $f(x)$ and cumulative distribution function $F(x)$, then the probability $Y_r$ is given $$f_{Y_r} = \frac{N!}{(r-1)!(N-r)!} [F(x)]^{r-1} [1-F(x)]^{N-r}f(x)$$
My Questions

Is an ordered statistic merely the ordering of a collection of random variables from highest to lowest? But I thought a random variable was a collection of values (e.g. $\lbrace 1,2,3,4,5,6 \rbrace$), so how can we rank them?
How do I derive that formula for $f_{Y_r}$? I googled it several times and I don't get how I found a would be derivation here I think on slide 4, but I don't follow what's going on.
Comment: A random variable $X$ is not a collection of values. It is a _single_ value chosen from the values in a certain set (such as the numbers $\{1,2,3,4,5,6\}$, for example) with a certain probability measure; the probability measure _may_ assign equal weight to each value in the set (each number is equally likely to be the value of $X$), but it _does not have to do so._ Some values can be more likely than others.
Comment: @DavidK Would it be fair to say a random variable is defined over a set of values?
Answer:
I believe that that ordered statics are the ordering of realizations of $X_1,\dotsc, X_n$ from lowest to highest. A random variable is a function.
The thing you posted for $f_{Y_r}$ is the formula for the $r$th order statistic. I do not advocate the memorization of this formula. And for a long time, I didn't even know it existed. To me, it is better to understand what is happening. I provide a simple example with a very well known result. In the first part, I talked through it, but it is essentially the formula you provide. You can see how it would generalize to an arbitrary number $n$, with a generic distribution $G$. In the second part, I approach using the cdf.

Let $Y_1,Y_2,Y_3$ iid exponential distributions with mean $1/\lambda$. Then, to find distribution of the minimum $M:=Y_{(1)}$, we must consider
\begin{align*}
P(M\in dm) &= P(M\in [m,m+\epsilon])\tag 1\\
&=P(\text{one of the $Y$'s } \in [m,m+\epsilon]\text{ and all others }>x)\tag 2
\end{align*}
where in $(1)$ and $(2)$ I use the notation provided in the slides.
Since there are $3$ choices for the minimum

$Y_1$, or
$Y_2$ or
$Y_3$,

the number of ways to choose a minimum is
$$\binom{3}{1} = 3$$
where $\binom{n}{k}$ is the counting factor called the binomial coefficient. Notice that I am not invoking the binomial distribution. In other words, there are $3$ choices to fall in the interval $[m,m+\epsilon]$.
Once we have chosen the smallest, then there is only
$$\binom{2}{2} = 1$$ way to choose the other two larger ones. In other words, there is one way have the rest fall into the interval $(m,\infty)$.
Recall that the $Y_i$ are iid $Y\sim\text{Exp}(\lambda)$, by which I mean that the average is $1/\lambda$.
So it must be the case that
\begin{align*}
P(M\in dm) &= P(M\in [m,m+\epsilon])\\
&=P(\text{one of the $Y$'s } \in [m,m+\epsilon]\text{ and all others }>m)\\
&=P(\text{one of the $Y$'s } \in [m,m+\epsilon])P(\text{All others }>m)\tag 3\\
&=\binom{3}{1}[f_Y(m)\epsilon]\binom{2}{2}[1-F_Y(m)]^2 \\
&=3[\lambda e^{-\lambda m}\epsilon][1-\{1-e^{-\lambda m}\}]^2 \\
&= 3\lambda\epsilon e^{-3\lambda m}
\end{align*}
where in $(3)$ I use independence.
This gives that the pdf is
$$f_M(m) = 3\lambda e^{-3\lambda m}.$$
Notice that the minimum $M$ (or $Y_{(1)}$) follows an exponential distribution with mean $\frac{1}{3\lambda}$.

Alternatively, for the $n$ case
$$P(Y_{(1)}\leq m) = 1-P(Y_{(1)}>m) =1- (e^{-\lambda m})^n = 1- e^{-n\lambda m}.$$
Then the pdf is $n\lambda e^{-n\lambda m}$. Notice that the interpretation is that
there is $\binom{n}{1}$ options for the smallest. Then the rest $\binom{n-1}{n-1} = 1$ have to fall in the interval $(m,\infty)$, hence $n\lambda e^{-n\lambda m}$.
Comment: Two questions: (1) what does $dm$ stand for? (2) where does $\binom{3}{1}f_Y(m)\binom{2}{2}(1-F_Y(m))^2$ come from? Is this the probability of it being $f_Y(m)$ and the probability of it not? If so, why do we need two different chooses, $\binom{3}{1}$ and $\binom{2}{2}$? I though binomial probability functions involved one choose $\binom{n}{k}$...
Comment: @StanShunpike I have updated my answer to address your question.
Answer: $\{X_1, ... X_n\}$ is a collection of samples no particular size order; usually arranged by sampling time, location, or whatever.   Eg: $\{0.4817, 0.2318, 0.7875, 0.1115\}$
$\{X_{(1)},...X_{(n)}\}$ is that collection reordered from least to most.   So that example becomes $\{ 0.1115, 0.2318, 0.4817, 0.7875\}$

For a continuous random distribution: formulae for $f_Y(y)$ (actually $f_{X_{(r)}}(y)$ is derived by:

Counting ways to selecting $r-1$ samples to be smaller, $n-r$ samples to be larger, and 1 sample to be the favoured sample out of all ways the samples could be ordered.  $\dfrac{n!}{(r-1)!\,(n-r)!}$
measuring the probability density of the favoured sample: $f_X(y)$.
measuring the probability that the $r-1$ samples are less than this $F_X(y)^{r-1}$
measuring the probability that the $n-r$ samples are more than this $(1-F_X(y))^{n-r}$
Putting it all together.

$$f_{X_{(r)}}(y) = \dfrac{n!}{(r-1)!\,(n-r)!} F_X(y)^{r-1} (1-F_X(y))^{n-r} f_X(y)$$
Note: this only works then there is a zero probability of ties; that is continuous random variables only.  The probability mass function of order statistics for discrete random variables is much more involved.
Comment: Excuse me, but in you last equation we should begin with a $f_{X_{(r)}}(y)$, not uppercase F, right?
Comment: Yes.  Thank you, @David
Answer: The probability that the $k$th order statistic is less than $x$ is the probability of the union of mutually exclusive events where at least $j \geq k$ of the samples are less than $x$ but the remaining $n-j$ samples are greater than $x$. Note that there are ${n}\choose{j}$ different combinations satisfying this condition. The probability of this union is a sum of probabilities over $j=k, \ldots,n$.
Assuming an iid sample of size $n$, the distribution function for $X_{(k)}$ is
$$\mathbb{P} (X_{(k)}\leq x) = \sum_{j=k}^{n} {{n}\choose{j}}[F(x)]^j[1-F(x)]^{n-j}$$
To get the density function, take the derivative of the distribution function with respect to $x$ to find
$$f_{(k)}(x) = \frac{n!}{(k-1)!(n-k)!}F(x)^{k-1}(1-F(x))^{n-k}f(x).$$
This a lengthy calculation and I believe there is no easy path other than something along the lines of
https://math.stackexchange.com/a/1179378/148510


Can't access formik.touched && formik.errors with Yup of internal property of an object

Question: First timer...
I am using formik with yup form validation in react typescript and trying to get formik.touched && formik.errors for nested object .
whatever I tried not working
how should I get to the nested object ?
{formik.touched.address?.state && formik.errors.address?.state && (
{formik.errors.address?.state}
 )}

 validationSchema: yup.object({
      firstName: yup.string().required().min(2),
      lastName: yup.string().required().min(2),
      email: yup.string().required().email(),
      address: yup.object({
        country: yup.string().required().min(2),
        state: yup.string().min(2),      }),
     }),

return

            <input
              type="text"
              className="form-control"
              id="floatingState"
              placeholder="John Doe"
              name="state"
              onChange={formik.handleChange}
              value={formik.values.address?.state}
              onBlur={formik.handleBlur}
            ></input>
            <label`your text` htmlFor="floatingState">State
            {formik.touched.address?.state && formik.errors.address?.state && (

{formik.errors.address?.state}

            )}

Answer: First you need to set initialValues for address if you haven't
 initialValues={
        // other fields...
        address: {
          country: ''
          state: ''
        }
      }

And change value of name attribute of input to name="address.state", since state is inside address object.
Comment: Thank you Usama!

I have had the initial values already an was able the get to address.state.
my problem is that I am getting errors on the formik.touched and formik.errors when I try to check the address.state ...

{formik.touched.address?.state && formik.errors.address?.state && ( {formik.errors.address?.state} )}
Answer: Input name should also be nested.
name="address.state"


Should I clear cookies on logout from the server or the client?

Question: I'm using React as my client and ExpressJs as the server. When a user clicks on the logout button, should I send a request to the server to clear the cookie or should I do it from the client-side?
Comment: Short answer: both.
Answer: Both. I'd use passport.js to manage the server side stuffs and use their tutorial https://www.passportjs.org/tutorials/password/ for sessionid authentication. On the server, once you ping the logout route, it will invalidate any sessionid passed to authenticated routes and not let you pass. The problem with not using both, is after logout is visited and only it is invalid on the server, your sessionid will not be valid for authenticated routes. The user would appear to have the same access, but once they try to access routes, it will drop a 401 error. The problem with only using client side logout then, would be that the user would not be able to see what they can access, but anyone that has managed to steal the sessionid would still be able to use their account!